Commit 7f5e535c authored by shajiaiming's avatar shajiaiming

自选分页

parent 809feb50
......@@ -2,6 +2,7 @@
namespace api\controllers;
use common\components\Tools;
use Yii;
use yii\data\Pagination;
use linslin\yii2\curl\Curl;
......@@ -170,8 +171,8 @@ class TickerController extends BaseController
$temp['symbol'] = $val['symbol'];
$temp['currency'] = strtoupper($tag_first);
$temp['base_currency'] = strtoupper($tag_second);
$temp['close'] = rtrim(sprintf('%.8f', floatval($quotation['last'])),'0');
$temp['close_usd'] = rtrim(sprintf('%.6f', floatval($quotation['last'] * $this->basic_price[$tag_second]['usd'])),'0');
$temp['close'] = rtrim(sprintf('%.8f', floatval($quotation['last'])), '0');
$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['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']);
......@@ -194,7 +195,24 @@ class TickerController extends BaseController
}
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 = [
......
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