ソースを参照

xyz zhenghe update api

xiaoyu 1 年間 前
コミット
68b2ed1811

+ 13 - 12
data/config/xyz/refill.ini.php

@@ -4875,41 +4875,41 @@ $cangxin_yi_phone = ['name' => 'cangxin_yi', 'store_id' => 191,'qualitys' => '2'
 $zhenghe_phone = ['name' => 'zhenghe', 'store_id' => 192,'qualitys' => '2',
     'amount' => [
         1 => [
-            ['goods_id' => 8463, 'price' => 1.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8463, 'price' => 1.015, 'quality' => 2, 'card_type' => 'chinaunicom'],
         ],
         2 => [
-            ['goods_id' => 8464, 'price' => 2.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8464, 'price' => 2.03, 'quality' => 2, 'card_type' => 'chinaunicom'],
         ],
         3 => [
-            ['goods_id' => 8465, 'price' => 3.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8465, 'price' => 3.045, 'quality' => 2, 'card_type' => 'chinaunicom'],
         ],
         4 => [
-            ['goods_id' => 8466, 'price' => 4.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8466, 'price' => 4.06, 'quality' => 2, 'card_type' => 'chinaunicom'],
         ],
         5 => [
-            ['goods_id' => 8467, 'price' => 5.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8467, 'price' => 5.075, 'quality' => 2, 'card_type' => 'chinaunicom'],
         ],
         6 => [
-            ['goods_id' => 8468, 'price' => 6.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8468, 'price' => 6.06, 'quality' => 2, 'card_type' => 'chinaunicom'],
         ],
         7 => [
-            ['goods_id' => 8469, 'price' => 7.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8469, 'price' => 7.07, 'quality' => 2, 'card_type' => 'chinaunicom'],
         ],
         8 => [
-            ['goods_id' => 8470, 'price' => 8.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8470, 'price' => 8.08, 'quality' => 2, 'card_type' => 'chinaunicom'],
         ],
         9 => [
-            ['goods_id' => 8471, 'price' => 9.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8471, 'price' => 9.09, 'quality' => 2, 'card_type' => 'chinaunicom'],
         ],
         10 => [
-            ['goods_id' => 7625, 'price' => 10.15, 'quality' => 2, 'card_type' => 'chinaunicom']
+            ['goods_id' => 7625, 'price' => 10.05, 'quality' => 2, 'card_type' => 'chinaunicom']
         ],
         20 => [
-            ['goods_id' => 7626, 'price' => 20.2, 'quality' => 2, 'card_type' => 'chinaunicom']
+            ['goods_id' => 7626, 'price' => 20.1, 'quality' => 2, 'card_type' => 'chinaunicom']
         ],
         30 => [
             ['goods_id' => 7627, 'price' => 30.09, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7627, 'price' => 30.3, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7627, 'price' => 30.09, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7627, 'price' => 30.09, 'quality' => 2, 'card_type' => 'chinatelecom'],
         ],
         50 => [
@@ -4934,6 +4934,7 @@ $zhenghe_phone = ['name' => 'zhenghe', 'store_id' => 192,'qualitys' => '2',
         ],
         500 => [
             ['goods_id' => 7632, 'price' => 501.5, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7632, 'price' => 500, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7632, 'price' => 501.5, 'quality' => 2, 'card_type' => 'chinatelecom'],
         ]
     ],

+ 48 - 0
helper/refill/api/xyz/zhenghe/API信息.txt

@@ -0,0 +1,48 @@
+登录参数
+http://api.bjxytxkj.com.cn:1008/hqorder/login
+账号:200024
+密码:123456(请及时更改初始密码)
+
+接口参数
+ID:200024
+秘钥:b5c5bae0bbf84eb58c3f38b091342059
+
+下单地址:http://api.bjxytxkj.com.cn:1008/hqorder/api/submit
+查询地址:http://api.bjxytxkj.com.cn:1008/hqorder/api/query
+查询余额地址:http://api.bjxytxkj.com.cn:1008/hqorder/api/balance
+
+请登录后台查看  产品  产品折扣  产品编码
+
+全国移动30元	1000030
+全国移动50元	1000050
+全国移动100元	1000100
+全国移动200元	1000200
+全国移动300元	1000300
+全国移动500元	1000500
+
+
+全国联通1元	2000001
+全国联通2元	2000002
+全国联通3元	2000003
+全国联通4元	2000004
+全国联通5元	2000005
+全国联通6元	2000006
+全国联通7元	2000007
+全国联通8元	2000008
+全国联通9元	2000009
+全国联通10元	2000010
+全国联通20元	2000020
+全国联通30元	2000030
+全国联通50元	2000050
+全国联通100元	2000100
+全国联通200元	2000200
+全国联通300元	2000300
+全国联通500元	2000500
+
+
+全国电信30元	3000030
+全国电信50元	3000050
+全国电信100元	3000100
+全国电信200元	3000200
+全国电信300元	3000300
+全国电信500元	3000500

+ 15 - 17
helper/refill/api/xyz/zhenghe/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;
@@ -18,33 +18,31 @@ class RefillCallBack implements refill\IRefillCallBack
 
     private function sign($params)
     {
-        $userid = config::USER_ID;
+        $mchid = config::MCHID;
         $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  = "mchid={$mchid}&orderid={$params['orderid']}&oid={$params['oid']}&number={$params['number']}&status={$params['status']}&key={$key}";
         return md5($content);
     }
 
     public function notify($params)
     {
-        $status = intval($params['nFlag']);
-        $order_sn = $params['szOrderId'];
+        $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'];
 
+        $order_id = $order_info['order_id'];
+        $status = intval($params['status']);
         if ($status === 2) {
-            $data['official_sn'] = strtolower($params['szRtnMsg']) == 'null' ? '' : $params['szRtnMsg'];
+            $official_sn = strtolower($params['voucher']) == 'null' ? '' : $params['voucher'];
+            $data['official_sn'] = $official_sn;
             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, $official_sn];
+        } elseif ($status === 3) {
+            return [$order_id, false, true, true, ''];
+        } else {
+            return [$order_id, false, false, false, ''];
         }
     }
-}
+}

+ 65 - 61
helper/refill/api/xyz/zhenghe/RefillPhone.php

@@ -16,15 +16,12 @@ class RefillPhone extends refill\IRefillPhone
 
     private function req_params(int $phone, int $amount, int $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['mchid'] = config::MCHID;
+        $params['orderid'] = $order_sn;
+        $params['number'] = $phone;
+        $params['productid'] = config::product_id[$card_type][$amount];
+        $params['timestamp'] = $this->getMillisecond();
+        $params['backurl'] = config::NOTIFY_URL;
         return $params;
     }
 
@@ -34,108 +31,115 @@ 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);
+        $params = json_encode($params);
+        $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders, $net_errno);
 
         if (empty($resp)) {
-            return [false, '网络错误', true];
+            return [false, '系统错误', true];
         }
         else
         {
             Log::record($resp, Log::DEBUG);
             $resp = json_decode($resp, true);
-
-            $nRtn = $resp['nRtn'];
             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'], true];
+                return [false, '系统错误', true];
+            } elseif ($resp['status'] === 0) {
+                return [true, $resp['oid'], false];
+            } elseif ($resp['status'] === -1) {
+                return [false, $resp['msg'], false];
             } else {
-                $err = 998;
-                $net_errno = "HTTP-{$err}";
-                return [false, $resp['szRtnCode'], true];
+                $net_errno = "HTTP-998";
+                return [false, $resp['msg'], true];
             }
         }
     }
 
     public function query($refill_info)
     {
-        $params['szAgentId'] = config::USER_ID;
-        $params['szOrderId'] = $refill_info['order_sn'];
+        $params['mchid'] = config::MCHID;
+        $params['orderid'] = $refill_info['order_sn'];
         $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szOrderId={$params['szOrderId']}&szKey={$key}";
-        $params['szVerifyString'] = md5($content);
+        $content = "mchid={$params['mchid']}&orderid={$params['orderid']}&key={$key}";
+        $params['sign'] = md5($content);
 
-        $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
+        $params = json_encode($params);
+        $resp = http_post_data(config::QUERY_URL, $params , config::ExtHeaders);
 
         if (empty($resp)) {
-            return [false, '网络错误'];
+            return [false, '系统错误', ''];
         }
         else
         {
             Log::record($resp, Log::DEBUG);
             $resp = json_decode($resp, true);
             if (empty($resp)) {
-                return [false, '网络错误'];
+                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 {
+                $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'] > 300)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $status, $offical_sn];
+                }
+                return [true, $order_state, $offical_sn];
             }
-
-            return [true, $order_state];
         }
     }
 
     public function balance()
     {
-        $params['szAgentId'] = config::USER_ID;
+        $params['mchid'] = config::MCHID;
         $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szKey={$key}";
-        $params['szVerifyString'] = md5($content);
+        $content = "mchid={$params['mchid']}&key={$key}";
+        $params['sign'] = md5($content);
+        $params = json_encode($params);
 
-        $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
+        $resp = http_post_data(config::BALANCE_URL, $params , config::ExtHeaders);
 
         if (empty($resp)) {
-            return [false, '网络错误'];
+            return [false, '系统错误'];
         }
         else
         {
             Log::record($resp, Log::DEBUG);
             $resp = json_decode($resp, true);
             if (empty($resp)) {
-                return [false, '网络错误'];
-            } elseif ($resp['nRtn'] === 0) {
-                return [true, $resp['fBalance']];
+                return [false, '系统错误'];
+            } elseif ($resp['status'] === 1) {
+                return [true, $resp['balance']];
             } else {
-                return [false, $resp['szRtnCode']];
+                return [false, $resp['msg']];
             }
         }
     }
 
     private function sign($params)
     {
-        $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  = "mchid={$params['mchid']}&orderid={$params['orderid']}&number={$params['number']}&productid={$params['productid']}";
+        $content .= "&timestamp={$params['timestamp']}&key={$key}";
         return md5($content);
     }
-}
+
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function getMillisecond()
+    {
+        $cur = microtime (true);
+        return intval($cur * 1000);
+    }
+}

+ 0 - 15
helper/refill/api/xyz/zhenghe/api.txt

@@ -1,15 +0,0 @@
-后台参数
-客户地址:http://47.98.208.128:10186/plat/index
-账号:gyhb
-密码:123456
-
-对接参数
-ID:200032
-秘钥:70fc4782de6e4686b7d1d125d3cd28ff
-
-正式环境:
-话费下单地址:http://47.98.208.128:10186/plat/api/old/submitorder
-查询地址:http://47.98.208.128:10186/plat/api/old/queryorder
-查询余额地址:http://47.98.208.128:10186/plat/api/old/queryBalance
-
-对接文档地址:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ

+ 42 - 13
helper/refill/api/xyz/zhenghe/config.php

@@ -6,21 +6,50 @@ namespace refill\zhenghe;
 use mtopcard;
 class config
 {
-    const ORDER_URL = 'http://47.98.208.128:10186/plat/api/old/submitorder';
-    const QUERY_URL= 'http://47.98.208.128:10186/plat/api/old/queryorder';
-    const BALANCE_URL = 'http://47.98.208.128:10186/plat/api/old/queryBalance';
+    const ORDER_URL = 'http://api.bjxytxkj.com.cn:1008/hqorder/api/submit';
+    const QUERY_URL = 'http://api.bjxytxkj.com.cn:1008/hqorder/api/query';
+    const BALANCE_URL = 'http://api.bjxytxkj.com.cn:1008/hqorder/api/balance';
 
-    const USER_ID= '200032';
-    const KEY = '70fc4782de6e4686b7d1d125d3cd28ff';
+    const MCHID = '200024';
+    const KEY = 'b5c5bae0bbf84eb58c3f38b091342059';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_zhenghe.php";
-    const operator = [
-        mtopcard\ChinaMobileCard  => 1,
-        mtopcard\ChinaUnicomCard  => 2,
-        mtopcard\ChinaTelecomCard => 3
-    ];
-    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ExtHeaders = ['Content-Type: application/json'];
 
-    const ERR_NOS = [
-        1000,1001,1003,1004,2001,2002,2003,2020,2021,1006,2030,3003
+    const product_id = [
+        mtopcard\ChinaMobileCard => [
+            30 => 1000030,
+            50 => 1000050,
+            100 => 1000100,
+            200 => 1000200,
+            300 => 1000300,
+            500 => 1000500
+        ],
+        mtopcard\ChinaUnicomCard => [
+            1 => 2000001,
+            2 => 2000002,
+            3 => 2000003,
+            4 => 2000004,
+            5 => 2000005,
+            6 => 2000006,
+            7 => 2000007,
+            8 => 2000008,
+            9 => 2000009,
+            10 => 2000010,
+            20 => 2000020,
+            30 => 2000030,
+            50 => 2000050,
+            100 => 2000100,
+            200 => 2000200,
+            300 => 2000300,
+            500 => 2000500
+        ],
+        mtopcard\ChinaTelecomCard => [
+            30 => 3000030,
+            50 => 3000050,
+            100 => 3000100,
+            200 => 3000200,
+            300 => 3000300,
+            500 => 3000500
+        ],
     ];
 }

BIN
helper/refill/api/xyz/zhenghe/hq接口文档V1.0.docx


+ 3 - 2
mobile/callback/refill_zhenghe.php

@@ -1,4 +1,5 @@
 <?php
-
-refill\util::push_notify('zhenghe',$_POST);
+$content = $_SERVER['post_content'] ?? [];
+$input = json_decode($content,true);
+refill\util::push_notify('zhenghe',$input);
 echo ('ok');