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
00bec23d
Commit
00bec23d
authored
Jan 13, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
89a23586
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
105 additions
and
5 deletions
+105
-5
WalletCoinController.php
api/controllers/WalletCoinController.php
+100
-0
FlashController.php
wallet/controllers/FlashController.php
+5
-5
No files found.
api/controllers/WalletCoinController.php
0 → 100644
View file @
00bec23d
<?php
namespace
api\controllers
;
use
common\models\psources\Coin
;
use
common\models\psources\CoinCurrency
;
use
Yii
;
use
api\base\BaseController
;
use
common\business\ExchangeBusiness
;
use
common\models\psources\RecommendCoin
;
class
WalletCoinController
extends
BaseController
{
public
function
actionIndex
()
{
$header
=
Yii
::
$app
->
request
->
headers
;
$platform_id
=
$header
[
'FZM-PLATFORM-ID'
]
??
null
;
$names
=
Yii
::
$app
->
request
->
post
(
'names'
,
''
);
if
(
false
==
$names
||
false
==
$platform_id
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'参数错误'
;
goto
doEnd
;
}
foreach
(
$names
as
$key
=>
$val
)
{
if
(
strpos
(
$val
,
','
)
!==
false
)
{
$val_array
=
explode
(
','
,
$val
);
if
(
'USDT'
==
strtoupper
(
$val_array
[
0
])
&&
'BTC'
==
strtoupper
(
$val_array
[
1
]))
{
$condition
[]
=
[
$val_array
[
0
],
'omni'
];
continue
;
}
$condition
[]
=
[
$val_array
[
0
],
$val_array
[
1
]];
}
else
{
$condition
[]
=
$val
;
}
}
$this
->
data
=
[];
if
(
count
(
$condition
[
0
])
>
1
)
{
foreach
(
$condition
as
$val
)
{
if
(
'null'
==
$val
[
1
]
||
'coin'
==
$val
[
1
])
{
$this
->
data
[]
=
Coin
::
find
()
->
select
(
'id,sid,icon,name,optional_name,nickname,introduce,platform,chain,address as contract_address,treaty'
)
->
where
([
'name'
=>
$val
[
0
]])
->
asArray
()
->
one
();
continue
;
}
$this
->
data
[]
=
Coin
::
find
()
->
select
(
'id,sid,icon,name,optional_name,nickname,introduce,platform,chain,address as contract_address,treaty'
)
->
where
([
'name'
=>
$val
[
0
]])
->
andWhere
([
'platform'
=>
$val
[
1
]])
->
asArray
()
->
one
();
}
}
else
{
$this
->
data
=
Coin
::
find
()
->
select
(
'id,sid,icon,name,optional_name,nickname,introduce,platform,chain,address as contract_address,treaty'
)
->
where
([
'in'
,
'name'
,
$condition
])
->
asArray
()
->
all
();
}
if
(
empty
(
$this
->
data
))
{
goto
doEnd
;
}
$chains
=
array_column
(
$this
->
data
,
'chain'
);
$symbol
=
array_column
(
$this
->
data
,
'name'
);
$chains_symbols
=
array_keys
(
array_flip
(
$chains
)
+
array_flip
(
$symbol
));
$coin_quotations
=
ExchangeBusiness
::
getQuatationByNames
(
$chains_symbols
);
$last
[]
=
1
;
$currency
=
CoinCurrency
::
find
()
->
where
([
'pj_id'
=>
$this
->
currency_id
])
->
one
();
if
(
false
!=
$currency
)
{
if
(
1111
==
$this
->
currency_id
)
{
$last
[]
=
1
;
}
else
{
$last
=
Yii
::
$app
->
redis_currency
->
hmget
(
'quotation_boc_'
.
'CNY_'
.
$currency
->
symbol
,
'last'
);
}
}
$ticker
=
[
'low'
=>
0
,
'high'
=>
0
,
'last'
=>
0
,
'open'
=>
0
,
'vol'
=>
0
,
'rmb'
=>
0
,
'usd'
=>
0
];
foreach
(
$this
->
data
as
$key
=>
&
$val
)
{
$val
[
'chain_quotation'
]
=
isset
(
$coin_quotations
[
strtoupper
(
$val
[
'chain'
])])
?
$coin_quotations
[
strtoupper
(
$val
[
'chain'
])]
:
[];
$nickname
=
json_decode
(
$val
[
'nickname'
],
true
);
$val
[
'nickname'
]
=
isset
(
$nickname
[
$this
->
lang
])
?
$nickname
[
$this
->
lang
]
:
''
;
$introduce
=
json_decode
(
$val
[
'introduce'
],
true
);
$val
[
'introduce'
]
=
isset
(
$introduce
[
$this
->
lang
])
?
$introduce
[
$this
->
lang
]
:
''
;
$this
->
data
[
$key
]
=
array_merge
(
$val
,
isset
(
$coin_quotations
[
strtoupper
(
$val
[
'name'
])])
?
$coin_quotations
[
strtoupper
(
$val
[
'name'
])]
:
$ticker
);
$val
[
'chain_rmb'
]
=
isset
(
$val
[
'chain_quotation'
][
'rmb'
])
?
$val
[
'chain_quotation'
][
'rmb'
]
:
0
;
$val
[
'chain_usd'
]
=
isset
(
$val
[
'chain_quotation'
][
'usd'
])
?
$val
[
'chain_quotation'
][
'usd'
]
:
0
;
$val
[
'chain_country_rate'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$last
[
0
]
*
$val
[
'chain_rmb'
]);
$val
[
'country_rate'
]
=
(
false
==
$currency
)
?
$val
[
'rmb'
]
:
(
float
)
sprintf
(
"%0.4f"
,
$last
[
0
]
*
$val
[
'rmb'
]);
}
doEnd
:
return
[
'code'
=>
$this
->
code
,
'data'
=>
$this
->
data
,
'msg'
=>
$this
->
msg
];
}
}
\ No newline at end of file
wallet/controllers/FlashController.php
View file @
00bec23d
...
...
@@ -338,11 +338,11 @@ class FlashController extends BaseController
$group
=
Yii
::
$app
->
request
->
getGroup
();
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
0
);
if
(
User
::
AUTH_SUPER
!==
$group
&&
$platform_id
!=
Yii
::
$app
->
request
->
getPlatformId
())
{
$msg
=
'暂无权限'
;
$code
=
-
1
;
goto
doEnd
;
}
//
if (User::AUTH_SUPER !== $group && $platform_id != Yii::$app->request->getPlatformId()) {
//
$msg = '暂无权限';
//
$code = -1;
//
goto doEnd;
//
}
if
(
!
isset
(
Yii
::
$app
->
params
[
'trusteeship'
][
'node_'
.
$platform_id
]))
{
return
[
'code'
=>
-
1
,
'data'
=>
[],
'msg'
=>
'此钱包节点尚未开通'
];
}
...
...
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