Commit 5fbea1bc authored by rlgy's avatar rlgy

bugfix

parent 22a4e81b
......@@ -12,14 +12,17 @@ use common\models\psources\Coin;
use common\service\coin\CoinFactory;
use common\service\exchange\ExchangeFactory;
use Yii;
/**
* Class ExchangeBusiness
* 各大交易所交易所api逻辑层
*
* @package common\business
*/
class ExchangeBusiness
{
/**支持的交易所
*
* @var array
*/
private static $exchanges = [
......@@ -33,6 +36,7 @@ class ExchangeBusiness
/**
* 获取行情
*
* @param string $tag 目标币种
* @param string $aim 计数币种
* @return array|bool
......@@ -78,14 +82,22 @@ class ExchangeBusiness
}
//格式化行情数据
foreach ($quotation as $key => $item) {
$quotation[$key] = (float) sprintf("%0.4f", (double) $item);
$quotation[$key] = (float)sprintf("%0.4f", (double)$item);
}
$quotation['rmb'] = (float) sprintf("%0.2f", 6.6 * $quotation['last']);
//用YCC计算汇率
/**
* @var $exchange \common\service\exchange\Exchange
*/
$exchange = ExchangeFactory::createExchange("Bty");
$rate = $exchange->getTicker("BTY", "USDT");
$rate = (float)$rate['rmb'] / $rate['last'];
$quotation['rmb'] = (float)sprintf("%0.2f", $rate * $quotation['last']);
return $quotation;
}
/**
* 保存各个交易所支持的交易对到redis,定时用crontab更新
*
* @return void
*/
public static function setSupportedSymbol()
......@@ -101,6 +113,7 @@ class ExchangeBusiness
/**
* 更新交易所的行情数据保存到redis,定时更新
*
* @return void
*/
public static function setQuotation()
......@@ -116,6 +129,7 @@ class ExchangeBusiness
/**
* 根据name返回币种信息
*
* @param array $condition 需要的币种sid列表
* @return array
*/
......@@ -167,6 +181,7 @@ class ExchangeBusiness
/**
* 根据名称搜索
*
* @param int $page
* @param int $limit
* @param array $condition
......@@ -183,6 +198,7 @@ class ExchangeBusiness
$rows[$key]['sid'] = ucfirst($rows[$key]['sid']);
$platform = strtoupper($rows[$key]['platform']);
$platform_icon = Yii::$app->redis->hget('platform_image_info',$platform);
$rows[$key]['platform_icon'] = $platform_icon ?? '';
}
return ['total' => $total, 'data' => $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