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
c850c3b7
Commit
c850c3b7
authored
Oct 15, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
行情排序
parent
dbd91bc4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
7 deletions
+31
-7
TickerController.php
api/controllers/TickerController.php
+2
-0
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+20
-2
TickerSortController.php
console/controllers/TickerSortController.php
+9
-5
No files found.
api/controllers/TickerController.php
View file @
c850c3b7
...
@@ -21,6 +21,8 @@ class TickerController extends BaseController
...
@@ -21,6 +21,8 @@ class TickerController extends BaseController
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$device_code
=
Yii
::
$app
->
request
->
get
(
'device_code'
,
''
);
$device_code
=
Yii
::
$app
->
request
->
get
(
'device_code'
,
''
);
$exchange
=
Yii
::
$app
->
request
->
get
(
'exchange'
,
'zhaobi'
);
$exchange
=
Yii
::
$app
->
request
->
get
(
'exchange'
,
'zhaobi'
);
$data_value
=
Yii
::
$app
->
request
->
get
(
'data-value'
,
''
);
$sort
=
Yii
::
$app
->
request
->
get
(
'sort'
,
''
);
$exchange_arr
=
[
'huobi'
,
'binance'
,
'okex'
,
'zhaobi'
];
$exchange_arr
=
[
'huobi'
,
'binance'
,
'okex'
,
'zhaobi'
];
if
(
!
in_array
(
$exchange
,
$exchange_arr
))
{
if
(
!
in_array
(
$exchange
,
$exchange_arr
))
{
...
...
common/service/exchange/factory/ZhaobiBuilder.php
View file @
c850c3b7
...
@@ -14,8 +14,10 @@ class ZhaobiBuilder extends FactoryService
...
@@ -14,8 +14,10 @@ class ZhaobiBuilder extends FactoryService
{
{
protected
$base_url
=
'https://api.biqianbao.top'
;
protected
$base_url
=
'https://api.biqianbao.top'
;
protected
$supported_symbol
=
'supported_symbol_zhaobi'
;
protected
$supported_symbol
=
'supported_symbol_zhaobi'
;
protected
$supported_symbol_list
=
'supported_symbol_zhaobi_list'
;
protected
$supported_symbol_close_sort_list
=
'supported_symbol_close_sort_zhaobi_list'
;
protected
$supported_symbol_close_sort_list
=
'supported_symbol_close_sort_zhaobi_list'
;
protected
$supported_symbol_change_sort_list
=
'supported_symbol_change_sort_zhaobi_list'
;
protected
$supported_symbol_change_sort_list
=
'supported_symbol_change_sort_zhaobi_list'
;
protected
$quotation_prefix
=
'quotation_zhaobi_'
;
public
function
getTickerFromCache
()
public
function
getTickerFromCache
()
{
{
...
@@ -66,10 +68,16 @@ class ZhaobiBuilder extends FactoryService
...
@@ -66,10 +68,16 @@ class ZhaobiBuilder extends FactoryService
public
function
TickerSort
()
public
function
TickerSort
()
{
{
$len
=
$this
->
redis
->
llen
(
$this
->
supported_symbol
);
$keys
=
$this
->
redis
->
smembers
(
$this
->
supported_symbol
);
if
(
false
==
$this
->
redis
->
exists
(
$this
->
supported_symbol_list
))
{
foreach
(
$keys
as
$val
)
{
$this
->
redis
->
lpush
(
$this
->
supported_symbol_list
,
$val
);
}
}
$len
=
$this
->
redis
->
llen
(
$this
->
supported_symbol_list
);
$ticker
=
[];
$ticker
=
[];
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
$symbol
=
$this
->
redis
->
lindex
(
$this
->
supported_symbol
,
$i
);
$symbol
=
$this
->
redis
->
lindex
(
$this
->
supported_symbol
_list
,
$i
);
list
(
$close
,
$open
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$symbol
),
'last'
,
'open'
);
list
(
$close
,
$open
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$symbol
),
'last'
,
'open'
);
$temp
=
[];
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
...
@@ -116,6 +124,15 @@ class ZhaobiBuilder extends FactoryService
...
@@ -116,6 +124,15 @@ class ZhaobiBuilder extends FactoryService
];
];
}
}
return
[
'code'
=>
$this
->
code
,
'notice'
=>
$data
];
return
[
'code'
=>
$this
->
code
,
'notice'
=>
$data
];
}
protected
function
arraySort
(
$array
,
$keys
,
$sort
=
SORT_DESC
)
{
$keysValue
=
[];
foreach
(
$array
as
$k
=>
$v
)
{
$keysValue
[
$k
]
=
$v
[
$keys
];
}
array_multisort
(
$keysValue
,
$sort
,
$array
);
return
$array
;
}
}
}
}
\ No newline at end of file
console/controllers/TickerController.php
→
console/controllers/Ticker
Sort
Controller.php
View file @
c850c3b7
...
@@ -9,17 +9,20 @@ use common\service\exchange\ExchangeBuilderFactory;
...
@@ -9,17 +9,20 @@ use common\service\exchange\ExchangeBuilderFactory;
use
yii\console\Controller
;
use
yii\console\Controller
;
use
Yii
;
use
Yii
;
class
TickerController
extends
Controller
class
Ticker
Sort
Controller
extends
Controller
{
{
/**
/**
* 行情排序
* 行情排序
*/
*/
public
function
action
TickerSort
()
public
function
action
Index
()
{
{
$class
=
[
/*'Binance', 'Huobi', */
'Zhaobi'
];
$class
=
[
'Binance'
,
'Huobi'
,
'Zhaobi'
];
foreach
(
$class
as
$val
)
{
foreach
(
$class
as
$val
)
{
$ticker_builder
=
ExchangeBuilderFactory
::
create
(
$val
);
go
(
function
()
use
(
$val
)
{
$ticker_builder
->
TickerSort
();
\Co
::
sleep
(
0.5
);
$ticker_builder
=
ExchangeBuilderFactory
::
create
(
$val
);
$ticker_builder
->
TickerSort
();
});
}
}
}
}
}
}
\ 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