浏览代码

椰林,兴创全国,兴创分省

lowkeyman 1 年之前
父节点
当前提交
12b6b5f03f

+ 84 - 0
data/config/yl/refill.ini.php

@@ -7986,6 +7986,88 @@ $yzpuchong2_phone = ['name' => 'yzpuchong2', 'store_id' => 308, 'qualitys' => '1
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$xingchuang_nation_phone = ['name' => 'xingchuang_nation', 'store_id' => 309, 'qualitys' => '1',
+    'amount' => [
+        10 => [
+//            ['goods_id' => 8483, 'price' => 9.7, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8483, 'price' => 9.4, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8483, 'price' => 9.75, 'quality' => 1, 'card_type' => 'chinatelecom'],
+        ],
+        20 => [
+//            ['goods_id' => 8484, 'price' => 19.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8484, 'price' => 18.8, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8484, 'price' => 19.5, 'quality' => 1, 'card_type' => 'chinatelecom'],
+        ],
+        30 => [
+            ['goods_id' => 8485, 'price' => 29.04, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8485, 'price' => 28.26, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8485, 'price' => 29.25, 'quality' => 1, 'card_type' => 'chinatelecom'],
+        ],
+        50 => [
+            ['goods_id' => 8486, 'price' => 48.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8486, 'price' => 47.1, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8486, 'price' => 48.75, 'quality' => 1, 'card_type' => 'chinatelecom'],
+        ],
+        100 => [
+            ['goods_id' => 8487, 'price' => 96.8, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8487, 'price' => 94.2, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8487, 'price' => 97.5, 'quality' => 1, 'card_type' => 'chinatelecom'],
+        ],
+        200 => [
+            ['goods_id' => 8488, 'price' => 193.6, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8488, 'price' => 188.4, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8488, 'price' => 195, 'quality' => 1, 'card_type' => 'chinatelecom'],
+        ],
+//        300 => [
+//            ['goods_id' => 8489, 'price' => 291, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8489, 'price' => 282, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8489, 'price' => 292.5, 'quality' => 1, 'card_type' => 'chinatelecom'],
+//        ],
+//        500 => [
+//            ['goods_id' => 8490, 'price' => 485, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8490, 'price' => 470, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8490, 'price' => 487.5, 'quality' => 1, 'card_type' => 'chinatelecom'],
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+$xingchuang_fs_phone = ['name' => 'xingchuang_fs', 'store_id' => 310, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 8491, 'price' => 9.54, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8491, 'price' => 9.42, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 8492, 'price' => 19.08, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8492, 'price' => 18.84, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+        30 => [
+//            ['goods_id' => 8493, 'price' => 28.62, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8493, 'price' => 28.26, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 8494, 'price' => 47.7, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8494, 'price' => 47.1, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 8495, 'price' => 95.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8495, 'price' => 94.2, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 8496, 'price' => 190.8, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8496, 'price' => 188.4, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+//        300 => [
+//            ['goods_id' => 8497, 'price' => 286.2, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8497, 'price' => 282.6, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        500 => [
+//            ['goods_id' => 8498, 'price' => 477, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8498, 'price' => 471, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -8241,6 +8323,8 @@ $phone_providers = [
     ['name' => 'beirui_trd', 'cfg' => $beirui_trd_phone],
     ['name' => 'yezipczy', 'cfg' => $yezipczy_phone],
     ['name' => 'yzpuchong2', 'cfg' => $yzpuchong2_phone],
+    ['name' => 'xingchuang_nation', 'cfg' => $xingchuang_nation_phone],
+    ['name' => 'xingchuang_fs', 'cfg' => $xingchuang_fs_phone],
 ];
 
 $config['phone_providers'] = $phone_providers;

+ 56 - 0
helper/refill/api/yl/xingchuang_fs/API.MD

@@ -0,0 +1,56 @@
+## 兴创分省
+
+### 正式环境:
+- 话费下单地址:http://121.43.238.2:16188/plat/api/hf/submitorder
+- 查询地址:http://121.43.238.2:16188/plat/api/queryorder
+- 查询余额地址:http://121.43.238.2:16188/plat/api/querybalance
+
+- 客户端地址: http://121.43.238.2:16188/plat/login
+- 账号:兴创分省
+- 密码:123456
+- ID   :   100002
+- 秘钥:82eb8599a2964066b54b7f0df753f089
+
+### 对接文档地址
+> https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
+
+### 店铺账号
+- xingchuang_fs
+- xingchuang_fs67890
+
+### 折扣
+- 分省移动
+  - 贵州 50-200 折扣93.7
+  - 云南 50-200 折扣94.7
+  - 甘肃 50-200 折扣94.7
+  - 江西 50-200 折扣94.7
+  - 湖南 50-200 折扣94.7
+  - 陕西 50-200 折扣95.4
+  - 江苏50-200 折扣95.4
+  - 天津50-200 折扣95.4
+  - 浙江50-200 折扣95.4
+  - 上海50-200 折扣95.4
+  - 山东50-200 折扣95.4
+  - 辽宁50-200 折扣95.4
+  - 安徽50-200 折扣95.4
+  - 北京50-200 折扣95.4
+  - 广西50-200 折扣95.4
+  - 黑龙江50-200 折扣95.4
+
+- 分省电信
+  - 福建30-200 折扣94.2
+  - 重庆30-200 折扣94.2
+  - 江苏30-200 折扣94.2
+  - 山东30-200 折扣94.2
+  - 北京30-200 折扣94.2
+  - 广东30-200 折扣94.2
+  - 安徽30-200 折扣94.2
+  - 上海30-200 折扣94.2
+  - 新疆30-200 折扣94.2
+  - 浙江30-200 折扣94.2
+  - 湖北30-200 折扣94.2
+  - 广西30-200 折扣93.2
+  - 四川30-200 折扣93.2
+  - 天津30-200 折扣93.2
+  - 湖南30-200 折扣93.2
+  - 青海30-200 折扣93.2

+ 52 - 0
helper/refill/api/yl/xingchuang_fs/RefillCallBack.php

@@ -0,0 +1,52 @@
+<?php
+namespace refill\xingchuang_fs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xingchuang_fs/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, ''];
+        }
+    }
+}

+ 165 - 0
helper/refill/api/yl/xingchuang_fs/RefillPhone.php

@@ -0,0 +1,165 @@
+<?php
+
+namespace refill\xingchuang_fs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xingchuang_fs/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, $regin_no)
+    {
+        $params['szAgentId'] = config::USER_ID;
+        $params['szOrderId'] = $order_sn;
+        $params['szPhoneNum'] = $phone;
+        $params['nMoney'] = $amount;
+        $params['nSortType'] = config::operator[$card_type];
+        $params['szProductId'] = config::Product[$card_type][$regin_no][$amount];
+        $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'];
+        $regin_no = $params['regin_no'] ?? -1;
+
+        if($regin_no <= 0) {
+            return [false, '省份获取错误', false];
+        }
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn, $regin_no);
+
+        $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 = $resp['nRtn'];
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            } elseif ($nRtn === 0) {
+                return [true, '', false];
+            } elseif (in_array($nRtn, config::ERR_NOS, true)) {
+                return [false, $resp['szRtnCode'], false];
+            } elseif (in_array($nRtn, [2050, 999], true)) {
+                $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 = $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],true)) {
+                $order_state = ORDER_STATE_SEND;
+            } elseif ($status === 5005 && (time() - $refill_info['commit_time'] >= 300)) {
+                $order_state = ORDER_STATE_NOEXIST;
+            } else {
+                return [false, $resp['szRtnMsg'], ''];
+            }
+
+            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);
+    }
+}

+ 283 - 0
helper/refill/api/yl/xingchuang_fs/config.php

@@ -0,0 +1,283 @@
+<?php
+
+
+namespace refill\xingchuang_fs;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://121.43.238.2:16188/plat/api/hf/submitorder';
+    const QUERY_URL= 'http://121.43.238.2:16188/plat/api/queryorder';
+    const BALANCE_URL = 'http://121.43.238.2:16188/plat/api/querybalance';
+
+    const USER_ID= '100002';
+    const KEY = '82eb8599a2964066b54b7f0df753f089';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xingchuang_fs.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
+    ];
+
+    const Product = [
+        mtopcard\ChinaMobileCard => [
+            //贵州
+            24 => [
+                50  => 1520050,
+                100 => 1520100,
+                200 => 1520200,
+            ],
+            //云南
+            25 => [
+                50  => 1530050,
+                100 => 1530100,
+                200 => 1530200,
+            ],
+            //甘肃
+            28 => [
+                50  => 1620050,
+                100 => 1620100,
+                200 => 1620200,
+            ],
+            //江西
+            14 => [
+                50  => 1360050,
+                100 => 1360100,
+                200 => 1360200,
+            ],
+            //湖南
+            18 => [
+                50  => 1430050,
+                100 => 1430100,
+                200 => 1430200,
+            ],
+            //陕西
+            27 => [
+                50  => 1610050,
+                100 => 1610100,
+                200 => 1610200,
+            ],
+            //江苏
+            10 => [
+                50  => 1320050,
+                100 => 1320100,
+                200 => 1320200,
+            ],
+            //天津
+            2 => [
+                50  => 1120050,
+                100 => 1120100,
+                200 => 1120200,
+            ],
+            //浙江
+            11 => [
+                50  => 1330050,
+                100 => 1330100,
+                200 => 1330200,
+            ],
+            //上海
+            9 => [
+                50  => 1310050,
+                100 => 1310100,
+                200 => 1310200,
+            ],
+            //山东
+            15 => [
+                50  => 1370050,
+                100 => 1370100,
+                200 => 1370200,
+            ],
+            //辽宁
+            6 => [
+                50  => 1210050,
+                100 => 1210100,
+                200 => 1210200,
+            ],
+            //安徽
+            12 => [
+                50  => 1340050,
+                100 => 1340100,
+                200 => 1340200,
+            ],
+            //北京
+            1 => [
+                50  => 1110050,
+                100 => 1110100,
+                200 => 1110200,
+            ],
+            //广西
+            20 => [
+                50  => 1450050,
+                100 => 1450100,
+                200 => 1450200,
+            ],
+            //黑龙江
+            8 => [
+                50  => 1230050,
+                100 => 1230100,
+                200 => 1230200,
+            ],
+        ],
+        mtopcard\ChinaTelecomCard => [
+            //福建
+            13 => [
+                30  => 3350030,
+                50  => 3350050,
+                100 => 3350100,
+                200 => 3350200,
+            ],
+            //重庆
+            22 => [
+                30  => 3500030,
+                50  => 3500050,
+                100 => 3500100,
+                200 => 3500200,
+            ],
+            //江苏
+            10 => [
+                30  => 3320030,
+                50  => 3320050,
+                100 => 3320100,
+                200 => 3320200,
+            ],
+            //山东
+            15 => [
+                30  => 3370030,
+                50  => 3370050,
+                100 => 3370100,
+                200 => 3370200,
+            ],
+            //北京
+            1 => [
+                30  => 3110030,
+                50  => 3110050,
+                100 => 3110100,
+                200 => 3110200,
+            ],
+            //广东
+            19 => [
+                30  => 3440030,
+                50  => 3440050,
+                100 => 3440100,
+                200 => 3440200,
+            ],
+            //安徽
+            12 => [
+                30  => 3340030,
+                50  => 3340050,
+                100 => 3340100,
+                200 => 3340200,
+            ],
+            //上海
+            9 => [
+                30  => 3310030,
+                50  => 3310050,
+                100 => 3310100,
+                200 => 3310200,
+            ],
+            //新疆
+            31 => [
+                30  => 3650030,
+                50  => 3650050,
+                100 => 3650100,
+                200 => 3650200,
+            ],
+            //浙江
+            11 => [
+                30  => 3330030,
+                50  => 3330050,
+                100 => 3330100,
+                200 => 3330200,
+            ],
+            //湖北
+            17 => [
+                30  => 3420030,
+                50  => 3420050,
+                100 => 3420100,
+                200 => 3420200,
+            ],
+            //广西
+            20 => [
+                30  => 3450030,
+                50  => 3450050,
+                100 => 3450100,
+                200 => 3450200,
+            ],
+            //四川
+            23 => [
+                30  => 3510030,
+                50  => 3510050,
+                100 => 3510100,
+                200 => 3510200,
+            ],
+            //天津
+            2 => [
+                30  => 3120030,
+                50  => 3120050,
+                100 => 3120100,
+                200 => 3120200,
+            ],
+            //湖南
+            18 => [
+                30  => 3430030,
+                50  => 3430050,
+                100 => 3430100,
+                200 => 3430200,
+            ],
+            //青海
+            29 => [
+                30  => 3630030,
+                50  => 3630050,
+                100 => 3630100,
+                200 => 3630200,
+            ],
+
+        ],
+    ];
+
+    //key格式 卡类型-面值-regin_no
+    const Price = [
+        //移动
+        "4-50-24" => 46.85, "4-100-24" => 93.7, "4-200-24" => 187.4, //贵州
+        "4-50-25" => 47.35, "4-100-25" => 94.7, "4-200-25" => 189.4, //云南
+        "4-50-28" => 47.35, "4-100-28" => 94.7, "4-200-28" => 189.4, //甘肃
+        "4-50-14" => 47.35, "4-100-14" => 94.7, "4-200-14" => 189.4, //江西
+        "4-50-18" => 47.35, "4-100-18" => 94.7, "4-200-18" => 189.4, //湖南
+        "4-50-27" => 47.7, "4-100-27" => 95.4, "4-200-27" => 190.8, //陕西
+        "4-50-10" => 47.7, "4-100-10" => 95.4, "4-200-10" => 190.8, //江苏
+        "4-50-2" => 47.7, "4-100-2" => 95.4, "4-200-2" => 190.8, //天津
+        "4-50-11" => 47.7, "4-100-11" => 95.4, "4-200-11" => 190.8, //浙江
+        "4-50-9" => 47.7, "4-100-9" => 95.4, "4-200-9" => 190.8, //上海
+        "4-50-15" => 47.7, "4-100-15" => 95.4, "4-200-15" => 190.8, //山东
+        "4-50-6" => 47.7, "4-100-6" => 95.4, "4-200-6" => 190.8, //辽宁
+        "4-50-12" => 47.7, "4-100-12" => 95.4, "4-200-12" => 190.8, //安徽
+        "4-50-1" => 47.7, "4-100-1" => 95.4, "4-200-1" => 190.8, //北京
+        "4-50-20" => 47.7, "4-100-20" => 95.4, "4-200-20" => 190.8, //广西
+        "4-50-8" => 47.7, "4-100-8" => 95.4, "4-200-8" => 190.8, //黑龙江
+
+        //电信
+        "6-30-13" => 28.26, "6-50-13" => 47.1, "6-100-13" => 94.2, "6-200-13" => 188.4, //福建
+        "6-30-22" => 28.26, "6-50-22" => 47.1, "6-100-22" => 94.2, "6-200-22" => 188.4, //重庆
+        "6-30-10" => 28.26, "6-50-10" => 47.1, "6-100-10" => 94.2, "6-200-10" => 188.4, //江苏
+        "6-30-15" => 28.26, "6-50-15" => 47.1, "6-100-15" => 94.2, "6-200-15" => 188.4, //山东
+        "6-30-1" => 28.26, "6-50-1" => 47.1, "6-100-1" => 94.2, "6-200-1" => 188.4, //北京
+        "6-30-19" => 28.26, "6-50-19" => 47.1, "6-100-19" => 94.2, "6-200-19" => 188.4, //广东
+        "6-30-12" => 28.26, "6-50-12" => 47.1, "6-100-12" => 94.2, "6-200-12" => 188.4, //安徽
+        "6-30-9" => 28.26, "6-50-9" => 47.1, "6-100-9" => 94.2, "6-200-9" => 188.4, //上海
+        "6-30-31" => 28.26, "6-50-31" => 47.1, "6-100-31" => 94.2, "6-200-31" => 188.4, //新疆
+        "6-30-11" => 28.26, "6-50-11" => 47.1, "6-100-11" => 94.2, "6-200-11" => 188.4, //浙江
+        "6-30-17" => 28.26, "6-50-17" => 47.1, "6-100-17" => 94.2, "6-200-17" => 188.4, //湖北
+        "6-30-20" => 27.96, "6-50-20" => 46.6, "6-100-20" => 93.2, "6-200-20" => 186.4, //广西
+        "6-30-23" => 27.96, "6-50-23" => 46.6, "6-100-23" => 93.2, "6-200-23" => 186.4, //四川
+        "6-30-2" => 27.96, "6-50-2" => 46.6, "6-100-2" => 93.2, "6-200-2" => 186.4, //天津
+        "6-30-18" => 27.96, "6-50-18" => 46.6, "6-100-18" => 93.2, "6-200-18" => 186.4, //湖南
+        "6-30-29" => 27.96, "6-50-29" => 46.6, "6-100-29" => 93.2, "6-200-29" => 186.4, //青海
+    ];
+
+}

二进制
helper/refill/api/yl/xingchuang_fs/product_code.xlsx


+ 31 - 0
helper/refill/api/yl/xingchuang_nation/API.MD

@@ -0,0 +1,31 @@
+## 兴创全国
+
+### 正式环境:
+- 话费下单地址:http://121.43.238.2:16188/plat/api/hf/submitorder
+- 查询地址:http://121.43.238.2:16188/plat/api/queryorder
+- 查询余额地址:http://121.43.238.2:16188/plat/api/querybalance
+
+- 客户端地址:http://121.43.238.2:16188/plat/login
+- 账号:兴创全国
+- 密码:123456
+- 客户ID:100001
+- 密钥:9dbf5d54c8ca48cb85b9894b0fad9fe8
+
+### 对接文档地址:
+> https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
+
+### 店铺账号
+- xingchuang_nation
+- xingchuang_nation67890
+### 产品编码
+- 联通30-200,折扣 942产品编码:
+  - 30 2000030
+  - 50 2000050
+  - 100 2000100
+  - 200 2000200
+
+- 移动全国的30-200,折扣 968产品编码:
+  - 30 1000030
+  - 50 1000050
+  - 100 1000100
+  - 200 1000200

+ 52 - 0
helper/refill/api/yl/xingchuang_nation/RefillCallBack.php

@@ -0,0 +1,52 @@
+<?php
+namespace refill\xingchuang_nation;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xingchuang_nation/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, ''];
+        }
+    }
+}

+ 146 - 0
helper/refill/api/yl/xingchuang_nation/RefillPhone.php

@@ -0,0 +1,146 @@
+<?php
+
+namespace refill\xingchuang_nation;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xingchuang_nation/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['szAgentId'] = config::USER_ID;
+        $params['szOrderId'] = $order_sn;
+        $params['szPhoneNum'] = $phone;
+        $params['nMoney'] = $amount;
+        $params['nSortType'] = config::operator[$card_type];
+        $params['szProductId'] = config::Product[$card_type][$amount];
+        $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 = $resp['nRtn'];
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            } elseif ($nRtn === 0) {
+                return [true, '', false];
+            } elseif (in_array($nRtn, config::ERR_NOS, true)) {
+                return [false, $resp['szRtnCode'], false];
+            } elseif (in_array($nRtn, [2050, 999], true)) {
+                $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 = $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],true)) {
+                $order_state = ORDER_STATE_SEND;
+            } elseif ($status === 5005 && (time() - $refill_info['commit_time'] > 300)) {
+                $order_state = ORDER_STATE_NOEXIST;
+            } else {
+                return [false, $resp['szRtnMsg'], ''];
+            }
+
+            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);
+    }
+}

+ 47 - 0
helper/refill/api/yl/xingchuang_nation/config.php

@@ -0,0 +1,47 @@
+<?php
+
+
+namespace refill\xingchuang_nation;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://121.43.238.2:16188/plat/api/hf/submitorder';
+    const QUERY_URL= 'http://121.43.238.2:16188/plat/api/queryorder';
+    const BALANCE_URL = 'http://121.43.238.2:16188/plat/api/querybalance';
+
+    const USER_ID= '100001';
+    const KEY = '9dbf5d54c8ca48cb85b9894b0fad9fe8';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xingchuang_nation.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
+    ];
+
+    const Product = [
+        mtopcard\ChinaMobileCard => [
+            30  => 1000030,
+            50  => 1000050,
+            100 => 1000100,
+            200 => 1000200,
+        ],
+        mtopcard\ChinaUnicomCard => [
+            30  => 2000030,
+            50  => 2000050,
+            100 => 2000100,
+            200 => 2000200,
+        ],
+        mtopcard\ChinaTelecomCard => [
+            50  => 3000050,
+            100 => 3000100,
+            200 => 3000200,
+        ],
+    ];
+}

+ 4 - 0
mobile/callback/refill_xingchuang_fs.php

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

+ 4 - 0
mobile/callback/refill_xingchuang_nation.php

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

+ 12 - 0
test/TestRefill.php

@@ -5905,6 +5905,18 @@ class TestRefill extends TestCase
         $provider = $this->getProvider('yeyekami_fast');
         $resp = $provider->balance();
     }
+
+    public function testxingchuang_nation()
+    {
+        $provider = $this->getProvider('xingchuang_nation');
+        $resp = $provider->balance();
+    }
+
+    public function testxingchuang_fs()
+    {
+        $provider = $this->getProvider('xingchuang_fs');
+        $resp = $provider->balance();
+    }
 }