Bladeren bron

xyz yl yunchonggong_yd

haru haru 3 jaren geleden
bovenliggende
commit
cf926b68fb

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

@@ -2489,14 +2489,14 @@ $sialan_tax_phone = ['name' => 'sialan_tax', 'store_id' => 119, 'qualitys' => '2
 
 $yunchonggong_yd_phone = ['name' => 'yunchonggong_yd', 'store_id' => 120, 'qualitys' => '1',
     'amount' => [
-        10 => [['goods_id' => 7043, 'price' => 9.54, 'quality' => 1, 'card_type' => 'chinamobile']],
-        20 => [['goods_id' => 7044, 'price' => 19.08, 'quality' => 1, 'card_type' => 'chinamobile']],
-        30 => [['goods_id' => 7045, 'price' => 28.62, 'quality' => 1, 'card_type' => 'chinamobile']],
-        50 => [['goods_id' => 7046, 'price' => 47.7, 'quality' => 1, 'card_type' => 'chinamobile']],
-        100 => [['goods_id' => 7047, 'price' => 95.4, 'quality' => 1, 'card_type' => 'chinamobile']],
-        200 => [['goods_id' => 7048, 'price' => 190.8, 'quality' => 1, 'card_type' => 'chinamobile']],
-        300 => [['goods_id' => 7049, 'price' => 286.2, 'quality' => 1, 'card_type' => 'chinamobile']],
-        500 => [['goods_id' => 7050, 'price' => 477, 'quality' => 1, 'card_type' => 'chinamobile']]
+//        10 => [['goods_id' => 7043, 'price' => 9.55, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        20 => [['goods_id' => 7044, 'price' => 19.1, 'quality' => 1, 'card_type' => 'chinamobile']],
+        30 => [['goods_id' => 7045, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 7046, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 7047, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 7048, 'price' => 191, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        300 => [['goods_id' => 7049, 'price' => 286.5, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        500 => [['goods_id' => 7050, 'price' => 477.5, 'quality' => 1, 'card_type' => 'chinamobile']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 

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

@@ -2489,14 +2489,14 @@ $sialan_tax_phone = ['name' => 'sialan_tax', 'store_id' => 119, 'qualitys' => '2
 
 $yunchonggong_yd_phone = ['name' => 'yunchonggong_yd', 'store_id' => 120, 'qualitys' => '1',
     'amount' => [
-        10 => [['goods_id' => 7043, 'price' => 9.54, 'quality' => 1, 'card_type' => 'chinamobile']],
-        20 => [['goods_id' => 7044, 'price' => 19.08, 'quality' => 1, 'card_type' => 'chinamobile']],
-        30 => [['goods_id' => 7045, 'price' => 28.62, 'quality' => 1, 'card_type' => 'chinamobile']],
-        50 => [['goods_id' => 7046, 'price' => 47.7, 'quality' => 1, 'card_type' => 'chinamobile']],
-        100 => [['goods_id' => 7047, 'price' => 95.4, 'quality' => 1, 'card_type' => 'chinamobile']],
-        200 => [['goods_id' => 7048, 'price' => 190.8, 'quality' => 1, 'card_type' => 'chinamobile']],
-        300 => [['goods_id' => 7049, 'price' => 286.2, 'quality' => 1, 'card_type' => 'chinamobile']],
-        500 => [['goods_id' => 7050, 'price' => 477, 'quality' => 1, 'card_type' => 'chinamobile']]
+//        10 => [['goods_id' => 7043, 'price' => 9.55, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        20 => [['goods_id' => 7044, 'price' => 19.1, 'quality' => 1, 'card_type' => 'chinamobile']],
+        30 => [['goods_id' => 7045, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 7046, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 7047, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 7048, 'price' => 191, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        300 => [['goods_id' => 7049, 'price' => 286.5, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        500 => [['goods_id' => 7050, 'price' => 477.5, 'quality' => 1, 'card_type' => 'chinamobile']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
@@ -5491,7 +5491,7 @@ $phone_providers = [
     ['name' => 'miaoxt_fs', 'cfg' => $miaoxt_fs_phone],
 //    ['name' => 'xianzhibb', 'cfg' => $xianzhibb_phone],
 //    ['name' => 'yikatong', 'cfg' => $yikatong_phone],
-//    ['name' => 'yunchonggong_yd', 'cfg' => $yunchonggong_yd_phone],
+    ['name' => 'yunchonggong_yd', 'cfg' => $yunchonggong_yd_phone],
     ['name' => 'guochuang_nation', 'cfg' => $guochuang_nation_phone],
 //    ['name' => 'tianyanman', 'cfg' => $tianyanman_phone],
 //    ['name' => 'shimier', 'cfg' => $shimier_phone],

+ 33 - 17
helper/refill/api/xyz/yunchonggong_yd/RefillCallBack.php

@@ -8,8 +8,10 @@ class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
-        $sign = $this->sign($params);
-        if ($params['szVerifyString'] == $sign) {
+        $input = $params;
+        unset($input['sign']);
+        $sign = $this->sign($input);
+        if ($params['sign'] == $sign) {
             return true;
         } else {
             return false;
@@ -18,33 +20,47 @@ class RefillCallBack implements refill\IRefillCallBack
 
     private function sign($params)
     {
-        $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}";
+        $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['nFlag']);
-        $order_sn = $params['szOrderId'];
+        $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 === 2) {
-            $data['official_sn'] = strtolower($params['szRtnMsg']) == 'null' ? '' : $params['szRtnMsg'];
+            $data['official_sn'] = strtolower($params['ext1']) == 'null' ? '' : $params['ext1'];
             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 === 3) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
         }
     }
 }

+ 70 - 55
helper/refill/api/xyz/yunchonggong_yd/RefillPhone.php

@@ -16,15 +16,14 @@ 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['appId'] = config::APP_ID;
+        $params['outOrderId'] = $order_sn;
+        $params['uuid'] = $phone;
+        $params['itemId'] = config::PRODUCT[$card_type][$amount];
+        $params['itemFace'] = $amount;
+        $params['amount'] = 1;
+        $params['callbackUrl'] = config::NOTIFY_URL;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
         return $params;
     }
 
@@ -32,9 +31,11 @@ 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['szVerifyString'] = $sign;
+        $params['sign'] = $sign;
 
         $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
 
@@ -45,32 +46,28 @@ class RefillPhone extends refill\IRefillPhone
         {
             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];
+            } 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, $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'];
-        $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szOrderId={$params['szOrderId']}&szKey={$key}";
-        $params['szVerifyString'] = 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);
 
@@ -84,32 +81,36 @@ class RefillPhone extends refill\IRefillPhone
             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']];
+            elseif ($resp['code'] === '00')
+            {
+                $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 ($status === '3') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === '1') {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($status === '4' && (time() - $refill_info['commit_time'] >= 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            }
+            else
+            {
+                return [false, $resp['msg']];
             }
-
-            return [true, $order_state];
         }
     }
 
     public function balance()
     {
-        $params['szAgentId'] = config::USER_ID;
-        $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szKey={$key}";
-        $params['szVerifyString'] = 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);
 
@@ -122,20 +123,34 @@ class RefillPhone extends refill\IRefillPhone
             $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '网络错误'];
-            } elseif ($resp['nRtn'] === 0) {
-                return [true, $resp['fBalance']];
+            } elseif ($resp['code'] === '00') {
+                return [true, $resp['balance']];
             } else {
-                return [false, $resp['szRtnCode']];
+                return [false, $resp['msg']];
             }
         }
     }
 
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function get_millisecond()
+    {
+        list($usec, $sec) = explode(" ", microtime());
+        return round($usec*1000);
+    }
+
     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}";
+        $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);
     }
 }

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

@@ -1,12 +0,0 @@
-正式环境:
-话费下单地址:http://47.98.253.40:10186/plat/api/old/submitorder
-查询地址:http://47.98.253.40:10186/plat/api/old/queryorder
-查询余额地址:http://47.98.253.40:10186/plat/api/old/queryBalance
-
-测试ID:   200043
-秘钥: 028a435cc21f42f39a4bb2d74bba2a34
-账号  gaoye
-密码 123456
-
-对接文档地址:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
-客户端地址:http://47.98.253.40:10186/plat/index

+ 20 - 14
helper/refill/api/xyz/yunchonggong_yd/config.php

@@ -6,22 +6,28 @@ namespace refill\yunchonggong_yd;
 use mtopcard;
 class config
 {
-    //954
-    const ORDER_URL = 'http://47.98.253.40:10186/plat/api/old/submitorder';
-    const QUERY_URL= 'http://47.98.253.40:10186/plat/api/old/queryorder';
-    const BALANCE_URL= 'http://47.98.253.40:10186/plat/api/old/queryBalance';
+    const ORDER_URL = 'http://119.23.54.206:8911/api/order/submit';
+    const QUERY_URL = 'http://119.23.54.206:8911/api/order/query';
+    const BALANCE_URL = 'http://119.23.54.206:8911/api/account/balance';
 
-    const USER_ID= '200043';
-    const KEY = '028a435cc21f42f39a4bb2d74bba2a34';
+    const APP_ID = 'kbDyqz9L7X';
+    const APP_SECRET = 'IXxRhCpFVvqEHgNC';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yunchonggong_yd.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 ERR_NOS = [
-        1000,1001,1003,1004,2001,2002,2003,2020,2021,1006,2030,3003
+    const PRODUCT = [
+        mtopcard\ChinaMobileCard => [
+            30  => 100130,
+            50  => 100131,
+            100 => 100132,
+            200 => 100133
+        ],
+        mtopcard\ChinaUnicomCard => [
+
+        ],
+        mtopcard\ChinaTelecomCard => [
+
+        ],
     ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ERRCODES = ['-10', '-12', '-13', '-14', '-15', '-16', '-18', '-21'];
 }

+ 24 - 0
helper/refill/api/xyz/yunchonggong_yd/开户信息.txt

@@ -0,0 +1,24 @@
+后台地址:http://119.23.54.206:8888
+帐号:yezi222
+密码:722763
+二级密码:YSyT6856
+appId:kbDyqz9L7X
+appSecret:IXxRhCpFVvqEHgNC
+后台-商品列表,可查看已配置商品信息
+后台-安全中心,可配置IP白名单
+接口文档:https://www.showdoc.com.cn/1686453783298366/7925312871840290
+话费直充接口:http://119.23.54.206:8911/api/hf/order/submit
+通用直充接口:http://119.23.54.206:8911/api/order/submit
+卡密提取接口:http://119.23.54.206:8911/api/card/get
+查询接口接口:http://119.23.54.206:8911/api/order/query
+余额查询接口:http://119.23.54.206:8911/api/account/balance
+
+
+100130
+云缴费移动30
+100131
+云缴费移动50
+100132
+云缴费移动100
+100133
+云缴费移动200

+ 33 - 17
helper/refill/api/yl/yunchonggong_yd/RefillCallBack.php

@@ -8,8 +8,10 @@ class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
-        $sign = $this->sign($params);
-        if ($params['szVerifyString'] == $sign) {
+        $input = $params;
+        unset($input['sign']);
+        $sign = $this->sign($input);
+        if ($params['sign'] == $sign) {
             return true;
         } else {
             return false;
@@ -18,33 +20,47 @@ class RefillCallBack implements refill\IRefillCallBack
 
     private function sign($params)
     {
-        $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}";
+        $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['nFlag']);
-        $order_sn = $params['szOrderId'];
+        $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 === 2) {
-            $data['official_sn'] = strtolower($params['szRtnMsg']) == 'null' ? '' : $params['szRtnMsg'];
+            $data['official_sn'] = strtolower($params['ext1']) == 'null' ? '' : $params['ext1'];
             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 === 3) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
         }
     }
 }

+ 70 - 55
helper/refill/api/yl/yunchonggong_yd/RefillPhone.php

@@ -16,15 +16,14 @@ 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['appId'] = config::APP_ID;
+        $params['outOrderId'] = $order_sn;
+        $params['uuid'] = $phone;
+        $params['itemId'] = config::PRODUCT[$card_type][$amount];
+        $params['itemFace'] = $amount;
+        $params['amount'] = 1;
+        $params['callbackUrl'] = config::NOTIFY_URL;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
         return $params;
     }
 
@@ -32,9 +31,11 @@ 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['szVerifyString'] = $sign;
+        $params['sign'] = $sign;
 
         $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
 
@@ -45,32 +46,28 @@ class RefillPhone extends refill\IRefillPhone
         {
             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];
+            } 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, $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'];
-        $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szOrderId={$params['szOrderId']}&szKey={$key}";
-        $params['szVerifyString'] = 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);
 
@@ -84,32 +81,36 @@ class RefillPhone extends refill\IRefillPhone
             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']];
+            elseif ($resp['code'] === '00')
+            {
+                $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 ($status === '3') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === '1') {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($status === '4' && (time() - $refill_info['commit_time'] >= 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            }
+            else
+            {
+                return [false, $resp['msg']];
             }
-
-            return [true, $order_state];
         }
     }
 
     public function balance()
     {
-        $params['szAgentId'] = config::USER_ID;
-        $key = config::KEY;
-        $content = "szAgentId={$params['szAgentId']}&szKey={$key}";
-        $params['szVerifyString'] = 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);
 
@@ -122,20 +123,34 @@ class RefillPhone extends refill\IRefillPhone
             $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '网络错误'];
-            } elseif ($resp['nRtn'] === 0) {
-                return [true, $resp['fBalance']];
+            } elseif ($resp['code'] === '00') {
+                return [true, $resp['balance']];
             } else {
-                return [false, $resp['szRtnCode']];
+                return [false, $resp['msg']];
             }
         }
     }
 
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function get_millisecond()
+    {
+        list($usec, $sec) = explode(" ", microtime());
+        return round($usec*1000);
+    }
+
     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}";
+        $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);
     }
 }

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

@@ -1,12 +0,0 @@
-正式环境:
-话费下单地址:http://47.98.253.40:10186/plat/api/old/submitorder
-查询地址:http://47.98.253.40:10186/plat/api/old/queryorder
-查询余额地址:http://47.98.253.40:10186/plat/api/old/queryBalance
-
-测试ID:   200043
-秘钥: 028a435cc21f42f39a4bb2d74bba2a34
-账号  gaoye
-密码 123456
-
-对接文档地址:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
-客户端地址:http://47.98.253.40:10186/plat/index

+ 20 - 14
helper/refill/api/yl/yunchonggong_yd/config.php

@@ -6,22 +6,28 @@ namespace refill\yunchonggong_yd;
 use mtopcard;
 class config
 {
-    //954
-    const ORDER_URL = 'http://47.98.253.40:10186/plat/api/old/submitorder';
-    const QUERY_URL= 'http://47.98.253.40:10186/plat/api/old/queryorder';
-    const BALANCE_URL= 'http://47.98.253.40:10186/plat/api/old/queryBalance';
+    const ORDER_URL = 'http://119.23.54.206:8911/api/order/submit';
+    const QUERY_URL = 'http://119.23.54.206:8911/api/order/query';
+    const BALANCE_URL = 'http://119.23.54.206:8911/api/account/balance';
 
-    const USER_ID= '200043';
-    const KEY = '028a435cc21f42f39a4bb2d74bba2a34';
+    const APP_ID = 't3iQhtu3sd';
+    const APP_SECRET = 'xaxdWZlzcMsIvzaU';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yunchonggong_yd.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 ERR_NOS = [
-        1000,1001,1003,1004,2001,2002,2003,2020,2021,1006,2030,3003
+    const PRODUCT = [
+        mtopcard\ChinaMobileCard => [
+            30  => 100130,
+            50  => 100131,
+            100 => 100132,
+            200 => 100133
+        ],
+        mtopcard\ChinaUnicomCard => [
+
+        ],
+        mtopcard\ChinaTelecomCard => [
+
+        ],
     ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ERRCODES = ['-10', '-12', '-13', '-14', '-15', '-16', '-18', '-21'];
 }

+ 24 - 0
helper/refill/api/yl/yunchonggong_yd/开户信息.txt

@@ -0,0 +1,24 @@
+后台地址:http://119.23.54.206:8888
+帐号:yelin222
+密码:765514
+二级密码:hauy5488
+appId:t3iQhtu3sd
+appSecret:xaxdWZlzcMsIvzaU
+后台-商品列表,可查看已配置商品信息
+后台-安全中心,可配置IP白名单
+接口文档:https://www.showdoc.com.cn/1686453783298366/7925312871840290
+话费直充接口:http://119.23.54.206:8911/api/hf/order/submit
+通用直充接口:http://119.23.54.206:8911/api/order/submit
+卡密提取接口:http://119.23.54.206:8911/api/card/get
+查询接口接口:http://119.23.54.206:8911/api/order/query
+余额查询接口:http://119.23.54.206:8911/api/account/balance
+
+
+100130
+云缴费移动30
+100131
+云缴费移动50
+100132
+云缴费移动100
+100133
+云缴费移动200

+ 2 - 5
test/TestRefill.php

@@ -934,12 +934,9 @@ class TestRefill extends TestCase
     public function testYunchonggong_yd()
     {
         $provider = $this->getProvider('yunchonggong_yd');
-        for ($i = 1; $i <= 5; $i++) {
-            $resp = $provider->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
-        }
-//        $resp = $provider->query(['order_sn' => '34061631002071526340']);
-
 //        $resp = $provider->balance();
+//        $resp = $provider->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '40181650866044454847']);
 
 //        $body = '{"szOrderId":"34061631002071526340","fSalePrice":"47.7","szAgentId":"200043","nFlag":"3","szVerifyString":"48a7329c13af06b5be1d2fdad706b22e","szPhoneNum":"13699279618","szRtnMsg":"","nDemo":"50"}';
 //        $params = json_decode($body, true);

+ 6 - 0
test/TestRefillYl.php

@@ -670,4 +670,10 @@ class TestRefillYl extends TestCase
         $provider = $this->getProvider('yingdian', 'RefillOil');
         $resp = $provider->balance();
     }
+
+    public function testYunchonggong_yd()
+    {
+        $provider = $this->getProvider('yunchonggong_yd');
+        $resp = $provider->balance();
+    }
 }