stanley-king 1 年之前
父节点
当前提交
8c63d162cf
共有 2 个文件被更改,包括 21 次插入15 次删除
  1. 19 11
      helper/refill/api/mh/guitong_fast/RefillPhone.php
  2. 2 4
      helper/refill/api/mh/guitong_fast/config.php

+ 19 - 11
helper/refill/api/mh/guitong_fast/RefillPhone.php

@@ -16,15 +16,21 @@ class RefillPhone extends refill\IRefillPhone
 
     private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
     {
+        $nSortType = config::operator[$card_type] ?? 0;
+        if($nSortType === 0) {
+            return [];
+        }
+
         $params['szAgentId'] = config::USER_ID;
         $params['szOrderId'] = $order_sn;
         $params['szPhoneNum'] = $phone;
         $params['nMoney'] = $amount;
-        $params['nSortType'] = config::operator[$card_type];
+        $params['nSortType'] = $nSortType;
         $params['nProductClass'] = 1;
-        $params['nProductType'] = 1;
+        $params['nProductType'] = '1';
         $params['szTimeStamp'] = date("Y-m-d H:i:s");
         $params['szNotifyUrl'] = config::NOTIFY_URL;
+
         return $params;
     }
 
@@ -32,12 +38,14 @@ class RefillPhone extends refill\IRefillPhone
     {
         $order_sn = $params['order_sn'];
         $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
+        if(empty($params)) {
+            return [false, '提单参数不符合', false];
+        }
 
         $sign = $this->sign($params);
         $params['szVerifyString'] = $sign;
 
         $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
-
         if (empty($resp)) {
             return [false, '网络错误', true];
         }
@@ -54,11 +62,11 @@ class RefillPhone extends refill\IRefillPhone
             } elseif (in_array($nRtn, config::ERR_NOS, true)) {
                 return [false, $resp['szRtnCode'], false];
             } elseif (in_array($nRtn, [2050, 999], true)) {
-                $net_errno = "HTTP-{$nRtn}";
+                $net_errno = "HTTP-$nRtn";
                 return [false, $resp['szRtnCode'], true];
             } else {
                 $err = 998;
-                $net_errno = "HTTP-{$err}";
+                $net_errno = "HTTP-$err";
                 return [false, $resp['szRtnCode'], true];
             }
         }
@@ -69,11 +77,11 @@ class RefillPhone extends refill\IRefillPhone
         $params['szAgentId'] = config::USER_ID;
         $params['szOrderId'] = $refill_info['order_sn'];
         $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szOrderId={$params['szOrderId']}&szKey={$key}";
+
+        $content = "szAgentId={$params['szAgentId']}&szOrderId={$params['szOrderId']}&szKey=$key";
         $params['szVerifyString'] = md5($content);
 
         $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
-
         if (empty($resp)) {
             return [false, '网络错误'];
         }
@@ -108,11 +116,10 @@ class RefillPhone extends refill\IRefillPhone
     {
         $params['szAgentId'] = config::USER_ID;
         $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szKey={$key}";
+        $content = "szAgentId={$params['szAgentId']}&szKey=$key";
         $params['szVerifyString'] = md5($content);
 
         $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
-
         if (empty($resp)) {
             return [false, '网络错误'];
         }
@@ -134,8 +141,9 @@ class RefillPhone extends refill\IRefillPhone
     {
         $userid = config::USER_ID;
         $key = config::KEY;
-        $content = "szAgentId={$userid}&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nMoney={$params['nMoney']}&nSortType={$params['nSortType']}";
-        $content .= "&nProductClass={$params['nProductClass']}&nProductType={$params['nProductType']}&szTimeStamp={$params['szTimeStamp']}&szKey={$key}";
+        $content = "szAgentId=$userid&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nMoney={$params['nMoney']}&nSortType={$params['nSortType']}";
+        $content .= "&nProductClass={$params['nProductClass']}&nProductType={$params['nProductType']}&szTimeStamp={$params['szTimeStamp']}&szKey=$key";
+
         return md5($content);
     }
 }

+ 2 - 4
helper/refill/api/mh/guitong_fast/config.php

@@ -19,9 +19,7 @@ class config
         mtopcard\ChinaUnicomCard  => 2,
         mtopcard\ChinaTelecomCard => 3
     ];
-    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
 
-    const ERR_NOS = [
-        1000,1001,1003,1004,2001,2002,2003,2020,2021,1006,2030,3003
-    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ERR_NOS = [1000, 1001, 1003, 1004, 2001, 2002, 2003, 2020, 2021, 1006, 2030, 3003];
 }