浏览代码

椰子快充通道,韬讯

lowkeyman 1 年之前
父节点
当前提交
51d2eeb532

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

@@ -10674,6 +10674,35 @@ $zunni_phone = ['name' => 'zunni', 'store_id' => 397, 'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$taoxun_phone = ['name' => 'taoxun', 'store_id' => 398, 'qualitys' => '2',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 9148, 'price' => 10, 'quality' => 2, 'card_type' => 'chinamobile'],
+//        ],
+//        20 => [
+//            ['goods_id' => 9149, 'price' => 20, 'quality' => 2, 'card_type' => 'chinamobile'],
+//        ],
+//        30 => [
+//            ['goods_id' => 9150, 'price' => 30, 'quality' => 2, 'card_type' => 'chinamobile'],
+//        ],
+//        50 => [
+//            ['goods_id' => 9151, 'price' => 50, 'quality' => 2, 'card_type' => 'chinamobile'],
+//        ],
+        100 => [
+            ['goods_id' => 9152, 'price' => 100.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+        ],
+        200 => [
+            ['goods_id' => 9153, 'price' => 200.3, 'quality' => 2, 'card_type' => 'chinamobile'],
+        ],
+        300 => [
+            ['goods_id' => 9154, 'price' => 300.45, 'quality' => 2, 'card_type' => 'chinamobile'],
+        ],
+        500 => [
+            ['goods_id' => 9155, 'price' => 500.75, 'quality' => 2, 'card_type' => 'chinamobile'],
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_p hone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -10992,6 +11021,7 @@ $phone_providers = [
     ['name' => 'menshang_sec', 'cfg' => $menshang_sec_phone],
     ['name' => 'yeyepucnt', 'cfg' => $yeyepucnt_phone],
     ['name' => 'zunni', 'cfg' => $zunni_phone],
+    ['name' => 'taoxun', 'cfg' => $taoxun_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 21 - 0
helper/refill/api/xyz/taoxun/API.MD

@@ -0,0 +1,21 @@
+### 韬讯
+后台地址:http://dm.duomilife.top/
+帐号:guoyan
+密码:058977
+二级密码:cQNk3322
+appId:OxsfUz4EmK
+appSecret:iBrdSRAaAHfNyAMQ
+后台-商品列表,可查看已配置商品信息
+后台-安全中心,可配置IP白名单
+接口文档:https://www.showdoc.com.cn/2167197494741781/9729864782737996
+话费直充接口:http://39.101.178.136:8911/api/hf/order/submit
+通用直充接口:http://39.101.178.136:8911/api/order/submit
+卡密提取接口:http://39.101.178.136:8911/api/card/get
+查询接口接口:http://39.101.178.136:8911/api/order/query
+余额查询接口:http://39.101.178.136:8911/api/account/balance
+
+运营商	面值	    折扣	        商品编码
+移动	    100	    100.2%	    100256
+移动	    200	    100.15%	    100257
+移动	    300	    100.15%	    100308
+移动	    500	    100.15%	    100307

+ 68 - 0
helper/refill/api/xyz/taoxun/RefillCallBack.php

@@ -0,0 +1,68 @@
+<?php
+namespace refill\taoxun;
+
+require_once(BASE_HELPER_RAPI_PATH . '/taoxun/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['sign']);
+        $sign = $this->sign($input);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
+        return md5($content);
+    }
+
+    private function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['orderStatus']);
+        $order_sn = $params['outOrderId'];
+        $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
+        if (empty($order_info)) {
+            return [false, false, false, false, ''];
+        }
+
+        $order_id = $order_info['order_id'];
+        if ($status === 2) {
+            $official_sn = strtolower($params['ext1']) == 'null' ? '' : $params['ext1'];
+            $data['official_sn'] = $official_sn;
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true, $official_sn];
+        } elseif ($status === 3) {
+            return [$order_id, false, true, true, ''];
+        } else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 158 - 0
helper/refill/api/xyz/taoxun/RefillPhone.php

@@ -0,0 +1,158 @@
+<?php
+
+namespace refill\taoxun;
+
+require_once(BASE_HELPER_RAPI_PATH . '/taoxun/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['appId'] = config::APP_ID;
+        $params['outOrderId'] = $order_sn;
+        $params['uuid'] = $phone;
+        $params['itemId'] = config::PRODUCT[$card_type][$amount];
+        $params['itemFace'] = $amount;
+        $params['callbackUrl'] = config::NOTIFY_URL;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
+        if(empty($params['itemId'])) {
+            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 = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            } elseif ($resp['code'] === '00') {
+                return [true, $resp['orderId'], false];
+            } elseif (in_array($resp['code'], config::ERRCODES, true)) {
+                return [false, $resp['msg'], false];
+            } elseif (in_array($resp['code'], ['-22', '-23', '-99'], true)) {
+                $net_errno = "HTTP-{$resp['code']}";
+                return [false, $resp['msg'], true];
+            } else {
+                $net_errno = "HTTP-998";
+                return [false, $resp['msg'], true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['appId'] = config::APP_ID;
+        $params['outOrderId'] = $refill_info['order_sn'];
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
+
+        $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, '网络错误', ''];
+            }
+            elseif ($resp['code'] === '00')
+            {
+                $official_sn = '';
+
+                $status = $resp['orderStatus'];
+                if ($status === '2') {
+                    $official_sn = $resp['ext1'];
+                    $updata['official_sn'] = $official_sn;
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === '3') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === '1') {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($status === '4' && (time() - $refill_info['commit_time'] >= 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resp['msg'], ''];
+                }
+                return [true, $order_state, $official_sn];
+            }
+            else
+            {
+                return [false, $resp['msg'], ''];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['appId'] = config::APP_ID;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::BALANCE_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, '网络错误'];
+            } elseif ($resp['code'] === '00') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function get_millisecond()
+    {
+        list($usec, $sec) = explode(" ", microtime());
+        return round($usec*1000);
+    }
+
+    private function sign($params)
+    {
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
+        return md5($content);
+    }
+}

+ 34 - 0
helper/refill/api/xyz/taoxun/config.php

@@ -0,0 +1,34 @@
+<?php
+
+
+namespace refill\taoxun;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://39.101.178.136:8911/api/hf/order/submit';
+    const QUERY_URL = 'http://39.101.178.136:8911/api/order/query';
+    const BALANCE_URL = 'http://39.101.178.136:8911/api/account/balance';
+
+    const APP_ID = 'OxsfUz4EmK';
+    const APP_SECRET = 'iBrdSRAaAHfNyAMQ';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_taoxun.php";
+
+    const PRODUCT = [
+        mtopcard\ChinaMobileCard => [
+            100 => 100256,
+            200 => 100257,
+            300 => 100308,
+            500 => 100307,
+        ],
+
+        mtopcard\ChinaUnicomCard => [
+
+        ],
+        mtopcard\ChinaTelecomCard => [
+
+        ]
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ERRCODES = ['-10', '-12', '-13', '-14', '-15', '-16', '-18', '-21'];
+}

+ 4 - 0
mobile/callback/refill_taoxun.php

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

+ 6 - 0
test/TestRefill.php

@@ -5992,6 +5992,12 @@ class TestRefill extends TestCase
         $resp = $provider->balance();
     }
 
+    public function testtaoxun()
+    {
+        $provider = $this->getProvider('taoxun');
+        $resp = $provider->balance();
+    }
+
 }