xiaoyu 3 years ago
parent
commit
e5aa9fc2be

+ 13 - 15
helper/refill/api/xyz/chizeng/RefillCallBack.php

@@ -9,7 +9,7 @@ class RefillCallBack implements refill\IRefillCallBack
     public function verify($params): bool
     {
         $sign = $this->sign($params);
-        if ($params['szVerifyString'] == $sign) {
+        if ($params['sign'] == $sign) {
             return true;
         } else {
             return false;
@@ -20,31 +20,29 @@ class RefillCallBack implements refill\IRefillCallBack
     {
         $userid = config::USER_ID;
         $key = config::KEY;
-        $content = "szAgentId={$userid}&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nDemo={$params['nDemo']}&fSalePrice={$params['fSalePrice']}";
-        $content .= "&nFlag={$params['nFlag']}&szKey={$key}";
+        $content = "userid={$userid}&orderid={$params['orderid']}&sporderid={$params['sporderid']}&merchantsubmittime={$params['merchantsubmittime']}";
+        $content .= "&resultno={$params['resultno']}&key={$key}";
         return md5($content);
     }
 
     public function notify($params)
     {
-        $status = intval($params['nFlag']);
-        $order_sn = $params['szOrderId'];
+        $status = intval($params['resultno']);
+        $order_sn = $params['sporderid'];
         $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
         if (empty($order_info)) {
             return [false, false, false,false];
         }
-        $order_id = $order_info['order_id'];
 
-        if ($status === 2) {
-            $data['official_sn'] = strtolower($params['szRtnMsg']) == 'null' ? '' : $params['szRtnMsg'];
+        $order_id = $order_info['order_id'];
+        if ($status === 1) {
+            $data['official_sn'] = strtolower($params['supnumber']) == 'null' ? '' : $params['supnumber'];
             Model('refill_order')->edit($order_id, $data);
-            return [$order_id, true, false,true];
-        }
-        elseif ($status === 3) {
-            return [$order_id, false, true,true];
-        }
-        else {
-            return [$order_id, false, false,false];
+            return [$order_id, true, false, true];
+        } elseif ($status === 9) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
         }
     }
 }

+ 66 - 57
helper/refill/api/xyz/chizeng/RefillPhone.php

@@ -6,6 +6,7 @@ require_once(BASE_HELPER_RAPI_PATH . '/chizeng/config.php');
 
 use refill;
 use Log;
+use mtopcard;
 
 class RefillPhone extends refill\IRefillPhone
 {
@@ -14,17 +15,18 @@ class RefillPhone extends refill\IRefillPhone
         parent::__construct($cfgs);
     }
 
-    private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
+    private function req_params(int $phone, int $amount, $card_type, string $order_sn)
     {
-        $params['szAgentId'] = config::USER_ID;
-        $params['szOrderId'] = $order_sn;
-        $params['szPhoneNum'] = $phone;
-        $params['nMoney'] = $amount;
-        $params['nSortType'] = config::operator[$card_type];
-        $params['nProductClass'] = 1;
-        $params['nProductType'] = 1;
-        $params['szTimeStamp'] = date("Y-m-d H:i:s");
-        $params['szNotifyUrl'] = config::NOTIFY_URL;
+        $params['userid'] = config::USER_ID;
+        $params['productid'] = '';
+        $params['price'] = $amount;
+        $params['num'] = 1;
+        $params['mobile'] = $phone;
+        $params['spordertime'] = date("YmdHis");
+        $params['sporderid'] = $order_sn;
+        $params['back_url'] = config::NOTIFY_URL;
+        $params['paytype'] = config::operator[$card_type];
+
         return $params;
     }
 
@@ -34,9 +36,9 @@ class RefillPhone extends refill\IRefillPhone
         $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
 
         $sign = $this->sign($params);
-        $params['szVerifyString'] = $sign;
+        $params['sign'] = $sign;
 
-        $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
+        $resp = http_request(config::ORDER_URL, $params);
 
         if (empty($resp)) {
             return [false, '网络错误', true];
@@ -44,35 +46,34 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
-            $resp = json_decode($resp, true);
-
-            $nRtn = $resp['nRtn'];
+            $resp = $this->xmlToArray($resp);
             if (empty($resp)) {
                 return [false, '网络错误', true];
-            } elseif ($nRtn === 0) {
-                return [true, '', false];
-            } elseif (in_array($nRtn, config::ERR_NOS, true)) {
-                return [false, $resp['szRtnCode'], false];
-            } elseif (in_array($nRtn, [2050, 999], true)) {
-                $net_errno = "HTTP-{$nRtn}";
-                return [false, $resp['szRtnCode'], false];
+            }
+
+            $resultno = $resp['resultno'];
+            if (in_array($resultno, ['0', '1', '2'], true)) {
+                return [true, $resp['orderid'], false];
+            } elseif (in_array($resultno, config::ERR_NOS, true)) {
+                return [false, $resultno, false];
+            } elseif ($resultno === '9999' || $resultno === '5006') {
+                $net_errno = "HTTP-{$resultno}";
+                return [false, $resultno, false];
             } else {
+                //未知结果码
                 $err = 998;
                 $net_errno = "HTTP-{$err}";
-                return [false, $resp['szRtnCode'], false];
+                return [false, $resultno, false];
             }
         }
     }
 
     public function query($refill_info)
     {
-        $params['szAgentId'] = config::USER_ID;
-        $params['szOrderId'] = $refill_info['order_sn'];
-        $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szOrderId={$params['szOrderId']}&szKey={$key}";
-        $params['szVerifyString'] = md5($content);
+        $params['userid'] = config::USER_ID;
+        $params['sporderid'] = $refill_info['order_sn'];
 
-        $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
+        $resp = http_request(config::QUERY_URL, $params);
 
         if (empty($resp)) {
             return [false, '网络错误'];
@@ -80,38 +81,41 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
-            $resp = json_decode($resp, true);
-            if (empty($resp)) {
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp))
+            {
                 return [false, '网络错误'];
             }
-
-            $status = $resp['nRtn'];
-            if ($status === 5012) {
-                $updata['official_sn'] = $resp['szRtnMsg'];
-                Model('refill_order')->edit($refill_info['order_id'], $updata);
-                $order_state = ORDER_STATE_SUCCESS;
-            } elseif ($status === 5013) {
-                $order_state = ORDER_STATE_CANCEL;
-            } elseif (in_array($status, [5011,5019],true)) {
-                $order_state = ORDER_STATE_SEND;
-            } elseif ($status === 5005 && (time() - $refill_info['commit_time'] >= 300)) {
-                $order_state = ORDER_STATE_NOEXIST;
-            } else {
-                return [false, $resp['szRtnMsg']];
+            else
+            {
+                $resultno = $resp['resultno'];
+                if ($resultno === '1') {
+                    $updata['official_sn'] = $resp['supnumber'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($resultno === '9') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($resultno, ['0','2'], true)) {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($resultno === '5007' && (time() - $refill_info['commit_time'] >= 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resultno];
+                }
+
+                return [true, $order_state];
             }
-
-            return [true, $order_state];
         }
     }
 
     public function balance()
     {
-        $params['szAgentId'] = config::USER_ID;
+        $params['userid'] = config::USER_ID;
         $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szKey={$key}";
-        $params['szVerifyString'] = md5($content);
+        $body = "userid={$params['userid']}&key={$key}";
+        $params['sign'] = md5($body);
 
-        $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
+        $resp = http_request(config::BALANCE_UTL, $params);
 
         if (empty($resp)) {
             return [false, '网络错误'];
@@ -119,13 +123,13 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
-            $resp = json_decode($resp, true);
+            $resp = $this->xmlToArray($resp);
             if (empty($resp)) {
                 return [false, '网络错误'];
-            } elseif ($resp['nRtn'] === 0) {
-                return [true, $resp['fBalance']];
+            } elseif ($resp['resultno'] === '1') {
+                return [true, $resp['balance']];
             } else {
-                return [false, $resp['szRtnCode']];
+                return [false, $resp['resultno']];
             }
         }
     }
@@ -134,8 +138,13 @@ 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 = "userid={$userid}&productid={$params['productid']}&price={$params['price']}&num={$params['num']}&mobile={$params['mobile']}&spordertime={$params['spordertime']}";
+        $content .= "&sporderid={$params['sporderid']}&key={$key}";
         return md5($content);
     }
+
+    public function xmlToArray($xml)
+    {
+        return json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
+    }
 }

+ 0 - 20
helper/refill/api/xyz/chizeng/api.txt

@@ -1,20 +0,0 @@
-正式环境:
-
-话费下单地址:http://120.27.219.88:10186/plat/api/old/submitorder
-
-
-查询地址:http://120.27.219.88:10186/plat/api/old/queryorder
-
-
-查询余额地址:http://120.27.219.88:10186/plat/api/old/queryBalance
-
-
-
-ID:200017
-秘钥:dd514d9c1c954f2b90d7faf25e2a7747
-
-
-对接文档地址:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
-
-账号:yezi
-密码: 123456

+ 10 - 12
helper/refill/api/xyz/chizeng/config.php

@@ -6,21 +6,19 @@ namespace refill\chizeng;
 use mtopcard;
 class config
 {
-    const ORDER_URL = 'http://120.27.219.88:10186/plat/api/old/submitorder';
-    const QUERY_URL= 'http://120.27.219.88:10186/plat/api/old/queryorder';
-    const BALANCE_URL= 'http://120.27.219.88:10186/plat/api/old/queryBalance';
+    const ORDER_URL = 'http://123.60.208.38:9086/onlinepay.do';
+    const QUERY_URL= 'http://123.60.208.38:9086/searchpay.do';
+    const BALANCE_UTL = 'http://123.60.208.38:9086/searchbalance.do';
 
-    const USER_ID= '200017';
-    const KEY = 'dd514d9c1c954f2b90d7faf25e2a7747';
-    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_chizeng.php";
+    const USER_ID= '10002523';
+    const KEY = 'BASm8ACwBZxjewFcrQssFxz6P8ydDHfc';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_wangliantx.php";
     const operator = [
-        mtopcard\ChinaMobileCard  => 1,
-        mtopcard\ChinaUnicomCard  => 2,
-        mtopcard\ChinaTelecomCard => 3
+        mtopcard\ChinaMobileCard  => 'yd',
+        mtopcard\ChinaUnicomCard  => 'lt',
+        mtopcard\ChinaTelecomCard => 'dx'
     ];
-    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
+        '5001','5002','5003','5004','5005','5008','5009','5010','5011','5012'
     ];
 }

+ 19 - 0
helper/refill/api/xyz/chizeng/对接文档-yezi.txt

@@ -0,0 +1,19 @@
+登录地址:http://123.60.208.38:7080/login.jsp
+
+账户名:yezi1
+
+密码:ye_feng21
+
+id:10002523
+
+idkey:BASm8ACwBZxjewFcrQssFxz6P8ydDHfc
+
+下单地址:http://123.60.208.38:9086/onlinepay.do
+
+查询地址:http://123.60.208.38:9086/searchpay.do
+
+余额地址:http://123.60.208.38:9086/searchbalance.do
+
+
+
+对接文档:https://www.showdoc.com.cn/AQL666666/