Commit 7c1d219d authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/ticker' into 'master'

托管行情 See merge request !486
parents 8d430edf c47fd6a1
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace api\controllers; namespace api\controllers;
use common\models\psources\WalletCoinTicker;
use common\service\exchange\ExchangeFactory; use common\service\exchange\ExchangeFactory;
use Yii; use Yii;
use api\base\BaseController; use api\base\BaseController;
...@@ -64,6 +65,25 @@ class MarketController extends BaseController ...@@ -64,6 +65,25 @@ class MarketController extends BaseController
goto doEnd; goto doEnd;
} }
$currency_ticker = WalletCoinTicker::find()->where(['coin_name' => $currency])->asArray()->one();
$base_currency_ticker = WalletCoinTicker::find()->where(['coin_name' => $base_currency])->asArray()->one();
if (!empty($currency_ticker) && !empty($currency_ticker)) {
$currency_quotation = [
'low' => $currency_ticker['ticker'],
'high' => $currency_ticker['ticker'],
'last' => $currency_ticker['ticker'],
'rmb' => $currency_ticker['ticker'],
];
$base_currency_quotation = [
'low' => $base_currency_ticker['ticker'],
'high' => $base_currency_ticker['ticker'],
'last' => $base_currency_ticker['ticker'],
'rmb' => $base_currency_ticker['ticker'],
];
goto doEnd;
}
$exchange = ExchangeFactory::createExchange($exchange); $exchange = ExchangeFactory::createExchange($exchange);
if ('USDT' == strtoupper($base_currency)) { if ('USDT' == strtoupper($base_currency)) {
...@@ -112,9 +132,8 @@ class MarketController extends BaseController ...@@ -112,9 +132,8 @@ class MarketController extends BaseController
'rmb' => (float)sprintf("%0.2f", $base_currency_ticker['last']), 'rmb' => (float)sprintf("%0.2f", $base_currency_ticker['last']),
]; ];
$this->data = rtrim(sprintf('%.6f', $currency_quotation['last'] / $base_currency_quotation['last']), '0');
doEnd : doEnd :
$this->data = rtrim(sprintf('%.6f', $currency_quotation['last'] / $base_currency_quotation['last']), '0');
return ['code' => $this->code, 'msg' => $this->msg, 'data' => $this->data]; return ['code' => $this->code, 'msg' => $this->msg, 'data' => $this->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