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
f555604a
Commit
f555604a
authored
Feb 06, 2020
by
shajiaming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
84d0571c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
65 deletions
+53
-65
WalletChainController.php
api/controllers/WalletChainController.php
+27
-3
WalletChain.php
common/models/psources/WalletChain.php
+6
-5
Chain33Service.php
common/service/chain33/Chain33Service.php
+20
-5
CoinsControl.php
common/service/coin/CoinsControl.php
+0
-52
No files found.
api/controllers/WalletChainController.php
View file @
f555604a
...
...
@@ -2,6 +2,7 @@
namespace
api\controllers
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
use
api\base\BaseController
;
use
common\models\psources\WalletChain
;
...
...
@@ -35,7 +36,7 @@ class WalletChainController extends BaseController
$size
=
Yii
::
$app
->
request
->
get
(
'size'
,
10
);
$query
=
WalletChain
::
find
()
->
select
(
'id, token, platform'
)
->
select
(
'id, token, platform
, status
'
)
->
where
([
'wallet_address'
=>
$wallet_address
])
->
orderBy
(
'id'
);
...
...
@@ -92,14 +93,37 @@ class WalletChainController extends BaseController
'wallet_address'
=>
isset
(
$post
[
'wallet_address'
])
?
$post
[
'wallet_address'
]
:
''
,
'status'
=>
WalletChain
::
STATUS_NO
,
'origin'
=>
WalletChain
::
ORIGIN_MANAGE
,
'fee'
=>
isset
(
$post
[
'fee'
])
?
$post
[
'fee'
]
:
''
'fee'
=>
isset
(
$post
[
'fee'
])
?
$post
[
'fee'
]
:
''
,
'hash'
=>
isset
(
$post
[
'hash'
])
?
$post
[
'hash'
]
:
''
];
if
(
$model
->
load
(
$params
,
''
)
&&
!
$model
->
save
())
{
$this
->
msg
=
$model
->
errors
;
$this
->
code
=
-
1
;
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
);
$result
=
$service
->
addPara
(
$params
[
'platform'
],
$params
[
'host'
]
.
':'
.
$params
[
'port'
]);
if
(
0
!=
$result
[
'code'
])
{
$this
->
code
=
$result
[
'code'
];
$this
->
msg
=
$result
[
'msg'
];
goto
doEnd
;
}
$chain_update
=
WalletChain
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
$chain_update
->
setScenario
(
WalletChain
::
SCENARIOS_UPDATE
);
$chain_update
->
status
=
WalletChain
::
STATUS_YES
;
$chain_update
->
save
();
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
...
...
@@ -128,7 +152,7 @@ class WalletChainController extends BaseController
}
$model
=
WalletChain
::
find
()
->
select
(
'platform, token, address, private_key, fee, host, port, hash'
)
->
where
([
'id'
=>
(
int
)
$id
])
->
asArray
()
->
one
();
$model
=
WalletChain
::
find
()
->
select
(
'platform, token, address, private_key, fee, host, port, hash
, status
'
)
->
where
([
'id'
=>
(
int
)
$id
])
->
asArray
()
->
one
();
if
(
empty
(
$model
))
{
goto
doEnd
;
}
...
...
common/models/psources/WalletChain.php
View file @
f555604a
...
...
@@ -42,15 +42,16 @@ class WalletChain extends BaseActiveRecord
'port'
=>
'钱包服务端口'
,
'wallet_address'
=>
'钱包地址'
,
'status'
=>
'申请状态'
,
'origin'
=>
'创建人'
'origin'
=>
'创建人'
,
'hash'
=>
'申请费用hash'
];
}
public
function
rules
()
{
return
[
[[
'platform'
,
'address'
,
'private_key'
,
'execer'
,
'brower_url'
,
'token'
,
'host'
,
'wallet_address'
,
'status'
,
'port'
,
'fee'
,
'origin'
],
'required'
],
[[
'platform'
,
'address'
,
'private_key'
,
'execer'
,
'brower_url'
,
'token'
,
'host'
,
'wallet_address'
],
'string'
],
[[
'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'
],
[[
'platform'
],
'string'
,
'length'
=>
[
1
,
30
]],
[[
'token'
],
'string'
,
'length'
=>
[
1
,
10
]],
[[
'port'
,
'status'
,
'origin'
],
'integer'
]
...
...
@@ -60,8 +61,8 @@ class WalletChain extends BaseActiveRecord
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'platform'
,
'token'
,
'address'
,
'private_key'
,
'fee'
,
'host'
,
'port'
,
'wallet_address'
,
'status'
,
'origin'
],
self
::
SCENARIOS_UPDATE
=>
[
'
platform'
,
'token'
,
'address'
,
'private_key'
,
'fee'
,
'host'
,
'port'
,
'wallet_address'
,
'status'
,
'origin
'
],
self
::
SCENARIOS_CREATE
=>
[
'platform'
,
'token'
,
'address'
,
'private_key'
,
'fee'
,
'host'
,
'port'
,
'wallet_address'
,
'status'
,
'origin'
,
'hash'
],
self
::
SCENARIOS_UPDATE
=>
[
'
status
'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
...
...
common/service/chain33/Chain33Service.php
View file @
f555604a
...
...
@@ -54,12 +54,8 @@ class Chain33Service
return
json_encode
(
$data
);
}
public
function
send
(
$params
=
[],
$method
=
'Chain33.Query'
)
public
function
send
(
$params
=
[],
$method
=
'Chain33.Query'
,
$timeout
=
[]
)
{
$timeout
=
[
'connect_timeout'
=>
50000
,
'timeout_ms'
=>
40000
];
$ch
=
new
Curl
(
$timeout
);
$jsonrpc
=
self
::
jsonRpcBuild
(
$params
,
$method
);
$ch
->
setHeader
(
'Content-Type'
,
'application/json'
);
...
...
@@ -449,4 +445,23 @@ class Chain33Service
];
return
$this
->
send
(
$params
,
'Chain33.UnLock'
);
}
/**
* @param ParaName
* @param ParaSerAddr
* @return array|mixed
* 解锁钱包
*/
public
function
addPara
(
$paraName
,
$paraSerAddr
)
{
$params
=
[
'ParaName'
=>
$paraName
,
'ParaSerAddr'
=>
$paraSerAddr
,
];
$timeout
=
[
'connect_timeout'
=>
50000
,
'timeout_ms'
=>
50000
];
return
$this
->
send
(
$params
,
'CoinsControl.AddParaCoinsInfo'
,
$timeout
);
}
}
common/service/coin/CoinsControl.php
deleted
100644 → 0
View file @
84d0571c
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-5
* Time: 上午11:17
*/
namespace
common\service\coin
;
use
Yii
;
use
common\helpers\Curl
;
/**
* 币种服务类
* Class CoinService
* @package common\service
*/
class
CoinsControl
{
protected
$url
;
public
function
__construct
()
{
$this
->
url
=
Yii
::
$app
->
params
[
'para'
][
'scheme'
]
.
'/'
.
Yii
::
$app
->
params
[
'para'
][
'host'
]
.
'/'
.
Yii
::
$app
->
params
[
'para'
][
'port'
];
}
public
function
init
()
{
$url
=
Yii
::
$app
->
params
[
'feixiaohao_domain'
]
.
Yii
::
$app
->
params
[
'feixiaohao_page'
][
'currencies'
]
.
$this
->
sid
.
'/'
;
$ch
=
new
Curl
();
$content
=
$ch
->
get
(
$url
,
true
);
$this
->
content
=
str_replace
([
' '
,
' '
],
''
,
$content
);
}
/**
* Gets the Article List ,Without Content field.
*
* @param number $page
* @param number $page_size
* @param string $language
* @return mixed
*/
public
function
getArticleList
(
$page
=
1
,
$page_size
=
20
,
$language
=
BISHIJIE_LANGUAGE_CN
)
{
$params
=
array
(
'language'
=>
$language
,
'page'
=>
$page
,
'size'
=>
$page_size
);
return
$this
->
get
(
'article/list'
,
$params
);
}
}
\ 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