Commit 1879956d authored by rlgy's avatar rlgy

接口数据格式修改

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