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
2c7661c8
Commit
2c7661c8
authored
Feb 19, 2020
by
shajiaming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/issue_coin' into develop
parents
eac8344b
d3bd85bc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
42 deletions
+75
-42
WalletChainController.php
api/controllers/WalletChainController.php
+71
-40
CoinPlatformWithHold.php
common/models/psources/CoinPlatformWithHold.php
+4
-2
No files found.
api/controllers/WalletChainController.php
View file @
2c7661c8
...
...
@@ -77,52 +77,83 @@ class WalletChainController extends BaseController
public
function
actionChain
()
{
$request
=
Yii
::
$app
->
request
;
if
(
!
$request
->
isPost
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'请求方式错误!'
;
goto
doEnd
;
}
$post
=
$request
->
post
();
$model
=
new
CoinPlatformWithHold
();
$model
->
setScenario
(
CoinPlatformWithHold
::
SCENARIOS_CREATE
);
$params
=
[
'platform'
=>
isset
(
$post
[
'platform'
])
?
$post
[
'platform'
]
:
''
,
'address'
=>
isset
(
$post
[
'address'
])
?
$post
[
'address'
]
:
''
,
'private_key'
=>
isset
(
$post
[
'private_key'
])
?
$post
[
'private_key'
]
:
''
,
'token'
=>
isset
(
$post
[
'token'
])
?
strtoupper
(
$post
[
'token'
])
:
''
,
'host'
=>
isset
(
$post
[
'host'
])
?
$post
[
'host'
]
:
''
,
'port'
=>
isset
(
$post
[
'port'
])
?
$post
[
'port'
]
:
''
,
'wallet_address'
=>
isset
(
$post
[
'wallet_address'
])
?
$post
[
'wallet_address'
]
:
''
,
'status'
=>
CoinPlatformWithHold
::
STATUS_NO
,
'origin'
=>
CoinPlatformWithHold
::
ORIGIN_USER
,
'fee'
=>
isset
(
$post
[
'fee'
])
?
$post
[
'fee'
]
:
''
,
'hash'
=>
isset
(
$post
[
'hash'
])
?
$post
[
'hash'
]
:
''
,
'exer'
=>
'user.p.'
.
(
isset
(
$post
[
'platform'
])
?
$post
[
'platform'
]
:
''
)
];
if
(
$model
->
load
(
$params
,
''
)
&&
!
$model
->
save
())
{
$this
->
msg
=
$model
->
errors
;
$this
->
code
=
-
1
;
goto
doEnd
;
}
$id
=
Yii
::
$app
->
p_sources
->
getLastInsertID
();
$node_params
=
Yii
::
$app
->
params
[
'para'
];
$service
=
new
Chain33Service
(
$node_params
);
$result
=
$service
->
addPara
(
$params
[
'platform'
],
$params
[
'host'
]
.
':'
.
$params
[
'port'
]);
if
(
0
!=
$result
[
'code'
])
{
$this
->
code
=
$result
[
'code'
];
$this
->
msg
=
$result
[
'msg'
];
if
(
$request
->
isPost
)
{
$model
=
new
CoinPlatformWithHold
();
$model
->
setScenario
(
CoinPlatformWithHold
::
SCENARIOS_CREATE
);
$params
=
[
'platform'
=>
isset
(
$post
[
'platform'
])
?
$post
[
'platform'
]
:
''
,
'address'
=>
isset
(
$post
[
'address'
])
?
$post
[
'address'
]
:
''
,
'private_key'
=>
isset
(
$post
[
'private_key'
])
?
$post
[
'private_key'
]
:
''
,
'token'
=>
isset
(
$post
[
'token'
])
?
strtoupper
(
$post
[
'token'
])
:
''
,
'host'
=>
isset
(
$post
[
'host'
])
?
$post
[
'host'
]
:
''
,
'port'
=>
isset
(
$post
[
'port'
])
?
$post
[
'port'
]
:
''
,
'wallet_address'
=>
isset
(
$post
[
'wallet_address'
])
?
$post
[
'wallet_address'
]
:
''
,
'status'
=>
CoinPlatformWithHold
::
STATUS_UNPAID
,
'origin'
=>
CoinPlatformWithHold
::
ORIGIN_USER
,
'fee'
=>
isset
(
$post
[
'fee'
])
?
$post
[
'fee'
]
:
''
,
'exer'
=>
'user.p.'
.
(
isset
(
$post
[
'platform'
])
?
$post
[
'platform'
]
:
''
)
];
if
(
$model
->
load
(
$params
,
''
)
&&
!
$model
->
validate
())
{
$errors
=
''
;
foreach
(
$model
->
errors
as
$error
)
{
$errors
.=
$error
[
0
];
}
$this
->
msg
=
$errors
;
$this
->
code
=
-
1
;
goto
doEnd
;
}
$node_params
=
Yii
::
$app
->
params
[
'para'
];
$service
=
new
Chain33Service
(
$node_params
);
$result
=
$service
->
addPara
(
$params
[
'platform'
],
$params
[
'host'
]
.
':'
.
$params
[
'port'
]);
if
(
0
!=
$result
[
'code'
])
{
$this
->
code
=
$result
[
'code'
];
$this
->
msg
=
$result
[
'msg'
];
goto
doEnd
;
}
$model
->
save
();
$this
->
data
=
(
int
)
Yii
::
$app
->
p_sources
->
getLastInsertID
();
goto
doEnd
;
}
$this
->
syncCoin
([
'platform'
=>
$params
[
'platform'
],
'token'
=>
$params
[
'token'
]]);
$chain_update
=
CoinPlatformWithHold
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
$chain_update
->
setScenario
(
CoinPlatformWithHold
::
SCENARIOS_UPDATE
);
$chain_update
->
status
=
CoinPlatformWithHold
::
STATUS_YES
;
$chain_update
->
save
();
if
(
$request
->
isPut
)
{
$id
=
isset
(
$post
[
'id'
])
?
$post
[
'id'
]
:
0
;
$hash
=
isset
(
$post
[
'hash'
])
?
$post
[
'hash'
]
:
0
;
if
(
false
==
$id
||
false
==
$hash
)
{
$this
->
msg
=
'缺少必要的参数'
;
$this
->
code
=
-
1
;
goto
doEnd
;
}
$model
=
CoinPlatformWithHold
::
findOne
(
$id
);
if
(
empty
(
$model
))
{
$this
->
msg
=
'数据不存在'
;
$this
->
code
=
-
1
;
goto
doEnd
;
}
$model
->
setScenario
(
CoinPlatformWithHold
::
SCENARIOS_UPDATE
);
$params
=
[
'id'
=>
$id
,
'hash'
=>
$hash
,
'status'
=>
CoinPlatformWithHold
::
STATUS_YES
];
if
(
$model
->
load
(
$params
,
''
)
&&
!
$model
->
save
())
{
$errors
=
''
;
foreach
(
$model
->
errors
as
$error
)
{
$errors
.=
$error
[
0
];
}
$this
->
msg
=
$errors
;
$this
->
code
=
-
1
;
goto
doEnd
;
}
$this
->
syncCoin
([
'platform'
=>
$model
[
'platform'
],
'token'
=>
$model
[
'token'
]]);
}
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
...
...
common/models/psources/CoinPlatformWithHold.php
View file @
2c7661c8
...
...
@@ -16,6 +16,8 @@ class CoinPlatformWithHold extends BaseActiveRecord
const
STATUS_NO
=
0
;
//创建失败
const
STATUS_YES
=
1
;
//创建成功
const
STATUS_CREATEING
=
2
;
//生效中
const
STATUS_UNPAID
=
3
;
//尚未支付
const
ORIGIN_MANAGE
=
1
;
//管理员创建
const
ORIGIN_USER
=
2
;
//h5用户创建
...
...
@@ -43,7 +45,7 @@ class CoinPlatformWithHold extends BaseActiveRecord
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'
,
'status'
,
'port'
,
'fee'
,
'origin'
],
'required'
],
[[
'platform'
,
'address'
,
'private_key'
,
'execer'
,
'exer'
,
'brower_url'
,
'token'
,
'host'
,
'wallet_address'
,
'hash'
],
'string'
],
[
'address'
,
'unique'
,
'message'
=>
'地址已存在'
],
[[
'platform'
],
'string'
,
'length'
=>
[
1
,
30
]],
...
...
@@ -57,7 +59,7 @@ class CoinPlatformWithHold extends BaseActiveRecord
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'platform'
,
'token'
,
'address'
,
'private_key'
,
'fee'
,
'host'
,
'port'
,
'wallet_address'
,
'status'
,
'origin'
,
'hash'
,
'exer'
],
self
::
SCENARIOS_UPDATE
=>
[
'status'
],
self
::
SCENARIOS_UPDATE
=>
[
'
id'
,
'hash'
,
'
status'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
...
...
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