浏览代码

Merge branch 'rch' into raccount

zhaoming 1 年之前
父节点
当前提交
ef43786dd2

+ 14 - 0
data/config/xyz/refill.ini.php

@@ -9918,6 +9918,19 @@ $yiqiandq_fs_phone = ['name' => 'yiqiandq_fs', 'store_id' => 378, 'qualitys' =>
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$liantuo_high_phone = ['name' => 'liantuo_high', 'store_id' => 379, 'qualitys' => '1',
+    'amount' => [
+//        10 => [['goods_id' => 8969, 'price' => 9.8, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        20 => [['goods_id' => 8970, 'price' => 19.6, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 8971, 'price' => 29.4, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 8972, 'price' => 49, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 8973, 'price' => 98, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 8974, 'price' => 196, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        300 => [['goods_id' => 8975, 'price' => 294, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        500 => [['goods_id' => 8976, 'price' => 490, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_p hone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -10217,6 +10230,7 @@ $phone_providers = [
     ['name' => 'yeyekami', 'cfg' => $yeyekami_phone],
     ['name' => 'yiqiandq', 'cfg' => $yiqiandq_phone],
     ['name' => 'yiqiandq_fs', 'cfg' => $yiqiandq_fs_phone],
+    ['name' => 'liantuo_high', 'cfg' => $liantuo_high_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 40 - 0
helper/refill/api/xyz/liantuo_high/API.MD

@@ -0,0 +1,40 @@
+
+## 联拓普充话费全国
+
+### 账号:
+- 登陆账号:福庆顺高价
+- 登陆密码:123456
+- 商户号:10002623
+- 秘钥:ZnxYb4PH34HhznSZDhfnmJYx53EJeRdF
+### 下游客户注册和登录地址:
+> http://139.9.203.254:7080/
+- api接口文档地址:
+ - https://www.showdoc.com.cn/AQL666666/
+- 话费下单地址:
+ - http://139.9.203.254:9086/onlinepay.do
+- 订单主动查询地址:
+ - http://139.9.203.254:9086/searchpay.do
+- 余额查询:
+- http://139.9.203.254:9086/searchbalance.do
+## 店铺
+- 账号:liantuo_high
+- 密码:liantuo_high67890
+
+### 编码
+- 全国移动
+  - 30面值编码101687,  
+  - 50面值编码101688 ,
+  - 100面值编码101689,  
+  - 200面值编码101690
+
+- 全国联通
+  - 30面值编码101705,
+  - 50面值编码101706,
+  - 100面值编码101707,
+  - 200面值编码101708
+
+- 全国电信
+  - 30面值编码101723,
+  - 50面值编码101724,
+  - 100面值编码101725,
+  - 200面值编码101726

+ 49 - 0
helper/refill/api/xyz/liantuo_high/RefillCallBack.php

@@ -0,0 +1,49 @@
+<?php
+namespace refill\liantuo_high;
+
+require_once(BASE_HELPER_RAPI_PATH . '/liantuo_high/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): string
+    {
+        $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): array
+    {
+        $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) {
+            $official_sn = strtolower($params['remark1']) == 'null' ? '' : $params['remark1'];
+            $data['official_sn'] = $official_sn;
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true, $official_sn];
+        } elseif ($status === 9) {
+            return [$order_id, false, true, true, ''];
+        } else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 163 - 0
helper/refill/api/xyz/liantuo_high/RefillPhone.php

@@ -0,0 +1,163 @@
+<?php
+
+namespace refill\liantuo_high;
+
+require_once(BASE_HELPER_RAPI_PATH . '/liantuo_high/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, $card_type, string $order_sn): array
+    {
+        $params['userid'] = config::USER_ID;
+        $productid = config::ProductIdS[$card_type][$amount] ?? false;
+        if ($productid === false){
+            return [];
+        }
+
+        $params['productid'] = $productid;
+        $params['price'] = $amount;
+        $params['num'] = 1;
+        $params['mobile'] = $phone;
+        $params['spordertime'] = date("YmdHis");
+        $params['sporderid'] = $order_sn;
+        $params['back_url'] = config::NOTIFY_URL;
+        $params['paytype'] = config::operator[$card_type];
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
+        if (empty($params)) {
+            return [false, '产品编码有误', false];
+        }
+
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
+
+        if (empty($resp)) {
+            return [false, '网络错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            }
+
+            $resultno = $resp['resultno'];
+            if (in_array($resultno, ['0', '2'], true)) {
+                return [true, $resp['orderid'], false];
+            } elseif (in_array($resultno, config::ERR_NOS, true)) {
+                return [false, $resultno, false];
+            } elseif ($resultno === '9999' || $resultno === '5006') {
+                $net_errno = "HTTP-{$resultno}";
+                return [false, $resultno, true];
+            } else {
+                //未知结果码
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resultno, true];
+            }
+        }
+    }
+
+    public function query($refill_info): array
+    {
+        $params['userid'] = config::USER_ID;
+        $params['sporderid'] = $refill_info['order_sn'];
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&sporderid={$params['sporderid']}&key={$key}";
+        $params['sign'] = strtoupper(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 = $this->xmlToArray($resp);
+            if (empty($resp))
+            {
+                return [false, '网络错误', ''];
+            }
+            else
+            {
+                $official_sn = !empty($resp['remark1']) ? $resp['remark1'] : '';
+
+                $resultno = $resp['resultno'];
+                if ($resultno === '1') {
+                    $updata['official_sn'] = $official_sn;
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($resultno === '9') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($resultno === '5007' && (time() - $refill_info['commit_time'] > 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    $order_state = ORDER_STATE_SEND;
+                }
+
+                return [true, $order_state, $official_sn];
+            }
+        }
+    }
+
+    public function balance(): array
+    {
+        $params['userid'] = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&key={$key}";
+        $params['sign'] = strtoupper(md5($content));
+
+        $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['resultno'] === '1') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['resultno']];
+            }
+        }
+    }
+
+    private function sign($params): string
+    {
+        $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 strtoupper(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 refill\util::xmlToArray($xml);
+    }
+}

+ 50 - 0
helper/refill/api/xyz/liantuo_high/config.php

@@ -0,0 +1,50 @@
+<?php
+
+
+namespace refill\liantuo_high;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://139.9.203.254:9086/onlinepay.do';
+    const QUERY_URL= 'http://139.9.203.254:9086/searchpay.do';
+    const BALANCE_URL = 'http://139.9.203.254:9086/searchbalance.do';
+
+    const USER_ID= '10002623';
+    const KEY = 'ZnxYb4PH34HhznSZDhfnmJYx53EJeRdF';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_liantuo_high.php";
+
+    const operator = [
+        mtopcard\ChinaMobileCard  => 'yd',
+        mtopcard\ChinaUnicomCard  => 'lt',
+        mtopcard\ChinaTelecomCard => 'dx'
+    ];
+    const ERR_NOS = [
+        '5001', '5002', '5003', '5004', '5005', '5008', '5009', '5010', '5011', '5012', '7001'
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;'];
+
+    const ProductIdS = [
+        mtopcard\ChinaMobileCard =>
+            [
+                30 => '101687',
+                50 => '101688',
+                100 => '101689',
+                200 => '101690'
+            ],
+        mtopcard\ChinaUnicomCard =>
+            [
+                30 => '101705',
+                50 => '101706',
+                100 => '101707',
+                200 => '101708'
+            ],
+        mtopcard\ChinaTelecomCard =>
+            [
+                30 => '101723',
+                50 => '101724',
+                100 => '101725',
+                200 => '101726'
+            ]
+    ];
+}

+ 4 - 0
mobile/callback/refill_liantuo_high.php

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

+ 7 - 0
test/TestRefill.php

@@ -5769,6 +5769,13 @@ class TestRefill extends TestCase
         $provider = $this->getProvider('guangxinxiaome');
         $resp = $provider->balance();
     }
+
+    public function testliantuo_high()
+    {
+        $provider = $this->getProvider('liantuo_high');
+//        $resp = $provider->balance();
+        $resp = $provider->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
+    }
 }