Commit 57117123 authored by shajiaiming's avatar shajiaiming

fix

parent e9cabdcb
...@@ -39,7 +39,8 @@ class ExchangeBusiness ...@@ -39,7 +39,8 @@ class ExchangeBusiness
8 => 'Isummit', 8 => 'Isummit',
9 => 'Ztb', 9 => 'Ztb',
10 => 'Wbf', 10 => 'Wbf',
11 => 'Gwa' 11 => 'Gwa',
12 => 'Ljz'
//1 => 'Hadax', //不需要 //1 => 'Hadax', //不需要
//2 => 'Bitfinex', //不需要 //2 => 'Bitfinex', //不需要
...@@ -208,6 +209,13 @@ class ExchangeBusiness ...@@ -208,6 +209,13 @@ class ExchangeBusiness
goto doEnd; goto doEnd;
} }
if (in_array(strtoupper($tag), ['GHT'])) {
$exchange = ExchangeFactory::createExchange("Ljz");
$quotation = $exchange->getTicker($tag, 'USDT');
$quotation['rmb'] = $quotation['last'];
goto doEnd;
}
if (in_array(strtoupper($tag), ['GLCW'])) { if (in_array(strtoupper($tag), ['GLCW'])) {
$exchange = ExchangeFactory::createExchange("Jinwang"); $exchange = ExchangeFactory::createExchange("Jinwang");
$quotation = $exchange->getTicker($tag, 'USDT'); $quotation = $exchange->getTicker($tag, 'USDT');
......
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace common\service\exchange;
use linslin\yii2\curl\Curl;
class Ljz extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_hd';
protected $quotation_prefix = 'quotation_hd_';
protected $base_url = 'http://api.ydqkl.com.cn/market/exchange-rate/cny/GHT';
public function symbolExists($tag = 'GHT', $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 = 'GHT', $aim = 'USDT')
{
return strtoupper($tag .'_'. $aim);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public function setSupportedSymbol()
{
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public function setQuotation()
{
$curl = new Curl();
$res = $curl->get($this->base_url, false);
if (is_array($res) && 0 == $res['code']) {
$key = $this->quotation_prefix . 'GHT_USDT';
$this->redis->hmset($key, 'low', $res['data'], 'high', $res['data'], 'last', $res['data'], 'change', $res['data']);
if (!$this->redis->sismember($this->supported_symbol, 'HDCUSDT')) {
$this->redis->sadd($this->supported_symbol, 'HDCUSDT');
}
}
}
}
\ 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