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
edd1d8d6
Commit
edd1d8d6
authored
Nov 25, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
60312f92
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
21 deletions
+51
-21
IssueChainController.php
api/controllers/IssueChainController.php
+5
-1
CoinIssueCoin.php
common/models/psources/CoinIssueCoin.php
+0
-5
CoinPlatform.php
common/models/psources/CoinPlatform.php
+1
-5
CoinPlatformWithHold.php
common/models/psources/CoinPlatformWithHold.php
+6
-0
IssueChainController.php
wallet/controllers/IssueChainController.php
+39
-10
No files found.
api/controllers/IssueChainController.php
View file @
edd1d8d6
...
...
@@ -2,6 +2,7 @@
namespace
api\controllers
;
use
common\models\psources\Coin
;
use
Yii
;
use
api\base\BaseController
;
use
common\models\psources\CoinPlatform
;
...
...
@@ -35,7 +36,10 @@ class IssueChainController extends BaseController
foreach
(
$chain_model
as
&
$val
)
{
$val
->
chain_name
=
isset
(
$val
->
chain
->
platform
)
?
$val
->
chain
->
platform
:
''
;
$val
->
issue_charge
=
(
float
)
sprintf
(
"%0.3f"
,
$val
->
issue_charge
);
$val
->
charge_unit
=
isset
(
$val
->
gas
->
coin_name
)
?
$val
->
gas
->
coin_name
:
''
;
$val
->
exer
=
isset
(
$val
->
chain
->
exer
)
?
$val
->
chain
->
exer
:
''
;
$coin_model
=
Coin
::
find
()
->
select
(
'name'
)
->
where
([
'name'
=>
strtoupper
(
$val
->
charge_unit
),
'platform'
=>
$val
->
chain_name
,
'treaty'
=>
2
])
->
one
();
$val
->
tokens
=
empty
(
$coin_model
)
?
false
:
true
;
unset
(
$val
->
download_url
);
unset
(
$val
->
introduce
);
unset
(
$val
->
create_time
);
...
...
common/models/psources/CoinIssueCoin.php
View file @
edd1d8d6
...
...
@@ -179,11 +179,6 @@ class CoinIssueCoin extends CommonActiveRecord
return
$this
->
hasOne
(
CoinPlatform
::
className
(),
[
'id'
=>
'platform_id'
]);
}
public
function
getGas
()
{
return
$this
->
hasOne
(
CoinSupportedCoin
::
className
(),
[
'id'
=>
'charge_unit_id'
]);
}
public
function
getTransfer
()
{
return
$this
->
hasOne
(
CoinIssueChainRecord
::
className
(),
[
'issue_coin_id'
=>
'id'
]);
...
...
common/models/psources/CoinPlatform.php
View file @
edd1d8d6
...
...
@@ -77,7 +77,7 @@ class CoinPlatform extends BaseActiveRecord
public
function
attributes
()
{
return
array_merge
(
parent
::
attributes
(),
[
'chain_name'
,
'charge_unit'
]);
return
array_merge
(
parent
::
attributes
(),
[
'chain_name'
,
'charge_unit'
,
'tokens'
,
'exer'
]);
}
public
function
getChain
()
...
...
@@ -85,8 +85,4 @@ class CoinPlatform extends BaseActiveRecord
return
$this
->
hasOne
(
CoinPlatformWithHold
::
className
(),
[
'id'
=>
'chain_id'
]);
}
public
function
getGas
()
{
return
$this
->
hasOne
(
CoinSupportedCoin
::
className
(),
[
'id'
=>
'charge_unit_id'
]);
}
}
common/models/psources/CoinPlatformWithHold.php
View file @
edd1d8d6
...
...
@@ -70,4 +70,9 @@ class CoinPlatformWithHold extends BaseActiveRecord
return
[
'code'
=>
$exception
->
getCode
(),
'message'
=>
$exception
->
getMessage
()];
}
}
public
function
attributes
()
{
return
array_merge
(
parent
::
attributes
(),
[
'tokens'
]);
}
}
\ No newline at end of file
wallet/controllers/IssueChainController.php
View file @
edd1d8d6
...
...
@@ -2,7 +2,9 @@
namespace
wallet\controllers
;
use
common\models\psources\Coin
;
use
common\models\psources\CoinPlatform
;
use
common\models\psources\CoinPlatformWithHold
;
use
common\models\psources\CoinSupportedCoin
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
...
...
@@ -102,10 +104,10 @@ class IssueChainController extends BaseController
$result
=
Yii
::
$app
->
request
->
post
();
$issue_charge
=
isset
(
$result
[
'issue_charge'
])
?
$result
[
'issue_charge'
]
:
''
;
$charge_unit
_id
=
isset
(
$result
[
'charge_unit_id'
])
?
strtoupper
(
$result
[
'charge_unit_id
'
])
:
''
;
$charge_unit
=
isset
(
$result
[
'charge_unit'
])
?
strtoupper
(
$result
[
'charge_unit
'
])
:
''
;
$id
=
isset
(
$result
[
'platform_id'
])
?
(
int
)
$result
[
'platform_id'
]
:
0
;
if
(
false
==
$issue_charge
||
false
==
$charge_unit
_id
)
{
if
(
false
==
$issue_charge
||
false
==
$charge_unit
)
{
$msg
=
'提交数据有误'
;
$code
=
-
1
;
goto
doEnd
;
...
...
@@ -123,7 +125,7 @@ class IssueChainController extends BaseController
}
$chain_model
->
issue_charge
=
$issue_charge
;
$chain_model
->
charge_unit
_id
=
$charge_unit_id
;
$chain_model
->
charge_unit
=
$charge_unit
;
if
(
false
==
$chain_model
->
save
())
{
$msg
=
'手续费设置失败'
;
$code
=
-
1
;
...
...
@@ -173,18 +175,44 @@ class IssueChainController extends BaseController
public
function
actionGetTokens
()
{
$data
=
null
;
$group
=
Yii
::
$app
->
request
->
getGroup
();
if
(
'administrator'
==
$group
)
{
$chains
=
array_keys
(
Yii
::
$app
->
params
[
'chain_nodes'
]);
$platform
=
CoinPlatformWithHold
::
find
()
->
select
(
'id, platform, exer'
)
->
where
([
'in'
,
'platform'
,
$chains
])
->
all
();
$execer
=
\Yii
::
$app
->
request
->
post
(
'execer'
,
'token'
);
$node
=
Yii
::
$app
->
params
[
'chain_nodes'
][
'STO'
];
$service
=
new
Chain33Service
(
$node
);
$funcName
=
'GetTokens'
;
$result
=
$service
->
getTokens
(
'user.p.daitao.token'
,
$funcName
);
echo
json_encode
(
$result
);
exit
;
}
else
{
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
$chain_model
=
CoinPlatform
::
find
()
->
select
(
'chain_id'
)
->
where
([
'id'
=>
$platform_id
])
->
andWhere
([
'<>'
,
'chain_id'
,
0
])
->
one
();
$platform
=
CoinPlatformWithHold
::
find
()
->
select
(
'id, platform, exer'
)
->
where
([
'id'
=>
$chain_model
->
chain_id
])
->
all
();
}
foreach
(
$platform
as
$val
)
{
$val
->
tokens
=
[];
if
(
!
empty
(
$val
->
exer
))
{
$node
=
Yii
::
$app
->
params
[
'chain_nodes'
][
strtoupper
(
$val
->
platform
)];
$service
=
new
Chain33Service
(
$node
);
$funcName
=
'GetTokens'
;
$result
=
$service
->
getTokens
(
$val
->
exer
,
$funcName
);
if
(
isset
(
$result
[
'code'
])
&&
0
==
$result
[
'code'
])
{
$symbol
=
[];
foreach
(
$result
[
'result'
][
'tokens'
]
as
$temp
)
{
$symbol
[]
=
$temp
[
'symbol'
];
}
}
$coin_model
=
Coin
::
find
()
->
select
(
'name'
)
->
where
([
'platform'
=>
$val
->
platform
,
'treaty'
=>
2
])
->
one
();
if
(
!
empty
(
$coin_model
))
{
array_unshift
(
$symbol
,
$coin_model
->
name
);
}
array_unshift
(
$symbol
,
'BTY'
);
$val
->
tokens
=
$symbol
;
}
}
$data
=
$platform
;
$code
=
0
;
$msg
=
'success'
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
];
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
}
\ 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