Commit 0f1a0bb2 authored by shajiaiming's avatar shajiaiming

ljz ticker

parent 4a818f76
...@@ -209,9 +209,9 @@ class ExchangeBusiness ...@@ -209,9 +209,9 @@ class ExchangeBusiness
goto doEnd; goto doEnd;
} }
if (in_array(strtoupper($tag), ['GHT'])) { if (in_array(strtoupper($tag), ['GHT','JD'])) {
$exchange = ExchangeFactory::createExchange("Ljz"); $exchange = ExchangeFactory::createExchange("Ljz");
$quotation = $exchange->getTicker($tag, 'USDT'); $quotation = $exchange->getTicker($tag, 'CNYD');
$quotation['rmb'] = $quotation['last']; $quotation['rmb'] = $quotation['last'];
goto doEnd; goto doEnd;
} }
......
...@@ -14,9 +14,9 @@ class Ljz extends Exchange implements ExchangeInterface ...@@ -14,9 +14,9 @@ class Ljz extends Exchange implements ExchangeInterface
{ {
protected $supported_symbol = 'supported_symbol_ljz'; protected $supported_symbol = 'supported_symbol_ljz';
protected $quotation_prefix = 'quotation_ljz_'; protected $quotation_prefix = 'quotation_ljz_';
protected $base_url = 'http://api.ydqkl.com.cn/market/exchange-rate/cny/GHT'; protected $base_url = 'http://api.ydqkl.com.cn/market/overview';
public function symbolExists($tag = 'GHT', $aim = "USDT") public function symbolExists($tag = 'GHT', $aim = "CNYD")
{ {
$supported = $this->redis->smembers($this->supported_symbol); $supported = $this->redis->smembers($this->supported_symbol);
if (is_array($supported) && in_array($this->formatSymbol($tag, $aim), $supported)) { if (is_array($supported) && in_array($this->formatSymbol($tag, $aim), $supported)) {
...@@ -32,7 +32,7 @@ class Ljz extends Exchange implements ExchangeInterface ...@@ -32,7 +32,7 @@ class Ljz extends Exchange implements ExchangeInterface
* @param string $aim * @param string $aim
* @return mixed * @return mixed
*/ */
public function formatSymbol($tag = 'GHT', $aim = 'USDT') public function formatSymbol($tag = 'GHT', $aim = 'CNYD')
{ {
return strtoupper($tag .'_'. $aim); return strtoupper($tag .'_'. $aim);
} }
...@@ -56,13 +56,14 @@ class Ljz extends Exchange implements ExchangeInterface ...@@ -56,13 +56,14 @@ class Ljz extends Exchange implements ExchangeInterface
{ {
$curl = new Curl(); $curl = new Curl();
$res = $curl->get($this->base_url, false); $res = $curl->get($this->base_url, false);
if (is_array($res) && 0 == $res['code']) { if (is_array($res) && count($res['changeRank']) > 0) {
$key = $this->quotation_prefix . 'GHT_USDT'; foreach ($res['changeRank'] as $val){
$this->redis->hmset($key, 'low', $res['data'], 'high', $res['data'], 'last', $res['data'], 'change', $res['data']); $key = $this->quotation_prefix . str_replace('/','_', $val['symbol']);
if (!$this->redis->sismember($this->supported_symbol, 'GHTUSDT')) { $this->redis->hmset($key, 'low', $val['low'], 'high', $val['high'], 'last', $val['close'], 'change', $val['change'],'open', $val['open'],'vol',$val['volume']);
$this->redis->sadd($this->supported_symbol, 'GHTUSDT'); if (!$this->redis->sismember($this->supported_symbol, str_replace('/','', $val['symbol']))) {
$this->redis->sadd($this->supported_symbol, str_replace('/','', $val['symbol']));
}
} }
} }
} }
} }
\ 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