Commit d3e4276e authored by shajiaming's avatar shajiaming

Merge branch 'master' into feature/fast_iterative

parents 060bdead dd7137e7
......@@ -230,8 +230,7 @@ class ExchangeBusiness
if (in_array(strtoupper($tag), ['TSC'])) {
$exchange = ExchangeFactory::createExchange("Tsc");
$quotation = $exchange->getTicker('TSC', 'CNDT');
$quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation = $exchange->getTicker('TSC', 'USDT');
goto doEnd;
}
......@@ -267,7 +266,7 @@ class ExchangeBusiness
'low' => (float)sprintf("%0.4f", $quotation['low'] / 100),
'high' => (float)sprintf("%0.4f", $quotation['high'] / 100),
'last' => (float)sprintf("%0.4f", $quotation['last'] / 100),
'rmb' => (float)sprintf("%0.2f", $quotation['last'] / 100),
'rmb' => (float)sprintf("%0.4f", $quotation['last'] / 100),
];
goto doEnd;
}
......@@ -329,7 +328,7 @@ class ExchangeBusiness
$exchange = ExchangeFactory::createExchange("Go");
$rate = $exchange->getTicker("CNY", "USD");
$cny_usd_rate = 1 / $rate['last'];
if (in_array(strtoupper($tag), ['FOLI', 'CIC', 'KPC8', 'BVA', 'DAG', 'BNC', 'GHP', 'DRA', 'ETC', 'PAX', 'STH', 'XJH', 'SFT'])) {
if (in_array(strtoupper($tag), ['FOLI', 'CIC', 'KPC8', 'BVA', 'DAG', 'BNC', 'GHP', 'DRA', 'ETC', 'PAX', 'STH', 'XJH', 'SFT', 'TSC'])) {
$quotation['usd'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last'] / $cny_usd_rate);
} else if (in_array(strtoupper($tag), ['SUSD'])) {
......
......@@ -54,7 +54,8 @@ class WalletChain extends BaseActiveRecord
[['platform', 'address', 'private_key', 'execer', 'brower_url', 'token', 'host', 'wallet_address', 'hash'], 'string'],
[['platform'], 'string', 'length' => [1, 30]],
[['token'], 'string', 'length' => [1, 10]],
[['port', 'status', 'origin'], 'integer']
[['port', 'status', 'origin'], 'integer'],
['host', 'verfiyIp']
];
}
......@@ -66,4 +67,12 @@ class WalletChain extends BaseActiveRecord
];
return array_merge(parent:: scenarios(), $scenarios);
}
public function verfiyIp($attribute, $params)
{
if (!preg_match('/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/', $this->host)) {
$this->addError($attribute, '错误的Ip地址');
return false;
}
}
}
\ No newline at end of file
......@@ -16,7 +16,7 @@ class Tsc extends Exchange implements ExchangeInterface
protected $quotation_prefix = 'quotation_tsc_';
protected $base_url = 'https://api.tsc100.vip/openapi/quote/v1/ticker/24hr';
public function symbolExists($tag = 'TSC', $aim = "CNDT")
public function symbolExists($tag = 'TSC', $aim = "USDT")
{
$supported = $this->redis->smembers($this->supported_symbol);
if (is_array($supported) && in_array($this->formatSymbol($tag, $aim), $supported)) {
......@@ -31,9 +31,9 @@ class Tsc extends Exchange implements ExchangeInterface
* @param string $aim
* @return mixed
*/
public function formatSymbol($tag = 'TSC', $aim = 'CNDT')
public function formatSymbol($tag = 'TSC', $aim = 'USDT')
{
return strtoupper($tag .'_'. $aim);
return strtoupper($tag . $aim);
}
/**
......@@ -43,7 +43,7 @@ class Tsc extends Exchange implements ExchangeInterface
*/
public function setSupportedSymbol()
{
$this->redis->sadd($this->supported_symbol, 'TSC_CNDT');
}
/**
......@@ -57,11 +57,10 @@ class Tsc extends Exchange implements ExchangeInterface
$content = $curl->get($this->base_url, false);
if (is_array($content)) {
foreach ($content as $item) {
if (in_array($item['symbol'], ['TSCCNDT'])) {
$data = $item;
$key = $this->quotation_prefix .'TSC_CNDT';
$this->redis->hmset($key, 'low', $data['lowPrice'], 'high', $data['highPrice'], 'last', $data['lastPrice']);
$this->redis->sadd($this->supported_symbol, $item['symbol']);
$key = $this->quotation_prefix . strtoupper($item['symbol']);
$this->redis->hmset($key, 'low', $item['lowPrice'], 'high', $item['highPrice'], 'last', $item['lastPrice']);
if (!$this->redis->sismember($this->supported_symbol, strtoupper($item['symbol']))){
$this->redis->sadd($this->supported_symbol, strtoupper($item['symbol']));
}
}
}
......
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