From 5a27956227b3b9130569ef4c65f38743cbb38e43 Mon Sep 17 00:00:00 2001
From: shajiaming <shajiaming@gmail.com>
Date: Fri, 14 Feb 2020 10:04:19 +0800
Subject: [PATCH] fix tsc ticker

---
 common/business/ExchangeBusiness.php |  5 ++---
 common/service/exchange/Tsc.php      | 17 ++++++++---------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/common/business/ExchangeBusiness.php b/common/business/ExchangeBusiness.php
index 83e8695b..2f7825bf 100644
--- a/common/business/ExchangeBusiness.php
+++ b/common/business/ExchangeBusiness.php
@@ -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;
         }
 
@@ -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'])) {
diff --git a/common/service/exchange/Tsc.php b/common/service/exchange/Tsc.php
index 52d19ef5..bf347d64 100644
--- a/common/service/exchange/Tsc.php
+++ b/common/service/exchange/Tsc.php
@@ -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']));
                 }
             }
         }
-- 
2.17.1