Bläddra i källkod

fix order_channels infomation cannot del

stanley-king 10 månader sedan
förälder
incheckning
dfc2c1df6a

+ 3 - 0
helper/refill/RefillBase.php

@@ -255,6 +255,9 @@ class RefillBase
                         return true;
                     }
                 }
+                else {
+                    $order->finish();
+                }
             }
             else {
                 $logic_vr_order->changeOrderStateCancel($order_info, '', "{$chname}接口回调通知失败,不可重试.",true,true);

+ 7 - 0
helper/refill/order.php

@@ -52,6 +52,13 @@ class order
         $this->mOverPriceFlag = 0;
     }
 
+    public function finish()
+    {
+        if($this->mChannelFilter != null) {
+            $this->mChannelFilter->finish();
+        }
+    }
+
     public function mchid()
     {
         return $this->mMchid;

+ 13 - 2
helper/refill/policy/channel_filter.php

@@ -11,12 +11,15 @@ class channel_filter
     private $mCardType;
     private $mDatas;
 
+    private $mFinish;
+
     public function __construct($mchid, $mch_order, $card_type)
     {
         $this->mMchid = $mchid;
         $this->mMchOrder = $mch_order;
         $this->mQuality = 0;
         $this->mCardType = $card_type;
+        $this->mFinish = false;
 
         if($this->mCardType != mtopcard\ThirdRefillCard) {
             $this->mDatas = util::get_order_channels($mchid,$mch_order);
@@ -28,11 +31,19 @@ class channel_filter
 
     public function __destruct()
     {
-        if($this->mCardType != mtopcard\ThirdRefillCard) {
-            util::set_order_channels($this->mMchid,$this->mMchOrder,$this->mDatas);
+        if(!$this->mFinish)
+        {
+            if($this->mCardType != mtopcard\ThirdRefillCard) {
+                util::set_order_channels($this->mMchid,$this->mMchOrder,$this->mDatas);
+            }
         }
     }
 
+    public function finish()
+    {
+        $this->mFinish = true;
+    }
+
     public function add($cur_quality, $name, $succ)
     {
         if ($this->mCardType == mtopcard\ThirdRefillCard) {

+ 3 - 0
rdispatcher/proxy.php

@@ -28,6 +28,7 @@ class proxy
         $mch_order = $order->mch_order();
         $last_order_id = $order->last_order_id();
         $order_time = $order->order_time();
+        $order->finish();
 
         if ($last_order_id === 0) {
             $order_id = refill\RefillFactory::instance()->zero_order($order, $errmsg);
@@ -127,6 +128,7 @@ class proxy
             return false;
         }
 
+        $order->finish();
         refill\util::pop_queue_order($mchid, $mch_order, $order->order_time());
         QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id, 'manual' => false]);
 
@@ -337,6 +339,7 @@ class proxy
         $mchid = $order->mchid();
         $mch_order = $order->mch_order();
         $order_time = $order->order_time();
+        $order->finish();
 
         refill\util::push_queue_order($mchid,$mch_order,ORDER_STATE_SEND);
         Model('refill_order')->partition(util::part_refill($order_time))->edit_detail($mchid,$mch_order,['order_state' => ORDER_STATE_SEND]);

+ 1 - 0
test/TestRedis.php

@@ -320,6 +320,7 @@ class TestRedis extends TestCase
 
     public function testValue()
     {
+        $ret = refill\util::set_order_channels(1,"xxxxxfdasfdas",['name' => 'stanley']);
         $ret = refill\util::get_order_channels(1,"xxxxxfdasfdas");
         refill\util::del_order_channels(1,"xxxxxfdasfdas");
     }