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
5061dabc
Commit
5061dabc
authored
Jun 13, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
空投
parent
c722682d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
336 additions
and
0 deletions
+336
-0
IndexAsset.php
backend/assets/airDrop/IndexAsset.php
+17
-0
AirDropController.php
backend/controllers/AirDropController.php
+89
-0
add.php
backend/views/air-drop/add.php
+19
-0
form.php
backend/views/air-drop/form.php
+39
-0
list.php
backend/views/air-drop/list.php
+14
-0
list.js
backend/web/js/air-drop/list.js
+83
-0
CoinAirDropTransfer.php
common/models/psources/CoinAirDropTransfer.php
+75
-0
No files found.
backend/assets/airDrop/IndexAsset.php
0 → 100644
View file @
5061dabc
<?php
namespace
backend\assets\airDrop
;
use
yii\web\AssetBundle
;
use
yii\web\View
;
class
IndexAsset
extends
AssetBundle
{
public
$sourcePath
=
'@backend/web/js/air-drop'
;
public
$js
=
[
'list.js'
,
];
public
$jsOptions
=
[
'position'
=>
View
::
POS_END
,
];
}
backend/controllers/AirDropController.php
0 → 100644
View file @
5061dabc
<?php
namespace
backend\controllers
;
use
Yii
;
use
yii\web\UploadedFile
;
use
common\models\psources\CoinAirDropTransfer
;
class
AirDropController
extends
BaseController
{
public
$enableCsrfValidation
=
false
;
public
function
actionList
()
{
$get
=
Yii
::
$app
->
request
->
get
();
$page
=
$get
[
'page'
]
??
1
;
$limit
=
$get
[
'limit'
]
??
10
;
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$condition
=
[];
$data
=
CoinAirDropTransfer
::
getList
(
$page
,
$limit
,
$condition
);
return
$data
;
}
return
$this
->
render
(
'list'
);
}
/**
* 导入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
)
{
$data
[]
=
$row
;
}
if
(
ctype_digit
(
$data
[
0
][
0
]))
{
array_shift
(
$data
);
}
foreach
(
$data
as
$key
=>
&
$value
){
$value
[
0
]
=
trim
(
$value
[
0
]);
$value
[
1
]
=
trim
(
$value
[
1
]);
}
if
(
$data
)
{
$additional
=
[
1
,
'0'
,
' '
,
0
];
foreach
(
$data
as
$key
=>
&
$val
){
$val
=
array_merge
(
$val
,
$additional
);
}
if
(
CoinAirDropTransfer
::
loadArray
(
$data
))
{
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
}
}
return
[
'code'
=>
1
,
'msg'
=>
'数据为空'
];
}
catch
(
\Exception
$e
)
{
return
[
'code'
=>
$e
->
getCode
(),
'msg'
=>
$e
->
getMessage
()];
}
}
public
function
actionAdd
()
{
$this
->
layout
=
false
;
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$post
=
Yii
::
$app
->
request
->
post
();
$model
=
new
CoinAirDropTransfer
();
$model
->
setScenario
(
CoinAirDropTransfer
::
SCENARIOS_CREATE
);
$post
[
'txhash'
]
=
'0'
;
$post
[
'msg'
]
=
''
;
$post
[
'balance'
]
=
0
;
$post
[
'origin'
]
=
CoinAirDropTransfer
::
ORIGIN_ADD
;
if
(
$model
->
load
(
$post
,
''
)
&&
$model
->
save
())
{
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
}
$error
=
$model
->
errors
;
if
(
$error
)
{
return
[
'code'
=>
-
1
,
'msg'
=>
current
(
$model
->
firstErrors
)];
}
}
else
{
return
$this
->
render
(
'add'
);
}
}
}
\ No newline at end of file
backend/views/air-drop/add.php
0 → 100644
View file @
5061dabc
<div
style=
"padding: 5px 20px;"
>
<br>
<form
id=
"addData"
>
<input
name=
"_csrf"
type=
"hidden"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<div
class=
"input-group my-group"
>
<span
class=
"input-group-addon"
>
打币地址
</span>
<input
name=
"to_address"
type=
"text"
class=
"form-control"
lay-verify=
"required"
>
</div>
<div
class=
"input-group my-group"
>
<span
class=
"input-group-addon"
>
打币数量
</span>
<input
name=
"amount"
type=
"text"
class=
"form-control"
lay-verify=
"required"
>
</div>
<div
class=
"input-group my-group"
>
<span
class=
"input-group-addon"
>
币种名称
</span>
<input
name=
"coin_name"
type=
"text"
class=
"form-control"
lay-verify=
"required"
>
</div>
</form>
</div>
\ No newline at end of file
backend/views/air-drop/form.php
0 → 100644
View file @
5061dabc
<?php
/**
* Created By Sublime Test 3
*
* @author rlgyzhcn <rlgyzhcn@qq.com>
*/
?>
<style
type=
"text/css"
>
.layui-form-label
{
width
:
100px
;
}
</style>
<div
class=
"layui-row"
style=
"padding: 5px;"
>
<div
class=
"layui-col-md12"
>
<form
class=
"layui-table"
id=
"form_data"
lay-filter=
"form_data"
>
<input
type=
"hidden"
name=
"_csrf"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
币种
</label>
<div
class=
"layui-input-block"
>
<input
type=
"text"
name=
"coin"
class=
"layui-input"
readonly=
"readonly"
value=
"
<?=
$token
?>
"
/>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
手机号码
</label>
<div
class=
"layui-input-block"
>
<input
type=
"text"
name=
"mobile"
class=
"layui-input"
/>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
总量
</label>
<div
class=
"layui-input-block"
>
<input
type=
"text"
name=
"amount"
class=
"layui-input"
/>
</div>
</div>
</form>
</div>
</div>
\ No newline at end of file
backend/views/air-drop/list.php
0 → 100644
View file @
5061dabc
<?php
use
backend\assets\airDrop\IndexAsset
;
IndexAsset
::
register
(
$this
);
?>
<div
class=
"layui-row"
>
<button
class=
"layui-btn layui-btn-sm"
lay-event=
"import"
id=
"import"
>
名单导入
</button>
<button
class=
"layui-btn layui-btn-sm"
lay-event=
"add"
id=
"add"
>
单笔添加
</button>
<!-- <button class="layui-btn layui-btn-sm" lay-event="transfer" id="transfer">批量打币</button>-->
</div>
<div
class=
"layui-row"
>
<table
class=
"layui-table"
id=
"table1"
></table>
</div>
backend/web/js/air-drop/list.js
0 → 100644
View file @
5061dabc
var
table
=
layui
.
table
;
var
upload
=
layui
.
upload
;
table
.
render
({
elem
:
"#table1"
,
url
:
'/admin/air-drop/list'
,
page
:
1
,
limit
:
10
,
cols
:
[[
{
field
:
'id'
,
width
:
100
,
title
:
'ID'
,
sort
:
true
},
{
field
:
'to_address'
,
width
:
400
,
title
:
'地址'
},
{
field
:
'amount'
,
title
:
'数量'
},
{
field
:
'coin_name'
,
title
:
'币种名称'
},
{
field
:
'txhash'
,
width
:
400
,
title
:
'hash'
},
{
field
:
'msg'
,
width
:
200
,
title
:
'返回结果'
},
{
field
:
'create_at'
,
title
:
'添加时间'
},
{
field
:
'update_at'
,
title
:
'处理时间'
}
]]
,
done
:
function
()
{
//$("[data-field='id']").css('display','none');
}
});
$
(
'#add'
).
click
(
function
()
{
//打开弹窗
$
.
get
(
'/admin/air-drop/add'
,
{},
function
(
str
)
{
var
index
=
layer
.
open
({
type
:
1
,
title
:
'添加数据'
,
id
:
'add-one'
,
skin
:
'layui-layer-lan'
,
area
:
[
'320px'
,
'auto'
],
content
:
str
,
btn
:
[
'确认'
,
'取消'
],
btn1
:
function
()
{
$
.
post
(
'/admin/air-drop/add'
,
$
(
"#addData"
).
serialize
(),
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
rev
.
code
==
0
)
{
layer
.
close
(
index
);
table
.
reload
(
"table1"
,
{});
}
});
}
});
layui
.
form
.
render
();
});
return
false
;
});
upload
.
render
({
elem
:
"#import"
,
url
:
"/admin/air-drop/load-file"
,
accept
:
'file'
,
exts
:
'csv'
,
done
:
function
(
res
)
{
if
(
res
.
code
==
0
){
layer
.
msg
(
res
.
msg
);
table
.
reload
(
'table1'
,
{
curr
:
1
});
}
else
{
layer
.
msg
(
res
.
msg
);
}
},
before
:
function
(
obj
)
{
//obj参数包含的信息,跟 choose回调完全一致,可参见上文。
layer
.
load
();
//上传loading
}
});
$
(
'#transfer'
).
click
(
function
()
{
//var data = obj.data; //得到所在行所有键值
$
.
get
(
'/admin/air-drop/batch-transfer'
,
{},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
table
.
reload
(
'table1'
,
{
page
:
{
curr
:
1
}
});
}
});
});
\ No newline at end of file
common/models/psources/CoinAirDropTransfer.php
0 → 100644
View file @
5061dabc
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
CoinAirDropTransfer
extends
BaseActiveRecord
{
const
ORIGIN_IMPORT
=
1
;
const
ORIGIN_ADD
=
2
;
const
ORIGIN_API
=
3
;
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%coin_airdrop_transfer}}'
;
}
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
function
rules
()
{
return
[
[[
'to_address'
,
'amount'
,
'coin_name'
],
'required'
,
'message'
=>
"请输入
{
attribute
}
"
],
[[
'origin'
,
'txhash'
,
'msg'
,
'balance'
],
'safe'
],
];
}
/**
* @inheritdoc
*/
public
function
attributeLabels
()
{
return
[
'to_address'
=>
'钱包地址'
,
'amount'
=>
'数量'
,
'coin_name'
=>
'币种名称'
,
'origin'
=>
'来源'
,
'txhash'
=>
'返回hash'
,
'msg'
=>
'返回结果'
,
'balance'
=>
'钱包余额'
,
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'to_address'
,
'amount'
,
'coin_name'
,
'origin'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
public
static
function
loadArray
(
array
$data
)
{
return
self
::
getDb
()
->
createCommand
()
->
batchInsert
(
self
::
tableName
(),
[
'to_address'
,
'coin_name'
,
'amount'
,
'origin'
,
'txhash'
,
'msg'
,
'balance'
],
$data
)
->
execute
();
}
public
static
function
getOrigin
()
{
return
[
self
::
ORIGIN_IMPORT
=>
'批量导入'
,
self
::
ORIGIN_ADD
=>
'单独添加'
,
self
::
ORIGIN_API
=>
'接口导入'
,
];
}
}
\ No newline at end of file
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