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
99c5b3db
Commit
99c5b3db
authored
Feb 10, 2020
by
shajiaming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into develop
parents
e03bbbc0
2a0ad4fc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
MarketController.php
api/controllers/MarketController.php
+16
-1
No files found.
api/controllers/MarketController.php
View file @
99c5b3db
...
...
@@ -34,6 +34,13 @@ class MarketController extends BaseController
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'tick'
=>
$ticker
??
[]];
}
public
function
actionExchange
()
{
$exchanges
=
Yii
::
$app
->
params
[
'exchange'
];
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$exchanges
];
}
public
function
actionIndex
()
{
$currency
=
Yii
::
$app
->
request
->
post
(
'currency'
,
''
);
...
...
@@ -45,6 +52,12 @@ class MarketController extends BaseController
goto
doEnd
;
}
if
(
false
==
$exchange
||
!
in_array
(
$exchange
,
Yii
::
$app
->
params
[
'exchange'
]))
{
$this
->
msg
=
'invalid exchange'
;
$this
->
code
=
-
1
;
goto
doEnd
;
}
$exchange
=
ExchangeFactory
::
createExchange
(
$exchange
);
$currency_ticker
=
$exchange
->
getTicker
(
$currency
,
'USDT'
);
$base_currency_ticker
=
$exchange
->
getTicker
(
$base_currency
,
'USDT'
);
...
...
@@ -67,10 +80,11 @@ class MarketController extends BaseController
'rmb'
=>
(
float
)
sprintf
(
"%0.2f"
,
$base_currency_ticker
[
'last'
]),
];
$this
->
data
=
(
float
)
sprintf
(
"%0.4f"
,
$currency_quotation
[
'last'
]
/
$base_currency_quotation
[
'last'
]
);
$this
->
data
=
rtrim
(
sprintf
(
'%.6f'
,
$currency_quotation
[
'last'
]
/
$base_currency_quotation
[
'last'
]),
'0'
);
doEnd
:
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
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