Bläddra i källkod

add xyz provider yunlingfs

ayHaru 4 år sedan
förälder
incheckning
078e46350b

+ 2 - 1
helper/fcgisrv/MobileServer.php

@@ -57,7 +57,8 @@ class MobileServer extends BaseServer
             'bridge_shr.php','refill_weit.php','refill_afand.php','refill_afandeng.php',
             'refill_afandnew.php','refill_lingzh.php','refill_lingzhdl.php','refill_tongy.php',
             'refill_weiyi.php','refill_tonglu.php','refill_xc.php','refill_xunyin.php',
-            'refill_yunling.php','refill_wantong.php'
+            'refill_yunling.php','refill_wantong.php','refill_zhongst.php','refill_luqian.php',
+            'refill_afandfs.php','refill_yunlingfs.php'
         ];
 
         $this->setExFiles($exfiles);

+ 55 - 0
helper/refill/api/xyz/yunlingfs/RefillCallBack.php

@@ -0,0 +1,55 @@
+<?php
+
+
+namespace refill\yunlingfs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yunlingfs/config.php');
+
+
+use refill;
+use Log;
+
+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 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['supnumber']) == 'null' ? '' : $params['supnumber'];
+            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];
+        }
+    }
+}

+ 154 - 0
helper/refill/api/xyz/yunlingfs/RefillPhone.php

@@ -0,0 +1,154 @@
+<?php
+
+namespace refill\yunlingfs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yunlingfs/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['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)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $order_sn);
+        $params['operator'] = config::operator[$card_type];
+        $region = $this->getPhoneInfo($card_no);
+        if($region === false) {
+            return [false, '归属地获取失败', false];
+        }
+
+        $params['region'] = $region;
+        $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 = $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];
+            } else {
+                return [false, $resp['message'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['sporderid'] = $refill_info['order_sn'];
+        $params['userid'] = config::USER_ID;
+
+        $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, '网络错误'];
+            }
+            $resultno = intval($resp['resultno']);
+            if ($resultno === 1) {
+                $order_state = ORDER_STATE_SUCCESS;
+                $updata['official_sn'] = $resp['supnumber'];
+                Model('refill_order')->edit($refill_info['order_id'], $updata);
+            } elseif ($resultno === 9) {
+                $order_state = ORDER_STATE_CANCEL;
+            } elseif (in_array($resultno, [0,2])) {
+                $order_state = ORDER_STATE_SEND;
+            } else {
+                return [false, $resp['message']];
+            }
+            return [true, $order_state];
+        }
+    }
+
+    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)
+    {
+        //禁止引用外部xml实体
+        libxml_disable_entity_loader(true);
+        $xmlstring = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
+        $val = json_decode(json_encode($xmlstring), true);
+
+        return $val;
+    }
+
+    private function getPhoneInfo($phone)
+    {
+        $url = "https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel={$phone}";
+        $resp = http_request($url);  //获取API返回 的数据
+        $resp = mb_convert_encoding($resp, 'UTF-8', 'UTF-8,GBK,GB2312,BIG5'); //解决中文乱码
+
+        $datas = explode('=', $resp);
+        if(count($datas) == 2)
+        {
+            $body = trim($datas[1]);
+            if(preg_match_all("/(\w+):'([^']+)/", $body, $m)) {
+                $res = array_combine($m[1], $m[2]);
+                return $this->formatProvince($res['province']);
+            }
+        }
+        return false;
+    }
+
+    public function formatProvince(string $province) : string
+    {
+        if(empty($province)) {
+            return '';
+        }
+
+        $checkArr = ["省","市","自治区","特别行政区"];
+
+        for($i = 0; $i < count($checkArr); $i++) {
+            if(strpos($province, $checkArr[$i]) === false) {
+                continue;
+            } else {
+                $province = mb_strcut($province, 0, strrpos($province, $checkArr[$i]));
+            }
+        }
+
+        return $province;
+    }
+}

+ 19 - 0
helper/refill/api/xyz/yunlingfs/config.php

@@ -0,0 +1,19 @@
+<?php
+
+
+namespace refill\yunlingfs;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://39.101.180.197:8177/soft/onlinepay.do';
+    const QUERY_URL= 'http://39.101.180.197:8177/soft/searchpay.do';
+    const USER_ID= '10073527';
+    const KEY = 'BA804D1914CFCDD19AB86EED110E0EF4';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/refill_yunlingfs.php";
+    const operator = [
+        mtopcard\ChinaMobileCard  => '移动',
+        mtopcard\ChinaUnicomCard  => '联通',
+        mtopcard\ChinaTelecomCard => '电信'
+    ];
+}

BIN
helper/refill/api/xyz/yunlingfs/代理接口话费充值文档1.0.6(2020).doc


+ 9 - 0
helper/refill/api/xyz/yunlingfs/北京椰子账户信息 (3.txt

@@ -0,0 +1,9 @@
+http://39.101.180.197:8178  代理系统
+登陆名:yezifs 
+ID:10073527
+秘钥:BA804D1914CFCDD19AB86EED110E0EF4
+密码:yezi131419
+
+余额查询接口:http://39.101.180.197:8177/soft/searchbalance.do
+充值请求接口:http://39.101.180.197:8177/soft/onlinepay.do
+订单查询接口:http://39.101.180.197:8177/soft/searchpay.do

+ 4 - 0
mobile/refill_yunlingfs.php

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