stanley-king 3 jaren geleden
bovenliggende
commit
09ca49fb79
4 gewijzigde bestanden met toevoegingen van 31 en 7 verwijderingen
  1. 6 3
      admin/control/refill_detail.php
  2. 5 0
      data/model/refill_order.model.php
  3. 10 0
      helper/refill/util.php
  4. 10 4
      mobile/control/refill.php

+ 6 - 3
admin/control/refill_detail.php

@@ -143,12 +143,14 @@ class refill_detailControl extends SystemControl
 
         $refill_detail = Model('refill_detail')->where($condition)->select();
         $mod = Model('refill_order');
-        foreach ($refill_detail as $detail) {
+        foreach ($refill_detail as $detail)
+        {
             $mchid = $detail['mchid'];
             $mch_order = $detail['mch_order'];
             Log::record("mchid: {$mchid} , mch_order: {$mch_order}", Log::DEBUG);
             $refill_order = $mod->getOrderInfo(['mchid' => $mchid,'mch_order' => $mch_order]);
-            if (empty($refill_order)) {
+            if (empty($refill_order))
+            {
                 Log::record("order dispose type:{$type}, params:{$detail['params']}",Log::DEBUG);
                 $params = json_decode($detail['params'],true);
                 if ($type == 'cancel') {
@@ -162,7 +164,8 @@ class refill_detailControl extends SystemControl
                 } else {
                     continue;
                 }
-            } else {
+            }
+            else {
                 util::pop_queue_order($mchid,$mch_order);
             }
         }

+ 5 - 0
data/model/refill_order.model.php

@@ -66,6 +66,11 @@ class refill_orderModel extends Model
         return $this->table('refill_detail')->insert(['mchid' => $mchid,'mch_order' => $mch_order,'order_time' => time(),'params' => json_encode($details),'order_state' => $order_state]);
     }
 
+    public function del_detail($mchid,$mch_order)
+    {
+        return $this->table('refill_detail')->where(['mchid' => $mchid,'mch_order' => $mch_order])->delete();
+    }
+
     public function edit_detail($mchid,$mch_order,$datas)
     {
         return $this->table('refill_detail')->where(['mchid' => $mchid,'mch_order' => $mch_order])->update($datas);

+ 10 - 0
helper/refill/util.php

@@ -519,6 +519,16 @@ class util
         $ins->hset($name, '', [$key => $order_state]);
     }
 
+    public static function del_queue_order($mchid,$mch_order)
+    {
+        if(empty($mch_order)) return;
+        $ins = Cache::getInstance('cacheredis');
+
+        $name = 'merchant_order_query';
+        $key = "{$mchid}-{$mch_order}";
+        $ret = $ins->hdel($name, '', $key);
+    }
+
     public static function pop_queue_order($mchid,$mch_order)
     {
         util::del_order_channels($mchid,$mch_order);

+ 10 - 4
mobile/control/refill.php

@@ -109,6 +109,9 @@ class refillControl extends merchantControl
             'notify_url' => $notify_url,
             'org_quality' => $quality];
 
+        refill\util::push_queue_order($this->mchid(),$mch_order,ORDER_STATE_QUEUE);
+        Model('refill_order')->add_detail($this->mchid(),$mch_order,$params,ORDER_STATE_QUEUE);
+
         [$can_refill, $period] = refill\util::can_commit($card_no, $card_type);
         if ($can_refill === false) {
             $state = refill\util::async_add($params, $period);
@@ -118,11 +121,11 @@ class refillControl extends merchantControl
 
         $mchid = $this->mchid();
         if ($state === true) {
-            refill\util::push_queue_order($this->mchid(),$mch_order,ORDER_STATE_QUEUE);
-            Model('refill_order')->add_detail($this->mchid(),$mch_order,$params,ORDER_STATE_QUEUE);
             Log::record("refill::util::push_add success mchid={$mchid} mch_order={$mch_order} state={$state}",Log::DEBUG);
             return self::outsuccess(['state' => true]);
         } else {
+            refill\util::del_queue_order($this->mchid(),$mch_order);
+            Model('refill_order')->del_detail($this->mchid(),$mch_order);
             Log::record("refill::util::push_add error mchid={$mchid} mch_order={$mch_order} state={$state}",Log::DEBUG);
             return self::outerr(208, '提交失败');
         }
@@ -197,12 +200,15 @@ class refillControl extends merchantControl
             'third_card_type' => $third_card_type
         ];
 
+        refill\util::push_queue_order($this->mchid(),$mch_order,ORDER_STATE_QUEUE);
+        Model('refill_order')->add_detail($this->mchid(),$mch_order,$params,ORDER_STATE_QUEUE);
+
         $state = refill\util::push_addthird($params);
         if ($state === true) {
-            refill\util::push_queue_order($this->mchid(),$mch_order,ORDER_STATE_QUEUE);
-            Model('refill_order')->add_detail($this->mchid(),$mch_order,$params,ORDER_STATE_QUEUE);
             return self::outsuccess(['state' => true]);
         } else {
+            refill\util::del_queue_order($this->mchid(),$mch_order);
+            Model('refill_order')->del_detail($this->mchid(),$mch_order);
             return self::outerr(208, '提交失败');
         }
     }