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
4482b5d7
Commit
4482b5d7
authored
Apr 23, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
329da850
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
372 additions
and
17 deletions
+372
-17
VisitStatisticsController.php
api/controllers/VisitStatisticsController.php
+10
-17
IndexAsset.php
backend/assets/coinTransfer/IndexAsset.php
+17
-0
CoinTransferController.php
backend/controllers/CoinTransferController.php
+111
-0
form.php
backend/views/coin-transfer/form.php
+39
-0
list.php
backend/views/coin-transfer/list.php
+15
-0
list.js
backend/web/js/coin-transfer/list.js
+55
-0
CoinTransfer.php
common/models/psources/CoinTransfer.php
+75
-0
Chain33Service.php
common/service/chain33/Chain33Service.php
+50
-0
No files found.
api/controllers/VisitStatisticsController.php
View file @
4482b5d7
...
...
@@ -22,31 +22,24 @@ class VisitStatisticsController extends BaseController
$duration
=
Yii
::
$app
->
request
->
get
(
'duration'
,
''
);
$address
=
Yii
::
$app
->
request
->
get
(
'address'
,
''
);
if
(
empty
(
$dapp
)
&&
!
empty
(
$identify
)){
$isExistModel
=
CoinAppVisitStatistics
::
find
()
->
where
([
'identify'
=>
$identify
])
->
one
();
if
(
$isExistModel
)
{
return
[
'code'
=>
0
,
'data'
=>
[],
'msg'
=>
'数据记录已存在'
];
}
if
(
empty
(
$dapp
)
||
empty
(
$identify
)
||
empty
(
$duration
)
||
empty
(
$address
)){
return
[
'code'
=>
-
1
,
'data'
=>
[],
'msg'
=>
'缺少必要的参数'
];
}
$isExistModel
=
CoinAppVisitStatistics
::
find
()
->
where
([
'identify'
=>
$identify
])
->
one
();
if
(
!
$isExistModel
)
{
$model
=
new
CoinAppVisitStatistics
();
$model
->
dapp
=
''
;
$model
->
duration
=
''
;
$model
->
address
=
''
;
$model
->
dapp
=
$dapp
;
$model
->
duration
=
$duration
;
$model
->
address
=
$address
;
$model
->
identify
=
$identify
;
$model
->
save
();
return
[
'code'
=>
0
,
'data'
=>
[],
'msg'
=>
'数据记录插入成功'
];
}
if
(
!
empty
(
$dapp
)
&&
!
empty
(
$identify
))
{
$isExistModel
=
CoinAppVisitStatistics
::
find
()
->
where
([
'identify'
=>
$identify
])
->
one
();
if
(
!
$isExistModel
){
return
[
'code'
=>
0
,
'data'
=>
[],
'msg'
=>
'数据记录不存在'
];
}
$isExistModel
->
dapp
=
$dapp
;
if
(
$duration
>
$isExistModel
->
duration
){
$isExistModel
->
duration
=
$duration
;
$isExistModel
->
address
=
$address
;
$isExistModel
->
save
();
return
[
'code'
=>
0
,
'data'
=>
[],
'msg'
=>
'数据记录更新成功'
];
}
}
...
...
backend/assets/coinTransfer/IndexAsset.php
0 → 100644
View file @
4482b5d7
<?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/CoinTransferController.php
0 → 100644
View file @
4482b5d7
<?php
/**
* Created by PhpStorm.
* User: shaji
* Date: 2019/4/23
* Time: 10:04
*/
namespace
backend\controllers
;
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
){
echo
$val
->
address
.
"<br/>"
;
$id
=
$val
->
id
;
$to
=
$val
->
address
;
$amount
=
str_replace
(
" TSC"
,
""
,
$val
->
amount
)
*
1e8
;
$fee
=
100000
;
$note
=
''
;
$execer
=
'user.p.tschain.coins'
;
$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
();
}
}
}
\ No newline at end of file
backend/views/coin-transfer/form.php
0 → 100644
View file @
4482b5d7
<?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
0 → 100644
View file @
4482b5d7
<?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/coin-transfer/list.js
0 → 100644
View file @
4482b5d7
var
table
=
layui
.
table
;
var
upload
=
layui
.
upload
;
table
.
render
({
elem
:
"#table1"
,
url
:
'/admin/coin-transfer/list'
,
page
:
1
,
limit
:
10
,
cols
:
[[
{
field
:
'id'
,
width
:
80
,
title
:
'ID'
,
sort
:
true
},
{
field
:
'address'
,
title
:
'地址'
},
{
field
:
'amount'
,
title
:
'数量'
},
{
field
:
'status'
,
title
:
'状态'
},
]]
,
done
:
function
()
{
//$("[data-field='id']").css('display','none');
}
});
upload
.
render
({
elem
:
"#implode"
,
url
:
"/admin/coin-transfer/load-file"
,
accept
:
'file'
,
exts
:
'csv'
,
done
:
function
(
res
)
{
if
(
res
.
code
==
0
){
table
.
reload
(
'table1'
,
{
page
:
{
curr
:
1
}
});
}
else
{
layer
.
msg
(
res
.
msg
);
}
},
before
:
function
(
obj
)
{
//obj参数包含的信息,跟 choose回调完全一致,可参见上文。
layer
.
load
();
//上传loading
}
});
$
(
'#transfer'
).
click
(
function
()
{
//var data = obj.data; //得到所在行所有键值
$
.
get
(
'/admin/coin-transfer/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/CoinTransfer.php
0 → 100644
View file @
4482b5d7
<?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
();
}
}
common/service/chain33/Chain33Service.php
View file @
4482b5d7
...
...
@@ -130,6 +130,56 @@ class Chain33Service
return
$this
->
send
(
$params
,
'Chain33.SendToAddress'
);
}
public
function
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
)
{
$params
=
[
"to"
=>
$to
,
"amount"
=>
$amount
,
"fee"
=>
$fee
,
"note"
=>
$note
,
"execer"
=>
$execer
,
];
return
$this
->
send
(
$params
,
'Chain33.CreateRawTransaction'
);
}
public
function
signRawTx
(
$privkey
,
$txHex
,
$expire
)
{
$params
=
[
'privkey'
=>
$privkey
,
'txHex'
=>
$txHex
,
'expire'
=>
$expire
];
return
$this
->
send
(
$params
,
'Chain33.SignRawTx'
);
}
public
function
sendTransaction
(
$data
)
{
$params
=
[
'data'
=>
$data
];
return
$this
->
send
(
$params
,
'Chain33.SendTransaction'
);
}
public
function
createNoBalanceTransaction
(
$txHex
,
$payAddr
,
$privkey
)
{
$params
=
[
'txHex'
=>
$txHex
,
'payAddr'
=>
$payAddr
,
'privkey'
=>
$privkey
];
return
$this
->
send
(
$params
,
'Chain33.CreateNoBalanceTransaction'
);
}
public
function
unLock
(
$passwd
,
$walletorticket
,
$timeout
)
{
$params
=
[
'passwd'
=>
$passwd
,
'walletorticket'
=>
$walletorticket
,
'timeout'
=>
$timeout
];
return
$this
->
send
(
$params
,
'Chain33.UnLock'
);
}
public
function
structureTrade
(
$amount
,
$execName
,
$fee
,
$isToken
=
True
,
$to
,
$tokenSymbol
=
''
)
{
...
...
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