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
2bb15a91
Commit
2bb15a91
authored
Nov 08, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/ticker' into develop
parents
df7f0eb1
7f5e535c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
15 deletions
+38
-15
TickerController.php
api/controllers/TickerController.php
+38
-15
No files found.
api/controllers/TickerController.php
View file @
2bb15a91
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
api\controllers
;
namespace
api\controllers
;
use
common\components\Tools
;
use
Yii
;
use
Yii
;
use
yii\data\Pagination
;
use
yii\data\Pagination
;
use
linslin\yii2\curl\Curl
;
use
linslin\yii2\curl\Curl
;
...
@@ -22,8 +23,8 @@ class TickerController extends BaseController
...
@@ -22,8 +23,8 @@ class TickerController extends BaseController
$device_code
=
Yii
::
$app
->
request
->
get
(
'device_code'
,
''
);
$device_code
=
Yii
::
$app
->
request
->
get
(
'device_code'
,
''
);
$platform_id
=
Yii
::
$app
->
request
->
get
(
'device_code'
,
0
);
$platform_id
=
Yii
::
$app
->
request
->
get
(
'device_code'
,
0
);
$exchange
=
Yii
::
$app
->
request
->
get
(
'exchange'
,
'zhaobi'
);
$exchange
=
Yii
::
$app
->
request
->
get
(
'exchange'
,
'zhaobi'
);
$data_value
=
Yii
::
$app
->
request
->
get
(
'data
-
value'
,
''
);
$data_value
=
Yii
::
$app
->
request
->
get
(
'data
_
value'
,
''
);
$sort_value
=
Yii
::
$app
->
request
->
get
(
'sort
-
value'
,
''
);
$sort_value
=
Yii
::
$app
->
request
->
get
(
'sort
_
value'
,
''
);
$exchange_arr
=
[
'huobi'
,
'binance'
,
'okex'
,
'zhaobi'
];
$exchange_arr
=
[
'huobi'
,
'binance'
,
'okex'
,
'zhaobi'
];
...
@@ -127,21 +128,26 @@ class TickerController extends BaseController
...
@@ -127,21 +128,26 @@ class TickerController extends BaseController
$msg
=
'参数错误'
;
$msg
=
'参数错误'
;
goto
doEnd
;
goto
doEnd
;
}
}
$data_value
=
Yii
::
$app
->
request
->
get
(
'data_value'
,
''
);
$sort_value
=
Yii
::
$app
->
request
->
get
(
'sort_value'
,
''
);
$condition
=
[];
if
(
false
!=
$data_value
&&
false
!=
$sort_value
)
{
$condition
=
[
'data_value'
=>
$data_value
,
'sort_value'
=>
$sort_value
];
}
$temp
=
[];
$temp
=
[];
$
query
=
CoinOptional
::
find
()
->
select
(
'symbol, platform'
)
$
data
=
CoinOptional
::
find
()
->
select
(
'symbol, platform'
)
->
where
([
'device_code'
=>
$device_code
,
'platform_id'
=>
(
int
)
$platform_id
])
->
where
([
'device_code'
=>
$device_code
,
'platform_id'
=>
(
int
)
$platform_id
])
->
orderBy
(
'update_time desc'
);
->
orderBy
(
'update_time desc'
)
$data
=
$query
->
offset
((
$page
-
1
)
*
50
)
->
limit
(
50
)
->
asArray
()
->
all
();
->
asArray
()
->
all
();
if
(
false
==
$data
)
{
if
(
false
==
$data
)
{
$msg
=
'success'
;
$msg
=
'success'
;
$code
=
0
;
$code
=
0
;
$data
=
[
$data
=
[];
'ticker'
=>
[],
'page'
=>
[
'pageSize'
=>
50
,
'currentPage'
=>
(
int
)
$page
,
]
];
goto
doEnd
;
goto
doEnd
;
}
}
$ticker
=
[];
$ticker
=
[];
...
@@ -165,8 +171,8 @@ class TickerController extends BaseController
...
@@ -165,8 +171,8 @@ class TickerController extends BaseController
$temp
[
'symbol'
]
=
$val
[
'symbol'
];
$temp
[
'symbol'
]
=
$val
[
'symbol'
];
$temp
[
'currency'
]
=
strtoupper
(
$tag_first
);
$temp
[
'currency'
]
=
strtoupper
(
$tag_first
);
$temp
[
'base_currency'
]
=
strtoupper
(
$tag_second
);
$temp
[
'base_currency'
]
=
strtoupper
(
$tag_second
);
$temp
[
'close'
]
=
number_format
(
$quotation
[
'last'
],
6
,
'.'
,
'
'
);
$temp
[
'close'
]
=
rtrim
(
sprintf
(
'%.8f'
,
floatval
(
$quotation
[
'last'
])),
'0
'
);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$quotation
[
'last'
]
*
$this
->
basic_price
[
$tag_second
][
'usd'
]
);
$temp
[
'close_usd'
]
=
rtrim
(
sprintf
(
'%.6f'
,
floatval
(
$quotation
[
'last'
]
*
$this
->
basic_price
[
$tag_second
][
'usd'
])),
'0'
);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
*
$this
->
basic_price
[
$tag_second
][
'rmb'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
*
$this
->
basic_price
[
$tag_second
][
'rmb'
]);
$temp
[
'change'
]
=
(
0
==
$quotation
[
'open'
])
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$quotation
[
'last'
]
-
$quotation
[
'open'
])
/
$quotation
[
'open'
]
*
100
);
$temp
[
'change'
]
=
(
0
==
$quotation
[
'open'
])
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$quotation
[
'last'
]
-
$quotation
[
'open'
])
/
$quotation
[
'open'
]
*
100
);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'high'
]
*
$this
->
basic_price
[
$tag_second
][
'usd'
]);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'high'
]
*
$this
->
basic_price
[
$tag_second
][
'usd'
]);
...
@@ -189,7 +195,24 @@ class TickerController extends BaseController
...
@@ -189,7 +195,24 @@ class TickerController extends BaseController
}
}
array_push
(
$ticker
,
$temp
);
array_push
(
$ticker
,
$temp
);
}
}
if
(
!
empty
(
$condition
))
{
if
(
'price'
==
$condition
[
'data_value'
])
{
if
(
'price-asc'
==
$condition
[
'sort_value'
])
{
$ticker
=
Tools
::
arraySort
(
$ticker
,
'close'
,
SORT_ASC
);
}
if
(
'price-desc'
==
$condition
[
'sort_value'
])
{
$ticker
=
Tools
::
arraySort
(
$ticker
,
'close'
,
SORT_DESC
);
}
}
if
(
'change'
==
$condition
[
'data_value'
])
{
if
(
'change-asc'
==
$condition
[
'sort_value'
])
{
$ticker
=
Tools
::
arraySort
(
$ticker
,
'change'
,
SORT_ASC
);
}
if
(
'change-desc'
==
$condition
[
'sort_value'
])
{
$ticker
=
Tools
::
arraySort
(
$ticker
,
'change'
,
SORT_DESC
);
}
}
}
}
}
$data
=
[
$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