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
3b1a244d
Commit
3b1a244d
authored
Feb 18, 2020
by
shajiaming
Browse files
Options
Browse Files
Download
Plain Diff
合并冲突
parents
092cb902
4ebc2a70
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
18 deletions
+75
-18
WalletChainController.php
api/controllers/WalletChainController.php
+13
-17
CoinPlatformWithHold.php
common/models/psources/CoinPlatformWithHold.php
+60
-0
WalletChain.php
common/models/psources/WalletChain.php
+1
-0
IssueChainTransferController.php
console/controllers/IssueChainTransferController.php
+1
-1
No files found.
api/controllers/WalletChainController.php
View file @
3b1a244d
...
...
@@ -3,6 +3,7 @@
namespace
api\controllers
;
use
common\models\psources\Coin
;
use
common\models\psources\CoinPlatformWithHold
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
use
api\base\BaseController
;
...
...
@@ -36,8 +37,8 @@ class WalletChainController extends BaseController
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$size
=
Yii
::
$app
->
request
->
get
(
'size'
,
10
);
$query
=
WalletChain
::
find
()
->
select
(
'id, token, platform,
create_time,
status'
)
$query
=
CoinPlatformWithHold
::
find
()
->
select
(
'id, token, platform, status'
)
->
where
([
'wallet_address'
=>
$wallet_address
])
->
orderBy
(
'id'
);
...
...
@@ -82,8 +83,8 @@ class WalletChainController extends BaseController
goto
doEnd
;
}
$post
=
$request
->
post
();
$model
=
new
WalletChain
();
$model
->
setScenario
(
WalletChain
::
SCENARIOS_CREATE
);
$model
=
new
CoinPlatformWithHold
();
$model
->
setScenario
(
CoinPlatformWithHold
::
SCENARIOS_CREATE
);
$params
=
[
'platform'
=>
isset
(
$post
[
'platform'
])
?
$post
[
'platform'
]
:
''
,
'address'
=>
isset
(
$post
[
'address'
])
?
$post
[
'address'
]
:
''
,
...
...
@@ -92,10 +93,11 @@ class WalletChainController extends BaseController
'host'
=>
isset
(
$post
[
'host'
])
?
$post
[
'host'
]
:
''
,
'port'
=>
isset
(
$post
[
'port'
])
?
$post
[
'port'
]
:
''
,
'wallet_address'
=>
isset
(
$post
[
'wallet_address'
])
?
$post
[
'wallet_address'
]
:
''
,
'status'
=>
WalletChain
::
STATUS_NO
,
'origin'
=>
WalletChain
::
ORIGIN_USER
,
'status'
=>
CoinPlatformWithHold
::
STATUS_NO
,
'origin'
=>
CoinPlatformWithHold
::
ORIGIN_USER
,
'fee'
=>
isset
(
$post
[
'fee'
])
?
$post
[
'fee'
]
:
''
,
'hash'
=>
isset
(
$post
[
'hash'
])
?
$post
[
'hash'
]
:
''
'hash'
=>
isset
(
$post
[
'hash'
])
?
$post
[
'hash'
]
:
''
,
'exer'
=>
'user.p.'
.
(
isset
(
$post
[
'platform'
])
?
$post
[
'platform'
]
:
''
)
];
if
(
$model
->
load
(
$params
,
''
)
&&
!
$model
->
save
())
{
...
...
@@ -104,12 +106,6 @@ class WalletChainController extends BaseController
goto
doEnd
;
}
$id
=
Yii
::
$app
->
p_sources
->
getLastInsertID
();
// $params = [
// 'platform' => 'BZCHAIN',
// 'host' => '112.74.59.221',
// 'port' => 1235,
// ];
$node_params
=
Yii
::
$app
->
params
[
'para'
];
$service
=
new
Chain33Service
(
$node_params
);
...
...
@@ -122,9 +118,9 @@ class WalletChainController extends BaseController
$this
->
syncCoin
([
'platform'
=>
$params
[
'platform'
],
'token'
=>
$params
[
'token'
]]);
$chain_update
=
WalletChain
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
$chain_update
->
setScenario
(
WalletChain
::
SCENARIOS_UPDATE
);
$chain_update
->
status
=
WalletChain
::
STATUS_YES
;
$chain_update
=
CoinPlatformWithHold
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
$chain_update
->
setScenario
(
CoinPlatformWithHold
::
SCENARIOS_UPDATE
);
$chain_update
->
status
=
CoinPlatformWithHold
::
STATUS_YES
;
$chain_update
->
save
();
...
...
@@ -155,7 +151,7 @@ class WalletChainController extends BaseController
}
$model
=
WalletChain
::
find
()
->
select
(
'platform, token, address, private_key, fee, host, port, hash, status, create_time'
)
->
where
([
'id'
=>
(
int
)
$id
])
->
asArray
()
->
one
();
$model
=
CoinPlatformWithHold
::
find
()
->
select
(
'platform, token, address, private_key, fee, host, port, hash, status, create_time'
)
->
where
([
'id'
=>
(
int
)
$id
])
->
asArray
()
->
one
();
if
(
empty
(
$model
))
{
goto
doEnd
;
}
...
...
common/models/psources/CoinPlatformWithHold.php
View file @
3b1a244d
...
...
@@ -10,6 +10,66 @@ namespace common\models\psources;
class
CoinPlatformWithHold
extends
BaseActiveRecord
{
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
const
STATUS_NO
=
0
;
//创建失败
const
STATUS_YES
=
1
;
//创建成功
const
ORIGIN_MANAGE
=
1
;
//管理员创建
const
ORIGIN_USER
=
2
;
//h5用户创建
public
function
attributeLabels
()
{
return
[
'id'
=>
'ID'
,
'platform'
=>
'平行链名称'
,
'address'
=>
'代扣地址'
,
'private_key'
=>
'代扣私钥'
,
'execer'
=>
'执行器'
,
'fee'
=>
'手续费'
,
'brower_url'
=>
'浏览器链接'
,
'token'
=>
'手续费(基础代币)'
,
'host'
=>
'钱包服务IP'
,
'port'
=>
'钱包服务端口'
,
'wallet_address'
=>
'钱包地址'
,
'status'
=>
'申请状态'
,
'origin'
=>
'创建人'
,
'hash'
=>
'申请费用hash'
];
}
public
function
rules
()
{
return
[
[[
'platform'
,
'address'
,
'private_key'
,
'execer'
,
'exer'
,
'brower_url'
,
'token'
,
'host'
,
'wallet_address'
,
'status'
,
'port'
,
'fee'
,
'origin'
,
'hash'
],
'required'
],
[[
'platform'
,
'address'
,
'private_key'
,
'execer'
,
'exer'
,
'brower_url'
,
'token'
,
'host'
,
'wallet_address'
,
'hash'
],
'string'
],
[
'address'
,
'unique'
,
'message'
=>
'地址已存在'
],
[[
'platform'
],
'string'
,
'length'
=>
[
1
,
30
]],
[[
'token'
],
'string'
,
'length'
=>
[
1
,
10
]],
[[
'port'
,
'status'
,
'origin'
],
'integer'
],
[
'host'
,
'verfiyIp'
]
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'platform'
,
'token'
,
'address'
,
'private_key'
,
'fee'
,
'host'
,
'port'
,
'wallet_address'
,
'status'
,
'origin'
,
'hash'
,
'exer'
],
self
::
SCENARIOS_UPDATE
=>
[
'status'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
public
function
verfiyIp
(
$attribute
,
$params
)
{
if
(
!
preg_match
(
'/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/'
,
$this
->
host
))
{
$this
->
addError
(
$attribute
,
'错误的Ip地址'
);
return
false
;
}
}
public
static
function
tableName
()
{
return
'coin_platform_withhold'
;
...
...
common/models/psources/WalletChain.php
View file @
3b1a244d
...
...
@@ -52,6 +52,7 @@ class WalletChain extends BaseActiveRecord
return
[
[[
'platform'
,
'address'
,
'private_key'
,
'execer'
,
'brower_url'
,
'token'
,
'host'
,
'wallet_address'
,
'status'
,
'port'
,
'fee'
,
'origin'
,
'hash'
],
'required'
],
[[
'platform'
,
'address'
,
'private_key'
,
'execer'
,
'brower_url'
,
'token'
,
'host'
,
'wallet_address'
,
'hash'
],
'string'
],
[
'address'
,
'unique'
,
'message'
=>
'地址已存在'
],
[[
'platform'
],
'string'
,
'length'
=>
[
1
,
30
]],
[[
'token'
],
'string'
,
'length'
=>
[
1
,
10
]],
[[
'port'
,
'status'
,
'origin'
],
'integer'
],
...
...
console/controllers/IssueChainTransferController.php
View file @
3b1a244d
...
...
@@ -372,7 +372,7 @@ class IssueChainTransferController extends Controller
public
function
actionAsyncCoin
()
{
$chains
=
WalletChain
::
find
()
->
select
(
'host, platform'
)
$chains
=
CoinPlatformWithHold
::
find
()
->
select
(
'host, platform'
)
->
where
([
'status'
=>
1
,
'origin'
=>
WalletChain
::
ORIGIN_USER
])
->
asArray
()
->
all
();
...
...
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