Commit 867871f2 authored by rlgy's avatar rlgy

update

parent 6b276b39
......@@ -12,7 +12,7 @@ class Bty extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_bty';
protected $quotation_prefix = 'quotation_bty_';
protected $base_url = 'http://40.83.77.188/api/data/Ticker?platform=HKJB&sort=cname';
protected $base_url = 'http://40.83.77.188/api/data/Ticker?sort=cname&platform=';
/**
* 转化交易对为请求变量
......@@ -43,15 +43,18 @@ class Bty extends Exchange implements ExchangeInterface
*/
public function setQuotation()
{
$content = $this->ch->get($this->base_url, false);
if (is_array($content) && isset($content['code']) && $content['code'] == 200) {
$data = $content['data']['USDT'];
foreach ($data as $item) {
if ($item['symbol'] == 'BTYUSDT' || $item['symbol'] == 'ITVBUSDT') {
$data = $item;
$key = $this->quotation_prefix . $item['symbol'];
$this->redis->hmset($key, 'low', $data['low'], 'high', $data['high'], 'last', $data['last'], 'rmb', $data['lastrmb']);
$this->redis->sadd($this->supported_symbol, $item['symbol']);
$platforms = ['HKJB', 'BB360'];
foreach($platforms as $platform) {
$content = $this->ch->get($this->base_url . $platform, false);
if (is_array($content) && isset($content['code']) && $content['code'] == 200) {
$data = $content['data']['USDT'];
foreach ($data as $item) {
if (in_array($item['symbol'], ['BTYUSDT', 'ITVBUSDT', 'SCTCUSDT'])) {
$data = $item;
$key = $this->quotation_prefix . $item['symbol'];
$this->redis->hmset($key, 'low', $data['low'], 'high', $data['high'], 'last', $data['last'], 'rmb', $data['lastrmb']);
$this->redis->sadd($this->supported_symbol, $item['symbol']);
}
}
}
}
......
......@@ -18,6 +18,7 @@ use yii\console\Controller;
use common\models\psources\CoinPublishRule;
use common\models\psources\CoinReleaseMember;
use backend\jobs\QueryTransJob;
use common\service\exchange\Bty;
/**
* Class ExchangeController
......@@ -53,4 +54,10 @@ class DevController extends Controller
$id = Yii::$app->queue->push(new JugdeAwardJob());
var_dump($id);
}
public function actionQuotation()
{
$bty = new Bty();
$bty->setQuotation();
}
}
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