stanley-king il y a 4 ans
Parent
commit
ff22b994f0

+ 0 - 2
conf/php/php-debug.ini

@@ -928,8 +928,6 @@ default_socket_timeout = 60
 ; Module Settings ;
 ;;;;;;;;;;;;;;;;;;;
 
-;extension=swoole.so
-
 [CLI Server]
 ; Whether the CLI web server uses ANSI color coding in its terminal output.
 cli_server.color = On

+ 1 - 1
data/config/dev/refill.ini.php

@@ -87,7 +87,7 @@ $config['oil_providers'] = $oil_providers;
 
 $baidu_phone = ['name' => 'baidu', 'store_id' => 8,
     'amount' => [
-        10 => [['goods_id' => 6245, 'price' => 9.51, 'quality' => 1, 'card_type' => 'chinaunicom'],
+        10 => [['goods_id' => 6245, 'price' => 9.51, 'quality' => 1, 'card_type' => 'chinaunicom,chinatelecom'],
                ['goods_id' => 6245, 'price' => 9.81, 'quality' => 2, 'card_type' => 'chinamobile']],
         20 => [['goods_id' => 6247, 'price' => 19.02, 'card_type' => 'chinaunicom,chinatelecom']],
         30 => [['goods_id' => 6249, 'price' => 28.53, 'card_type' => 'chinamobile,chinatelecom']],

+ 0 - 2
docker/conf/php/php-debug.ini

@@ -928,8 +928,6 @@ default_socket_timeout = 60
 ; Module Settings ;
 ;;;;;;;;;;;;;;;;;;;
 
-extension=swoole.so
-
 [CLI Server]
 ; Whether the CLI web server uses ANSI color coding in its terminal output.
 cli_server.color = On

+ 0 - 15
helper/refill/IRefillOil.php

@@ -3,25 +3,10 @@
 
 namespace refill;
 
-use mtopcard;
-use Log;
-
 abstract class IRefillOil extends IRefill
 {
     public function __construct($cfgs)
     {
         parent::__construct($cfgs);
-
-        foreach ($cfgs['card_type'] as $ctype)
-        {
-            $ctype = strtolower($ctype);
-            if ($ctype == "petrochina") {
-                $this->mCardType[] = mtopcard\PetroChinaCard;
-            } elseif ($ctype == "sinopec") {
-                $this->mCardType[] = mtopcard\SinopecCard;
-            } else {
-                Log::record("Oil Provider has no name", Log::ERR);
-            }
-        }
     }
 }

+ 0 - 18
helper/refill/IRefillPhone.php

@@ -3,28 +3,10 @@
 
 namespace refill;
 
-use mtopcard;
-use Log;
-
-
 abstract class IRefillPhone extends IRefill
 {
     public function __construct($cfgs)
     {
         parent::__construct($cfgs);
-
-        foreach ($cfgs['card_type'] as $ctype)
-        {
-            $ctype = strtolower($ctype);
-            if ($ctype == "chinamobile") {
-                $this->mCardType[] = mtopcard\ChinaMobileCard;
-            } elseif ($ctype == "chinaunicom") {
-                $this->mCardType[] = mtopcard\ChinaUnicomCard;
-            } elseif($ctype == "chinatelecom") {
-                $this->mCardType[] = mtopcard\ChinaTelecomCard;
-            } else {
-                Log::record("Phone Provider has no name", Log::ERR);
-            }
-        }
     }
 }

+ 3 - 4
helper/refill/ProviderManager.php

@@ -121,10 +121,8 @@ class ProviderManager
         foreach ($channels as $item)
         {
             $name = $item['name'];
-            $opened = $item['opened'] == 1 ? true : false;
-
             if(array_key_exists($name,$this->mProviders)) {
-                $this->mProviders[$name]->setOpened($opened);
+                $this->mProviders[$name]->setOpened($item['opened']);
             }
         }
     }
@@ -137,7 +135,8 @@ class ProviderManager
         $result = [];
         foreach ($items as $item) {
             $name = $item['name'];
-            $val = ['type' => intval($item['type']),
+            $val = ['name' => $name,
+                    'type' => intval($item['type']),
                     'opened' => (intval($item['opened']) == 1) ? true : false,
                     'sort' => intval($item['sort'])];
             $result[$name] = $val;

+ 0 - 2
helper/refill/api/test/baidu/RefillPhone.php

@@ -32,8 +32,6 @@ class RefillPhone extends refill\IRefillPhone
 
     public function add($card_no, $card_type, $amount, $params)
     {
-        return [true, '系统错误',true];
-
         $params = $this->req_params($card_no, $amount, $params['order_sn']);
         $sign = $this->sign($params);
         $params['sign'] = $sign;

+ 14 - 4
helper/refill/policy/lingzh/chctl.php

@@ -18,11 +18,12 @@ class chctl
 
     public function __construct()
     {
-
+        $this->mSpeedtable = [];
     }
 
     public function load()
     {
+        $this->mSpeedtable = [];
         foreach (self::$cache_names as $cache)
         {
             $quality = $cache['quality'];
@@ -31,7 +32,8 @@ class chctl
             $data = rcache($cache_name,"provider-");
             $data = unserialize($data['data']);
 
-            $cfgs = $data ?? [];
+            $cfgs = empty($data) ? [] : $data;
+
             foreach ($cfgs as $items)
             {
                 foreach ($items as $item) {
@@ -52,10 +54,18 @@ class chctl
 
     public function match($names,int $spec, int $card_type,int $quality)
     {
+
         $ctl_items = [];
-        foreach ($names as $name) {
+        foreach ($names as $name)
+        {
             $key = $this->prefix($name,$spec,$card_type,$quality);
-            $ctl_items[] = $this->mSpeedtable[$key];
+            if(array_key_exists($key,$this->mSpeedtable)) {
+                $ctl_items[] = $this->mSpeedtable[$key];
+            }
+        }
+
+        if(empty($ctl_items)) {
+            return $names;
         }
 
         $usable_items = [];

+ 1 - 2
helper/refill/policy/lingzh/policy.php

@@ -20,17 +20,16 @@ class policy extends ProviderManager implements IPolicy
         $this->mChannelControl = new chctl();
     }
 
-
     public function load()
     {
         parent::load();
         $this->mChannelControl->load();
     }
 
-
     public function find_providers(int $spec, int $card_type,int $quality): array
     {
         $providers = parent::find_providers($spec,$card_type,$quality);
+        if(empty($providers)) return $providers;
 
         $names = [];
         foreach ($providers as $provider) {

+ 1 - 1
rdispatcher/proxy.php

@@ -26,7 +26,7 @@ class proxy
         $commit_times = $params['commit_times'] ?? 0;
 
         [$errcode, $errmsg,$order_id,$neterr] = refill\RefillFactory::instance()->add($mchid, $buyer_id, $amount, $card_no,
-            $mch_order, $idcard, $card_name, $notify_url, $order_time, $commit_times,$quality);
+            $mch_order, $idcard, $card_name, $notify_url,$quality, $order_time, $commit_times);
         $params['commit_times'] += 1;
         $commit_times += 1;
 

+ 2 - 2
test/TestDispatcher.php

@@ -55,7 +55,7 @@ class TestDispatcher extends TestCase
 
     public function testAddoil()
     {
-        foreach (range(1,1,1) as $i) {
+        foreach (range(1,10,1) as $i) {
             queue\DispatcherClient::instance()->push('add',$this->make_order());
         }
     }
@@ -68,7 +68,7 @@ class TestDispatcher extends TestCase
 
         $params = [ 'mchid' => $this->mMchid,
             'buyer_id' => $buyer_id,
-            'amount' => 50,
+            'amount' => 10,
             'card_no' => 13911129867,
             'mch_order' => $this->make_sn(),
             'notify_url' => 'https://www.xyzshops.cn/mobile/signature.php'];