Commit 1879956d authored by rlgy's avatar rlgy

接口数据格式修改

parent e6c70099
......@@ -139,6 +139,12 @@ class CoinBusiness
{
$row = Coin::find()->where(['id' => $id])->asArray()->One();
if ($row) {
if (empty($row['publish_count'])) {
$row['publish_count'] = 0;
}
if (empty($row['circulate_count'])) {
$row['circulate_count'] = 0;
}
$coin = CoinFactory::createCoin($row['name'], $row['id'], $row['sid']);
$row['quotation'] = $coin->quotation();
$row['exchange'] = $coin->exchange();
......
......@@ -77,9 +77,9 @@ class ExchangeBusiness
}
//格式化行情数据
foreach ($quotation as $key => $item) {
$quotation[$key] = (double)$item;
$quotation[$key] = sprintf("%0.4f", (double)$item);
}
$quotation['rmb'] = 6.6 * $quotation['last'];
$quotation['rmb'] = sprintf("%0.2f", 6.6 * $quotation['last']);
return $quotation;
}
......@@ -158,19 +158,19 @@ class ExchangeBusiness
$rows = $rows['data'];
foreach ($rows as $key => $row) {
$rows[$key]['sid'] = ucfirst($rows[$key]['sid']);
$quotation = self::getquatation($row['name']);
if (!$quotation) {
$quotation = [];
//使用Coin服务
$coinServer = CoinFactory::createCoin($row['name'], $row['id'], $row['sid']);
$rows[$key]['sid'] = ucfirst($rows[$key]['sid']);
$rows[$key]['rmb'] = $coinServer->getPrice();
$rows[$key]['last'] = $coinServer->getDollar();
$rows[$key]['low'] = $coinServer->getLow();
$rows[$key]['high'] = $coinServer->getHigh();
$coinServer->__destruct();
}
$rows[$key] = array_merge($rows[$key], $quotation);
// $quotation = self::getquatation($row['name']);
// if (!$quotation) {
// $quotation = [];
// //使用Coin服务
// $coinServer = CoinFactory::createCoin($row['name'], $row['id'], $row['sid']);
// $rows[$key]['sid'] = ucfirst($rows[$key]['sid']);
// $rows[$key]['rmb'] = $coinServer->getPrice();
// $rows[$key]['last'] = $coinServer->getDollar();
// $rows[$key]['low'] = $coinServer->getLow();
// $rows[$key]['high'] = $coinServer->getHigh();
// $coinServer->__destruct();
// }
// $rows[$key] = array_merge($rows[$key], $quotation);
}
return $rows;
}
......
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