Explorar el Código

椰子,秒信通分省3号

zhaoming hace 1 año
padre
commit
3f34c9887c

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

@@ -10185,6 +10185,19 @@ $yiqian_tax_phone = ['name' => 'yiqian_tax', 'store_id' => 385, 'qualitys' => '2
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$miaoxt_fs_three_phone = ['name' => 'miaoxt_fs_three', 'store_id' => 386, 'qualitys' => '2',
+    'amount' => [
+        10 => [['goods_id' => 9025, 'price' => 10.05, 'quality' => 2, 'card_type' => 'chinamobile']],
+        20 => [['goods_id' => 9026, 'price' => 20.1, 'quality' => 2, 'card_type' => 'chinamobile']],
+        30 => [['goods_id' => 9027, 'price' => 30.15, 'quality' => 2, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 9028, 'price' => 50.25, 'quality' => 2, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 9029, 'price' => 100.5, 'quality' => 2, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 9030, 'price' => 201, 'quality' => 2, 'card_type' => 'chinamobile']],
+        300 => [['goods_id' => 9031, 'price' => 301.5, 'quality' => 2, 'card_type' => 'chinamobile']],
+        500 => [['goods_id' => 9032, 'price' => 502.5, 'quality' => 2, 'card_type' => 'chinamobile']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_p hone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -10491,6 +10504,7 @@ $phone_providers = [
 //    ['name' => 'beirui_trd', 'cfg' => $beirui_trd_phone],
     ['name' => 'weisanhuo', 'cfg' => $weisanhuo_phone],
 //    ['name' => 'yiqian_tax', 'cfg' => $yiqian_tax_phone],
+    ['name' => 'miaoxt_fs_three', 'cfg' => $miaoxt_fs_three_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 17 - 0
helper/refill/api/xyz/miaoxt_fs_three/API.MD

@@ -0,0 +1,17 @@
+## 秒信通分分省3号
+### 账号信息
+- 账户:112901
+- 密码:gy123456
+- 秘钥:06f547ff6c1a4a3ab888f23b48238e0c
+- ID:200138
+- 前台:http://47.118.46.242:10186/plat/index
+### 接口信息
+- 话费下单地址:http://47.118.46.242:10186/plat/api/old/submitorder
+- 查询地址:http://47.118.46.242:10186/plat/api/old/queryorder
+- 查询余额地址:http://47.118.46.242:10186/plat/api/old/queryBalance
+- 文档地址:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
+### 店铺账号
+- miaoxt_fs_three
+- miaoxt_fs_three67890
+### 面额&折扣
+> 辽宁移动,10-500,折扣100.5

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

@@ -0,0 +1,51 @@
+<?php
+namespace refill\miaoxt_fs_three;
+
+require_once(BASE_HELPER_RAPI_PATH . '/miaoxt_fs_three/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['szVerifyString'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "szAgentId={$userid}&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nDemo={$params['nDemo']}&fSalePrice={$params['fSalePrice']}";
+        $content .= "&nFlag={$params['nFlag']}&szKey={$key}";
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['nFlag']);
+        $order_sn = $params['szOrderId'];
+        $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['szRtnMsg']) == 'null' ? '' : $params['szRtnMsg'];
+            $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, ''];
+        }
+    }
+}

+ 159 - 0
helper/refill/api/xyz/miaoxt_fs_three/RefillPhone.php

@@ -0,0 +1,159 @@
+<?php
+
+namespace refill\miaoxt_fs_three;
+
+require_once(BASE_HELPER_RAPI_PATH . '/miaoxt_fs_three/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    public function goods($quality,int $amount,int $card_type,$regin_no,$other)
+    {
+        [$goods_id, $price] = parent::goods($quality,$amount,$card_type,$regin_no,$other);
+        if($goods_id <= 0) return [0,0];
+        $key = "{$card_type}-{$amount}-{$regin_no}";
+        $price = config::Price[$key];
+        if(empty($price)) {
+            Log::record("channel cannot find price where name={$this->mName}, goods_id = {$goods_id} card_type={$card_type} amount={$amount} regin_no={$regin_no}",Log::ERR);
+            return [0,0];
+        } else {
+            return [$goods_id,ncPriceFormat($price)];
+        }
+    }
+
+    private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
+    {
+        $params['szAgentId'] = config::USER_ID;
+        $params['szOrderId'] = $order_sn;
+        $params['szPhoneNum'] = $phone;
+        $params['nMoney'] = $amount;
+        $params['nSortType'] = config::operator[$card_type];
+        $params['nProductClass'] = 1;
+        $params['nProductType'] = 1;
+        $params['szTimeStamp'] = date("Y-m-d H:i:s");
+        $params['szNotifyUrl'] = config::NOTIFY_URL;
+        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);
+
+        $sign = $this->sign($params);
+        $params['szVerifyString'] = $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);
+            $nRtn = intval($resp['nRtn']);
+
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            } elseif ($nRtn == 0) {
+                return [true, '', false];
+            } elseif (in_array($nRtn, config::ERR_NOS)) {
+                if($nRtn === 2003) {
+                    refill\util::set_black($card_no);
+                }
+                return [false, $resp['szRtnCode'], false];
+            } elseif (in_array($nRtn, [2050, 999])) {
+                $net_errno = "HTTP-{$nRtn}";
+                return [false, $resp['szRtnCode'], true];
+            } else {
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resp['szRtnCode'], true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['szAgentId'] = config::USER_ID;
+        $params['szOrderId'] = $refill_info['order_sn'];
+        $key = config::KEY;
+        $content = "szAgentId={$params['szAgentId']}&szOrderId={$params['szOrderId']}&szKey={$key}";
+        $params['szVerifyString'] = 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 = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误', ''];
+            }
+            $official_sn = '';
+
+            $status = intval($resp['nRtn']);
+            if ($status === 5012) {
+                $official_sn = $resp['szRtnMsg'];
+                $updata['official_sn'] = $official_sn;
+                Model('refill_order')->edit($refill_info['order_id'], $updata);
+                $order_state = ORDER_STATE_SUCCESS;
+            } elseif ($status === 5013) {
+                $order_state = ORDER_STATE_CANCEL;
+            } elseif (in_array($status, [5011, 5019])) {
+                $order_state = ORDER_STATE_SEND;
+            } elseif ($status === 5005 && (time() - $refill_info['commit_time'] >= 300)) {
+                $order_state = ORDER_STATE_NOEXIST;
+            } else {
+                return [false, $status, ''];
+            }
+            return [true, $order_state, $official_sn];
+        }
+    }
+
+    public function balance()
+    {
+        $params['szAgentId'] = config::USER_ID;
+        $key = config::KEY;
+        $content = "szAgentId={$params['szAgentId']}&szKey={$key}";
+        $params['szVerifyString'] = 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 = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['nRtn'] == 0) {
+                return [true, $resp['fBalance']];
+            } else {
+                return [false, $resp['szRtnCode']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "szAgentId={$userid}&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nMoney={$params['nMoney']}&nSortType={$params['nSortType']}";
+        $content .= "&nProductClass={$params['nProductClass']}&nProductType={$params['nProductType']}&szTimeStamp={$params['szTimeStamp']}&szKey={$key}";
+        return md5($content);
+    }
+}

+ 32 - 0
helper/refill/api/xyz/miaoxt_fs_three/config.php

@@ -0,0 +1,32 @@
+<?php
+
+
+namespace refill\miaoxt_fs_three;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://47.118.46.242:10186/plat/api/old/submitorder';
+    const QUERY_URL= 'http://47.118.46.242:10186/plat/api/old/queryorder';
+    const BALANCE_URL = 'http://47.118.46.242:10186/plat/api/old/queryBalance';
+
+    const USER_ID= '200138';
+    const KEY = '06f547ff6c1a4a3ab888f23b48238e0c';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_miaoxt_fs_three.php";
+    const operator = [
+        mtopcard\ChinaMobileCard  => 1,
+        mtopcard\ChinaUnicomCard  => 2,
+        mtopcard\ChinaTelecomCard => 3
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+
+    const ERR_NOS = [
+        1000,1001,1003,1004,2001,2002,2003,2020,2021,1006,2030,3003
+    ];
+
+    //key格式 卡类型-面值-regin_no
+    const Price = [
+        //移动
+        "4-10-6" => 10.05, "4-20-6" => 20.1, "4-30-6" => 30.15, "4-50-6" => 50.25, "4-100-6" => 100.5, "4-200-6" => 201, "4-300-6" => 301.5, "4-500-6" => 502.5,//辽宁 6
+    ];
+}

+ 4 - 0
mobile/callback/refill_miaoxt_fs_three.php

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

+ 6 - 0
test/TestRefill.php

@@ -5829,6 +5829,12 @@ class TestRefill extends TestCase
 //        $resp = $provider->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
 //        $resp = $provider->query(['order_sn' => '24271700815859899563']);
     }
+
+    public function testmiaoxt_fs_three()
+    {
+        $provider = $this->getProvider('miaoxt_fs_three');
+        $resp = $provider->balance();
+    }
 }