Browse Source

增加手动回调标志参数

stanley-king 4 years ago
parent
commit
fb384920c1

+ 1 - 1
admin/control/merchant.php

@@ -604,7 +604,7 @@ class merchantControl extends SystemControl
     public function notify_merchantOp()
     {
         $order_id = $_GET['order_id'];
-        QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id]);
+        QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id,'manual' => true]);
         showMessage('操作成功', 'index.php?act=merchant&op=refill_order');
     }
 

+ 3 - 1
data/logic/queue.logic.php

@@ -1396,10 +1396,12 @@ class queueLogic
     public function NotifyMerchantComplete($params)
     {
         $order_id = intval($params['order_id']);
+        $manual = $params['manual'] ?? false;
+
         if($order_id <= 0) {
             return callback(false);
         }
-        [$success,$err] = refill\RefillFactory::instance()->notify_merchant($order_id);
+        [$success,$err] = refill\RefillFactory::instance()->notify_merchant($order_id,$manual);
         if($success) {
             return callback(true, '通知机构成功', ['order_id' => $order_id]);
         }

+ 7 - 5
helper/refill/RefillFactory.php

@@ -339,7 +339,7 @@ class RefillFactory
 
                 $mod_refill = Model('refill_order');
                 $mod_refill->edit($order_id, ['notify_time' => time(), 'notify_state' => 1]);
-                QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id]);
+                QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id,'manual' => false]);
             } else {
                 Log::record("系统无此订单ID:{$order_id}", Log::ERR);
 
@@ -542,7 +542,7 @@ class RefillFactory
         return $checker($url, "http://") || $checker($url, "https://");
     }
 
-    public function notify_merchant($order_id)
+    public function notify_merchant($order_id,$manual)
     {
         if ($order_id <= 0) {
             return [false, "订单ID小于0"];
@@ -557,7 +557,9 @@ class RefillFactory
         if (empty($order_info) || empty($refill_info)) {
             return [false, "无此订单"];
         }
-        if ($refill_info['mch_notify_state'] != 0) {
+
+        //手动通知,之所以不做尝试,是担心客户方状态处理不当
+        if (!$manual && $refill_info['mch_notify_state'] != 0) {
             return [false, "已经通知客户方"];
         }
 
@@ -601,7 +603,7 @@ class RefillFactory
             } else {
                 $N = intval($times / 5);
                 $period = intval(pow(2, $N));
-                QueueClient::async_push("NotifyMerchantComplete", ['order_id' => $order_id], $period);
+                QueueClient::async_push("NotifyMerchantComplete", ['order_id' => $order_id,'manual' => false], $period);
             }
             return [false, "通知{$times}次,失败."];
         }
@@ -658,7 +660,7 @@ class RefillFactory
 
                 if($modify_able) {
                     $mod_refill->edit($order_id, ['notify_time' => time(), 'notify_state' => 1]);
-                    QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id]);
+                    QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id,'manual' => false]);
                 }
             }
 

+ 1 - 1
test/TestRBridge.php

@@ -120,7 +120,7 @@ class TestRBridge extends TestCase
 
     public function testCallBack()
     {
-        refill\RefillFactory::instance()->notify_merchant(304);
+        refill\RefillFactory::instance()->notify_merchant(304,true);
     }
 
     private function make_sn()

+ 3 - 3
test/TestRefill.php

@@ -459,7 +459,7 @@ class TestRefill extends TestCase
     public function testCallMech()
     {
         $logic = Logic('queue');
-        $logic->NotifyMerchantComplete(['order_id' => 18171]);
+        $logic->NotifyMerchantComplete(['order_id' => 18171,'manual' => true]);
     }
 
     //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefill::testCallMech)( .*)?$/" --test-suffix TestRefill.php /var/www/html/test
@@ -604,7 +604,7 @@ class TestRefill extends TestCase
     public function testCall()
     {
         $order_id = 14974;
-        QueueClient::async_push("NotifyMerchantComplete", ['order_id' => $order_id], 10);
+        QueueClient::async_push("NotifyMerchantComplete", ['order_id' => $order_id,'manual' => true], 10);
     }
 
     public function testSyncconfig()
@@ -768,6 +768,6 @@ class TestRefill extends TestCase
 }
 
 
-//docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefill::testCall)( .*)?$/" --test-suffix TestRefill.php /var/www/html/test
+//docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefill::testLoadBlack)( .*)?$/" --test-suffix TestRefill.php /var/www/html/test
 
 //docker-compose -f ./docker-compose-dev.yml run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefill::testCall)( .*)?$/" --test-suffix TestRefill.php /var/www/html/test