Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
f42616f8
Commit
f42616f8
authored
6 years ago
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
空投导入数据
parent
220a8f78
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
5 deletions
+63
-5
InvestmentController.php
backend/controllers/InvestmentController.php
+30
-0
index.php
backend/views/investment/index.php
+11
-1
index.js
backend/web/js/investment/index.js
+15
-3
Investment.php
common/models/pwallet/Investment.php
+7
-1
No files found.
backend/controllers/InvestmentController.php
View file @
f42616f8
...
...
@@ -8,9 +8,11 @@
namespace
backend\controllers
;
use
common\base\Exception
;
use
Yii
;
use
common\models\pwallet\InvestmentType
;
use
common\models\pwallet\Investment
;
use
yii\web\UploadedFile
;
class
InvestmentController
extends
BaseController
{
...
...
@@ -156,4 +158,31 @@ class InvestmentController extends BaseController
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
}
}
/**
* 导入cvs
*/
public
function
actionLoadFile
()
{
Yii
::
$app
->
response
->
format
=
'json'
;
$file
=
UploadedFile
::
getInstanceByName
(
'file'
);
try
{
$fd
=
fopen
(
$file
->
tempName
,
'r'
);
$data
=
[];
while
((
$row
=
fgetcsv
(
$fd
))
!==
false
)
{
array_push
(
$row
,
date
(
'Y-m-d H:i:s'
));
$data
[]
=
$row
;
}
if
(
$data
)
{
if
(
Investment
::
loadArray
(
$data
))
{
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
}
}
return
[
'code'
=>
1
,
'msg'
=>
'数据为空'
];
}
catch
(
\Exception
$e
)
{
return
[
'code'
=>
$e
->
getCode
(),
'msg'
=>
$e
->
getMessage
()];
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/views/investment/index.php
View file @
f42616f8
...
...
@@ -5,10 +5,20 @@
* Date: 18-6-13
* Time: 下午3:27
*/
$this
->
registerJsFile
(
'@web/js/investment/index.js'
);
use
common\models\pwallet\InvestmentType
;
$_csrf
=
Yii
::
$app
->
request
->
getCsrfToken
();
$js
=
<<<EOF
var csrf='{$_csrf}'
EOF;
/**
* @var $this \yii\web\View
*/
$this
->
registerJs
(
$js
,
\yii\web\View
::
POS_BEGIN
);
$this
->
registerJsFile
(
'@web/js/investment/index.js'
);
$type
=
InvestmentType
::
getList
(
1
,
999
,
[]);
?>
<h4>
空投管理
</h4>
...
...
This diff is collapsed.
Click to expand it.
backend/web/js/investment/index.js
View file @
f42616f8
...
...
@@ -3,6 +3,8 @@
*/
var
table
=
layui
.
table
;
var
form
=
layui
.
form
;
var
upload
=
layui
.
upload
;
form
.
render
();
table
.
render
({
elem
:
"#table1"
,
...
...
@@ -42,8 +44,7 @@ $("#add1").click(function () {
layer
.
msg
(
rev
.
msg
);
if
(
rev
.
code
==
0
)
{
layer
.
close
(
index
);
table
.
reload
(
"table1"
,
{
});
table
.
reload
(
"table1"
,
{});
}
});
$btn
.
button
(
'reset'
);
...
...
@@ -61,11 +62,21 @@ $("#add1").click(function () {
$
(
"#add2"
).
click
(
function
()
{
return
false
;
});
form
.
on
(
'submit(form1)'
,
function
(
data
)
{
table
.
reload
(
'table1'
,
{
where
:
data
.
field
,
page
:
{
curr
:
1
}
});
return
false
;
});
upload
.
render
({
elem
:
"#add2"
,
url
:
"/admin/investment/load-file"
,
accept
:
'file'
,
exts
:
'csv'
,
data
:
{
_csrf
:
csrf
},
done
:
function
(
res
)
{
layer
.
msg
(
res
.
msg
);
table
.
reload
(
'table1'
,
{
curr
:
1
});
}
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
common/models/pwallet/Investment.php
View file @
f42616f8
...
...
@@ -109,5 +109,10 @@ class Investment extends BaseActiveRecord
return
$data
;
}
public
static
function
loadArray
(
array
$data
)
{
return
self
::
getDb
()
->
createCommand
()
->
batchInsert
(
self
::
tableName
(),
[
'uid'
,
'count'
,
'coin'
,
'tid'
,
'create_at'
],
$data
)
->
execute
();
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment