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
a405b83c
Commit
a405b83c
authored
Aug 12, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
空投优化
parent
cd538ca7
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
84 additions
and
268 deletions
+84
-268
IndexAsset.php
backend/assets/coinTransfer/IndexAsset.php
+0
-17
AirDropController.php
backend/controllers/AirDropController.php
+8
-7
CoinTransferController.php
backend/controllers/CoinTransferController.php
+0
-113
form.php
backend/views/coin-transfer/form.php
+0
-39
list.php
backend/views/coin-transfer/list.php
+0
-15
list.js
backend/web/js/air-drop/list.js
+2
-2
CoinTransfer.php
common/models/psources/CoinTransfer.php
+0
-75
AirDropController.php
console/controllers/AirDropController.php
+74
-0
No files found.
backend/assets/coinTransfer/IndexAsset.php
deleted
100644 → 0
View file @
cd538ca7
<?php
namespace
backend\assets\coinTransfer
;
use
yii\web\AssetBundle
;
use
yii\web\View
;
class
IndexAsset
extends
AssetBundle
{
public
$sourcePath
=
'@backend/web/js/coin-transfer'
;
public
$js
=
[
'list.js'
,
];
public
$jsOptions
=
[
'position'
=>
View
::
POS_END
,
];
}
backend/controllers/AirDropController.php
View file @
a405b83c
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
backend\controllers
;
namespace
backend\controllers
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
use
Yii
;
use
yii\web\UploadedFile
;
use
yii\web\UploadedFile
;
use
common\models\psources\CoinAirDropTransfer
;
use
common\models\psources\CoinAirDropTransfer
;
...
@@ -12,8 +13,8 @@ class AirDropController extends BaseController
...
@@ -12,8 +13,8 @@ class AirDropController extends BaseController
public
function
actionList
()
public
function
actionList
()
{
{
$get
=
Yii
::
$app
->
request
->
get
();
$get
=
Yii
::
$app
->
request
->
get
();
$page
=
$get
[
'page'
]
??
1
;
$page
=
$get
[
'page'
]
??
1
;
$limit
=
$get
[
'limit'
]
??
10
;
$limit
=
$get
[
'limit'
]
??
10
;
if
(
Yii
::
$app
->
request
->
isAjax
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
...
@@ -34,7 +35,7 @@ class AirDropController extends BaseController
...
@@ -34,7 +35,7 @@ class AirDropController extends BaseController
$file
=
UploadedFile
::
getInstanceByName
(
'file'
);
$file
=
UploadedFile
::
getInstanceByName
(
'file'
);
try
{
try
{
$fd
=
fopen
(
$file
->
tempName
,
'r'
);
$fd
=
fopen
(
$file
->
tempName
,
'r'
);
$data
=
[];
$data
=
[];
while
((
$row
=
fgetcsv
(
$fd
))
!==
false
)
{
while
((
$row
=
fgetcsv
(
$fd
))
!==
false
)
{
$data
[]
=
$row
;
$data
[]
=
$row
;
...
@@ -42,14 +43,14 @@ class AirDropController extends BaseController
...
@@ -42,14 +43,14 @@ class AirDropController extends BaseController
if
(
ctype_digit
(
$data
[
0
][
0
]))
{
if
(
ctype_digit
(
$data
[
0
][
0
]))
{
array_shift
(
$data
);
array_shift
(
$data
);
}
}
foreach
(
$data
as
$key
=>
&
$value
){
foreach
(
$data
as
$key
=>
&
$value
)
{
$value
[
0
]
=
trim
(
$value
[
0
]);
$value
[
0
]
=
trim
(
$value
[
0
]);
$value
[
1
]
=
trim
(
$value
[
1
]);
$value
[
1
]
=
trim
(
$value
[
1
]);
}
}
if
(
$data
)
{
if
(
$data
)
{
$additional
=
[
1
,
'0'
,
' '
,
0
];
$additional
=
[
1
,
'0'
,
' '
,
0
];
foreach
(
$data
as
$key
=>
&
$val
){
foreach
(
$data
as
$key
=>
&
$val
)
{
$val
=
array_merge
(
$val
,
$additional
);
$val
=
array_merge
(
$val
,
$additional
);
}
}
if
(
CoinAirDropTransfer
::
loadArray
(
$data
))
{
if
(
CoinAirDropTransfer
::
loadArray
(
$data
))
{
...
@@ -67,14 +68,14 @@ class AirDropController extends BaseController
...
@@ -67,14 +68,14 @@ class AirDropController extends BaseController
$this
->
layout
=
false
;
$this
->
layout
=
false
;
if
(
Yii
::
$app
->
request
->
isPost
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
Yii
::
$app
->
response
->
format
=
'json'
;
$post
=
Yii
::
$app
->
request
->
post
();
$post
=
Yii
::
$app
->
request
->
post
();
$model
=
new
CoinAirDropTransfer
();
$model
=
new
CoinAirDropTransfer
();
$model
->
setScenario
(
CoinAirDropTransfer
::
SCENARIOS_CREATE
);
$model
->
setScenario
(
CoinAirDropTransfer
::
SCENARIOS_CREATE
);
$post
[
'txhash'
]
=
'0'
;
$post
[
'txhash'
]
=
'0'
;
$post
[
'msg'
]
=
''
;
$post
[
'msg'
]
=
''
;
$post
[
'balance'
]
=
0
;
$post
[
'balance'
]
=
0
;
$post
[
'origin'
]
=
CoinAirDropTransfer
::
ORIGIN_ADD
;
$post
[
'origin'
]
=
CoinAirDropTransfer
::
ORIGIN_ADD
;
if
(
$model
->
load
(
$post
,
''
)
&&
$model
->
save
())
{
if
(
$model
->
load
(
$post
,
''
)
&&
$model
->
save
())
{
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
}
}
$error
=
$model
->
errors
;
$error
=
$model
->
errors
;
...
...
backend/controllers/CoinTransferController.php
deleted
100644 → 0
View file @
cd538ca7
<?php
/**
* Created by PhpStorm.
* User: shaji
* Date: 2019/4/23
* Time: 10:04
*/
namespace
backend\controllers
;
use
backend\models\Coin
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
use
common\models\psources\CoinTransfer
;
use
yii\web\UploadedFile
;
class
CoinTransferController
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
=
CoinTransfer
::
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
)
{
if
(
CoinTransfer
::
loadArray
(
$data
))
{
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
}
}
return
[
'code'
=>
1
,
'msg'
=>
'数据为空'
];
}
catch
(
\Exception
$e
)
{
return
[
'code'
=>
$e
->
getCode
(),
'msg'
=>
$e
->
getMessage
()];
}
}
public
function
actionBatchTransfer
()
{
$model
=
CoinTransfer
::
find
()
->
where
([
'status'
=>
0
])
->
limit
(
30
)
->
all
();
foreach
(
$model
as
$val
){
$id
=
$val
->
id
;
$to
=
$val
->
address
;
$amount
=
$val
->
amount
*
1e8
;
$fee
=
100000
;
$note
=
''
;
$execer
=
'user.p.tschain.coins'
;
$isExist
=
CoinTransfer
::
find
()
->
where
([
'address'
=>
$val
->
address
,
'status'
=>
1
])
->
one
();
if
(
$isExist
)
continue
;
$service
=
new
Chain33Service
();
$createRawTransaction
=
$service
->
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
);
if
(
0
!=
$createRawTransaction
[
'code'
]){
continue
;
}
$txHex
=
$createRawTransaction
[
'result'
];
$privkey
=
'72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e2'
;
$expire
=
'1m'
;
$signRawTx
=
$service
->
signRawTx
(
$privkey
,
$txHex
,
$expire
);
if
(
0
!=
$signRawTx
[
'code'
]){
continue
;
}
$sign_str
=
$signRawTx
[
'result'
];
$result
=
$service
->
sendTransaction
(
$sign_str
);
if
(
0
!=
$result
[
'code'
]){
continue
;
}
$hash
=
$result
[
'result'
];
$current_model
=
CoinTransfer
::
findOne
(
$id
);
$current_model
->
hash
=
$hash
;
$current_model
->
status
=
1
;
$current_model
->
save
();
echo
$val
->
address
.
"-----"
.
$hash
.
"<br/>"
;
}
}
}
\ No newline at end of file
backend/views/coin-transfer/form.php
deleted
100644 → 0
View file @
cd538ca7
<?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/coin-transfer/list.php
deleted
100644 → 0
View file @
cd538ca7
<?php
use
backend\assets\coinTransfer\IndexAsset
;
IndexAsset
::
register
(
$this
);
?>
<div
class=
"layui-row"
>
<button
class=
"layui-btn layui-btn-sm"
lay-event=
"implode"
id=
"implode"
>
名单导入
</button>
<button
class=
"layui-btn layui-btn-sm"
lay-event=
"transfer"
id=
"transfer"
>
批量打币
</button>
</div>
<div
class=
"layui-row"
>
<div
class=
"layui-col-md8"
>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table1"
></table>
</div>
</div>
backend/web/js/air-drop/list.js
View file @
a405b83c
...
@@ -13,8 +13,8 @@ table.render({
...
@@ -13,8 +13,8 @@ table.render({
{
field
:
'coin_name'
,
title
:
'币种名称'
},
{
field
:
'coin_name'
,
title
:
'币种名称'
},
{
field
:
'txhash'
,
width
:
400
,
title
:
'hash'
},
{
field
:
'txhash'
,
width
:
400
,
title
:
'hash'
},
{
field
:
'msg'
,
width
:
200
,
title
:
'返回结果'
},
{
field
:
'msg'
,
width
:
200
,
title
:
'返回结果'
},
{
field
:
'create_
at
'
,
title
:
'添加时间'
},
{
field
:
'create_
time
'
,
title
:
'添加时间'
},
{
field
:
'update_
at
'
,
title
:
'处理时间'
}
{
field
:
'update_
time
'
,
title
:
'处理时间'
}
]]
]]
,
done
:
function
()
{
,
done
:
function
()
{
//$("[data-field='id']").css('display','none');
//$("[data-field='id']").css('display','none');
...
...
common/models/psources/CoinTransfer.php
deleted
100644 → 0
View file @
cd538ca7
<?php
namespace
common\models\psources
;
use
common\core\BaseActiveRecord
;
use
Yii
;
/**
* CoinReleaseMember
*
* @property int $id
* @property int $status
* @property string $address
* @property string $amount
*/
class
CoinTransfer
extends
BaseActiveRecord
{
const
SCENARIOS_ADD
=
'add'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%coin_transfer}}'
;
}
public
function
attributeLabels
()
{
return
[
'id'
=>
'ID'
,
'address'
=>
'地址'
,
'amount'
=>
'数量'
,
'hash'
=>
'交易hash'
,
'status'
=>
'状态'
,
];
}
public
function
rules
()
{
return
[
[[
'address'
,
'amount'
,
'hash'
],
'string'
],
];
}
public
function
sercians
()
{
return
[
self
::
SCENARIOS_ADD
=>
[
'address'
,
'amount'
,
'hash'
,
'status'
],
self
::
SCENARIOS_UPDATE
=>
[
'address'
,
'amount'
,
'hash'
,
'status'
],
];
}
/**
* 批量返回用户
*
* @param integer|array $ids
* @return array
*/
public
static
function
getMemberByRuleIds
(
$ids
)
{
return
CoinReleaseMember
::
find
()
->
where
([
'rule_id'
=>
$ids
])
->
andWhere
([
'>'
,
'freeze'
,
0
])
->
asArray
()
->
all
();
}
public
static
function
loadArray
(
array
$data
)
{
return
self
::
getDb
()
->
createCommand
()
->
batchInsert
(
self
::
tableName
(),
[
'address'
,
'amount'
],
$data
)
->
execute
();
}
}
console/controllers/AirDropController.php
0 → 100644
View file @
a405b83c
<?php
namespace
console\controllers
;
use
Yii
;
use
yii\console\Controller
;
use
common\service\chain33\Chain33Service
;
use
common\models\psources\CoinAirDropTransfer
;
class
AirDropController
extends
Controller
{
/**
* 获取游戏状态
*
* @return array
*/
public
function
actionAutoAirDrop
()
{
$model
=
CoinAirDropTransfer
::
find
()
->
where
([
'txhash'
=>
"0"
,
'msg'
=>
''
])
->
limit
(
20
)
->
asArray
()
->
all
();
if
(
empty
(
$model
))
{
echo
date
(
'Y-m-d H:i:s'
)
.
'暂无空投计划'
.
PHP_EOL
;
return
0
;
}
foreach
(
$model
as
$key
=>
$val
)
{
go
(
function
()
use
(
$val
)
{
\Co
::
sleep
(
0.5
);
$id
=
$val
[
'id'
];
$to
=
$val
[
'to_address'
];
$amount
=
$val
[
'amount'
]
*
1e8
;
$fee
=
100000
;
$note
=
''
;
$execer
=
isset
(
Yii
::
$app
->
params
[
'chain_parallel'
][
'wasm'
][
$val
[
'coin_name'
]
.
'_wallet'
])
?
Yii
::
$app
->
params
[
'chain_parallel'
][
'wasm'
][
$val
[
'coin_name'
]
.
'_wallet'
][
'execer'
]
:
null
;
$node_params
=
Yii
::
$app
->
params
[
'chain_parallel'
][
'wasm'
][
$val
[
'coin_name'
]
.
'_wallet'
];
$service
=
new
Chain33Service
(
$node_params
);
$createRawTransaction
=
$service
->
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
);
if
(
0
!=
$createRawTransaction
[
'code'
])
{
$txhash
=
'0'
;
$msg
=
$createRawTransaction
[
'msg'
];
goto
doEnd
;
}
$txHex
=
$createRawTransaction
[
'result'
];
$privkey
=
'72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e21'
;
$expire
=
'1m'
;
$signRawTx
=
$service
->
signRawTx
(
$privkey
,
$txHex
,
$expire
);
if
(
0
!=
$signRawTx
[
'code'
])
{
$txhash
=
'0'
;
$msg
=
$signRawTx
[
'msg'
];
goto
doEnd
;
}
$sign_str
=
$signRawTx
[
'result'
];
$result
=
$service
->
sendTransaction
(
$sign_str
);
if
(
0
!=
$result
[
'code'
])
{
$txhash
=
'0'
;
$msg
=
$result
[
'msg'
];
goto
doEnd
;
}
$txhash
=
$result
[
'result'
];
$msg
=
'success'
;
doEnd
:
$currentModel
=
CoinAirDropTransfer
::
findOne
(
$id
);
$currentModel
->
txhash
=
$txhash
;
$currentModel
->
msg
=
$msg
;
$currentModel
->
save
();
});
}
return
0
;
}
}
\ 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