Commit 9eaa53d0 authored by shajiaiming's avatar shajiaiming

fix

parent ab9be1a1
......@@ -23,7 +23,7 @@ class TickerController extends BaseController
$platform_id = Yii::$app->request->get('device_code', 0);
$exchange = Yii::$app->request->get('exchange', 'zhaobi');
$data_value = Yii::$app->request->get('data-value', '');
$sort = Yii::$app->request->get('sort', '');
$sort_value = Yii::$app->request->get('sort-value', '');
$exchange_arr = ['huobi', 'binance', 'okex', 'zhaobi'];
......@@ -33,8 +33,15 @@ class TickerController extends BaseController
$data = [];
goto doEnd;
}
$condition = [];
if (false != $data_value && false != $sort_value) {
$condition = [
'data_value' => $data_value,
'sort_value' => $sort_value
];
}
$builder = ExchangeBuilderFactory::create($exchange);
$result = $builder->getTickerFromCache($page);
$result = $builder->getTickerFromCache($page, $condition);
$code = $result['code'];
$data = $result['data'];
......
......@@ -39,7 +39,7 @@ class HuobiBuilder extends FactoryService
}
}
public function getTickerFromCache($page = 1)
public function getTickerFromCache($page = 1, $condition = [])
{
$size = 0;
for ($i = 0; $i < $page; $i++) {
......@@ -59,7 +59,16 @@ class HuobiBuilder extends FactoryService
}
}
}
if (false != $condition) {
if ('price' == $condition['data_value']) {
$keys = $this->redis->lrange($this->supported_symbol_close_sort_list, $this->start, $this->end);
}
if ('sort' == $condition['data_value']) {
$keys = $this->redis->lrange($this->supported_symbol_change_sort_list, $this->start, $this->end);
}
} else {
$keys = $this->redis->lrange($this->supported_symbol_list, $this->start, $this->end);
}
$ticker = [];
foreach ($keys as $val) {
foreach ($this->basic_coin as $k => $coin) {
......@@ -112,11 +121,11 @@ class HuobiBuilder extends FactoryService
}
$ticker_sort_close = $this->arraySort($ticker, 'close');
foreach ($ticker_sort_close as $val) {
$this->redis->lpush($this->supported_symbol_close_sort_list, $val['symbol']);
$this->redis->lpush($this->supported_symbol_close_sort_list, strtolower($val['symbol']));
}
$ticker_change_close = $this->arraySort($ticker, 'change');
foreach ($ticker_change_close as $val) {
$this->redis->lpush($this->supported_symbol_change_sort_list, $val['symbol']);
$this->redis->lpush($this->supported_symbol_change_sort_list, strtolower($val['symbol']));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment