Commit 24a108c2 authored by rlgy's avatar rlgy

接口数据格式修改

parent 1879956d
......@@ -131,10 +131,10 @@ class ExchangeBusiness
//使用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();
$rows[$key]['rmb'] = sprintf("%0.2f", $coinServer->getPrice());
$rows[$key]['last'] = sprintf("%0.4f", $coinServer->getDollar());
$rows[$key]['low'] = sprintf("%0.2f", $coinServer->getLow());
$rows[$key]['high'] = sprintf("%0.2f", $coinServer->getHigh());
$coinServer->__destruct();
}
$rows[$key] = array_merge($rows[$key], $quotation);
......
......@@ -141,11 +141,11 @@ class CoinService extends Coin implements CoinInterface
}
preg_match_all('/<div class=lowHeight>(.*?)<\/div><div class=sub>/is', $this->content, $matchs);
preg_match_all('/<span class=value>(.*?)<\/span>/is', $matchs[1][0], $matchs);
$this->setHigh(str_replace(['$', '≈', ','], '', $matchs[1][0]));
$this->setHigh(str_replace(['', ','], '', $matchs[1][0]));
Yii::$app->cache->set($this->cache_key_prifx . $this->sid . '_high', $this->high,
Yii::$app->params['curl_cache_time']['quotation']);
} else {
$this->setBtc($result);
$this->setHigh($result);
}
return $this->high;
}
......@@ -170,7 +170,7 @@ class CoinService extends Coin implements CoinInterface
}
preg_match_all('/<div class=lowHeight>(.*?)<\/div><div class=sub>/is', $this->content, $matchs);
preg_match_all('/<span class=value>(.*?)<\/span>/is', $matchs[1][0], $matchs);
$this->setLow(str_replace(['$', '≈', ','], '', $matchs[1][1]));
$this->setLow(str_replace(['', ','], '', $matchs[1][1]));
Yii::$app->cache->set($this->cache_key_prifx . $this->sid . '_low', $this->low,
Yii::$app->params['curl_cache_time']['quotation']);
} else {
......
......@@ -84,4 +84,14 @@ class CoinYCCService extends Coin implements CoinInterface
return 0;
}
public function getHigh()
{
return 0.2;
}
public function getLow()
{
return 0.2;
}
}
\ No newline at end of file
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