Browse Source

Merge branch 'rmaster' of 39.97.239.116:gyfl/xyzshop into rmaster

HARUHARU 4 years atrás
parent
commit
ea4e426fe0

+ 1 - 1
core/framework/libraries/model.php

@@ -847,7 +847,7 @@ class ModelDb
         //|| is_numeric($value)
         if(is_string($value)) {
             $value = '\''.$this->escapeString($value).'\'';
-        }elseif(isset($value[0]) && is_string($value[0]) && strtolower($value[0]) == 'exp'){
+        }elseif(isset($value[0]) && is_string($value[0]) && strtolower($value[0]) == 'exp') {
             $value   =  $value[1];
         }elseif(is_array($value)) {
             $value   =  array_map([$this, 'parseValue'],$value);

+ 2 - 2
data/config/dev/base.ini.php

@@ -68,14 +68,14 @@ else {
     $config['db'][1]['dbhost']       = MASTER_DBHOST;
     $config['db'][1]['dbport']       = '3307';
     $config['db'][1]['dbuser']       = 'root';
-    $config['db'][1]['dbpwd']        = 'Linzhuhmnbmhhah#2021';
+    $config['db'][1]['dbpwd']        = 'XTZ@shop@951688';
     $config['db'][1]['dbname']       = 'xyzshop';
     $config['db'][1]['dbcharset']    = 'UTF-8';
 
     $config['db']['slave'][0]['dbhost']     = SLAVE_DBHOST;
     $config['db']['slave'][0]['dbport']     = '3307';
     $config['db']['slave'][0]['dbuser']     = 'root';
-    $config['db']['slave'][0]['dbpwd']      = 'Linzhuhmnbmhhah#2021';
+    $config['db']['slave'][0]['dbpwd']      = 'XTZ@shop@951688';
     $config['db']['slave'][0]['dbname']     = 'xyzshop';
     $config['db']['slave'][0]['dbcharset']  = 'UTF-8';
 }

+ 0 - 15
docker/compose/stanley/docker-compose.yml

@@ -63,21 +63,6 @@ services:
     depends_on:
        - "redisrv"
 
-  rdsrv:
-    image: php-zts-debug:7.3.18
-    volumes:
-      - ../../conf/etc/localtime:/etc/localtime:ro
-      - ../../../:/var/www/html
-      - /Volumes/Transcend/upload:/var/www/html/data/upload
-      - /Users/stanley-king/work/PHPProject/shoplog:/var/www/html/data/log
-      - ../../conf/php/php-local-debug.ini:/usr/local/etc/php/php.ini
-    links:
-      - redisrv
-    container_name: "panda-dispatcher"
-    command: [php,"/var/www/html/rdispatcher/dispatcher.php","1"]
-    depends_on:
-      - "redisrv"
-
   cordsrv:
     image: php-swool-redis:latest
     volumes:

+ 45 - 0
docker/compose/xyzab-worker/docker-compose.yml

@@ -0,0 +1,45 @@
+version: "3.7"
+
+services:
+  cordsrv:
+    image: php-swool-redis:latest
+    volumes:
+      - ../../conf/etc/localtime:/etc/localtime:ro
+      - ../../../:/var/www/html
+      - /nfs/upload:/var/www/html/data/upload
+      - /mnt/shoplog:/var/www/html/data/log
+      - ../../conf/php/xyz-php-swoole.ini:/usr/local/etc/php/php.ini
+    container_name: "panda-codispatcher"
+    command: [php,"/var/www/html/rdispatcher/codispatcher.php","1"]
+
+  queuesrv:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - ../../conf/etc/localtime:/etc/localtime:ro
+      - ../../../:/var/www/html
+      - /nfs/upload:/var/www/html/data/upload
+      - /mnt/shoplog:/var/www/html/data/log
+      - ../../conf/php/xyz-php.ini:/usr/local/etc/php/php.ini
+    container_name: "panda-queue"
+    command: [php,"/var/www/html/queue/index.php", "queue", "index"]
+
+  searcher:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - ../../conf/etc/localtime:/etc/localtime:ro
+      - ../../../:/var/www/html
+      - /nfs/upload:/var/www/html/data/upload
+      - /mnt/shoplog:/var/www/html/data/log
+      - ../../conf/php/xyz-php.ini:/usr/local/etc/php/php.ini
+    container_name: "panda-searcher"
+    command: [php, "/var/www/html/searcher.php"]
+
+  phpcli:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - ../../conf/etc/localtime:/etc/localtime:ro
+      - ../../conf/php/xyz-php.ini:/usr/local/etc/php/php.ini
+      - ../../../:/var/www/html
+      - /nfs/upload:/var/www/html/data/upload
+      - /mnt/shoplog:/var/www/html/data/log
+    container_name: "panda-php"

+ 45 - 9
helper/queue/iqueue.php

@@ -15,7 +15,9 @@ class IQueueDB
 
     private $_tb_prefix;
     //存定义存储表的数量,系统会随机分配存储
+
     private $_tb_num = 3;
+    private $_comode;
 
     public function __construct($queue_name,$comode = false)
     {
@@ -23,16 +25,33 @@ class IQueueDB
             throw_exception('redis failed to load');
         }
         $this->_tb_prefix = $queue_name;
+        $this->_comode = $comode;
 
-        if($comode) {
-            $this->_redis  = new \Swoole\Coroutine\Redis();
+        if ($this->_comode) {
+            $this->_redis = new \Swoole\Coroutine\Redis();
             $ret = $this->_redis->connect(C('coroutine.redis_host'), C('coroutine.redis_port'));
-            Log::record("Swoole\Coroutine\Redis connect ret = {$ret}",Log::DEBUG);
-        }
-        else {
+        } else {
             $this->_redis = new Redis();
-            $this->_redis->connect(C('queue.host'), C('queue.port'), 20);
-            $this->_redis->setOption(Redis::OPT_READ_TIMEOUT, 10);
+            $ret = $this->_redis->connect(C('queue.host'), C('queue.port'), 20);
+        }
+
+        $this->connect();
+    }
+
+    public function connect(): bool
+    {
+        if ($this->_comode) {
+            if ($this->_redis->connected) return true;
+            $ret = $this->_redis->connect(C('coroutine.redis_host'), C('coroutine.redis_port'));
+            Log::record("Swoole\Coroutine\Redis connect ret = {$ret}", Log::DEBUG);
+
+            return $this->_redis->connected;
+        } else {
+            if ($this->_redis->isConnected()) return true;
+            $ret = $this->_redis->connect(C('queue.host'), C('queue.port'), 20);
+            Log::record("Redis connect ret = {$ret}", Log::DEBUG);
+
+            return $this->_redis->isConnected();
         }
     }
 
@@ -102,6 +121,7 @@ class IClient
     {
         $this->mQueuedb = $queueDb;
     }
+
     public function push($key, $value)
     {
         return $this->mQueuedb->lpush(serialize([$key=>$value]));
@@ -116,6 +136,11 @@ class IServer
         $this->_queuedb = $queueDb;
     }
 
+    public function connect() : bool
+    {
+        return $this->_queuedb->connect();
+    }
+
     public function pop($key,$time)
     {
         $result = $this->_queuedb->rpop($key,$time);
@@ -178,7 +203,12 @@ abstract class ILooper
 
                     if($num < ILooper::MAX_COROUTINE)
                     {
-//                        Log::record("coroutine counts = {$num}",Log::DEBUG);
+                        if($this->mServer->connect() == false) {
+                            \Swoole\Coroutine::sleep(1);
+                            Log::record("Processor redis disconnect.",Log::ERR);
+                            continue;
+                        }
+
                         $content = $this->mServer->pop($queues,1);
                         if(empty($content)) continue;
 
@@ -190,7 +220,13 @@ abstract class ILooper
                         \Swoole\Coroutine::sleep(0.1);
                     }
                 }
-                else {
+                else
+                {
+                    if($this->mServer->connect() == false) {
+                        sleep(1);
+                        continue;
+                    }
+
                     $content = $this->mServer->pop($queues,1);
                     if(empty($content)) continue;
 

+ 2 - 0
helper/refill/LZRefillFactory.php

@@ -9,6 +9,8 @@ require_once(BASE_HELPER_PATH . '/refill/policy/IPolicy.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/lingzh/policy.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/chctl.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/ctl_item.php');
+require_once(BASE_HELPER_PATH . '/refill/policy/mchctl.php');
+
 
 use Log;
 use StatesHelper;

+ 7 - 4
helper/refill/RefillBase.php

@@ -44,6 +44,10 @@ class RefillBase
         $this->mPolicy->load();
     }
 
+    public function first_quality($mchid) {
+        return $this->mPolicy->first_quality($mchid);
+    }
+
     public function notify($chname, $input)
     {
         $caller = $this->mPolicy->getCaller($chname);
@@ -127,15 +131,14 @@ class RefillBase
 
     private function retry(array $refill_info, array $order_info)
     {
-        if(!$this->mPolicy->can_retry($refill_info,$order_info)) {
-            return false;
-        }
+        [$cantry,$quality] = $this->mPolicy->can_retry($refill_info,$order_info);
+        if(!$cantry) return false;
 
         $params = [ 'mchid' => $refill_info['mchid'],
             'buyer_id' => $order_info['buyer_id'],
             'amount' => $refill_info['refill_amount'],
             'card_no' => $refill_info['card_no'],
-            'quality' => $refill_info['quality'],
+            'quality' => $quality,
             'mch_order' =>  $refill_info['mch_order'],
             'notify_url' => $refill_info['notify_url'],
             'idcard' => $refill_info['idcard'] ?? '',

+ 1 - 0
helper/refill/XYZRefillFactory.php

@@ -11,6 +11,7 @@ require_once(BASE_HELPER_PATH . '/refill/policy/IPolicy.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/xyz/policy.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/chctl.php');
 require_once(BASE_HELPER_PATH . '/refill/policy/ctl_item.php');
+require_once(BASE_HELPER_PATH . '/refill/policy/mchctl.php');
 
 use Log;
 use StatesHelper;

+ 4 - 2
helper/refill/policy/IPolicy.php

@@ -6,8 +6,10 @@ namespace refill;
 
 interface IPolicy
 {
-    public function can_retry(array $refill_info, array $order_info) : bool;
+    //[can_try,quality]
+    public function can_retry(array $refill_info, array $order_info) : array;
+    public function first_quality($mchid): int;
     public function allow($mchid,$card_type,$amount,$quality) : bool;
-    public function can_nettry($quality,$order_time,$commit_times) : bool;
+    public function can_nettry($mchid,$quality,$order_time,$commit_times) : bool;
     public function notify($order_info, $refill_info) : bool;
 }

+ 11 - 4
helper/refill/policy/lingzh/policy.php

@@ -14,17 +14,19 @@ class policy extends ProviderManager implements IPolicy
     const high_time_out = 30;
 
     protected $mChannelControl;
-
+    protected $mMchctl;
     public function __construct()
     {
         parent::__construct();
         $this->mChannelControl = new chctl();
+        $this->mMchctl = new mchctl();
     }
 
     public function load()
     {
         parent::load();
         $this->mChannelControl->load();
+        $this->mMchctl->load();
     }
 
     public function find_providers(int $spec, int $card_type,int $quality): array
@@ -55,9 +57,14 @@ class policy extends ProviderManager implements IPolicy
         return [$result,$overload];
     }
 
-    public function can_retry(array $refill_info, array $order_info): bool
+    public function first_quality($mchid): int
+    {
+        return 1;
+    }
+
+    public function can_retry(array $refill_info, array $order_info): array
     {
-        return false;
+        return [false,0];
     }
 
     public function allow($mchid, $card_type, $amount, $quality): bool
@@ -65,7 +72,7 @@ class policy extends ProviderManager implements IPolicy
         return true;
     }
 
-    public function can_nettry($quality,$order_time,$commit_times) : bool
+    public function can_nettry($mchid,$quality,$order_time,$commit_times) : bool
     {
         if($quality == 1) {
             return $commit_times < policy::normal_times && time() - $order_time < policy::normle_time_out;

+ 56 - 0
helper/refill/policy/mchctl.php

@@ -0,0 +1,56 @@
+<?php
+
+
+namespace refill;
+
+class mchctl
+{
+    private $mMchidMapCtls;
+    public function __construct()
+    {
+        $this->load();
+
+    }
+
+    public function load()
+    {
+        $this->update_ctl();
+    }
+
+    private function update_price()
+    {
+
+    }
+
+    private function update_ctl()
+    {
+        $this->mMchidMapCtls = [];
+        $mod_merchant = Model('merchant');
+        $merchants = $mod_merchant->getMerchantList([]);
+
+        foreach ($merchants as $item) {
+            $mchid = $item['mchid'];
+            $quality = intval($item['quality']);
+            $time_out = $item['time_out'];
+
+            if ($quality < 1 || $quality > 3) {
+                $quality = 1;
+            }
+
+            $this->mMchidMapCtls[$mchid] = ['quality' => $quality,'time_out' => $time_out];
+        }
+    }
+
+    public function getCtls($mchid)
+    {
+        if(array_key_exists($mchid,$this->mMchidMapCtls)) {
+            $quality = $this->mMchidMapCtls[$mchid]['quality'];
+            $time_out = $this->mMchidMapCtls[$mchid]['time_out'];
+
+            return [true,$quality,$time_out];
+        }
+        else {
+            return [false,0,0];
+        }
+    }
+}

+ 56 - 18
helper/refill/policy/xyz/policy.php

@@ -16,16 +16,19 @@ class policy extends ProviderManager implements IPolicy
     const high_time_out = 60;
 
     protected $mChannelControl;
+    protected $mMchctl;
     public function __construct()
     {
         parent::__construct();
         $this->mChannelControl = new chctl();
+        $this->mMchctl = new mchctl();
     }
 
     public function load()
     {
         parent::load();
         $this->mChannelControl->load();
+        $this->mMchctl->load();
     }
 
     public function find_providers(int $spec, int $card_type,int $quality): array
@@ -81,31 +84,74 @@ class policy extends ProviderManager implements IPolicy
         return $providers;
     }
 
-    public function can_retry(array $refill_info, array $order_info) : bool
+    public function can_retry(array $refill_info, array $order_info) : array
     {
-        $checker = function ($refill, $order)
+        $checker = function ($refill, $order,$time_out,$quality)
         {
             $state = intval($order['order_state']);
             if ($state !== ORDER_STATE_SEND) {
                 Log::record("retry false:order_state != send", Log::DEBUG);
-                return false;
+                return [false,0];
             }
 
             $times = intval($refill['commit_times']);
             if ($times > policy::normal_times) {
-                return false;
+                return [false,0];
             }
 
             $period = time() - $refill['order_time'];
-            if ($period >= policy::normle_time_out) {
+            if ($period >= $time_out) {
                 Log::record("retry false:time > 15m", Log::DEBUG);
-                return false;
+                return [false,0];
+            }
+            elseif($period + 60 > $time_out && $quality == 3) {
+                return [true,2];
+            }
+            else {
+                return [true,$quality];
             }
-
-            return true;
         };
 
-        return $checker($refill_info, $order_info);
+        $mchid = $refill_info['mchid'];
+        [$sucdess,$quality,$time_out] = $this->mMchctl->getCtls($mchid);
+
+        if($sucdess) {
+            return $checker($refill_info, $order_info,$time_out,$quality);
+        }
+        else {
+            return $checker($refill_info, $order_info,policy::normle_time_out,1);
+        }
+    }
+
+    public function can_nettry($mchid,$quality,$order_time,$commit_times) : bool
+    {
+        [$sucdess,$quality,$time_out] = $this->mMchctl->getCtls($mchid);
+
+        if($sucdess)
+        {
+            if($quality == 1) {
+                return $commit_times < policy::normal_times && time() - $order_time < $time_out;
+            }
+            else {
+                return $commit_times < policy::high_times && time() - $order_time < $time_out;
+            }
+        }
+        elseif($quality == 1) {
+            return $commit_times < policy::normal_times && time() - $order_time < policy::normle_time_out;
+        }
+        else {
+            return $commit_times < policy::high_times && time() - $order_time < policy::high_time_out;
+        }
+    }
+
+    public function first_quality($mchid): int
+    {
+        [$sucdess,$quality,$time_out] = $this->mMchctl->getCtls($mchid);
+        if($sucdess) {
+            return $quality;
+        } else {
+            return 1;
+        }
     }
 
     public function allow($mchid,$card_type,$amount,$quality) : bool
@@ -142,15 +188,7 @@ class policy extends ProviderManager implements IPolicy
             return true;
         }
     }
-    public function can_nettry($quality,$order_time,$commit_times) : bool
-    {
-        if($quality == 1) {
-            return $commit_times < policy::normal_times && time() - $order_time < policy::normle_time_out;
-        }
-        else {
-            return $commit_times < policy::high_times && time() - $order_time < policy::high_time_out;
-        }
-    }
+
     public function notify($order_info, $refill_info) : bool
     {
         $order_state = $order_info['order_state'];

+ 4 - 0
mobile/control/merchant_info.php

@@ -43,6 +43,10 @@ class merchant_infoControl extends mbMerchantControl
         $merchant_info['evidence_count'] = count($day_evidence);
         $merchant_info['time_out'] = intval($merchant_info['time_out'] / 60);
         $merchant_info['quality'] = intval($merchant_info['quality']);
+
+        $pub = new message\publisher();
+        $pub->modify_refill_merchant();
+
         return self::outsuccess($merchant_info);
     }
 

+ 1 - 3
mobile/control/refill.php

@@ -67,7 +67,6 @@ class refillControl extends merchantControl
         $card_no = $_GET['cardno'];
         $notify_url = $_GET['notifyurl'];
         $mch_order = $_GET['order_sn']; //对方的order编号
-        $quality = $_GET['quality'] ?? 1;
 
         if(!$this->check_mchorder($this->mchid(),$mch_order)) {
             return self::outerr(205,"客户订单号重复或者为空.");
@@ -97,8 +96,7 @@ class refillControl extends merchantControl
             'amount' => $amount,
             'card_no' => $card_no,
             'mch_order' => $mch_order,
-            'notify_url' => $notify_url,
-            'quality' => $quality];
+            'notify_url' => $notify_url];
 
         $state = refill\util::push_add($params);
         if($state === true) {

+ 1 - 3
racc/control/lzrefill.php

@@ -74,7 +74,6 @@ class lzrefillControl extends lzbaseControl
         $card_no = $_GET['mob'];
         $notify_url = $_GET['notifyurl'];
         $mch_order = $_GET['ord']; //对方的order编号
-        $quality = $_GET['quality'];
 
         //此处判断是对的
         if($amount > $this->member_available) {
@@ -94,8 +93,7 @@ class lzrefillControl extends lzbaseControl
             'amount' => $amount,
             'card_no' => $card_no,
             'mch_order' => $mch_order,
-            'notify_url' => $notify_url,
-            'quality' => $quality];
+            'notify_url' => $notify_url];
 
         $ret = refill\util::push_add($params);
         if($ret) {

+ 96 - 21
rdispatcher/codispatcher.php

@@ -21,8 +21,6 @@ require_once(BASE_PATH . '/processor.php');
 require_once(BASE_PATH . '/coprocessor.php');
 require_once(BASE_PATH . '/proxy.php');
 
-Co::set(['hook_flags' => SWOOLE_HOOK_NATIVE_CURL]);
-
 if (empty($_SERVER['argv'][1])) exit('parameter error');
 $process_count = intval($_SERVER['argv'][1]);
 
@@ -42,13 +40,25 @@ function handle_error($level, $message, $file, $line)
     Log::record($trace,Log::ERR);
 }
 
+$waiting_quit = false;
+
 function sub_message($channels)
 {
-    while (true)
+    global $waiting_quit;
+
+    $redis = new Swoole\Coroutine\Redis();
+
+    while (!$waiting_quit)
     {
-        try {
-            $redis = new Swoole\Coroutine\Redis();
-            $ret = $redis->connect(C('coroutine.redis_host'), C('coroutine.redis_port'));
+        try
+        {
+            if(!$redis->connected) {
+                $ret = $redis->connect(C('coroutine.redis_host'), C('coroutine.redis_port'));
+                Log::record("sub_message redis connected = {$redis->connected}",Log::DEBUG);
+            }
+            else {
+                $ret = true;
+            }
 
             if(!$ret) {
                 Log::record("sub_message cannot connet redis.",Log::DEBUG);
@@ -57,26 +67,22 @@ function sub_message($channels)
             }
             elseif($redis->subscribe($channels))
             {
-                Log::record("sub_message starting recv",Log::DEBUG);
                 while ($msg = $redis->recv())
                 {
                     [$sub_type, $channel, $content] = $msg;
-                    Log::record("sub_message recv mgs:{$sub_type}-{$channel}-{$content}",Log::DEBUG);
-
                     $content = unserialize($content);
                     $type = $content['type'];
-                    Log::record("sub_message recv mgs:{$sub_type}-{$channel}-{$type}",Log::DEBUG);
 
-                    if($channel == 'refill' && $type == 'channel') {
-                        Log::record("recv publish message reload refill",Log::DEBUG);
+                    if($channel != 'refill') continue;
+                    if($type == 'channel' || $type == 'merchant') {
+                        Log::record("sub_message recv mgs:{$sub_type}-{$channel}-{$type}",Log::DEBUG);
                         refill\RefillFactory::instance()->load();
                     }
                 }
-                $redis->close();
-                Log::record("sub_message redis close",Log::DEBUG);
+                Log::record("sub_message redis recv timeout",Log::DEBUG);
             }
             else {
-                Log::record("subscribe publish message error",Log::ERR);
+                Log::record("sub_message subscribe error",Log::ERR);
             }
         }
         catch (Exception $ex)
@@ -84,11 +90,28 @@ function sub_message($channels)
             Log::record($ex->getMessage(),Log::ERR);
         }
     }
+    Log::record("sub_message quit",Log::DEBUG);
 }
 
-
 //Co\run(function()
 //{
+//    Swoole\Process::signal(SIGINT, function($signal_num) {
+//        Log::record("signal call 1 = $signal_num",Log::DEBUG);
+//    });
+//    Swoole\Process::signal(SIGHUP, function($signal_num) {
+//        Log::record("signal call 1 = $signal_num",Log::DEBUG);
+//    });
+//    Swoole\Process::signal(SIGQUIT, function($signal_num) {
+//        Log::record("signal call 1 = $signal_num",Log::DEBUG);
+//    });
+//    Swoole\Process::signal(SIGTERM, function($signal_num) {
+//        Log::record("signal call 1 = $signal_num",Log::DEBUG);
+//
+//    });
+//    Swoole\Process::signal(SIGKILL, function($signal_num) {
+//        Log::record("signal call 1 = $signal_num",Log::DEBUG);
+//    });
+//
 //    Base::run_util();
 //    set_error_handler('handle_error');
 //    go(function () {
@@ -98,25 +121,77 @@ function sub_message($channels)
 //    $looper->run();
 //});
 
+Swoole\Runtime::enableCoroutine(false);
 for ($i = 0; $i < $process_count;$i++)
 {
-    $process = new Swoole\Process(function(Swoole\Process $worker)
+    global $waiting_quit;
+
+    $process = new Swoole\Process(function(Swoole\Process $worker) use (&$waiting_quit)
     {
+        Co::set(['hook_flags' => SWOOLE_HOOK_NATIVE_CURL]);
+        Swoole\Process::signal(SIGINT, function($signal_num) use ($worker) {
+            Log::record("signal call 1 = $signal_num, #{$worker->pid}",Log::DEBUG);
+        });
+        Swoole\Process::signal(SIGHUP, function($signal_num) use ($worker) {
+            Log::record("signal call 2 = $signal_num, #{$worker->pid}",Log::DEBUG);
+        });
+        Swoole\Process::signal(SIGQUIT, function($signal_num) use ($worker) {
+            Log::record("signal call 3 = $signal_num, #{$worker->pid}",Log::DEBUG);
+        });
+        Swoole\Process::signal(SIGTERM, function($signal_num) use ($worker,&$waiting_quit)
+        {
+            swoole_async_set(['enable_coroutine' => false]);
+            Log::record("signal call 4 = $signal_num, #{$worker->pid}",Log::DEBUG);
+            $waiting_quit = true;
+        });
+        Swoole\Process::signal(SIGKILL, function($signal_num) use ($worker) {
+            Log::record("signal call 5 = $signal_num, #{$worker->pid}",Log::DEBUG);
+        });
+
         Base::run_util();
         set_error_handler('handle_error');
         go(function () {
             sub_message(['refill']);
         });
-        $looper = new processor(true);
-        $looper->run();
+
+//        $looper = new processor(true);
+//        $looper->run();
 
     }, false, false, true);
 
-    $process->start();
+    $pid = $process->start();
 }
 
+
+Log::record("main process",Log::DEBUG);
+
+Swoole\Process::signal(SIGINT, function ($signo) {
+    Log::record("shutdown 1.", Log::DEBUG);
+});
+Swoole\Process::signal(SIGHUP, function ($signo) {
+    Log::record("shutdown 2.", Log::DEBUG);
+});
+Swoole\Process::signal(SIGQUIT, function ($signo) {
+    Log::record("shutdown 3.", Log::DEBUG);
+});
+Swoole\Process::signal(SIGTERM, function ($signo) {
+    Log::record("shutdown 4.", Log::DEBUG);
+});
+
+swoole_process::signal(SIGCHLD, function () {
+    Log::record("shutdown 5.", Log::DEBUG);
+});
+
+Swoole\Process::signal(SIGKILL, function ($signal_num) {
+    Log::record("shutdown 6.", Log::DEBUG);
+});
+
 for ($i = 0; $i < $process_count;$i++)
 {
+    Log::record("process {$i} start wait",Log::DEBUG);
     $status = Swoole\Process::wait(true);
     Log::record("Recycled #{$status['pid']}, code={$status['code']}, signal={$status['signal']}",Log::DEBUG);
-}
+}
+Log::record("Quit all",Log::DEBUG);
+
+

+ 7 - 1
rdispatcher/proxy.php

@@ -17,7 +17,6 @@ class proxy
         $amount = intval($params['amount']);
 
         $card_no = $params['card_no'];
-        $quality = intval($params['quality'] ?? 1);
         $mch_order = $params['mch_order'];
         $notify_url = $params['notify_url'];
         $idcard = $params['idcard'] ?? '';
@@ -27,6 +26,13 @@ class proxy
         $commit_times = $params['commit_times'] ?? 0;
         $last_order_id = $params['order_id'] ?? 0;
 
+        $quality = intval($params['quality']);
+
+        if($quality != 1 && $quality != 2) {
+            $quality =  refill\RefillFactory::instance()->first_quality($mchid);
+        }
+
+
         [$errcode, $errmsg,$order_id,$neterr] = refill\RefillFactory::instance()->add($mchid, $buyer_id, $amount, $card_no,
             $mch_order, $idcard, $card_name, $notify_url,$quality, $order_time, $commit_times,$last_order_id);
 

+ 6 - 0
test/TestRefill.php

@@ -1164,6 +1164,12 @@ class TestRefill extends TestCase
 
 
     }
+
+    public function testMchctl()
+    {
+        $ctl = new refill\mchctl();
+
+    }
 }