Browse Source

xyz yl dezhi update api

xiaoyu 2 years ago
parent
commit
35829bc0c2

+ 3 - 3
data/config/win/base.ini.php

@@ -10,13 +10,13 @@ define('BONUS_EXPIRY_DATE',true);
 define('USE_BONUS_RATE',false);
 define('SERVER_TYPE','panda');
 define('CROSS_DOAMIN',true);
-define('COOKIE_DOMAIN','192.168.1.218');
+define('COOKIE_DOMAIN','192.168.3.218');
 define('COMPANY_NAME', 'XYZ_COMPANY');
 define('NET_IP','123.117.109.96');
 define('ZERO_GOODS_ID', 6666);
 define('ADMIN_NAME', 'YELIN');
 
-$SRV_HOST = 'http://192.168.1.218';
+$SRV_HOST = 'http://192.168.3.218';
 $REMOTE_IMG_HOST = $SRV_HOST;
 
 $config = [];
@@ -120,4 +120,4 @@ $config['refill_specs'] = [
     'chinamobile'   => [10 , 20 , 30 , 50 , 100 , 200 , 500 , 1000],
     'chinaunicom'   => [10 , 20 , 30 , 50 , 100 , 200 , 500 , 1000],
     'chinatelecom'  => [10 , 20 , 30 , 50 , 100 , 200 , 500 , 1000]
-];
+];

+ 24 - 24
data/config/xyz/refill.ini.php

@@ -6293,46 +6293,46 @@ $xinruiheng_phone = ['name' => 'xinruiheng', 'store_id' => 235, 'qualitys' => '1
 
 $dezhi_phone = ['name' => 'dezhi', 'store_id' => 236, 'qualitys' => '1',
     'amount' => [
-//        10 => [
+        10 => [
 //            ['goods_id' => 7951, 'price' => 9.67, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 7951, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7951, 'price' => 9.3, 'quality' => 1, 'card_type' => 'chinaunicom'],
 //            ['goods_id' => 7951, 'price' => 9.55, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
-//        20 => [
+        ],
+        20 => [
 //            ['goods_id' => 7952, 'price' => 19.34, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 7952, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7952, 'price' => 18.6, 'quality' => 1, 'card_type' => 'chinaunicom'],
 //            ['goods_id' => 7952, 'price' => 19.1, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
+        ],
         30 => [
-            ['goods_id' => 7953, 'price' => 29.01, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7953, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7953, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7953, 'price' => 28.86, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7953, 'price' => 27.9, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7953, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         50 => [
-            ['goods_id' => 7954, 'price' => 48.35, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7954, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7954, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7954, 'price' => 48.1, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7954, 'price' => 46.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7954, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         100 => [
-            ['goods_id' => 7955, 'price' => 96.7, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7955, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7955, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7955, 'price' => 96.2, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7955, 'price' => 93, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7955, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         200 => [
-            ['goods_id' => 7956, 'price' => 193.4, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7956, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7956, 'price' => 191, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7956, 'price' => 192.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7956, 'price' => 186, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7956, 'price' => 191, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
-//        300 => [
+        300 => [
 //            ['goods_id' => 7957, 'price' => 290.1, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 7957, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7957, 'price' => 279, 'quality' => 1, 'card_type' => 'chinaunicom'],
 //            ['goods_id' => 7957, 'price' => 286.5, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
-//        500 => [
+        ],
+        500 => [
 //            ['goods_id' => 7958, 'price' => 483.5, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 7958, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7958, 'price' => 465, 'quality' => 1, 'card_type' => 'chinaunicom'],
 //            ['goods_id' => 7958, 'price' => 477.5, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ]
+        ]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 

+ 24 - 24
data/config/yl/refill.ini.php

@@ -6099,46 +6099,46 @@ $xinruiheng_phone = ['name' => 'xinruiheng', 'store_id' => 226, 'qualitys' => '1
 
 $dezhi_phone = ['name' => 'dezhi', 'store_id' => 227, 'qualitys' => '1',
     'amount' => [
-//        10 => [
+        10 => [
 //            ['goods_id' => 7906, 'price' => 9.67, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 7906, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7906, 'price' => 9.3, 'quality' => 1, 'card_type' => 'chinaunicom'],
 //            ['goods_id' => 7906, 'price' => 9.55, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
-//        20 => [
+        ],
+        20 => [
 //            ['goods_id' => 7907, 'price' => 19.34, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 7907, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7907, 'price' => 18.6, 'quality' => 1, 'card_type' => 'chinaunicom'],
 //            ['goods_id' => 7907, 'price' => 19.1, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
+        ],
         30 => [
-            ['goods_id' => 7908, 'price' => 29.01, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7908, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7908, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7908, 'price' => 28.86, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7908, 'price' => 27.9, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7908, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         50 => [
-            ['goods_id' => 7909, 'price' => 48.35, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7909, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7909, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7909, 'price' => 48.1, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7909, 'price' => 46.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7909, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         100 => [
-            ['goods_id' => 7910, 'price' => 96.7, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7910, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7910, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7910, 'price' => 96.2, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7910, 'price' => 93, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7910, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         200 => [
-            ['goods_id' => 7911, 'price' => 193.4, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7911, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7911, 'price' => 191, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7911, 'price' => 192.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7911, 'price' => 186, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7911, 'price' => 191, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
-//        300 => [
+        300 => [
 //            ['goods_id' => 7912, 'price' => 290.1, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 7912, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7912, 'price' => 279, 'quality' => 1, 'card_type' => 'chinaunicom'],
 //            ['goods_id' => 7912, 'price' => 286.5, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
-//        500 => [
+        ],
+        500 => [
 //            ['goods_id' => 7913, 'price' => 483.5, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 7913, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7913, 'price' => 465, 'quality' => 1, 'card_type' => 'chinaunicom'],
 //            ['goods_id' => 7913, 'price' => 477.5, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ]
+        ]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 

+ 15 - 17
helper/refill/api/xyz/dezhi/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}";
-        return md5($content);
+        $content = "userid={$userid}&orderid={$params['orderid']}&sporderid={$params['sporderid']}&merchantsubmittime={$params['merchantsubmittime']}";
+        $content .= "&resultno={$params['resultno']}&key={$key}";
+        return strtoupper(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['remark1']) == 'null' ? '' : $params['remark1'];
             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];
         }
     }
-}
+}

+ 69 - 55
helper/refill/api/xyz/dezhi/RefillPhone.php

@@ -14,17 +14,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'] = config::ProductIdS[$card_type][$amount];
+        $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,7 +35,7 @@ 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);
 
@@ -44,33 +45,35 @@ 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'], true];
+            }
+
+            $resultno = $resp['resultno'];
+            if (in_array($resultno, ['0', '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, true];
             } else {
+                //未知结果码
                 $err = 998;
                 $net_errno = "HTTP-{$err}";
-                return [false, $resp['szRtnCode'], true];
+                return [false, $resultno, true];
             }
         }
     }
 
     public function query($refill_info)
     {
-        $params['szAgentId'] = config::USER_ID;
-        $params['szOrderId'] = $refill_info['order_sn'];
+        $params['userid'] = config::USER_ID;
+        $params['sporderid'] = $refill_info['order_sn'];
         $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szOrderId={$params['szOrderId']}&szKey={$key}";
-        $params['szVerifyString'] = md5($content);
+        $content = "userid={$params['userid']}&sporderid={$params['sporderid']}&key={$key}";
+        $params['sign'] = strtoupper(md5($content));
 
         $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -80,36 +83,39 @@ 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['remark1'];
+                    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);
+        $content = "userid={$params['userid']}&key={$key}";
+        $params['sign'] = strtoupper(md5($content));
 
         $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -119,13 +125,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 +140,16 @@ 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}";
-        return md5($content);
+        $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 strtoupper(md5($content));
+    }
+
+    public function xmlToArray($xml)
+    {
+        $replace_str = str_replace(' ','','encoding="gb2312"');
+        $xml = mb_convert_encoding($xml,"UTF-8","gb2312");
+        $xml = str_replace($replace_str, "encoding='utf-8'", $xml);
+        return refill\util::xmlToArray($xml);
     }
-}
+}

+ 0 - 12
helper/refill/api/xyz/dezhi/api.txt

@@ -1,12 +0,0 @@
-正式环境:
-话费下单地址:http://121.196.98.113:10186/plat/api/old/submitorder
-查询地址:http://121.196.98.113:10186/plat/api/old/queryorder
-查询余额地址:http://121.196.98.113:10186/plat/api/old/queryBalance
-
-ID:200002
-秘钥:4c789456e08c4d7a915cea0f2fe0b58a
-
-对接文档地址:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
-
-http://121.196.98.113:10186/plat/index
-登陆账号 北京椰子    密码123456

+ 32 - 12
helper/refill/api/xyz/dezhi/config.php

@@ -6,22 +6,42 @@ namespace refill\dezhi;
 use mtopcard;
 class config
 {
-    const ORDER_URL = 'http://121.196.98.113:10186/plat/api/old/submitorder';
-    const QUERY_URL= 'http://121.196.98.113:10186/plat/api/old/queryorder';
-    const BALANCE_URL = 'http://121.196.98.113:10186/plat/api/old/queryBalance';
+    //https://www.showdoc.com.cn/AQL666666/
+    const ORDER_URL = 'http://124.70.214.140:9086/onlinepay.do';
+    const QUERY_URL= 'http://124.70.214.140:9086/searchpay.do';
+    const BALANCE_URL = 'http://124.70.214.140:9086/searchbalance.do';
 
-    const USER_ID= '200002';
-    const KEY = '4c789456e08c4d7a915cea0f2fe0b58a';
+    const USER_ID= '10002505';
+    const KEY = 'twm8xaSnJcdjbbKrj5CYWdYtS3YzS8BM';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_dezhi.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'
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;'];
+    const ProductIdS = [
+        mtopcard\ChinaMobileCard =>
+            [
+                30  => '101687',
+                50  => '101688',
+                100 => '101689',
+                200 => '101690',
+            ],
+        mtopcard\ChinaUnicomCard =>
+            [
+                10  => '101703',
+                20  => '101704',
+                30  => '101705',
+                50  => '101706',
+                100 => '101707',
+                200 => '101708',
+                300 => '101709',
+                500 => '101710',
+            ],
     ];
-}
+}

+ 31 - 0
helper/refill/api/xyz/dezhi/对接文档-yezi.txt

@@ -0,0 +1,31 @@
+http://124.70.214.140:7080/
+账号:椰子
+密码:yezi131419
+ID:10002505
+秘钥:twm8xaSnJcdjbbKrj5CYWdYtS3YzS8BM
+
+api接口文档地址:
+https://www.showdoc.com.cn/AQL666666/
+
+话费下单地址:
+http://124.70.214.140:9086/onlinepay.do
+查询地址:
+http://124.70.214.140:9086/searchpay.do
+查询余额地址:
+http://124.70.214.140:9086/searchbalance.do
+
+101687    全国移动30
+101688    全国移动50
+101689     全国移动100
+101690    全国移动200
+
+
+
+101703 	全国联通话费10元直充
+101704 	全国联通话费20元直充
+101705 	全国联通话费30元直充
+101706 	全国联通话费50元直充
+101707 	全国联通话费100元直充
+101708 	全国联通话费200元直充
+101709 	全国联通话费300元直充
+101710     全国联通话费500元直充

+ 15 - 17
helper/refill/api/yl/dezhi/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}";
-        return md5($content);
+        $content = "userid={$userid}&orderid={$params['orderid']}&sporderid={$params['sporderid']}&merchantsubmittime={$params['merchantsubmittime']}";
+        $content .= "&resultno={$params['resultno']}&key={$key}";
+        return strtoupper(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['remark1']) == 'null' ? '' : $params['remark1'];
             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];
         }
     }
-}
+}

+ 69 - 55
helper/refill/api/yl/dezhi/RefillPhone.php

@@ -14,17 +14,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'] = config::ProductIdS[$card_type][$amount];
+        $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,7 +35,7 @@ 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);
 
@@ -44,33 +45,35 @@ 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'], true];
+            }
+
+            $resultno = $resp['resultno'];
+            if (in_array($resultno, ['0', '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, true];
             } else {
+                //未知结果码
                 $err = 998;
                 $net_errno = "HTTP-{$err}";
-                return [false, $resp['szRtnCode'], true];
+                return [false, $resultno, true];
             }
         }
     }
 
     public function query($refill_info)
     {
-        $params['szAgentId'] = config::USER_ID;
-        $params['szOrderId'] = $refill_info['order_sn'];
+        $params['userid'] = config::USER_ID;
+        $params['sporderid'] = $refill_info['order_sn'];
         $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szOrderId={$params['szOrderId']}&szKey={$key}";
-        $params['szVerifyString'] = md5($content);
+        $content = "userid={$params['userid']}&sporderid={$params['sporderid']}&key={$key}";
+        $params['sign'] = strtoupper(md5($content));
 
         $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -80,36 +83,39 @@ 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['remark1'];
+                    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);
+        $content = "userid={$params['userid']}&key={$key}";
+        $params['sign'] = strtoupper(md5($content));
 
         $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -119,13 +125,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 +140,16 @@ 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}";
-        return md5($content);
+        $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 strtoupper(md5($content));
+    }
+
+    public function xmlToArray($xml)
+    {
+        $replace_str = str_replace(' ','','encoding="gb2312"');
+        $xml = mb_convert_encoding($xml,"UTF-8","gb2312");
+        $xml = str_replace($replace_str, "encoding='utf-8'", $xml);
+        return refill\util::xmlToArray($xml);
     }
-}
+}

+ 0 - 12
helper/refill/api/yl/dezhi/api.txt

@@ -1,12 +0,0 @@
-正式环境:
-话费下单地址:http://121.196.98.113:10186/plat/api/old/submitorder
-查询地址:http://121.196.98.113:10186/plat/api/old/queryorder
-查询余额地址:http://121.196.98.113:10186/plat/api/old/queryBalance
-
-ID:	200003
-秘钥;51649f34c38542cd8476f37d60b959af
-
-对接文档地址:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
-
-http://121.196.98.113:10186/plat/index
-登陆账号  北京椰林      密码123456

+ 32 - 12
helper/refill/api/yl/dezhi/config.php

@@ -6,22 +6,42 @@ namespace refill\dezhi;
 use mtopcard;
 class config
 {
-    const ORDER_URL = 'http://121.196.98.113:10186/plat/api/old/submitorder';
-    const QUERY_URL= 'http://121.196.98.113:10186/plat/api/old/queryorder';
-    const BALANCE_URL = 'http://121.196.98.113:10186/plat/api/old/queryBalance';
+    //https://www.showdoc.com.cn/AQL666666/
+    const ORDER_URL = 'http://124.70.214.140:9086/onlinepay.do';
+    const QUERY_URL= 'http://124.70.214.140:9086/searchpay.do';
+    const BALANCE_URL = 'http://124.70.214.140:9086/searchbalance.do';
 
-    const USER_ID= '200003';
-    const KEY = '51649f34c38542cd8476f37d60b959af';
+    const USER_ID= '10002504';
+    const KEY = '8zRZx7nGK7sAG6MXrBxNcG234DxPrB8y';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_dezhi.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'
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;'];
+    const ProductIdS = [
+        mtopcard\ChinaMobileCard =>
+            [
+                30  => '101687',
+                50  => '101688',
+                100 => '101689',
+                200 => '101690',
+            ],
+        mtopcard\ChinaUnicomCard =>
+            [
+                10  => '101703',
+                20  => '101704',
+                30  => '101705',
+                50  => '101706',
+                100 => '101707',
+                200 => '101708',
+                300 => '101709',
+                500 => '101710',
+            ],
     ];
-}
+}

+ 31 - 0
helper/refill/api/yl/dezhi/对接文档-yelin.txt

@@ -0,0 +1,31 @@
+http://124.70.214.140:7080/
+账号:椰林
+密码:yelin131419
+ID:10002504
+秘钥:8zRZx7nGK7sAG6MXrBxNcG234DxPrB8y
+
+api接口文档地址:
+https://www.showdoc.com.cn/AQL666666/
+
+话费下单地址:
+http://124.70.214.140:9086/onlinepay.do
+查询地址:
+http://124.70.214.140:9086/searchpay.do
+查询余额地址:
+http://124.70.214.140:9086/searchbalance.do
+
+101687    全国移动30
+101688    全国移动50
+101689    全国移动100
+101690    全国移动200
+
+
+
+101703 	全国联通话费10元直充
+101704 	全国联通话费20元直充
+101705 	全国联通话费30元直充
+101706 	全国联通话费50元直充
+101707 	全国联通话费100元直充
+101708 	全国联通话费200元直充
+101709 	全国联通话费300元直充
+101710     全国联通话费500元直充

+ 2 - 2
mobile/callback/refill_dezhi.php

@@ -1,4 +1,4 @@
 <?php
 
-refill\util::push_notify('dezhi',$_POST);
-echo ('ok');
+refill\util::push_notify('feimingyunew',$_POST);
+echo ('OK');

+ 3 - 3
test/TestRefill.php

@@ -2421,10 +2421,10 @@ class TestRefill extends TestCase
     {
 //        $provider = $this->getProvider('dezhi');
 //        $resp = $provider->balance();
-//        $resp = $provider->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
-//        $resp = $provider->query(['order_sn' => '86811656400057476279']);
+//        $resp = $provider->add(15811535608, 4, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '16601665727931494879']);
 
-        $body = '{"szOrderId":"61171656397023525645","fSalePrice":"28.59","szAgentId":"200002","nFlag":"3","szVerifyString":"1a56ff14e3edae6e526d0f8418050530","szPhoneNum":"18500608333","szRtnMsg":"","nDemo":"30"}';
+        $body = '{"orderid":"XEV22101414121957347","sporderid":"16601665727931494879","userid":"10002505","merchantsubmittime":"20221014141213","resultno":"9","parvalue":"30","remark1":"","payno":"","fundbalance":"-17409.66","sign":"666E01E56191A7C997049E965E67A31F"}';
         $params = json_decode($body, true);
         $provider = $this->getProvider('dezhi','RefillCallBack');
         $ret = $provider->verify($params);