Commit 00d91e80 authored by shajiaiming's avatar shajiaiming

Merge branch 'master' into feature/optimize

parents 1bcd233e 22dd39ab
...@@ -152,8 +152,8 @@ class ExchangeBusiness ...@@ -152,8 +152,8 @@ class ExchangeBusiness
} }
if (in_array(strtoupper($tag), ['GHP'])) { if (in_array(strtoupper($tag), ['GHP'])) {
$exchange = ExchangeFactory::createExchange("Zg"); $exchange = ExchangeFactory::createExchange("Bitnasdaq");
$quotation = $exchange->getTicker($tag, 'CNZ'); $quotation = $exchange->getTicker($tag);
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']); $quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
goto doEnd; goto doEnd;
} }
......
...@@ -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,13 +61,14 @@ class Boc extends Exchange implements ExchangeInterface ...@@ -60,13 +61,14 @@ 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) {
if ($key == 5) {
$key = $this->quotation_prefix . 'CNY_JPY'; $key = $this->quotation_prefix . 'CNY_JPY';
$this->redis->hmset($key, 'low', $e->innertext, 'high', $e->innertext, 'last', $e->innertext); $this->redis->hmset($key, 'low', $e->innertext, 'high', $e->innertext, 'last', $e->innertext);
$this->redis->sadd($this->supported_symbol, 'CNYJPY'); $this->redis->sadd($this->supported_symbol, 'CNYJPY');
...@@ -74,5 +76,6 @@ class Boc extends Exchange implements ExchangeInterface ...@@ -74,5 +76,6 @@ class Boc extends Exchange implements ExchangeInterface
} }
} }
} }
}
} }
\ No newline at end of file
...@@ -45,11 +45,12 @@ class TickerController extends Controller ...@@ -45,11 +45,12 @@ 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'));
if ($div->find('td')) {
foreach ($div->find('td') as $key => $e) { foreach ($div->find('td') as $key => $e) {
if ($key == 5) { if ($key == 5) {
$key = 'quotation_boc_' . 'CNY_' . $val->currency->symbol; $key = 'quotation_boc_' . 'CNY_' . $val->currency->symbol;
...@@ -57,6 +58,7 @@ class TickerController extends Controller ...@@ -57,6 +58,7 @@ class TickerController extends Controller
Yii::$app->redis_currency->hmset($key, 'low', $currency, 'high', $currency, 'last', $currency, 'open', $currency); Yii::$app->redis_currency->hmset($key, 'low', $currency, 'high', $currency, 'last', $currency, 'open', $currency);
} }
} }
}
}); });
} }
echo date('Y-m-d H:i:s') . '计价货币更新成功' . PHP_EOL; echo date('Y-m-d H:i:s') . '计价货币更新成功' . PHP_EOL;
......
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