瀏覽代碼

wangliantx

xiaoyu 3 年之前
父節點
當前提交
84e778fcca

+ 51 - 0
helper/refill/api/xyz/wangliantx/RefillCallBack.php

@@ -0,0 +1,51 @@
+<?php
+namespace refill\wangliantx;
+
+require_once(BASE_HELPER_RAPI_PATH . '/wangliantx/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)
+    {
+        $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));
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['resultno']);
+        $order_sn = $params['sporderid'];
+        $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'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 9) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 160 - 0
helper/refill/api/xyz/wangliantx/RefillPhone.php

@@ -0,0 +1,160 @@
+<?php
+
+namespace refill\wangliantx;
+
+require_once(BASE_HELPER_RAPI_PATH . '/wangliantx/config.php');
+
+use refill;
+use Log;
+use mtopcard;
+
+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['productid'] = '';
+        $params['productType'] = '1';
+        $params['price'] = $amount;
+        $params['num'] = 1;
+        $params['mobile'] = $phone;
+        $params['spordertime'] = date("YmdHis");
+        $params['sporderid'] = $order_sn;
+        $params['back_url'] = 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, $amount, $order_sn);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $params['region'] = urlencode(mtopcard\ProvinceList[$regin_no]);
+        $params['operator'] = urlencode(config::operator[$card_type]);
+
+        $resp = http_request(config::ORDER_URL, $params);
+
+        if (empty($resp)) {
+            return [false, '网络错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            }
+            $resultno = intval($resp['resultno']);
+            if (in_array($resultno, [0, 1, 2])) {
+                return [true, $resp['orderid'], false];
+            } elseif ($resultno === 9999) {
+                $net_errno = "HTTP-{$resultno}";
+                return [false, $resultno, false];
+            } else {
+                return [false, $resultno, false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['sporderid'] = $refill_info['order_sn'];
+
+        $resp = http_request(config::QUERY_URL, $params);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp))
+            {
+                return [false, '网络错误'];
+            }
+            else
+            {
+                $resultno = intval($resp['resultno']);
+                if ($resultno === 1) {
+                    $updata['official_sn'] = $resp['remark1'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($resultno === 9) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($resultno, [0,2])) {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($resultno === 5007 && (time() - $refill_info['commit_time'] >= 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resultno];
+                }
+
+                return [true, $order_state];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['userid'] = config::USER_ID;
+        $key = config::KEY;
+        $body = "userid={$params['userid']}&key={$key}";
+        $params['sign'] = md5($body);
+
+        $resp = http_request(config::BALANCE_UTL, $params);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp))
+            {
+                return [false, '网络错误'];
+            }
+            else
+            {
+                if($resp['resultno'] == 1) {
+                    return [true, $resp['balance']];
+                }else {
+                    return [false, $resp['resultno']];
+                }
+
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $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 md5($content);
+    }
+
+    public function xmlToArray($xml)
+    {
+        $replace_str = str_replace(' ','','encoding="gb2312"');
+        $xml = mb_convert_encoding($xml,"UTF-8","gb2312");
+        $xml = str_replace($replace_str, "encoding='utf-8'", $xml);
+        return json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
+    }
+}

+ 21 - 0
helper/refill/api/xyz/wangliantx/config.php

@@ -0,0 +1,21 @@
+<?php
+
+
+namespace refill\wangliantx;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://39.99.143.124:8177/soft/onlinepay.do';
+    const QUERY_URL= 'http://39.99.143.124:8177/soft/searchpay.do';
+    const BALANCE_UTL = 'http://39.99.143.124:8177/soft/searchbalance.do';
+
+    const USER_ID= '10073664';
+    const KEY = 'ZcWJfd4Jt63JAwiymPEXzGDHyjy8H62F';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_wangliantx.php";
+    const operator = [
+        mtopcard\ChinaMobileCard  => '移动',
+        mtopcard\ChinaUnicomCard  => '联通',
+        mtopcard\ChinaTelecomCard => '电信'
+    ];
+}

二進制
helper/refill/api/xyz/wangliantx/代理接口话费充值文档1.0.6(2020).doc


+ 8 - 0
helper/refill/api/xyz/wangliantx/账号.txt

@@ -0,0 +1,8 @@
+代理系统:http://39.99.143.124:8178 
+账号yezi,密码123456
+id:    10073664
+密钥:ADE28CAF69A0FFE7E5E3C5FD5EBCA7F9
+
+余额查询接口:http://39.99.143.124:8177/soft/searchbalance.do
+充值请求接口:http://39.99.143.124:8177/soft/onlinepay.do
+订单查询接口:http://39.99.143.124:8177/soft/searchpay.do