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
c576f397
Commit
c576f397
authored
Oct 17, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/ticker' into 'master'
修复已知问题 See merge request
!157
parents
c8622bfc
dd51be96
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
12 deletions
+24
-12
TickerController.php
api/controllers/TickerController.php
+17
-7
CoinOptional.php
common/models/psources/CoinOptional.php
+7
-5
No files found.
api/controllers/TickerController.php
View file @
c576f397
...
...
@@ -20,11 +20,19 @@ class TickerController extends BaseController
{
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$device_code
=
Yii
::
$app
->
request
->
get
(
'device_code'
,
''
);
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
''
);
$exchange
=
Yii
::
$app
->
request
->
get
(
'exchange'
,
'zhaobi'
);
$data_value
=
Yii
::
$app
->
request
->
get
(
'data-value'
,
''
);
$sort
=
Yii
::
$app
->
request
->
get
(
'sort'
,
''
);
$data_value
=
Yii
::
$app
->
request
->
get
(
'data-value'
,
''
);
$sort
=
Yii
::
$app
->
request
->
get
(
'sort'
,
''
);
$exchange_arr
=
[
'huobi'
,
'binance'
,
'okex'
,
'zhaobi'
];
if
(
false
==
$platform_id
)
{
$msg
=
'参数错误'
;
$code
=
-
1
;
$data
=
[];
goto
doEnd
;
}
if
(
!
in_array
(
$exchange
,
$exchange_arr
))
{
$msg
=
'不存在的交易平台'
;
$code
=
-
1
;
...
...
@@ -37,7 +45,7 @@ class TickerController extends BaseController
$data
=
$result
[
'data'
];
if
(
false
!=
$device_code
)
{
$coin_optional
=
CoinOptional
::
find
()
->
select
(
'symbol'
)
->
where
([
'platform'
=>
$exchange
,
'device_code'
=>
$device_code
])
->
asArray
()
->
all
();
$coin_optional
=
CoinOptional
::
find
()
->
select
(
'symbol'
)
->
where
([
'platform'
=>
$exchange
,
'device_code'
=>
$device_code
,
'platform_id'
=>
$platform_id
])
->
asArray
()
->
all
();
$coin_optional
=
ArrayHelper
::
getColumn
(
$coin_optional
,
'symbol'
);
foreach
(
$data
[
'ticker'
]
as
&
$val
)
{
if
(
in_array
(
$val
[
'symbol'
],
$coin_optional
))
{
...
...
@@ -82,8 +90,9 @@ class TickerController extends BaseController
$symbol
=
$request
->
post
(
'symbol'
,
''
);
$platform
=
$request
->
post
(
'platform'
,
''
);
$device_code
=
$request
->
post
(
'device_code'
,
''
);
$platform_id
=
$request
->
post
(
'platform_id'
,
''
);
if
(
empty
(
$symbol
)
||
empty
(
$platform
)
||
empty
(
$device_code
))
{
if
(
empty
(
$symbol
)
||
empty
(
$platform
)
||
empty
(
$device_code
)
||
empty
(
$platform_id
)
)
{
$msg
=
'参数错误'
;
goto
doEnd
;
}
...
...
@@ -106,14 +115,15 @@ class TickerController extends BaseController
if
(
$request
->
isGet
)
{
$device_code
=
$request
->
get
(
'device_code'
,
''
);
$platform_id
=
$request
->
get
(
'platform_id'
,
''
);
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
if
(
empty
(
$device_code
)
)
{
if
(
false
==
$device_code
||
false
==
$platform_id
)
{
$msg
=
'参数错误'
;
goto
doEnd
;
}
$temp
=
[];
$query
=
CoinOptional
::
find
()
->
select
(
'symbol, platform'
)
->
where
([
'device_code'
=>
$device_code
])
->
where
([
'device_code'
=>
$device_code
,
'platform_id'
=>
$platform_id
])
->
orderBy
(
'update_time desc'
);
$data
=
$query
->
offset
((
$page
-
1
)
*
50
)
->
limit
(
50
)
->
asArray
()
->
all
();
if
(
false
==
$data
)
{
...
...
@@ -145,7 +155,7 @@ class TickerController extends BaseController
$exchange
=
ExchangeFactory
::
createExchange
(
$exchange
);
$quotation
=
$exchange
->
getTicker
(
strtolower
(
$tag_first
),
strtolower
(
$tag_second
));
if
(
empty
(
$quotation
))
continue
;
if
(
empty
(
$quotation
))
continue
;
$temp
[
'symbol'
]
=
$val
[
'symbol'
];
$temp
[
'currency'
]
=
strtoupper
(
$tag_first
);
$temp
[
'base_currency'
]
=
strtoupper
(
$tag_second
);
...
...
common/models/psources/CoinOptional.php
View file @
c576f397
...
...
@@ -21,16 +21,18 @@ class CoinOptional extends BaseActiveRecord
const
SCENARIOS_CREATE
=
'create'
;
public
function
rules
()
{
public
function
rules
()
{
return
[
[[
'symbol'
,
'platform'
,
'device_code
'
],
'required'
],
[[
'symbol'
,
'platform'
,
'device_code'
,
'platform_id
'
],
'required'
],
];
}
public
function
scenarios
()
{
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'symbol'
,
'platform'
,
'device_code
'
],
self
::
SCENARIOS_CREATE
=>
[
'symbol'
,
'platform'
,
'device_code'
,
'platform_id
'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
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