Commit 68b06e20 authored by shajiaiming's avatar shajiaiming

fix

parent 742c3367
...@@ -15,7 +15,7 @@ class Boc extends Exchange implements ExchangeInterface ...@@ -15,7 +15,7 @@ class Boc extends Exchange implements ExchangeInterface
{ {
protected $supported_symbol = 'supported_symbol_boc'; protected $supported_symbol = 'supported_symbol_boc';
protected $quotation_prefix = 'quotation_boc_'; protected $quotation_prefix = 'quotation_boc_';
protected $base_url = 'http://srh.bankofchina.com/search/whpj/search.jsp'; protected $base_url = 'https://srh.bankofchina.com/search/whpj/search_cn.jsp';
public function symbolExists($tag = 'CNY', $aim = "JPY") public function symbolExists($tag = 'CNY', $aim = "JPY")
{ {
...@@ -25,6 +25,7 @@ class Boc extends Exchange implements ExchangeInterface ...@@ -25,6 +25,7 @@ class Boc extends Exchange implements ExchangeInterface
} }
return false; return false;
} }
/** /**
* 转化交易对为请求变量 * 转化交易对为请求变量
* *
...@@ -34,7 +35,7 @@ class Boc extends Exchange implements ExchangeInterface ...@@ -34,7 +35,7 @@ class Boc extends Exchange implements ExchangeInterface
*/ */
public function formatSymbol($tag = 'CNY', $aim = 'JPY') public function formatSymbol($tag = 'CNY', $aim = 'JPY')
{ {
return strtoupper($tag .'_'. $aim); return strtoupper($tag . '_' . $aim);
} }
/** /**
...@@ -60,17 +61,19 @@ class Boc extends Exchange implements ExchangeInterface ...@@ -60,17 +61,19 @@ class Boc extends Exchange implements ExchangeInterface
'erectDate' => '', 'erectDate' => '',
'nothing' => '', 'nothing' => '',
'pjname' => 1323 'pjname' => 1323
])->post('http://srh.bankofchina.com/search/whpj/search.jsp'); ])->post('https://srh.bankofchina.com/search/whpj/search_cn.jsp');
$response = iconv('UTF-8', 'GBK//TRANSLIT',$response); $response = iconv('UTF-8', 'GBK//TRANSLIT', $response);
$html = HtmlDomParser::str_get_html($response); $html = HtmlDomParser::str_get_html($response);
$div = ($html->find('div.BOC_main')); $div = ($html->find('div.BOC_main'));
foreach ($div->find('td') as $key => $e){ if ($div->find('td')) {
if($key == 5){ foreach ($div->find('td') as $key => $e) {
$key = $this->quotation_prefix . 'CNY_JPY'; if ($key == 5) {
$this->redis->hmset($key, 'low', $e->innertext, 'high', $e->innertext, 'last', $e->innertext); $key = $this->quotation_prefix . 'CNY_JPY';
$this->redis->sadd($this->supported_symbol, 'CNYJPY'); $this->redis->hmset($key, 'low', $e->innertext, 'high', $e->innertext, 'last', $e->innertext);
break; $this->redis->sadd($this->supported_symbol, 'CNYJPY');
break;
}
} }
} }
} }
......
...@@ -45,16 +45,18 @@ class TickerController extends Controller ...@@ -45,16 +45,18 @@ class TickerController extends Controller
'erectDate' => '', 'erectDate' => '',
'nothing' => '', 'nothing' => '',
'pjname' => $val->currency->pj_id 'pjname' => $val->currency->pj_id
])->post('http://srh.bankofchina.com/search/whpj/search.jsp'); ])->post('https://srh.bankofchina.com/search/whpj/search_cn.jsp');
$response = iconv('UTF-8', 'GBK//TRANSLIT', $response); $response = iconv('UTF-8', 'GBK//TRANSLIT', $response);
$html = HtmlDomParser::str_get_html($response); $html = HtmlDomParser::str_get_html($response);
$div = ($html->find('div.BOC_main')); $div = ($html->find('div.BOC_main'));
foreach ($div->find('td') as $key => $e) { if ($div->find('td')) {
if ($key == 5) { foreach ($div->find('td') as $key => $e) {
$key = 'quotation_boc_' . 'CNY_' . $val->currency->symbol; if ($key == 5) {
$currency = rtrim(sprintf('%.6f', 1 / ($e->innertext / 100)), '0'); $key = 'quotation_boc_' . 'CNY_' . $val->currency->symbol;
Yii::$app->redis_currency->hmset($key, 'low', $currency, 'high', $currency, 'last', $currency, 'open', $currency); $currency = rtrim(sprintf('%.6f', 1 / ($e->innertext / 100)), '0');
Yii::$app->redis_currency->hmset($key, 'low', $currency, 'high', $currency, 'last', $currency, 'open', $currency);
}
} }
} }
}); });
......
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