فهرست منبع

椰子,兴创全国2号

lowkeyman 1 سال پیش
والد
کامیت
bee743578b

+ 47 - 1
data/config/xyz/refill.ini.php

@@ -10408,6 +10408,51 @@ $huifen_fast_phone = ['name' => 'huifen_fast', 'store_id' => 391, 'qualitys' =>
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$xingchuang_sec_phone = ['name' => 'xingchuang_sec', 'store_id' => 392, 'qualitys' => '1',
+    'amount' => [
+        10 => [
+//            ['goods_id' => 9073, 'price' => 9.7, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9073, 'price' => 9.4, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9073, 'price' => 9.75, 'quality' => 1, 'card_type' => 'chinatelecom'],
+        ],
+        20 => [
+//            ['goods_id' => 9074, 'price' => 19.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9074, 'price' => 18.8, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9074, 'price' => 19.5, 'quality' => 1, 'card_type' => 'chinatelecom'],
+        ],
+        30 => [
+            ['goods_id' => 9075, 'price' => 29.04, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9075, 'price' => 28.26, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9075, 'price' => 29.25, 'quality' => 1, 'card_type' => 'chinatelecom'],
+        ],
+        50 => [
+            ['goods_id' => 9076, 'price' => 48.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9076, 'price' => 47.1, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9076, 'price' => 48.75, 'quality' => 1, 'card_type' => 'chinatelecom'],
+        ],
+        100 => [
+            ['goods_id' => 9077, 'price' => 96.8, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9077, 'price' => 94.2, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9077, 'price' => 97.5, 'quality' => 1, 'card_type' => 'chinatelecom'],
+        ],
+        200 => [
+            ['goods_id' => 9078, 'price' => 193.6, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9078, 'price' => 188.4, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9078, 'price' => 195, 'quality' => 1, 'card_type' => 'chinatelecom'],
+        ],
+        300 => [
+            ['goods_id' => 9079, 'price' => 290.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9079, 'price' => 282, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9079, 'price' => 292.5, 'quality' => 1, 'card_type' => 'chinatelecom'],
+        ],
+//        500 => [
+//            ['goods_id' => 9080, 'price' => 485, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9080, 'price' => 470, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9080, 'price' => 487.5, 'quality' => 1, 'card_type' => 'chinatelecom'],
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_p hone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -10719,7 +10764,8 @@ $phone_providers = [
     ['name' => 'yeyekami_fast', 'cfg' => $yeyekami_fast_phone],
     ['name' => 'tengyoujun_ylyw', 'cfg' => $tengyoujun_ylyw_phone],
     ['name' => 'tengyoujun_yj', 'cfg' => $tengyoujun_yj_phone],
-    ['name' => 'huifen_fast', 'cfg' => $huifen_fast_phone],
+//    ['name' => 'huifen_fast', 'cfg' => $huifen_fast_phone],
+        ['name' => 'xingchuang_sec', 'cfg' => $xingchuang_sec_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 39 - 0
helper/refill/api/xyz/xingchuang_sec/API.MD

@@ -0,0 +1,39 @@
+## 兴创全国2号
+
+### 正式环境:
+- 话费下单地址: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
+- 账号:兴创全国2
+- 密码:123456
+- 客户ID:100003
+- 密钥:2201590e62154a62976d5bef043493a9
+
+### 对接文档地址:
+> https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
+
+### 店铺账号
+- xingchuang_sec
+- xingchuang_sec67890
+
+### 产品编码
+#### 全国
+> 联通30-200,折扣 942产品编码:
+- 30 2000030
+- 50 2000050
+- 100 2000100
+- 200 2000200
+
+> 移动全国的30-200,折扣 968产品编码:
+- 30 1000030
+- 50 1000050
+- 100 1000100
+- 200 1000200
+- 300 1000300
+
+> 全国电信 50-200 折扣:975
+- 全国电信50元 3000050
+- 全国电信100元 3000100
+- 全国电信200元 3000200

+ 52 - 0
helper/refill/api/xyz/xingchuang_sec/RefillCallBack.php

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

@@ -0,0 +1,146 @@
+<?php
+
+namespace refill\xingchuang_sec;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xingchuang_sec/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/xyz/xingchuang_sec/config.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace refill\xingchuang_sec;
+
+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= '100003';
+    const KEY = '2201590e62154a62976d5bef043493a9';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xingchuang_sec.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,
+            300 => 1000300,
+        ],
+        mtopcard\ChinaUnicomCard => [
+            30  => 2000030,
+            50  => 2000050,
+            100 => 2000100,
+            200 => 2000200,
+        ],
+        mtopcard\ChinaTelecomCard => [
+            50  => 3000050,
+            100 => 3000100,
+            200 => 3000200,
+        ],
+    ];
+}

+ 4 - 0
mobile/callback/refill_xingchuang_sec.php

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

+ 6 - 0
test/TestRefill.php

@@ -5940,6 +5940,12 @@ class TestRefill extends TestCase
 //        $resp = $provider->query(['order_sn' => '39941705567795321592']); //充值中
         $resp = $provider->query(['order_sn' => '399417055677953215921']); //查询不存在的订单
     }
+
+    public function testxingchuang_sec()
+    {
+        $provider = $this->getProvider('xingchuang_sec');
+        $resp = $provider->balance();
+    }
 }