Kaynağa Gözat

refactor create refill orider

stanley-king 3 yıl önce
ebeveyn
işleme
d58fa5f6af

+ 12 - 1
docker/compose/xyz/master-unique/docker-compose.yml

@@ -22,4 +22,15 @@ services:
       - /nfs/upload:/var/www/html/data/upload
       - /mnt/shoplog:/var/www/html/data/log
     container_name: "panda-cronsec"
-    command: [php,"/var/www/html/crontab/index.php",'minutes','second_queue']
+    command: [php,"/var/www/html/crontab/index.php",'minutes','second_queue']
+
+  accedit:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - ../../../../:/var/www/html
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - ../conf/php/php.ini:/usr/local/etc/php/php.ini
+      - /nfs/upload:/var/www/html/data/upload
+      - /mnt/shoplog:/var/www/html/data/log
+    container_name: "panda-accedit"
+    command: [php,"/var/www/html/crontab/index.php",'minutes','account_edit']

+ 11 - 3
helper/refill/RefillBase.php

@@ -438,6 +438,12 @@ class RefillBase
             }
         };
 
+        $order_canceler = function ($order_id,$err_msg) {
+            $logic_vr_order = Logic("vr_order");
+            $order_info = Model('vr_order')->getOrderInfo(['order_id' => $order_id]);
+            $logic_vr_order->changeOrderStateCancel($order_info, '', $err_msg, true, true);
+        };
+
         try
         {
             $logic_buy_virtual = Logic('buy_virtual');
@@ -459,13 +465,15 @@ class RefillBase
                 $order_id = $result['data']['order_id'];
                 $last_orderid = $order->last_order_id();
                 $fSuccess = $refill_creater($order,$last_orderid,$order_id,$order_sn,$mod_refill);
+
                 if(!$fSuccess) {
                     Log::record("refill_creater fail:order_sn={$order_sn}",Log::ERR);
+                    $order_canceler($order_id,'refill_order 记录创建失败');
+                    return [false, $order_id, $order_sn];
                 }
+
                 if (!$this->pay_completed($order_sn)) {
-                    $logic_vr_order = Logic("vr_order");
-                    $order_info = Model('vr_order')->getOrderInfo(['order_id' => $order_id]);
-                    $logic_vr_order->changeOrderStateCancel($order_info, '', "预存款不足以支付该订单", true, true);
+                    $order_canceler($order_id,'预存款不足以支付该订单');
                     return [false, $order_id, $order_sn];
                 }
 

+ 4 - 0
helper/refill/util.php

@@ -626,6 +626,8 @@ class util
     //for tester
     public static function send_normal($order_sn)
     {
+        return true;
+
         $status = mt_rand(1,10);
         if($status > 9) {
             $status = 1;
@@ -649,6 +651,8 @@ class util
 
     public static function send_quick($order_sn)
     {
+        return true;
+
         $status = mt_rand(1,10);
         if($status > 3) {
             $status = 1;

+ 1 - 1
test/TestRefillThird.php

@@ -96,7 +96,7 @@ class TestRefillThird extends TestCase
     public function testPushPhones()
     {
         $time = time();
-        for ($i = 0; $i < 100000; $i++)
+        for ($i = 0; $i < 1000000; $i++)
         {
             $params = [ 'mchid' => 1092,
                 'buyer_id' => 60221,