Commit c8997076 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/optimize' into 'master'

fix See merge request !499
parents 9de92d26 5e2cb024
......@@ -250,7 +250,7 @@ class CoinController extends BaseController
foreach ($chains as $key => $value) {
$chain_quotation[$value] = ExchangeBusiness::getquatation($value);
}
$last[] = $rate[] = 1;
$last[] = 1;
$currency = CoinCurrency::find()->where(['pj_id' => $this->currency_id])->one();
if (false != $currency) {
if (1111 == $this->currency_id) {
......@@ -259,12 +259,11 @@ class CoinController extends BaseController
if (Yii::$app->redis->hkeys('quotation_go_CNY_USD')) {
$last[0] = 1 / Yii::$app->redis->hmget('quotation_go_CNY_USD', 'last')[0];
} else {
$last = Yii::$app->redis_currency->hmget('quotation_currency_' . 'USD_' . $currency->symbol, 'last');
$last = Yii::$app->redis_currency->hmget('quotation_boc_' . 'CNY_' . $currency->symbol, 'last');
}
} else {
$last = Yii::$app->redis_currency->hmget('quotation_currency_' . 'USD_' . $currency->symbol, 'last');
$last = Yii::$app->redis_currency->hmget('quotation_boc_' . 'CNY_' . $currency->symbol, 'last');
}
$rate = Yii::$app->redis_currency->hmget('quotation_currency_' . 'CNY_' . $currency->symbol, 'last');
}
foreach ($result['data'] as $key => &$value) {
......@@ -276,8 +275,8 @@ class CoinController extends BaseController
$value['chain_quotation'] = $chain_quotation[$value['chain']] ?: null;
$value['chain_rmb'] = isset($value['chain_quotation']['rmb']) ? $value['chain_quotation']['rmb'] : 0;
$value['chain_usd'] = isset($value['chain_quotation']['usd']) ? $value['chain_quotation']['usd'] : 0;
$value['chain_country_rate'] = (float)sprintf("%0.4f", $rate[0] * $value['chain_rmb']);
$value['country_rate'] = (false == $currency) ? $value['rmb'] : (float)sprintf("%0.4f", $last[0] * $value['last']);
$value['chain_country_rate'] = (float)sprintf("%0.4f", $last[0] * $value['chain_rmb']);
$value['country_rate'] = (false == $currency) ? $value['rmb'] : (float)sprintf("%0.4f", $last[0] * $value['rmb']);
}
return $result;
}
......
......@@ -432,7 +432,7 @@ class TickerController extends BaseController
if (1111 == $val->currency->pj_id) {
$rate = (string)1;
} else {
list($rate) = Yii::$app->redis_currency->hmget('quotation_currency_' . 'CNY_' . $val->currency->symbol, 'last');
list($rate) = Yii::$app->redis_currency->hmget('quotation_boc_' . 'CNY_' . $val->currency->symbol, 'last');
}
$val->pj_id = $val->currency->pj_id;
$val->pj_name = $val->currency->pj_name;
......
......@@ -79,11 +79,14 @@ class WalletCoinController extends BaseController
$chains_symbols = array_keys(array_flip($chains) + array_flip($symbol));
$coin_quotations = ExchangeBusiness::getQuatationByNames($chains_symbols);
$last[] = $rate[] = 1;
$last[] = 1;
$currency = CoinCurrency::find()->where(['pj_id' => $this->currency_id])->one();
if (false != $currency) {
$rate = Yii::$app->redis_currency->hmget('quotation_currency_' . 'CNY_' . $currency->symbol, 'last');
$last = Yii::$app->redis_currency->hmget('quotation_currency_' . 'USD_' . $currency->symbol, 'last');
if (1111 == $this->currency_id) {
$last[] = 1;
} else {
$last = Yii::$app->redis_currency->hmget('quotation_boc_' . 'CNY_' . $currency->symbol, 'last');
}
}
$ticker = ['low' => 0, 'high' => 0, 'last' => 0, 'open' => 0, 'vol' => 0, 'rmb' => 0, 'usd' => 0];
......@@ -97,8 +100,8 @@ class WalletCoinController extends BaseController
$val['chain_rmb'] = isset($val['chain_quotation']['rmb']) ? $val['chain_quotation']['rmb'] : 0;
$val['chain_usd'] = isset($val['chain_quotation']['usd']) ? $val['chain_quotation']['usd'] : 0;
$val['chain_country_rate'] = (float)sprintf("%0.4f", $rate[0] * $val['chain_rmb']);
$val['country_rate'] = (false == $currency) ? $val['rmb'] : (float)sprintf("%0.4f", $last[0] * $val['last']);
$val['chain_country_rate'] = (float)sprintf("%0.4f", $last[0] * $val['chain_rmb']);
$val['country_rate'] = (false == $currency) ? $val['rmb'] : (float)sprintf("%0.4f", $last[0] * $val['rmb']);
unset($val['chain_quotation']);
}
......
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