Commit eb81f0ec authored by shajiaiming's avatar shajiaiming

Merge branch 'master' into feature/issue_coin

parents 7a3f1bd2 e5254edb
......@@ -154,6 +154,7 @@ class TickerController extends BaseController
$temp['low_usd'] = (float)sprintf("%0.4f", $quotation['low'] * $this->basic_price[$tag_second]['usd']);
$temp['high_rmb'] = (float)sprintf("%0.4f", $quotation['high'] * $this->basic_price[$tag_second]['rmb']);
$temp['low_rmb'] = (float)sprintf("%0.4f", $quotation['low'] * $this->basic_price[$tag_second]['rmb']);
$temp['vol'] = (float)sprintf("%0.4f", $quotation['vol']);
$temp['platform_us'] = $val['platform'];
if ('ZHAOBI' == strtoupper($val['platform'])) {
$temp['platform_zh'] = '找币';
......
......@@ -44,7 +44,8 @@ class ExchangeBusiness
15 => 'Tsc',
16 => 'Binance',
17 => 'Ceohk',
18 => 'Biki'
18 => 'Biki',
19 => 'Bilaxy'
];
/**
......@@ -198,6 +199,12 @@ class ExchangeBusiness
goto doEnd;
}
if (in_array(strtoupper($tag), ['BVA'])) {
$exchange = ExchangeFactory::createExchange("Bilaxy");
$quotation = $exchange->getTicker('BVA', 'USDT');
goto doEnd;
}
if (in_array(strtoupper($tag), ['SJPY'])) {
$exchange = ExchangeFactory::createExchange("Boc");
$quotation = $exchange->getTicker('CNY', 'JPY');
......@@ -267,7 +274,7 @@ class ExchangeBusiness
$exchange = ExchangeFactory::createExchange("Go");
$rate = $exchange->getTicker("CNY", "USD");
$cny_usd_rate = 1 / $rate['last'];
if (in_array(strtoupper($tag), ['FOLI', 'CIC', 'KPC8'])) {
if (in_array(strtoupper($tag), ['FOLI', 'CIC', 'KPC8', 'BVA'])) {
$quotation['usd'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last'] / $cny_usd_rate);
} else if (in_array(strtoupper($tag), ['SUSD'])) {
......
<?php
namespace common\service\exchange;
use linslin\yii2\curl\Curl;
class Bilaxy extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_bilaxy';
protected $quotation_prefix = 'quotation_bilaxy_';
protected $base_url = 'https://api.bilaxy.com/v1/tickers';
public function symbolExists($tag = 'BVA', $aim = "USDT")
{
$supported = $this->redis->smembers($this->supported_symbol);
if (is_array($supported) && in_array($this->formatSymbol($tag, $aim), $supported)) {
return true;
}
return false;
}
/**
* 转化交易对为请求变量
*
* @param string $tag
* @param string $aim
* @return mixed
*/
public function formatSymbol($tag = 'BVA', $aim = 'USDT')
{
return strtoupper($tag .'_'. $aim);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public function setSupportedSymbol()
{
$this->redis->sadd($this->supported_symbol, 'BVA_USDT');
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public function setQuotation()
{
$curl = new Curl();
$content = $curl->get($this->base_url, false);
if (is_array($content) && isset($content['data'])) {
$data = $content['data'];
$key = $this->quotation_prefix . 'BVA_USDT';
foreach ($data as $item) {
if ( 260 == $item['symbol']) {
$this->redis->hmset($key, 'low', $item['low'], 'high', $item['high'], 'last', $item['last']);
$this->redis->sadd($this->supported_symbol, 'KPC8_USDT');
}
}
}
}
}
\ 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