stanley-king 4 tahun lalu
induk
melakukan
96aee52daf

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

@@ -1391,6 +1391,34 @@ class queueLogic
 
     public function NotifyMerchantComplete($params)
     {
-        $order_id = $params['order_id'];
+        $order_id = intval($params['order_id']);
+        if($order_id <= 0) {
+            return callback(false);
+        }
+
+        $vr_order = Model('vr_order');
+        $refill_order = Model('refill_order');
+
+        $order_info = $vr_order->getOrderInfo(['order_id' => $order_id]);
+        $refill_info = $refill_order->getOrderInfo(['order_id' => $order_id]);
+
+        if(empty($order_info) || empty($refill_info) || $refill_info['mch_notify_state'] != 0) {
+            return callback(false);
+        }
+
+
+        $order_state = $order_info['order_state'];
+        if($order_state == ORDER_STATE_CANCEL) {
+            $state = "SUCCESS";
+        }
+        elseif($order_state == ORDER_STATE_SUCCESS) {
+            $state = "CANCEL";
+        }
+        else {
+            return callback(false);
+        }
+
+
+
     }
 }

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

@@ -5,6 +5,16 @@ defined('InShopNC') or exit('Access Invalid!');
 
 class refill_orderModel extends Model
 {
+	public function getOrderInfo($condition = array(), $fields = '*', $master = false)
+    {
+        $order_info = $this->table('refill_order')->field($fields)->where($condition)->master($master)->find();
+        if (empty($order_info)) {
+            return array();
+        }
+        
+        return $order_info;
+    }
+
     public function add_refill($params)
     {
         return $this->table('refill_order')->insert($params);

+ 17 - 4
helper/refill/RefillFactory.php

@@ -85,11 +85,24 @@ class RefillFactory
             return false;
         }
 
-        if($caller->verify($input)) {
-            $caller->notify($input);
-        }
+        if($caller->verify($input))
+        {
+            [$order_id,$success] = $caller->notify($input);
+            if($order_id !== false)
+            {
+                $logic_vr_order = Logic("vr_order");
+                if($success) {
+                    $logic_vr_order->changeOrderStateSuccess($order_id);
+                } else {
+                    $logic_vr_order->changeOrderStateCancel($order_id);
+                }
+
+                $mod_refill = Model('refill_order');
+                $mod_refill->edit($order_id,['notify_time' => time(),'notify_state' => 1]);
+                QueueClient::push("NotifyMerchantComplete",['order_id' => $order_id]);
 
+            }
+        }
         return true;
     }
-
 }

+ 1 - 6
helper/refill/beixt/RefillCallBack.php

@@ -14,13 +14,8 @@ class RefillCallBack implements refill\IRefillCallBack
         return true;
     }
 
-    public function onOil($params)
+    public function notify($params)
     {
 
     }
-
-    public function onPhone($params)
-    {
-        // TODO: Implement onPhone() method.
-    }
 }

+ 3 - 9
helper/refill/suhc/RefillCallBack.php

@@ -9,7 +9,6 @@ use QueueClient;
 
 class RefillCallBack implements refill\IRefillCallBack
 {
-
     public function verify($params) : bool
     {
         $input = $params;
@@ -43,19 +42,14 @@ class RefillCallBack implements refill\IRefillCallBack
 
         $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
         if(empty($order_info)) {
-            return false;
+            return [false,false];
         }
 
         $order_id = $order_info['order_id'];
         if($status === 2) {
-            $logic_vr_order = Logic("vr_order");
-            $logic_vr_order->changeOrderStateSuccess($order_id);
-            QueueClient::push("NotifyMerchantComplete",['order_id' => $order_id]);
+            return [$order_id,true];
         } else {
-            $logic_vr_order = Logic("vr_order");
-            $logic_vr_order->changeOrderStateCancel($order_id);
-            QueueClient::push("NotifyMerchantComplete",['order_id' => $order_id]);
+            return [$order_id,false];
         }
-        return true;
     }
 }

+ 7 - 0
mobile/control/merchant_admin.php

@@ -0,0 +1,7 @@
+<?php
+
+
+class merchant_admin
+{
+
+}

+ 0 - 7
mobile/control/merchant_base.php

@@ -1,7 +0,0 @@
-<?php
-
-
-class merchant_base
-{
-
-}