瀏覽代碼

yelin yunchonggongfs

xiaoyu 2 年之前
父節點
當前提交
6672896c99

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

@@ -3267,10 +3267,10 @@ $yunchonggongfs_phone = ['name' => 'yunchonggongfs', 'store_id' => 149,'qualitys
     'amount' => [
 //        10 => [['goods_id' => 7275, 'price' => 9.41, 'quality' => 1, 'card_type' => 'chinamobile']],
 //        20 => [['goods_id' => 7276, 'price' => 18.82, 'quality' => 1, 'card_type' => 'chinamobile']],
-        30 => [['goods_id' => 7277, 'price' => 28.23, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
-        50 => [['goods_id' => 7278, 'price' => 47.05, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
-        100 => [['goods_id' => 7279, 'price' => 94.1, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
-        200 => [['goods_id' => 7280, 'price' => 188.2, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+        30 => [['goods_id' => 7277, 'price' => 28.23, 'quality' => 1, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 7278, 'price' => 47.05, 'quality' => 1, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 7279, 'price' => 94.1, 'quality' => 1, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 7280, 'price' => 188.2, 'quality' => 1, 'card_type' => 'chinamobile']],
 //        300 => [['goods_id' => 7281, 'price' => 282.3, 'quality' => 1, 'card_type' => 'chinamobile']],
 //        500 => [['goods_id' => 7282, 'price' => 470.5, 'quality' => 1, 'card_type' => 'chinamobile']]
     ],

+ 9 - 28
helper/refill/api/xyz/yunchonggongfs/RefillCallBack.php

@@ -8,10 +8,8 @@ class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
-        $input = $params;
-        unset($input['sign']);
-        $sign = $this->sign($input);
-        if ($params['sign'] == $sign) {
+        $sign = $this->sign($params);
+        if ($params['szVerifyString'] == $sign) {
             return true;
         } else {
             return false;
@@ -20,34 +18,17 @@ class RefillCallBack implements refill\IRefillCallBack
 
     private function sign($params)
     {
-        $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, '&');
+        $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);
     }
 
-    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['orderStatus']);
-        $order_sn = $params['outOrderId'];
+        $status = intval($params['nFlag']);
+        $order_sn = $params['szOrderId'];
         $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
         if (empty($order_info)) {
             return [false, false, false,false];
@@ -55,7 +36,7 @@ class RefillCallBack implements refill\IRefillCallBack
 
         $order_id = $order_info['order_id'];
         if ($status === 2) {
-            $data['official_sn'] = strtolower($params['ext1']) == 'null' ? '' : $params['ext1'];
+            $data['official_sn'] = strtolower($params['szRtnMsg']) == 'null' ? '' : $params['szRtnMsg'];
             Model('refill_order')->edit($order_id, $data);
             return [$order_id, true, false, true];
         } elseif ($status === 3) {

+ 57 - 90
helper/refill/api/xyz/yunchonggongfs/RefillPhone.php

@@ -14,46 +14,27 @@ class RefillPhone extends refill\IRefillPhone
         parent::__construct($cfgs);
     }
 
-    public function goods($quality,int $amount,int $card_type,$regin_no,$other)
+    private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
     {
-        [$goods_id, $price] = parent::goods($quality,$amount,$card_type,$regin_no,$other);
-        if($goods_id <= 0) return [0,0];
-        $key = "{$card_type}-{$amount}-{$regin_no}";
-        $price = config::Price[$key];
-        if(empty($price)) {
-            Log::record("channel cannot find price where name={$this->mName}, goods_id = {$goods_id} card_type={$card_type} amount={$amount} regin_no={$regin_no}",Log::ERR);
-            return [0,0];
-        } else {
-            return [$goods_id,ncPriceFormat($price)];
-        }
-    }
-
-    private function req_params(int $phone, int $card_type, int $amount, string $order_sn, $regin_no)
-    {
-        $params['appId'] = config::APP_ID;
-        $params['outOrderId'] = $order_sn;
-        $params['uuid'] = $phone;
-        $params['itemId'] = config::ProvinceItemId[$card_type][$regin_no][$amount];
-        $params['itemFace'] = $amount;
-        $params['amount'] = 1;
-        $params['callbackUrl'] = config::NOTIFY_URL;
-        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $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;
         return $params;
     }
 
     public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
     {
         $order_sn = $params['order_sn'];
-        $regin_no = $params['regin_no'] ?? -1;
-        if($regin_no <= 0) {
-            return [false, '省份获取错误', false];
-        }
-        $params = $this->req_params($card_no, $card_type, $amount, $order_sn, $regin_no);
-        if(empty($params['itemId'])) {
-            return [false, '商品编号错误', false];
-        }
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
+
         $sign = $this->sign($params);
-        $params['sign'] = $sign;
+        $params['szVerifyString'] = $sign;
 
         $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
 
@@ -64,28 +45,32 @@ 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 ($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];
+            } 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];
             } else {
-                $net_errno = "HTTP-998";
-                return [false, $resp['msg'], true];
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resp['szRtnCode'], true];
             }
         }
     }
 
     public function query($refill_info)
     {
-        $params['appId'] = config::APP_ID;
-        $params['outOrderId'] = $refill_info['order_sn'];
-        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
-        $params['sign'] = $this->sign($params);
+        $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);
 
         $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -99,36 +84,32 @@ class RefillPhone extends refill\IRefillPhone
             if (empty($resp)) {
                 return [false, '网络错误'];
             }
-            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']];
+
+            $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']];
             }
+
+            return [true, $order_state];
         }
     }
 
     public function balance()
     {
-        $params['appId'] = config::APP_ID;
-        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
-        $params['sign'] = $this->sign($params);
+        $params['szAgentId'] = config::USER_ID;
+        $key = config::KEY;
+        $content = "szAgentId={$params['szAgentId']}&szKey={$key}";
+        $params['szVerifyString'] = md5($content);
 
         $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
 
@@ -141,34 +122,20 @@ class RefillPhone extends refill\IRefillPhone
             $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '网络错误'];
-            } elseif ($resp['code'] === '00') {
-                return [true, $resp['balance']];
+            } elseif ($resp['nRtn'] === 0) {
+                return [true, $resp['fBalance']];
             } else {
-                return [false, $resp['msg']];
+                return [false, $resp['szRtnCode']];
             }
         }
     }
 
-    /**
-     * 获取毫秒级别的时间戳
-     */
-    private function get_millisecond()
-    {
-        list($usec, $sec) = explode(" ", microtime());
-        return round($usec*1000);
-    }
-
     private function sign($params)
     {
-        $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, '&');
+        $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);
     }
 }

+ 13 - 0
helper/refill/api/xyz/yunchonggongfs/api.txt

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

+ 11 - 43
helper/refill/api/xyz/yunchonggongfs/config.php

@@ -6,54 +6,22 @@ namespace refill\yunchonggongfs;
 use mtopcard;
 class config
 {
-    const ORDER_URL = 'http://39.108.50.235:8911/api/order/submit';
-    const QUERY_URL = 'http://39.108.50.235:8911/api/order/query';
-    const BALANCE_URL = 'http://39.108.50.235:8911/api/account/balance';
+    const ORDER_URL = 'http://47.96.107.82:10186/plat/api/old/submitorder';
+    const QUERY_URL= 'http://47.96.107.82:10186/plat/api/old/queryorder';
+    const BALANCE_URL = 'http://47.96.107.82:10186/plat/api/old/queryBalance';
 
-    const APP_ID = 'dyipx0WORM';
-    const APP_SECRET = 'LSBNkvMPKoAMfDrt';
+    const USER_ID= '200006';
+    const KEY = 'afa9e7fede694735b2443d27e32daede';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yunchonggongfs.php";
 
-    const ProvinceItemId = [
-        mtopcard\ChinaMobileCard => [
-            25	=> [
-                30  => 100012,
-                50  => 100013,
-                100 => 100014,
-                200 => 100015
-            ], //'云南',
-            24	=> [
-                30  => 100016,
-                50  => 100017,
-                100 => 100018,
-                200 => 100019
-            ], //'贵州',
-        ],
-        mtopcard\ChinaTelecomCard => [
-            9	=> [
-                30  => 100024,
-                50  => 100025,
-                100 => 100026,
-                200 => 100027
-            ], //'上海',
-            18	=> [
-                30  => 100024,
-                50  => 100025,
-                100 => 100026,
-                200 => 100027
-            ], //'湖南',
-        ]
+    const operator = [
+        mtopcard\ChinaMobileCard  => 1,
+        mtopcard\ChinaUnicomCard  => 2,
+        mtopcard\ChinaTelecomCard => 3
     ];
     const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
-    const ERRCODES = ['-10', '-12', '-13', '-14', '-15', '-16', '-18', '-21'];
-    //key格式 卡类型-面值-regin_no
-    const Price = [
-        //移动
-        "4-30-24" => 28.23, "4-50-24" => 47.05, "4-100-24" => 94.1, "4-200-24" => 188.2,//贵州 24
-        "4-30-25" => 28.23, "4-50-25" => 47.05, "4-100-25" => 94.1, "4-200-25" => 188.2,//云南 25
 
-        //电信
-        "6-30-9" => 28.23, "6-50-9" => 47.05, "6-100-9" => 94.1, "6-200-9" => 188.2,//上海 9
-        "6-30-18" => 28.23, "6-50-18" => 47.05, "6-100-18" => 94.1, "6-200-18" => 188.2,//湖南 18
+    const ERR_NOS = [
+        1000,1001,1003,1004,2001,2002,2003,2020,2021,1006,2030,3003
     ];
 }

+ 0 - 34
helper/refill/api/xyz/yunchonggongfs/开户信息.txt

@@ -1,34 +0,0 @@
-后台地址:http://39.108.50.235:8888
-帐号:yezi11
-密码:494749
-二级密码:TpKM4298
-appId:dyipx0WORM
-appSecret:LSBNkvMPKoAMfDrt
-后台-商品列表,可查看已配置商品信息
-后台-安全中心,可配置IP白名单
-接口文档:https://www.showdoc.com.cn/1686453783298366/7925312871840290
-话费直充接口:http://39.108.50.235:8911/api/hf/order/submit
-通用直充接口:http://39.108.50.235:8911/api/order/submit
-卡密提取接口:http://39.108.50.235:8911/api/card/get
-查询接口接口:http://39.108.50.235:8911/api/order/query
-余额查询接口:http://39.108.50.235:8911/api/account/balance
-
-100012	云南移动30
-100013	云南移动50
-100014	云南移动100
-100015	云南移动200
-
-100016	贵州移动30
-100017	贵州移动50
-100018	贵州移动100
-100019	贵州移动200
-
-
-100024
-分省电信30
-100025
-分省电信50
-100026
-分省电信100
-100027
-分省电信200

+ 3 - 3
test/TestRefill.php

@@ -2726,10 +2726,10 @@ class TestRefill extends TestCase
     {
 //        $provider = $this->getProvider('yunchonggong');
 //        $resp = $provider->balance();
-//        $resp = $provider->add(13699279618, 4, 100, ['order_sn' => $this->make_sn()]);
-//        $resp = $provider->query(['order_sn' => '86941657084629542911']);
+//        $resp = $provider->add(15811535608, 4, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '30391661237853787868']);
 
-        $body = '{"orderId":"220706131710000002","appId":"ihAIbQsfqg","outOrderId":"86941657084629542911","sign":"0dcf571414e9d3e1eb371a90ad1f0b72","orderStatus":"3","completeTime":"20220706132031","orderDesc":"\u8ba2\u5355\u5931\u8d25"}';
+        $body = '{"szOrderId":"30391661237853787868","fSalePrice":"28.8","szAgentId":"200005","nFlag":"3","szVerifyString":"5996f052094ed3c7655ed666d66b2804","szPhoneNum":"15811535608","szRtnMsg":"","nDemo":"30"}';
         $params = json_decode($body, true);
         $provider = $this->getProvider('yunchonggong', 'RefillCallback');
         $ret = $provider->verify($params);