Commit 674ffd86 authored by shajiaiming's avatar shajiaiming

Merge branch 'master' into feature/ucenter

parents bc82505f 45c902dd
......@@ -223,9 +223,16 @@ class CoinController extends BaseController
return ['code' => 0, 'data' => []];
}
foreach ($names as $key => $val) {
if(strpos($val, ',') !== false){
$val_array = explode(',', $val);
if(count($val_array) < 2) continue;
if('USDT' == strtoupper($val_array[0]) && 'BTC' == strtoupper($val_array[1])) {
$condition[] = [$val_array[0], 'omni'];
continue;
}
$condition[] = [$val_array[0], $val_array[1]];
} else {
$condition[] = $val;
}
}
$result = ExchangeBusiness::getApiListForIndex(1, 999, $condition);
if ($result) {
......
......@@ -101,49 +101,52 @@ class ExchangeBusiness
if (in_array(strtoupper($tag), ['FOLI'])) {
$exchange = ExchangeFactory::createExchange("Ex");
$quotation = $exchange->getTicker($tag, 'USDT');
$quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
goto doEnd;
}
if (in_array(strtoupper($tag), ['GM', 'BSTC'])) {
$exchange = ExchangeFactory::createExchange("Token7");
$quotation = $exchange->getTicker($tag, 'HA');
$quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
goto doEnd;
}
if (in_array(strtoupper($tag), ['BECC'])) {
$exchange = ExchangeFactory::createExchange("S");
$quotation = $exchange->getTicker($tag, 'ST');
$quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
goto doEnd;
}
if (in_array(strtoupper($tag), ['GHP'])) {
$exchange = ExchangeFactory::createExchange("Zg");
$quotation = $exchange->getTicker($tag, 'CNZ');
$quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
goto doEnd;
}
if (in_array(strtoupper($tag), ['SFT'])) {
$exchange = ExchangeFactory::createExchange("Zhaobi");
$quotation = $exchange->getTicker($tag, 'CNY');
$quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation['low'] = (float)sprintf("%0.4f", $quotation['low']);
$quotation['high'] = (float)sprintf("%0.4f", $quotation['high']);
$quotation['last'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
goto doEnd;
}
if (in_array(strtoupper($tag), ['CTG'])) {
$exchange = ExchangeFactory::createExchange("Gdpro");
$quotation = $exchange->getTicker($tag, 'CNY');
$quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
goto doEnd;
}
if (in_array(strtoupper($tag), ['USDT'])) {
$exchange = ExchangeFactory::createExchange("Go");
$quotation = $exchange->getTicker('CNY', 'USD');
$quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
goto doEnd;
}
......@@ -154,7 +157,7 @@ class ExchangeBusiness
'low' => (float)sprintf("%0.4f", $quotation['low'] / 100),
'high' => (float)sprintf("%0.4f", $quotation['high'] / 100),
'last' => (float)sprintf("%0.4f", $quotation['last'] / 100),
'rmb' => (float)sprintf("%0.4f", $quotation['last'] / 100),
'rmb' => (float)sprintf("%0.2f", $quotation['last'] / 100),
];
goto doEnd;
}
......@@ -216,7 +219,12 @@ class ExchangeBusiness
$exchange = ExchangeFactory::createExchange("Go");
$rate = $exchange->getTicker("CNY", "USD");
$cny_usd_rate = 1 / $rate['last'];
if (in_array(strtoupper($tag), ['FOLI'])) {
$quotation['usd'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last'] / $cny_usd_rate);
} else {
$quotation['usd'] = (float)sprintf("%0.4f", $quotation['rmb'] * $cny_usd_rate);
}
return $quotation;
}
......@@ -260,8 +268,9 @@ class ExchangeBusiness
*/
public static function getApiListForIndex($page = 1, $limit = 999, $condition = [], $fields = [])
{
if (count($condition[0]) > 1) {
foreach ($condition as $val) {
if($val[1] == 'null'){
if ('null' == $val[1] || 'coin' == $val[1]) {
$data[] = Coin::find()->select('id,sid,icon,name,optional_name,nickname,platform,chain,address as contract_address,treaty')
->where(['name' => $val[0]])
->asArray()
......@@ -274,6 +283,11 @@ class ExchangeBusiness
->asArray()
->one();
}
} else {
$data = Coin::find()->select('id,sid,icon,name,optional_name,nickname,platform,chain,address as contract_address,treaty')
->where(['in', 'name', $condition])
->asArray()->all();
}
$rows = [
'count' => count($data),
'data' => $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