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
c47fd6a1
Commit
c47fd6a1
authored
3 years ago
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
托管行情
parent
8d430edf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
2 deletions
+21
-2
MarketController.php
api/controllers/MarketController.php
+21
-2
No files found.
api/controllers/MarketController.php
View file @
c47fd6a1
...
...
@@ -2,6 +2,7 @@
namespace
api\controllers
;
use
common\models\psources\WalletCoinTicker
;
use
common\service\exchange\ExchangeFactory
;
use
Yii
;
use
api\base\BaseController
;
...
...
@@ -64,6 +65,25 @@ class MarketController extends BaseController
goto
doEnd
;
}
$currency_ticker
=
WalletCoinTicker
::
find
()
->
where
([
'coin_name'
=>
$currency
])
->
asArray
()
->
one
();
$base_currency_ticker
=
WalletCoinTicker
::
find
()
->
where
([
'coin_name'
=>
$base_currency
])
->
asArray
()
->
one
();
if
(
!
empty
(
$currency_ticker
)
&&
!
empty
(
$currency_ticker
))
{
$currency_quotation
=
[
'low'
=>
$currency_ticker
[
'ticker'
],
'high'
=>
$currency_ticker
[
'ticker'
],
'last'
=>
$currency_ticker
[
'ticker'
],
'rmb'
=>
$currency_ticker
[
'ticker'
],
];
$base_currency_quotation
=
[
'low'
=>
$base_currency_ticker
[
'ticker'
],
'high'
=>
$base_currency_ticker
[
'ticker'
],
'last'
=>
$base_currency_ticker
[
'ticker'
],
'rmb'
=>
$base_currency_ticker
[
'ticker'
],
];
goto
doEnd
;
}
$exchange
=
ExchangeFactory
::
createExchange
(
$exchange
);
if
(
'USDT'
==
strtoupper
(
$base_currency
))
{
...
...
@@ -112,9 +132,8 @@ class MarketController extends BaseController
'rmb'
=>
(
float
)
sprintf
(
"%0.2f"
,
$base_currency_ticker
[
'last'
]),
];
$this
->
data
=
rtrim
(
sprintf
(
'%.6f'
,
$currency_quotation
[
'last'
]
/
$base_currency_quotation
[
'last'
]),
'0'
);
doEnd
:
$this
->
data
=
rtrim
(
sprintf
(
'%.6f'
,
$currency_quotation
[
'last'
]
/
$base_currency_quotation
[
'last'
]),
'0'
);
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
}
...
...
This diff is collapsed.
Click to expand it.
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