Forráskód Böngészése

add xuyou channel to xyz

dong 1 éve
szülő
commit
62745e321c

+ 2 - 1
helper/refill/api/xyz/xuyou_hf/RefillCallBack.php

@@ -62,13 +62,14 @@ class RefillCallBack implements refill\IRefillCallBack
 
     public function notify($params) : array
     {
-        $status = $params['status'];
+        $status = intval($params['status']);
         $order_sn = $params['orderid'];
         $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
         if (empty($order_info)) {
             return [false, false, false,false];
         }
         $order_id = $order_info['order_id'];
+
         if ($status === 2) {
             $data['ch_trade_no'] = $params['oid'];
             $data['official_sn'] = strtolower($params['voucher']) == 'null' ? '' : $params['voucher'];

+ 3 - 6
helper/refill/api/xyz/xuyou_hf/RefillPhone.php

@@ -59,11 +59,10 @@ class RefillPhone extends refill\IRefillPhone
         $params['sign'] = $this->sign($params);
         $params = json_encode($params);
         $resp = http_post_data(config::QUERY_URL, $params , config::ExtHeaders);
+
         if (empty($resp)) {
             return [false, '系统错误'];
-        }
-        else
-        {
+        } else {
             Log::record($resp, Log::DEBUG);
             $resp = json_decode($resp, true);
             if (empty($resp)) {
@@ -71,7 +70,7 @@ class RefillPhone extends refill\IRefillPhone
             }
             elseif ($resp['status'] === 2)
             {
-                $save['official_sn'] = strtolower($resp['orderid']) == 'null' ? '' : $resp['orderid'];
+                $save['official_sn'] = strtolower($resp['voucher']) == 'null' ? '' : $resp['voucher'];
                 Model('refill_order')->edit($refill_info['order_id'], $save);
                 $order_state = ORDER_STATE_SUCCESS;
                 return [true, $order_state];
@@ -114,8 +113,6 @@ class RefillPhone extends refill\IRefillPhone
                 return [false, '系统错误'];
             } elseif ($resp['status'] === 1) {
                 return [true, $resp['balance']];
-            }elseif ($resp['status'] === -1){
-                return [false, $resp['msg']];
             } else {
                 return [false, $resp['msg']];
             }

+ 14 - 11
helper/refill/api/xyz/xuyou_oil/RefillCallBack.php

@@ -18,7 +18,7 @@ class RefillCallBack implements refill\IRefillCallBack
 
     private function sign($params) : string
     {
-        $mchid = config::MCHID;
+        $mchid = config::MCH_ID;
         $key = config::KEY;
         $content  = "mchid={$mchid}&orderid={$params['orderid']}&oid={$params['oid']}&number={$params['number']}&status={$params['status']}&key={$key}";
         return md5($content);
@@ -26,23 +26,26 @@ class RefillCallBack implements refill\IRefillCallBack
 
     public function notify($params) : array
     {
+        $status = intval($params['status']);
         $order_sn = $params['orderid'];
         $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
         if (empty($order_info)) {
-            return [false, false, false, false, ''];
+            return [false, false, false, false];
         }
-
         $order_id = $order_info['order_id'];
-        $status = intval($params['status']);
+
         if ($status === 2) {
-            $official_sn = strtolower($params['voucher']) == 'null' ? '' : $params['voucher'];
-            $data['official_sn'] = $official_sn;
+            $data['ch_trade_no'] = $params['oid'];
+            $data['official_sn'] = strtolower($params['voucher']) == 'null' ? '' : $params['voucher'];;
             Model('refill_order')->edit($order_id, $data);
-            return [$order_id, true, false, true, $official_sn];
-        } elseif ($status === 3) {
-            return [$order_id, false, true, true, ''];
-        } else {
-            return [$order_id, false, false, false, ''];
+            return [$order_id, true, false, true];
+        }
+        elseif ($status === 3) {
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $params['oid']]);
+            return [$order_id, false, true, true];
+        }
+        else {
+            return [$order_id, false, false, false];
         }
     }
 }

+ 29 - 31
helper/refill/api/xyz/xuyou_oil/RefillOil.php

@@ -17,7 +17,7 @@ class RefillOil extends refill\IRefillOil
 
     private function req_params(int $phone, string $order_sn, $productid, $province) : array
     {
-        $params['mchid'] = config::MCHID;
+        $params['mchid'] = config::MCH_ID;
         $params['orderid'] = $order_sn;
         $params['number'] = $phone;
         $params['productid'] = $productid;
@@ -49,7 +49,6 @@ class RefillOil extends refill\IRefillOil
             } elseif ($resp['status'] === -1) {
                 return [false, $resp['msg'], false];
             } else {
-                $net_errno = "HTTP-998";
                 return [false, $resp['msg'], true];
             }
         }
@@ -57,53 +56,52 @@ class RefillOil extends refill\IRefillOil
 
     public function query($refill_info) : array
     {
-        $params['mchid'] = config::MCHID;
+        $params['mchid'] = config::MCH_ID;
         $params['orderid'] = $refill_info['order_sn'];
         $key = config::KEY;
         $content = "mchid={$params['mchid']}&orderid={$params['orderid']}&key={$key}";
         $params['sign'] = md5($content);
-
         $params = json_encode($params);
-        $resp = http_post_data(config::QUERY_URL, $params , config::ExtHeaders);
+        $resp = http_post_data(config::QUERY_URL, $params, config::ExtHeaders);
 
         if (empty($resp)) {
-            return [false, '系统错误', ''];
-        }
-        else
-        {
+            return [false, '系统错误'];
+        } else {
             Log::record($resp, Log::DEBUG);
             $resp = json_decode($resp, true);
             if (empty($resp)) {
-                return [false, '系统错误', ''];
+                return [false, '系统错误'];
+            }
+            elseif ($resp['status'] === 2)
+            {
+                $save['official_sn'] = strtolower($resp['voucher']) == 'null' ? '' : $resp['voucher'];
+                Model('refill_order')->edit($refill_info['order_id'], $save);
+                $order_state = ORDER_STATE_SUCCESS;
+                return [true, $order_state];
+            }
+            elseif ($resp['status'] === -1){
+                return [false, $resp['msg']];
+            }
+            elseif ($resp['status'] === 1){
+                return [false, $resp['msg']];
+            }
+            elseif ($resp['status'] === 3){
+                return [false, $resp['msg']];
+            }
+            elseif ($resp['status'] === 4 && (time() - $refill_info['commit_time'] >= 600))
+            {
+                return [true, ORDER_STATE_NOEXIST];
             }
             else
             {
-                $offical_sn = '';
-                $status = $resp['status'];
-
-                if ($status === 2) {
-                    $offical_sn = $resp['voucher'];
-                    $updata['official_sn'] = $offical_sn;
-                    Model('refill_order')->edit($refill_info['order_id'], $updata);
-                    $order_state = ORDER_STATE_SUCCESS;
-                } elseif ($status === 3) {
-                    $order_state = ORDER_STATE_CANCEL;
-                } elseif ($status === 1) {
-                    $order_state = ORDER_STATE_SEND;
-                } elseif ($status === 4 && (time() - $refill_info['commit_time'] > 600)) {
-                    $order_state = ORDER_STATE_NOEXIST;
-                } else {
-                    return [false, $status, $offical_sn];
-                }
-
-                return [true, $order_state, $offical_sn];
+                return [false, $resp['message']];
             }
         }
-    }
+}
 
     public function balance() : array
     {
-        $params['mchid'] = config::MCHID;
+        $params['mchid'] = config::MCH_ID;
         $key = config::KEY;
         $content = "mchid={$params['mchid']}&key={$key}";
         $params['sign'] = md5($content);

+ 1 - 1
helper/refill/api/xyz/xuyou_oil/config.php

@@ -10,7 +10,7 @@ class config
     const QUERY_URL = 'http://123.56.68.57:1008/hqorder/api/query';
     const BALANCE_URL = 'http://123.56.68.57:1008/hqorder/api/balance';
 
-    const MCHID = '1';
+    const MCH_ID = '1';
     const KEY = '52e4fd509410446a8259fd8a93de6c85';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xuyou_oil.php";
     const ExtHeaders = ['Content-Type: application/json'];