Browse Source

lingzh app provider

ayHaru 4 years ago
parent
commit
555c27bc9f

File diff suppressed because it is too large
+ 328 - 547
data/config/win/refill.ini.php


+ 55 - 0
helper/refill/api/lingzh/app/RefillCallBack.php

@@ -0,0 +1,55 @@
+<?php
+namespace refill\app;
+require_once(BASE_HELPER_RAPI_PATH . '/app/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::APP_KEY . $params['TimesTamp'] . $params['MOrderID'] . $params['OrderID'] . $params['State'] . $params['ChargeAccount'];
+        $content .= $params['BuyCount'] . config::App_Secret;
+        return strtoupper(md5($content));
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['State']);
+        $order_sn = $params['MOrderID'];
+        $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) {
+            //卡密信息,需返回
+            $CardInfo = $this->rsa_decode($params['CardInfo'], $params['private_key']);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 3) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+
+    private function rsa_decode($card_data,$private_key)
+    {
+        $res = openssl_pkey_get_private($private_key);
+        //使用私钥解密数据
+        openssl_private_decrypt($card_data, $decrypted, $res);
+        return $decrypted;
+    }
+}

+ 184 - 0
helper/refill/api/lingzh/app/RefillPhone.php

@@ -0,0 +1,184 @@
+<?php
+
+namespace refill\app;
+
+require_once(BASE_HELPER_RAPI_PATH . '/app/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(string $order_sn)
+    {
+        $params['AppKey'] = config::APP_KEY;
+        $params['TimesTamp'] = time();
+        $params['ProductCode'] = 'PLM100024'; //产品编码需传入
+        $params['BuyCount'] = 1;
+        $params['MOrderID'] = $order_sn;
+        $params['CustomerIP'] = config::API_IP;
+        $params['IsCallback'] = 1;
+        $params['CallBackUrl'] = config::NOTIFY_URL;
+        $params['Version'] = '1.0';
+        return $params;
+    }
+
+    //直充提单
+    public function add($card_no, $card_type, $amount, $params)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($order_sn);
+
+        $params['ChargeAccount'] = $card_no;
+        $params['ChargeAccountType'] = 1;//账号类型1 手机号,2 QQ号,3 微信号
+
+        $sign = $this->sign($params);
+        $params['Sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params);
+
+        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'] == 999) {
+                return [true, $resp['OrderModel']['OrderId'], false];
+            } else {
+                return [false, $resp['Msg'], false];
+            }
+        }
+    }
+
+    public function CardOrderAdd($card_no, $card_type, $amount, $params)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($order_sn);
+
+        $params['PublicKey'] = $this->CT_RSA($params['order_id']);
+
+        $sign = $this->sign($params);
+        $params['Sign'] = $sign;
+
+        $resp = http_request(config::CARD_ORDER_URL, $params);
+
+        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'] == 999) {
+                return [true, $resp['OrderModel']['OrderId'], false];
+            } else {
+                return [false, $resp['Msg'], false];
+            }
+        }
+    }
+
+    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;
+        $params['TimesTamp'] = time();
+        $params['MOrderID'] = $refill_info['order_sn'];
+        $params['Version'] = '1.0';
+
+        $content = config::APP_KEY . $params['TimesTamp'] . $params['Version'] . $params['MOrderID'] . config::App_Secret;
+        $params['Sign'] = strtoupper(md5($content));
+
+        $resp = http_request(config::QUERY_URL, $params);
+
+        if (empty($resp)) {
+            return [false, '网络错误', []];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误', []];
+            }
+            elseif ($resp['Code'] == 999)
+            {
+                $status = intval($resp['Data']['OrderState']);
+                $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);
+
+                        $card_data = [];
+                        foreach ($cards as $card) {
+                            $card_data[] = json_decode($card, true);
+                        }
+                        //需返回卡密信息
+                    }
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === 3) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($status, [1,4])) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $resp['Message'], $card_data];
+                }
+                return [true, $order_state, $card_data];
+            }
+            else
+            {
+                return [false, $resp['Message'], []];
+            }
+        }
+    }
+
+    private function rsa_decode($card_data,$private_key)
+    {
+        $res = openssl_pkey_get_private($private_key);
+        //使用私钥解密数据
+        openssl_private_decrypt($card_data, $decrypted, $res);
+        return $decrypted;
+    }
+
+    private function sign($params)
+    {
+        $content = config::APP_KEY . $params['BuyCount'] . $params['CallBackUrl'] . $params['ChargeAccount'] . $params['CustomerIP'] . $params['MOrderID'];
+        $content .= $params['ProductCode'] . $params['TimesTamp'] . $params['Version'] . config::App_Secret;
+        return strtoupper(md5($content));
+    }
+}

+ 24 - 0
helper/refill/api/lingzh/app/api.txt

@@ -0,0 +1,24 @@
+视频会员系统
+
+前台登录地址:http://video.member.sctongqian.com
+登录账号 15756480554
+登录密码LZ88888888
+
+----------------------接口相关-----------------------
+AppKey   211394768
+AppSecret   vA+24E7SOUWPAIHvNMdXyw==
+
+直充订单提交地址
+http://video.api.sctongqian.com/Order/DirectOrder
+
+卡密订单提交接口地址
+http://video.api.sctongqian.com/Order/CardOrder
+
+订单查询地址
+http://video.api.sctongqian.com/Business/QueryOrder
+
+余额查询地址
+http://video.api.sctongqian.com/Business/QueryAmount
+
+
+

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

@@ -0,0 +1,24 @@
+<?php
+namespace refill\app;
+
+
+class config
+{
+    //正式地址及正式账号信息
+//    const ORDER_URL = 'http://video.api.sctongqian.com/Order/DirectOrder';//直充订单提交地址
+//    const CARD_ORDER_URL = 'http://video.api.sctongqian.com/Order/CardOrder';//卡密订单提交地址
+//    const QUERY_URL= 'http://video.api.sctongqian.com/Business/QueryOrder';
+//    const APP_KEY= 211394768;
+//    const App_Secret = 'vA+24E7SOUWPAIHvNMdXyw==';
+
+    //沙箱环境账号
+    const ORDER_URL = 'http://182.150.21.90:8050/Order/DirectOrder';//直充订单提交地址
+    const CARD_ORDER_URL = 'http://182.150.21.90:8050/Order/CardOrder';//卡密订单提交地址
+    const QUERY_URL= 'http://182.150.21.90:8050/Business/QueryOrder';
+    const APP_KEY= 211394658;
+    const App_Secret = 'ZZV9akQWGkmR0ln6zOGmsQ==';
+
+//    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;
+}

BIN
helper/refill/api/lingzh/app/产品报价表B.xlsx


BIN
helper/refill/api/lingzh/app/综合充值系统接口文档(V1.5).docx


+ 4 - 0
racc/callback/lingzh/app.php

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

File diff suppressed because it is too large
+ 39 - 0
test/TestRefill.php