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
7c1d219d
Commit
7c1d219d
authored
Sep 15, 2021
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/ticker' into 'master'
托管行情 See merge request
!486
parents
8d430edf
c47fd6a1
Show 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 @
7c1d219d
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
api\controllers
;
namespace
api\controllers
;
use
common\models\psources\WalletCoinTicker
;
use
common\service\exchange\ExchangeFactory
;
use
common\service\exchange\ExchangeFactory
;
use
Yii
;
use
Yii
;
use
api\base\BaseController
;
use
api\base\BaseController
;
...
@@ -64,6 +65,25 @@ class MarketController extends BaseController
...
@@ -64,6 +65,25 @@ class MarketController extends BaseController
goto
doEnd
;
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
);
$exchange
=
ExchangeFactory
::
createExchange
(
$exchange
);
if
(
'USDT'
==
strtoupper
(
$base_currency
))
{
if
(
'USDT'
==
strtoupper
(
$base_currency
))
{
...
@@ -112,9 +132,8 @@ class MarketController extends BaseController
...
@@ -112,9 +132,8 @@ class MarketController extends BaseController
'rmb'
=>
(
float
)
sprintf
(
"%0.2f"
,
$base_currency_ticker
[
'last'
]),
'rmb'
=>
(
float
)
sprintf
(
"%0.2f"
,
$base_currency_ticker
[
'last'
]),
];
];
$this
->
data
=
rtrim
(
sprintf
(
'%.6f'
,
$currency_quotation
[
'last'
]
/
$base_currency_quotation
[
'last'
]),
'0'
);
doEnd
:
doEnd
:
$this
->
data
=
rtrim
(
sprintf
(
'%.6f'
,
$currency_quotation
[
'last'
]
/
$base_currency_quotation
[
'last'
]),
'0'
);
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
}
}
...
...
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