ayHaru 4 年之前
父節點
當前提交
ef0a9731a6

+ 4 - 29
helper/refill/api/lingzh/app/RefillPhone.php

@@ -66,7 +66,7 @@ class RefillPhone extends refill\IRefillPhone
         $product_code = $params['product_code'];
         $params = $this->req_params($order_sn,$product_code);
 
-        $params['PublicKey'] = $this->CT_RSA($params['order_id']);
+        $params['PublicKey'] = urlencode(config::PUBLIC_KEY);
 
         $sign = $this->sign($params);
         $params['Sign'] = $sign;
@@ -90,31 +90,6 @@ class RefillPhone extends refill\IRefillPhone
         }
     }
 
-    private function CT_RSA($order_id)
-    {
-        //创建公私钥
-        $res = openssl_pkey_new();
-        //获取私钥
-        openssl_pkey_export($res, $private_key);
-        //获取公钥
-        $public_key = openssl_pkey_get_details($res)['key'];
-
-        $rsa = [
-            'public_key' => $public_key,
-            'private_key' => $private_key,
-        ];
-
-        $rsa_json = json_encode($rsa);
-        Log::record("rsa info : {$rsa_json}");
-
-        //公钥私钥与订单绑定,加rsa字段
-        $updata['public_key'] = $public_key;
-        $updata['private_key'] = $private_key;
-        Model('refill_order')->edit($order_id, $updata);
-
-        return $public_key;
-    }
-
     public function query($refill_info)
     {
         $params['AppKey'] = config::APP_KEY;
@@ -143,8 +118,7 @@ class RefillPhone extends refill\IRefillPhone
                 $card_data = [];
                 if ($status === 2) {
                     if(!empty($resp['Data']['CardData'])) {
-                        $private_key = $refill_info['private_key'];
-                        $cards = $this->rsa_decode($resp['Data']['CardData'],$private_key);
+                        $cards = $this->rsa_decode($resp['Data']['CardData']);
 
                         $card_data = [];
                         foreach ($cards as $card) {
@@ -169,8 +143,9 @@ class RefillPhone extends refill\IRefillPhone
         }
     }
 
-    private function rsa_decode($card_data,$private_key)
+    private function rsa_decode($card_data)
     {
+        $private_key = config::PRIVATE_KEY;
         $res = openssl_pkey_get_private($private_key);
         //使用私钥解密数据
         openssl_private_decrypt($card_data, $decrypted, $res);

+ 41 - 0
helper/refill/api/lingzh/app/config.php

@@ -21,4 +21,45 @@ class config
 //    const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/lingzh/app.php";
     const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
     const API_IP = NET_IP;
+    const PUBLIC_KEY = <<<heredoc
+-----BEGIN PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4fTqUAlhB5MAxUIxDPZ9
+8p2rcek4agbds6WsDzzi3jppnMFAxkASdNuSQ2cDteE2/2xEOvqvVXLNUGG1XYCf
+iyDHSm4oE/qaI9u4az4z4G/CabkYzh3dMGOGXX9xT+unI5+bErrYU0Cww21aqBVh
+gL820LBBXJju1jVlnDagGGjv5VvLrH9LbkMWIJEbV5RsTp8TmQerFTs1eGmz39U4
+psNjwQtqv8wYgBouz5cz82gn3suskWXqebiu3uABmhtAM6xwGKKR+vIiRHyAMesf
+j99wobnjcsK69t3oSPkcA6PqgC48Jfy14drhhILUoKCdUXyhh1wDOJdl0ScK2m2h
+DwIDAQAB
+-----END PUBLIC KEY-----
+heredoc;
+    const PRIVATE_KEY = <<<heredoc
+-----BEGIN PRIVATE KEY-----
+MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDh9OpQCWEHkwDF
+QjEM9n3ynatx6ThqBt2zpawPPOLeOmmcwUDGQBJ025JDZwO14Tb/bEQ6+q9Vcs1Q
+YbVdgJ+LIMdKbigT+poj27hrPjPgb8JpuRjOHd0wY4Zdf3FP66cjn5sSuthTQLDD
+bVqoFWGAvzbQsEFcmO7WNWWcNqAYaO/lW8usf0tuQxYgkRtXlGxOnxOZB6sVOzV4
+abPf1Timw2PBC2q/zBiAGi7PlzPzaCfey6yRZep5uK7e4AGaG0AzrHAYopH68iJE
+fIAx6x+P33ChueNywrr23ehI+RwDo+qALjwl/LXh2uGEgtSgoJ1RfKGHXAM4l2XR
+JwrabaEPAgMBAAECggEAeeVhPnpA0RA52zChO4gCXA84/UO+vlwj4BVhI/tJvG8w
+qHMM2aaZDlehqSD6vHTZ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ceWDMo/x02UDae4qs8yFfrMe8we5sRnT7ZKVVSDt5ew3cnAXUH2t
+m6373eWegHiXIj6RZ/WJMmDLaujoUjL1mUoR+/wTgZPQxfL2oCMkYprzOB7yiFBn
+lDDq9GbaFR4ZBEnVN0vTSkE=
+-----END PRIVATE KEY-----
+heredoc;
 }

+ 50 - 0
helper/refill/api/xyz/suyuan/RefillCallBack.php

@@ -0,0 +1,50 @@
+<?php
+namespace refill\suyuan;
+
+require_once(BASE_HELPER_RAPI_PATH . '/suyuan/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['szVerifyString'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    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}";
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $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];
+        }
+        $order_id = $order_info['order_id'];
+
+        if ($status === 2) {
+            $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) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 102 - 0
helper/refill/api/xyz/suyuan/RefillPhone.php

@@ -0,0 +1,102 @@
+<?php
+
+namespace refill\suyuan;
+
+require_once(BASE_HELPER_RAPI_PATH . '/suyuan/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    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;
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
+
+        $sign = $this->sign($params);
+        $params['szVerifyString'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            } elseif ($resp['nRtn'] == 0) {
+                return [true, '', false];
+            } else {
+                return [false, $resp['szRtnCode'], false];
+            }
+        }
+    }
+
+    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);
+
+        $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            }
+            $status = intval($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])) {
+                $order_state = ORDER_STATE_SEND;
+            } else {
+                return [false, $status];
+            }
+            return [true, $order_state];
+        }
+    }
+
+    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}";
+        return md5($content);
+    }
+}

+ 22 - 0
helper/refill/api/xyz/suyuan/config.php

@@ -0,0 +1,22 @@
+<?php
+
+
+namespace refill\suyuan;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://121.196.63.222:10186/plat/api/old/submitorder';
+    const QUERY_URL= 'http://121.196.63.222:10186/plat/api/old/queryorder';
+
+    const USER_ID= '200000';
+    const KEY = '2a7533687d974571a2051ad555bfd2f5';
+//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/refill_suyuan.php";
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const operator = [
+        mtopcard\ChinaMobileCard  => 1,
+        mtopcard\ChinaUnicomCard  => 2,
+        mtopcard\ChinaTelecomCard => 3
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+}

+ 12 - 0
helper/refill/api/xyz/suyuan/炫捷接口地址.txt

@@ -0,0 +1,12 @@
+话费下单地址:http://121.196.63.222:10186/plat/api/old/submitorder
+油卡下单地址:http://121.196.63.222:10186/plat/api/sh/submitorder
+
+查询地址:http://121.196.63.222:10186/plat/api/old/queryorder
+查询余额地址:http://121.196.63.222:10186/plat/api/old/queryBalance
+
+测试ID:200000
+秘钥:2a7533687d974571a2051ad555bfd2f5
+
+对接文档地址:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
+
+全953

+ 53 - 0
helper/refill/api/xyz/zanzan/RefillCallBack.php

@@ -0,0 +1,53 @@
+<?php
+
+
+namespace refill\zanzan;
+
+require_once(BASE_HELPER_RAPI_PATH . '/zanzan/config.php');
+
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $content  = config::USER_ID . $params['ordernum'] . $params['timestamp'] . config::KEY;
+        return md5($content);
+    }
+
+    //[$order_id, $success, $can_try, $need_handle]
+    public function notify($params)
+    {
+        $status = intval($params['state']);
+        $order_sn = $params['ordernum'];
+        $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'];
+        
+        $data['official_sn'] = strtolower($params['serialno']) == 'null' ? '' : $params['serialno'];
+
+        if ($status === 2) {
+            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];
+        }
+    }
+}

+ 97 - 0
helper/refill/api/xyz/zanzan/RefillPhone.php

@@ -0,0 +1,97 @@
+<?php
+
+namespace refill\zanzan;
+
+require_once(BASE_HELPER_RAPI_PATH . '/zanzan/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, int $amount, string $order_sn)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['orderid'] = $order_sn;
+        $params['echo'] = rand(100000,999999);
+        $params['timestamp'] = date("YmdHis");
+        $params['version'] = '1.0';
+        $params['packcode'] = $amount;
+        $params['mobile'] = $phone;
+        $params['flowtype'] = '1001';
+        $params['callback_url'] = config::NOTIFY_URL;
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $sign = $this->sign($params);
+        $params['chargeSign'] = $sign;
+
+        $params = json_encode($params);
+
+        $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '系统错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($resp['code'] === '0000') {
+                return [true, '', false];
+            } else {
+                return [false, $resp['desc'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['orderid'] = $refill_info['order_sn'];
+        $params['userid'] = config::USER_ID;
+        $params['timestamp'] = date("YmdHis");
+        $content = $params['userid'] . $params['orderid'] . $params['timestamp'] . config::KEY;
+        $params['sign'] = md5($content);
+        $params = json_encode($params);
+
+        $resp = http_post_data(config::QUERY_URL, $params , config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif ($resp['code'] === '0000') {
+                $order_state = ORDER_STATE_SUCCESS;
+            } elseif ($resp['code'] === '0004') {
+                $order_state = ORDER_STATE_CANCEL;
+            } elseif ($resp['code'] === '0002' || $resp['code'] === '0003') {
+                $order_state = ORDER_STATE_SEND;
+            } else {
+                return [false, $resp['desc']];
+            }
+            return [true, $order_state];
+        }
+    }
+
+    private function sign($params)
+    {
+        $content  = $params['userid'] . $params['orderid'] . config::KEY . $params['echo'] . $params['timestamp'];
+        return md5($content);
+    }
+
+}

+ 17 - 0
helper/refill/api/xyz/zanzan/config.php

@@ -0,0 +1,17 @@
+<?php
+
+
+namespace refill\zanzan;
+
+
+class config
+{
+    const ORDER_URL = 'http://115.28.209.246:8081/api/charge.do';
+    const QUERY_URL = 'http://115.28.209.246:8081/api/query_chargestate.do';
+
+    const USER_ID = 'd845a4635f7e47668f5e';
+    const KEY = '06cfafb0c3804943a582';
+//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_zanzan.php";
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const ExtHeaders = ['Content-Type: application/json'];
+}

+ 7 - 0
helper/refill/api/xyz/zanzan/账号.txt

@@ -0,0 +1,7 @@
+
+账号密码 beijingyezi/123456
+地址http://47.105.74.255:7066/agent/login.do
+userid:d845a4635f7e47668f5e
+秘钥 06cfafb0c3804943a582
+
+91.5三网50-200慢充

二進制
helper/refill/api/xyz/zanzan/赞赞话费分销系统接口文档.doc


File diff suppressed because it is too large
+ 14 - 30
test/TestRefill.php