stanley-king преди 2 години
родител
ревизия
ba77a3d5d2
променени са 3 файла, в които са добавени 56 реда и са изтрити 25 реда
  1. 30 20
      helper/refill/RefillBase.php
  2. 7 5
      helper/refill/api/xyz/meixu/RefillPhone.php
  3. 19 0
      test/TestHttp.php

+ 30 - 20
helper/refill/RefillBase.php

@@ -60,7 +60,7 @@ class RefillBase
         elseif ($caller->verify($input))
         {
             $values = $caller->notify($input);
-            if(count($values) == 4) {
+            if(count($values) == 4) { //老的接口返回四个参数
                 [$order_id, $success, $can_try, $need_handle] = $values;
                 $official_sn = false;
             } else {
@@ -85,7 +85,7 @@ class RefillBase
         return true;
     }
 
-    private function risksn_check($refill_info)
+    private function risksn_check($refill_info,$org_official_sn)
     {
         $card_type = intval($refill_info['card_type']);
         $chk_types = [mtopcard\ChinaMobileCard , mtopcard\ChinaUnicomCard , mtopcard\ChinaTelecomCard];
@@ -94,6 +94,10 @@ class RefillBase
             return false;
         }
 
+        if ($org_official_sn !== false and count($org_official_sn) > 48) {
+            return true;
+        }
+
         $quality = intval($refill_info['quality']);
         $official_sn = $refill_info['official_sn'];
 
@@ -170,11 +174,7 @@ class RefillBase
             $mch_order = $refill_info['mch_order'];
             $order_time = intval($refill_info['order_time']);
 
-            if($official_sn != false and count($official_sn) > 48) {
-
-            }
-
-            if($success && $this->risksn_check($refill_info)) {
+            if ($success && $this->risksn_check($refill_info, $official_sn)) {
                 $tran->commit();
                 $params = ['store_id' => $order_info['store_id'],
                     'channel_name' => $refill_info['channel_name'],
@@ -730,18 +730,22 @@ class RefillBase
             $provider = $this->mPolicy->provider($chname);
             if(empty($provider)) return false;
 
-            [$state, $order_state] = $provider->query($refill_info);
-            if(!$state) {
-                return false;
-            }
-            elseif($order_state == ORDER_STATE_SUCCESS) {
-                $this->proc_notify($order_id,true,false,$chname);
-            }
-            elseif($order_state == ORDER_STATE_CANCEL) {
-                $this->proc_notify($order_id,false,true,$chname);
+            $values = $provider->query($refill_info);
+            if (count($values) == 2) {
+                [$state, $order_state] = $values;
+                $official_sn = false;
+            } else {
+                [$state, $order_state, $official_sn] = $values;
             }
-            else {
-                Log::record("RefillBase::query order_state={$order_state}",Log::DEBUG);
+
+            if (!$state) {
+                return false;
+            } elseif ($order_state == ORDER_STATE_SUCCESS) {
+                $this->proc_notify($order_id, true, false, $chname, $official_sn);
+            } elseif ($order_state == ORDER_STATE_CANCEL) {
+                $this->proc_notify($order_id, false, true, $chname, $official_sn);
+            } else {
+                Log::record("RefillBase::query order_state={$order_state}", Log::DEBUG);
             }
         }
 
@@ -806,7 +810,13 @@ class RefillBase
         $provider = $this->mPolicy->provider($chname);
         if(empty($provider)) return false;
 
-        [$state, $order_state] = $provider->query($refill_info);
+        $values = $provider->query($refill_info);
+        if (count($values) == 2) {
+            [$state, $order_state] = $values;
+            $official_sn = false;
+        } else {
+            [$state, $order_state, $official_sn] = $values;
+        }
 
         try {
             $can_try = false;
@@ -827,7 +837,7 @@ class RefillBase
         if($can_try)
         {
             if($trans_succ) {
-                $this->proc_notify($order_id, false, true, $chname);
+                $this->proc_notify($order_id, false, true, $chname, $official_sn);
             } else {
                 QueueClient::async_push("QueryOrderNeterr",['order_id' => $order_id],30);
             }

+ 7 - 5
helper/refill/api/xyz/meixu/RefillPhone.php

@@ -75,7 +75,7 @@ class RefillPhone extends refill\IRefillPhone
         $resp = http_request(config::QUERY_URL, $params, 'POST');
 
         if (empty($resp)) {
-            return [false, '网络错误'];
+            return [false, '网络错误',''];
         }
         else
         {
@@ -83,13 +83,15 @@ class RefillPhone extends refill\IRefillPhone
             $resp = $this->xmlToArray($resp);
             if (empty($resp))
             {
-                return [false, '网络错误'];
+                return [false, '网络错误',''];
             }
             else
             {
+                $offical_sn = '';
                 $resultno = $resp['resultno'];
                 if ($resultno === '1') {
-                    $updata['official_sn'] = $resp['remark1'];
+                    $offical_sn = $resp['remark1'];
+                    $updata['official_sn'] = $offical_sn;
                     Model('refill_order')->edit($refill_info['order_id'], $updata);
                     $order_state = ORDER_STATE_SUCCESS;
                 } elseif ($resultno === '9') {
@@ -99,10 +101,10 @@ class RefillPhone extends refill\IRefillPhone
                 } elseif ($resultno === '5007' && (time() - $refill_info['commit_time'] > 600)) {
                     $order_state = ORDER_STATE_NOEXIST;
                 } else {
-                    return [false, $resultno];
+                    return [false, $resultno, $offical_sn];
                 }
 
-                return [true, $order_state];
+                return [true, $order_state, $offical_sn];
             }
         }
     }

Файловите разлики са ограничени, защото са твърде много
+ 19 - 0
test/TestHttp.php