Commit 809feb50 authored by shajiaiming's avatar shajiaiming

fix

parent 690ded30
...@@ -22,8 +22,8 @@ class TickerController extends BaseController ...@@ -22,8 +22,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 +127,26 @@ class TickerController extends BaseController ...@@ -127,21 +127,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 +170,8 @@ class TickerController extends BaseController ...@@ -165,8 +170,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']);
......
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