Browse Source

xyz yl kailinyu new api

xiaoyu 2 years ago
parent
commit
abc63cd86a

+ 30 - 11
helper/refill/api/xyz/kailinyu/RefillCallBack.php

@@ -8,7 +8,9 @@ class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
-        $sign = $this->sign($params);
+        $input = $params;
+        unset($input['sign']);
+        $sign = $this->sign($input);
         if ($params['sign'] == $sign) {
             return true;
         } else {
@@ -18,28 +20,45 @@ class RefillCallBack implements refill\IRefillCallBack
 
     private function sign($params)
     {
-        $userid = config::USER_ID;
-        $key = config::KEY;
-        $content = "userid={$userid}&orderid={$params['orderid']}&sporderid={$params['sporderid']}&merchantsubmittime={$params['merchantsubmittime']}";
-        $content .= "&resultno={$params['resultno']}&key={$key}";
-        return strtoupper(md5($content));
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
+        return md5($content);
+    }
+
+    private function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
     }
 
     public function notify($params)
     {
-        $status = intval($params['resultno']);
-        $order_sn = $params['sporderid'];
+        $status = intval($params['orderStatus']);
+        $order_sn = $params['outOrderId'];
         $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 === 1) {
-            $data['official_sn'] = strtolower($params['remark1']) == 'null' ? '' : $params['remark1'];
+        if ($status === 2) {
+            $data['official_sn'] = strtolower($params['ext1']) == 'null' ? '' : $params['ext1'];
             Model('refill_order')->edit($order_id, $data);
             return [$order_id, true, false, true];
-        } elseif ($status === 9) {
+        } elseif ($status === 3) {
             return [$order_id, false, true, true];
         } else {
             return [$order_id, false, false, false];

+ 62 - 62
helper/refill/api/xyz/kailinyu/RefillPhone.php

@@ -14,18 +14,15 @@ class RefillPhone extends refill\IRefillPhone
         parent::__construct($cfgs);
     }
 
-    private function req_params(int $phone, int $amount, $card_type, string $order_sn)
+    private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
     {
-        $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];
-
+        $params['appId'] = config::APP_ID;
+        $params['outOrderId'] = $order_sn;
+        $params['uuid'] = $phone;
+        $params['itemId'] = config::PRODUCT[$card_type][$amount];
+        $params['itemFace'] = $amount;
+        $params['callbackUrl'] = config::NOTIFY_URL;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
         return $params;
     }
 
@@ -33,7 +30,9 @@ class RefillPhone extends refill\IRefillPhone
     {
         $order_sn = $params['order_sn'];
         $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
-
+        if(empty($params['itemId'])) {
+            return [false, '商品编号错误', false];
+        }
         $sign = $this->sign($params);
         $params['sign'] = $sign;
 
@@ -45,35 +44,29 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
-            $resp = $this->xmlToArray($resp);
+            $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '网络错误', 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];
+            } elseif ($resp['code'] === '00') {
+                return [true, $resp['orderId'], false];
+            } elseif (in_array($resp['code'], config::ERRCODES, true)) {
+                return [false, $resp['msg'], false];
+            } elseif (in_array($resp['code'], ['-22', '-23', '-99'], true)) {
+                $net_errno = "HTTP-{$resp['code']}";
+                return [false, $resp['msg'], true];
             } else {
-                //未知结果码
-                $err = 998;
-                $net_errno = "HTTP-{$err}";
-                return [false, $resultno, true];
+                $net_errno = "HTTP-998";
+                return [false, $resp['msg'], true];
             }
         }
     }
 
     public function query($refill_info)
     {
-        $params['userid'] = config::USER_ID;
-        $params['sporderid'] = $refill_info['order_sn'];
-        $key = config::KEY;
-        $content = "userid={$params['userid']}&sporderid={$params['sporderid']}&key={$key}";
-        $params['sign'] = strtoupper(md5($content));
+        $params['appId'] = config::APP_ID;
+        $params['outOrderId'] = $refill_info['order_sn'];
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
 
         $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -83,39 +76,40 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
-            $resp = $this->xmlToArray($resp);
-            if (empty($resp))
-            {
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
                 return [false, '网络错误'];
             }
-            else
+            elseif ($resp['code'] === '00')
             {
-                $resultno = $resp['resultno'];
-                if ($resultno === '1') {
-                    $updata['official_sn'] = $resp['remark1'];
+                $status = $resp['orderStatus'];
+                if ($status === '2') {
+                    $updata['official_sn'] = $resp['ext1'];
                     Model('refill_order')->edit($refill_info['order_id'], $updata);
                     $order_state = ORDER_STATE_SUCCESS;
-                } elseif ($resultno === '9') {
+                } elseif ($status === '3') {
                     $order_state = ORDER_STATE_CANCEL;
-                } elseif (in_array($resultno, ['0','2'], true)) {
+                } elseif ($status === '1') {
                     $order_state = ORDER_STATE_SEND;
-                } elseif ($resultno === '5007' && (time() - $refill_info['commit_time'] > 600)) {
+                } elseif ($status === '4' && (time() - $refill_info['commit_time'] >= 600)) {
                     $order_state = ORDER_STATE_NOEXIST;
                 } else {
-                    return [false, $resultno];
+                    return [false, $resp['msg']];
                 }
-
                 return [true, $order_state];
             }
+            else
+            {
+                return [false, $resp['msg']];
+            }
         }
     }
 
     public function balance()
     {
-        $params['userid'] = config::USER_ID;
-        $key = config::KEY;
-        $content = "userid={$params['userid']}&key={$key}";
-        $params['sign'] = strtoupper(md5($content));
+        $params['appId'] = config::APP_ID;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
 
         $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -125,31 +119,37 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
-            $resp = $this->xmlToArray($resp);
+            $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '网络错误'];
-            } elseif ($resp['resultno'] === '1') {
+            } elseif ($resp['code'] === '00') {
                 return [true, $resp['balance']];
             } else {
-                return [false, $resp['resultno']];
+                return [false, $resp['msg']];
             }
         }
     }
 
-    private function sign($params)
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function get_millisecond()
     {
-        $userid = config::USER_ID;
-        $key = config::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 strtoupper(md5($content));
+        list($usec, $sec) = explode(" ", microtime());
+        return round($usec*1000);
     }
 
-    public function xmlToArray($xml)
+    private function sign($params)
     {
-        $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);
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
+        return md5($content);
     }
 }

+ 33 - 43
helper/refill/api/xyz/kailinyu/config.php

@@ -6,50 +6,40 @@ namespace refill\kailinyu;
 use mtopcard;
 class config
 {
-    //https://www.showdoc.com.cn/AQL666666/
-    const ORDER_URL = 'http://116.62.32.89:9086/onlinepay.do';
-    const QUERY_URL= 'http://116.62.32.89:9086/searchpay.do';
-    const BALANCE_URL = 'http://116.62.32.89:9086/searchbalance.do';
+    const ORDER_URL = 'http://120.76.52.71:8911/api/hf/order/submit';
+    const QUERY_URL = 'http://120.76.52.71:8911/api/order/query';
+    const BALANCE_URL = 'http://120.76.52.71:8911/api/account/balance';
 
-    const USER_ID= '10002963';
-    const KEY = 'j7DyFHTeznfNzT2Kc6dehhbXjFcyXwXK';
+    const APP_ID = 'FcSAzHuWQ4';
+    const APP_SECRET = 'FsDuvrzqNwRPJXxm';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_kailinyu.php";
-    const operator = [
-        mtopcard\ChinaMobileCard  => 'yd',
-        mtopcard\ChinaUnicomCard  => 'lt',
-        mtopcard\ChinaTelecomCard => 'dx'
-    ];
-    const ERR_NOS = [
-        '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',
-                300 => '30000000912',
-                500 => '30000000913',
-            ],
-        mtopcard\ChinaUnicomCard =>
-            [
-                30  => '101705',
-                50  => '101706',
-                100 => '101707',
-                200 => '101708',
-                300 => '101709',
-                500 => '101710',
-            ],
-        mtopcard\ChinaTelecomCard =>
-            [
-                30  => '101723',
-                50  => '101724',
-                100 => '101725',
-                200 => '101726',
-                300 => '101727',
-                500 => '101728',
-            ]
+
+    const PRODUCT = [
+        mtopcard\ChinaMobileCard => [
+            30  => 100000,
+            50  => 100001,
+            100 => 100002,
+            200 => 100003,
+            300 => 100004,
+            500 => 100005,
+        ],
+        mtopcard\ChinaUnicomCard => [
+            30  => 100006,
+            50  => 100007,
+            100 => 100008,
+            200 => 100009,
+            300 => 100010,
+            500 => 100011,
+        ],
+        mtopcard\ChinaTelecomCard => [
+            30  => 100012,
+            50  => 100013,
+            100 => 100014,
+            200 => 100015,
+            300 => 100016,
+            500 => 100017,
+        ],
     ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ERRCODES = ['-10', '-12', '-13', '-14', '-15', '-16', '-18', '-21'];
 }

+ 0 - 34
helper/refill/api/xyz/kailinyu/对接文档-yezi.txt

@@ -1,34 +0,0 @@
-后台地址:  http://116.62.32.89:7080/
-账户:椰汁
-密码:ye123456
-
-ID:10002963
-密钥:j7DyFHTeznfNzT2Kc6dehhbXjFcyXwXK
-
-http://116.62.32.89:9086/onlinepay.do 下单地址
-http://116.62.32.89:9086/searchpay.do 订单主动查询地址
-http://116.62.32.89:9086/searchbalance.do 余额查询
-
-api接口文档地址:https://www.showdoc.com.cn/AQL666666/
-白名单地址: 116.62.32.89
-
-101687 	全国移动话费30元直充
-101688 	全国移动话费50元直充
-101689 	全国移动话费100元直充
-101690 	全国移动话费200元直充
-30000000912 	全国移动300元直充
-30000000913 	全国移动500元直充
-
-101705 	全国联通话费30元直充
-101706 	全国联通话费50元直充
-101707 	全国联通话费100元直充
-101708 	全国联通话费200元直充
-101709 	全国联通话费300元直充
-101710 	全国联通话费500元直充
-
-101723 	全国电信话费30元直充
-101724 	全国电信话费50元直充
-101725 	全国电信话费100元直充
-101726 	全国电信话费200元直充
-101727 	全国电信话费300元直充
-101728 	全国电信话费500元直充

+ 39 - 0
helper/refill/api/xyz/kailinyu/开户信息.txt

@@ -0,0 +1,39 @@
+后台地址:http://120.76.52.71:8888
+帐号:椰子
+密码:735217
+二级密码:lXkw7225
+appId:FcSAzHuWQ4
+appSecret:FsDuvrzqNwRPJXxm
+后台-商品列表,可查看已配置商品信息
+后台-安全中心,可配置IP白名单
+接口文档:https://www.showdoc.com.cn/1686453783298366/7925312871840290
+话费直充接口:http://120.76.52.71:8911/api/hf/order/submit
+通用直充接口:http://120.76.52.71:8911/api/order/submit
+卡密提取接口:http://120.76.52.71:8911/api/card/get
+查询接口接口:http://120.76.52.71:8911/api/order/query
+余额查询接口:http://120.76.52.71:8911/api/account/balance
+
+
+移动
+100000  移动30
+100001  移动50
+100002  移动100
+100003  移动200
+100004  移动300
+100005  移动500
+
+联通
+100006  联通30
+100007  联通50
+100008  联通100
+100009  联通200
+100010  联通300
+100011  联通500
+
+电信
+100012  电信30
+100013  电信50
+100014  电信100
+100015  电信200
+100016  电信300
+100017  电信500

+ 30 - 11
helper/refill/api/yl/kailinyu/RefillCallBack.php

@@ -8,7 +8,9 @@ class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
-        $sign = $this->sign($params);
+        $input = $params;
+        unset($input['sign']);
+        $sign = $this->sign($input);
         if ($params['sign'] == $sign) {
             return true;
         } else {
@@ -18,28 +20,45 @@ class RefillCallBack implements refill\IRefillCallBack
 
     private function sign($params)
     {
-        $userid = config::USER_ID;
-        $key = config::KEY;
-        $content = "userid={$userid}&orderid={$params['orderid']}&sporderid={$params['sporderid']}&merchantsubmittime={$params['merchantsubmittime']}";
-        $content .= "&resultno={$params['resultno']}&key={$key}";
-        return strtoupper(md5($content));
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
+        return md5($content);
+    }
+
+    private function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
     }
 
     public function notify($params)
     {
-        $status = intval($params['resultno']);
-        $order_sn = $params['sporderid'];
+        $status = intval($params['orderStatus']);
+        $order_sn = $params['outOrderId'];
         $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 === 1) {
-            $data['official_sn'] = strtolower($params['remark1']) == 'null' ? '' : $params['remark1'];
+        if ($status === 2) {
+            $data['official_sn'] = strtolower($params['ext1']) == 'null' ? '' : $params['ext1'];
             Model('refill_order')->edit($order_id, $data);
             return [$order_id, true, false, true];
-        } elseif ($status === 9) {
+        } elseif ($status === 3) {
             return [$order_id, false, true, true];
         } else {
             return [$order_id, false, false, false];

+ 62 - 62
helper/refill/api/yl/kailinyu/RefillPhone.php

@@ -14,18 +14,15 @@ class RefillPhone extends refill\IRefillPhone
         parent::__construct($cfgs);
     }
 
-    private function req_params(int $phone, int $amount, $card_type, string $order_sn)
+    private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
     {
-        $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];
-
+        $params['appId'] = config::APP_ID;
+        $params['outOrderId'] = $order_sn;
+        $params['uuid'] = $phone;
+        $params['itemId'] = config::PRODUCT[$card_type][$amount];
+        $params['itemFace'] = $amount;
+        $params['callbackUrl'] = config::NOTIFY_URL;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
         return $params;
     }
 
@@ -33,7 +30,9 @@ class RefillPhone extends refill\IRefillPhone
     {
         $order_sn = $params['order_sn'];
         $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
-
+        if(empty($params['itemId'])) {
+            return [false, '商品编号错误', false];
+        }
         $sign = $this->sign($params);
         $params['sign'] = $sign;
 
@@ -45,35 +44,29 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
-            $resp = $this->xmlToArray($resp);
+            $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '网络错误', 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];
+            } elseif ($resp['code'] === '00') {
+                return [true, $resp['orderId'], false];
+            } elseif (in_array($resp['code'], config::ERRCODES, true)) {
+                return [false, $resp['msg'], false];
+            } elseif (in_array($resp['code'], ['-22', '-23', '-99'], true)) {
+                $net_errno = "HTTP-{$resp['code']}";
+                return [false, $resp['msg'], true];
             } else {
-                //未知结果码
-                $err = 998;
-                $net_errno = "HTTP-{$err}";
-                return [false, $resultno, true];
+                $net_errno = "HTTP-998";
+                return [false, $resp['msg'], true];
             }
         }
     }
 
     public function query($refill_info)
     {
-        $params['userid'] = config::USER_ID;
-        $params['sporderid'] = $refill_info['order_sn'];
-        $key = config::KEY;
-        $content = "userid={$params['userid']}&sporderid={$params['sporderid']}&key={$key}";
-        $params['sign'] = strtoupper(md5($content));
+        $params['appId'] = config::APP_ID;
+        $params['outOrderId'] = $refill_info['order_sn'];
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
 
         $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -83,39 +76,40 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
-            $resp = $this->xmlToArray($resp);
-            if (empty($resp))
-            {
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
                 return [false, '网络错误'];
             }
-            else
+            elseif ($resp['code'] === '00')
             {
-                $resultno = $resp['resultno'];
-                if ($resultno === '1') {
-                    $updata['official_sn'] = $resp['remark1'];
+                $status = $resp['orderStatus'];
+                if ($status === '2') {
+                    $updata['official_sn'] = $resp['ext1'];
                     Model('refill_order')->edit($refill_info['order_id'], $updata);
                     $order_state = ORDER_STATE_SUCCESS;
-                } elseif ($resultno === '9') {
+                } elseif ($status === '3') {
                     $order_state = ORDER_STATE_CANCEL;
-                } elseif (in_array($resultno, ['0','2'], true)) {
+                } elseif ($status === '1') {
                     $order_state = ORDER_STATE_SEND;
-                } elseif ($resultno === '5007' && (time() - $refill_info['commit_time'] > 600)) {
+                } elseif ($status === '4' && (time() - $refill_info['commit_time'] >= 600)) {
                     $order_state = ORDER_STATE_NOEXIST;
                 } else {
-                    return [false, $resultno];
+                    return [false, $resp['msg']];
                 }
-
                 return [true, $order_state];
             }
+            else
+            {
+                return [false, $resp['msg']];
+            }
         }
     }
 
     public function balance()
     {
-        $params['userid'] = config::USER_ID;
-        $key = config::KEY;
-        $content = "userid={$params['userid']}&key={$key}";
-        $params['sign'] = strtoupper(md5($content));
+        $params['appId'] = config::APP_ID;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
 
         $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -125,31 +119,37 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
-            $resp = $this->xmlToArray($resp);
+            $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '网络错误'];
-            } elseif ($resp['resultno'] === '1') {
+            } elseif ($resp['code'] === '00') {
                 return [true, $resp['balance']];
             } else {
-                return [false, $resp['resultno']];
+                return [false, $resp['msg']];
             }
         }
     }
 
-    private function sign($params)
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function get_millisecond()
     {
-        $userid = config::USER_ID;
-        $key = config::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 strtoupper(md5($content));
+        list($usec, $sec) = explode(" ", microtime());
+        return round($usec*1000);
     }
 
-    public function xmlToArray($xml)
+    private function sign($params)
     {
-        $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);
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
+        return md5($content);
     }
 }

+ 33 - 43
helper/refill/api/yl/kailinyu/config.php

@@ -6,50 +6,40 @@ namespace refill\kailinyu;
 use mtopcard;
 class config
 {
-    //https://www.showdoc.com.cn/AQL666666/
-    const ORDER_URL = 'http://116.62.32.89:9086/onlinepay.do';
-    const QUERY_URL= 'http://116.62.32.89:9086/searchpay.do';
-    const BALANCE_URL = 'http://116.62.32.89:9086/searchbalance.do';
+    const ORDER_URL = 'http://120.76.52.71:8911/api/hf/order/submit';
+    const QUERY_URL = 'http://120.76.52.71:8911/api/order/query';
+    const BALANCE_URL = 'http://120.76.52.71:8911/api/account/balance';
 
-    const USER_ID= '10003105';
-    const KEY = 'hDRHw7StsnRTFEZmFnEbmrkGajW3WyQB';
+    const APP_ID = 'f54dHy7DXI';
+    const APP_SECRET = 'EgwaXJGtfZzTrQog';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_kailinyu.php";
-    const operator = [
-        mtopcard\ChinaMobileCard  => 'yd',
-        mtopcard\ChinaUnicomCard  => 'lt',
-        mtopcard\ChinaTelecomCard => 'dx'
-    ];
-    const ERR_NOS = [
-        '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',
-                300 => '30000000912',
-                500 => '30000000913',
-            ],
-        mtopcard\ChinaUnicomCard =>
-            [
-                30  => '101705',
-                50  => '101706',
-                100 => '101707',
-                200 => '101708',
-                300 => '101709',
-                500 => '101710',
-            ],
-        mtopcard\ChinaTelecomCard =>
-            [
-                30  => '101723',
-                50  => '101724',
-                100 => '101725',
-                200 => '101726',
-                300 => '101727',
-                500 => '101728',
-            ]
+
+    const PRODUCT = [
+        mtopcard\ChinaMobileCard => [
+            30  => 100000,
+            50  => 100001,
+            100 => 100002,
+            200 => 100003,
+            300 => 100004,
+            500 => 100005,
+        ],
+        mtopcard\ChinaUnicomCard => [
+            30  => 100006,
+            50  => 100007,
+            100 => 100008,
+            200 => 100009,
+            300 => 100010,
+            500 => 100011,
+        ],
+        mtopcard\ChinaTelecomCard => [
+            30  => 100012,
+            50  => 100013,
+            100 => 100014,
+            200 => 100015,
+            300 => 100016,
+            500 => 100017,
+        ],
     ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ERRCODES = ['-10', '-12', '-13', '-14', '-15', '-16', '-18', '-21'];
 }

+ 0 - 35
helper/refill/api/yl/kailinyu/对接文档-yezi.txt

@@ -1,35 +0,0 @@
-凯霖宇
-http://116.62.32.89:7080/
-账号:椰林
-密码:yelin123456
-
-ID:10003105
-密钥:hDRHw7StsnRTFEZmFnEbmrkGajW3WyQB
-
-http://116.62.32.89:9086/onlinepay.do 下单地址
-http://116.62.32.89:9086/searchpay.do 订单主动查询地址
-http://116.62.32.89:9086/searchbalance.do 余额查询
-
-api接口文档地址:https://www.showdoc.com.cn/AQL666666/
-白名单地址: 116.62.32.89
-
-101687  全国移动话费30元直充
-101688  全国移动话费50元直充
-101689  全国移动话费100元直充
-101690  全国移动话费200元直充
-30000000912  全国移动300元直充
-30000000913  全国移动500元直充
-
-101705  全国联通话费30元直充
-101706  全国联通话费50元直充
-101707  全国联通话费100元直充
-101708  全国联通话费200元直充
-101709  全国联通话费300元直充
-101710  全国联通话费500元直充
-
-101723  全国电信话费30元直充
-101724  全国电信话费50元直充
-101725  全国电信话费100元直充
-101726  全国电信话费200元直充
-101727  全国电信话费300元直充
-101728  全国电信话费500元直充

+ 39 - 0
helper/refill/api/yl/kailinyu/开户信息.txt

@@ -0,0 +1,39 @@
+后台地址:http://120.76.52.71:8888
+帐号:椰林
+密码:137022
+二级密码:tnwt2560
+appId:f54dHy7DXI
+appSecret:EgwaXJGtfZzTrQog
+后台-商品列表,可查看已配置商品信息
+后台-安全中心,可配置IP白名单
+接口文档:https://www.showdoc.com.cn/1686453783298366/7925312871840290
+话费直充接口:http://120.76.52.71:8911/api/hf/order/submit
+通用直充接口:http://120.76.52.71:8911/api/order/submit
+卡密提取接口:http://120.76.52.71:8911/api/card/get
+查询接口接口:http://120.76.52.71:8911/api/order/query
+余额查询接口:http://120.76.52.71:8911/api/account/balance
+
+
+移动
+100000  移动30
+100001  移动50
+100002  移动100
+100003  移动200
+100004  移动300
+100005  移动500
+
+联通
+100006  联通30
+100007  联通50
+100008  联通100
+100009  联通200
+100010  联通300
+100011  联通500
+
+电信
+100012  电信30
+100013  电信50
+100014  电信100
+100015  电信200
+100016  电信300
+100017  电信500

+ 1 - 1
mobile/callback/refill_kailinyu.php

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

+ 2 - 2
test/TestRefill.php

@@ -2051,9 +2051,9 @@ class TestRefill extends TestCase
 //        $provider = $this->getProvider('kailinyu');
 //        $resp = $provider->balance();
 //        $resp = $provider->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
-//        $resp = $provider->query(['order_sn' => '96401647327929264712']);
+//        $resp = $provider->query(['order_sn' => '94371658718403772370']);
 
-        $body = '{"orderid":"AFO22031515056588604","sporderid":"96401647327929264712","userid":"10002963","merchantsubmittime":"20220315150727","resultno":"9","parvalue":"30","remark1":"","payno":"","fundbalance":"-28.59","sign":"597D9581047FD47B4117870FD49D9D10"}';
+        $body = '{"orderId":"220725110647030575","appId":"FcSAzHuWQ4","outOrderId":"94371658718403772370","sign":"6c2c7c91864f12ff1986ac4ea6fd7b4f","orderStatus":"3","completeTime":"20220725110647","orderDesc":"\u8ba2\u5355\u5931\u8d25"}';
         $params = json_decode($body, true);
         $provider = $this->getProvider('kailinyu','RefillCallBack');
         $ret = $provider->verify($params);