ソースを参照

Merge branch 'raccount' of 39.97.239.116:gyfl/xyzshop into raccount

stanley-king 1 ヶ月 前
コミット
ce494b2d47

+ 12 - 12
data/config/yl/phone.ini.php

@@ -2773,8 +2773,8 @@ $techaohe_trd_phone = [
 //        ]
     ]
 ];
-$nantai_phone = [
-    'name' => 'nantai', 'store_id' => 364, 'qualitys' => '1', 'official_sn' => true, 'refill_type' => 'api',
+$canbin_phone = [
+    'name' => 'canbin', 'store_id' => 364, 'qualitys' => '1', 'official_sn' => true, 'refill_type' => 'api',
     'amount' => [
 //        10 => [
 //            ['goods_id' => 8930, 'price' => 10, 'quality' => 1, 'card_type' => 'chinamobile'],
@@ -2818,8 +2818,8 @@ $nantai_phone = [
 //        ]
     ]
 ];
-$nantai_sec_phone = [
-    'name' => 'nantai_sec', 'store_id' => 365, 'qualitys' => '1', 'official_sn' => true, 'refill_type' => 'api',
+$canbin_sec_phone = [
+    'name' => 'canbin_sec', 'store_id' => 365, 'qualitys' => '1', 'official_sn' => true, 'refill_type' => 'api',
     'amount' => [
 //        10 => [
 //            ['goods_id' => 8938, 'price' => 10, 'quality' => 1, 'card_type' => 'chinamobile'],
@@ -2863,8 +2863,8 @@ $nantai_sec_phone = [
 //        ]
     ]
 ];
-$nantai_jingdong_phone = [
-    'name' => 'nantai_jingdong', 'store_id' => 366, 'qualitys' => '1', 'official_sn' => true, 'refill_type' => 'api',
+$canbin_jingdong_phone = [
+    'name' => 'canbin_jingdong', 'store_id' => 366, 'qualitys' => '1', 'official_sn' => true, 'refill_type' => 'api',
     'amount' => [
 //        10 => [
 //            ['goods_id' => 8946, 'price' => 10, 'quality' => 1, 'card_type' => 'chinamobile'],
@@ -2892,8 +2892,8 @@ $nantai_jingdong_phone = [
 //        ]
     ]
 ];
-$nantai_fs_phone = [
-    'name' => 'nantai_fs', 'store_id' => 367, 'qualitys' => '1', 'official_sn' => true, 'refill_type' => 'api',
+$canbin_fs_phone = [
+    'name' => 'canbin_fs', 'store_id' => 367, 'qualitys' => '1', 'official_sn' => true, 'refill_type' => 'api',
     'amount' => [
 //        10 => [
 //            ['goods_id' => 8954, 'price' => 10, 'quality' => 1, 'card_type' => 'chinamobile'],
@@ -3063,9 +3063,9 @@ $phone_providers = [
     [ 'name' => 'cuanqi_sec', 'cfg' => $cuanqi_sec_phone ],
     [ 'name' => 'tetengsu_sec', 'cfg' => $tetengsu_sec_phone ],
     [ 'name' => 'techaohe_trd', 'cfg' => $techaohe_trd_phone ],
-    [ 'name' => 'nantai', 'cfg' => $nantai_phone ],
-    [ 'name' => 'nantai_sec', 'cfg' => $nantai_sec_phone ],
-    [ 'name' => 'nantai_jingdong', 'cfg' => $nantai_jingdong_phone ],
-    [ 'name' => 'nantai_fs', 'cfg' => $nantai_fs_phone ],
+    [ 'name' => 'canbin', 'cfg' => $canbin_phone ],
+    [ 'name' => 'canbin_sec', 'cfg' => $canbin_sec_phone ],
+    [ 'name' => 'canbin_jingdong', 'cfg' => $canbin_jingdong_phone ],
+    [ 'name' => 'canbin_fs', 'cfg' => $canbin_fs_phone ],
     [ 'name' => 'yeyekcthreehv', 'cfg' => $yeyekcthreehv_phone ],
 	];

+ 39 - 0
helper/refill/api/yl/canbin/API.MD

@@ -0,0 +1,39 @@
+## 灿彬全国1号
+
+### 正式环境:
+- 话费下单地址:http://8.154.19.179:16188/plat/api/hf/submitorder
+- 查询地址:http://8.154.19.179:16188/plat/api/queryorder
+- 查询余额地址:http://8.154.19.179:16188/plat/api/querybalance
+
+- 客户端地址:http://8.154.19.179:16188/plat/login
+- 账号:南泰全国1
+- 密码:nt123456
+- 客户ID:100003
+- 密钥:aa5303ead7314d2ea5f4145d908b7bfb
+
+### 对接文档地址:
+> https://docs.qq.com/doc/DWEhQWEhDVEJIdUVC
+
+### 店铺账号
+- canbin
+- nantai67890
+
+### 产品编码
+```angular2html
+全国1账户产品 移动30-200 折扣96.8
+全国移动200元 1000200
+全国移动100元 1000100
+全国移动50元 1000050
+全国移动30元 1000030
+
+全国1账户产品 联通 30-200 折扣94
+全国联通200元 2000200
+全国联通100元 2000100
+全国联通50元 2000050
+全国联通30元 2000030
+
+全国1账户产品 电信 50-200 折扣97.2
+全国电信200元 3000200
+全国电信100元 3000100
+全国电信50元 3000050
+```

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

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

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

@@ -0,0 +1,47 @@
+<?php
+
+
+namespace refill\canbin;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://8.154.19.179:16188/plat/api/hf/submitorder';
+    const QUERY_URL= 'http://8.154.19.179:16188/plat/api/queryorder';
+    const BALANCE_URL = 'http://8.154.19.179:16188/plat/api/querybalance';
+
+    const USER_ID= '100003';
+    const KEY = 'aa5303ead7314d2ea5f4145d908b7bfb';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_canbin.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,
+        ],
+    ];
+}

+ 64 - 0
helper/refill/api/yl/canbin_fs/API.MD

@@ -0,0 +1,64 @@
+## 灿彬分省
+
+### 正式环境:
+- 话费下单地址:http://8.154.19.179:16188/plat/api/hf/submitorder
+- 查询地址:http://8.154.19.179:16188/plat/api/queryorder
+- 查询余额地址:http://8.154.19.179:16188/plat/api/querybalance
+
+- 客户端地址:http://8.154.19.179:16188/plat/login
+- 账号:南泰分省
+- 密码:nt123456
+- 客户ID:100006
+- 密钥:a783bf4f3d9643c8ad098c566f659469
+
+### 对接文档地址:
+> https://docs.qq.com/doc/DWEhQWEhDVEJIdUVC
+
+### 店铺账号
+- canbin_fs
+- nantai_fs67890
+
+### 产品编码
+```angular2html
+分省账户产品 移动 50-200 折扣95
+陕西移动200元 1610200
+陕西移动100元 1610100
+陕西移动50元 1610050
+
+广东移动200元 1440200
+广东移动100元 1440100
+广东移动50元 1440050
+
+湖南移动200元 1430200
+湖南移动100元 1430100
+湖南移动50元 1430050
+
+江苏移动200元 1320200
+江苏移动100元 1320100
+江苏移动50元 1320050
+
+天津移动200元 1120200
+天津移动100元 1120100
+天津移动50元 1120050
+
+分省账户产品 电信 50-200 折扣95
+甘肃电信200元 3620200
+甘肃电信100元 3620100
+甘肃电信50元 3620050
+
+陕西电信200元 3610200
+陕西电信100元 3610100
+陕西电信50元 3610050
+
+广东电信200元 3440200
+广东电信100元 3440100
+广东电信50元 3440050
+
+湖南电信200元 3430200
+湖南电信100元 3430100
+湖南电信50元 3430050
+
+天津电信200元 3120200
+天津电信100元 3120100
+天津电信50元 3120050
+```

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

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

@@ -0,0 +1,165 @@
+<?php
+
+namespace refill\canbin_fs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/canbin_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, string $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);
+    }
+}

+ 115 - 0
helper/refill/api/yl/canbin_fs/config.php

@@ -0,0 +1,115 @@
+<?php
+
+
+namespace refill\canbin_fs;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://8.154.19.179:16188/plat/api/hf/submitorder';
+    const QUERY_URL= 'http://8.154.19.179:16188/plat/api/queryorder';
+    const BALANCE_URL = 'http://8.154.19.179:16188/plat/api/querybalance';
+
+    const USER_ID= '100006';
+    const KEY = 'a783bf4f3d9643c8ad098c566f659469';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_canbin_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 => [
+            //陕西
+            27 => [
+                50  => 1610050,
+                100 => 1610100,
+                200 => 1610200,
+            ],
+            //广东
+            19 => [
+                50  => 1440050,
+                100 => 1440100,
+                200 => 1440200,
+            ],
+            //湖南
+            18 => [
+                50  => 1430050,
+                100 => 1430100,
+                200 => 1430200,
+            ],
+            //江苏
+            10 => [
+                50  => 1320050,
+                100 => 1320100,
+                200 => 1320200,
+            ],
+            //天津
+            2 => [
+                50  => 1120050,
+                100 => 1120100,
+                200 => 1120200,
+            ],
+
+        ],
+        mtopcard\ChinaUnicomCard => [
+
+        ],
+        mtopcard\ChinaTelecomCard => [
+            //甘肃
+            28 => [
+                50  => 3620050,
+                100 => 3620100,
+                200 => 3620200,
+            ],
+            //陕西
+            27 => [
+                50  => 3610050,
+                100 => 3610100,
+                200 => 3610200,
+            ],
+            //广东
+            19 => [
+                50  => 3440050,
+                100 => 3440100,
+                200 => 3440200,
+            ],
+            //湖南
+            18 => [
+                50  => 3430050,
+                100 => 3430100,
+                200 => 3430200,
+            ],
+            //天津
+            2 => [
+                50  => 3120050,
+                100 => 3120100,
+                200 => 3120200,
+            ],
+        ]
+    ];
+
+    //key格式 卡类型-面值-regin_no
+    const Price = [
+        //移动
+        "4-50-27" => 47.5, "4-100-27" => 95, "4-200-27" => 190, //陕西
+        "4-50-19" => 47.5, "4-100-19" => 95, "4-200-19" => 190, //广东
+        "4-50-18" => 47.5, "4-100-18" => 95, "4-200-18" => 190, //湖南
+        "4-50-10" => 47.5, "4-100-10" => 95, "4-200-10" => 190, //江苏
+        "4-50-2" => 47.5, "4-100-2" => 95, "4-200-2" => 190, //天津
+
+        //电信
+        "6-50-28" => 47.5, "6-100-28" => 95, "6-200-28" => 190, //甘肃
+        "6-50-27" => 47.5, "6-100-27" => 95, "6-200-27" => 190, //陕西
+        "6-50-19" => 47.5, "6-100-19" => 95, "6-200-19" => 190, //广东
+        "6-50-18" => 47.5, "6-100-18" => 95, "6-200-18" => 190, //湖南
+        "6-50-2" => 47.5, "6-100-2" => 95, "6-200-2" => 190, //天津
+    ];
+}

+ 27 - 0
helper/refill/api/yl/canbin_jingdong/API.MD

@@ -0,0 +1,27 @@
+## 灿彬京东
+
+### 正式环境:
+- 话费下单地址:http://8.154.19.179:16188/plat/api/hf/submitorder
+- 查询地址:http://8.154.19.179:16188/plat/api/queryorder
+- 查询余额地址:http://8.154.19.179:16188/plat/api/querybalance
+
+- 客户端地址:http://8.154.19.179:16188/plat/login
+- 账号:南泰京东
+- 密码:nt123456
+- 客户ID:100005
+- 密钥:8a7df5c90c4948fa870316a844c19f21
+
+### 对接文档地址:
+> https://docs.qq.com/doc/DWEhQWEhDVEJIdUVC
+
+### 店铺账号
+- canbin_jingdong
+- nantai_jingdong67890
+
+### 产品编码
+```angular2html
+南泰京东账户 产品 移动 50-200 折扣96.8
+全国移动200元 1000200
+全国移动100元 1000100
+全国移动50元 1000050
+```

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

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

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

+ 41 - 0
helper/refill/api/yl/canbin_jingdong/config.php

@@ -0,0 +1,41 @@
+<?php
+
+
+namespace refill\canbin_jingdong;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://8.154.19.179:16188/plat/api/hf/submitorder';
+    const QUERY_URL= 'http://8.154.19.179:16188/plat/api/queryorder';
+    const BALANCE_URL = 'http://8.154.19.179:16188/plat/api/querybalance';
+
+    const USER_ID= '100005';
+    const KEY = '8a7df5c90c4948fa870316a844c19f21';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_canbin_jingdong.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 => [
+            50 => 1000050,
+            100 => 1000100,
+            200 => 1000200,
+        ],
+        mtopcard\ChinaUnicomCard => [
+
+        ],
+        mtopcard\ChinaTelecomCard => [
+
+        ],
+    ];
+}

+ 38 - 0
helper/refill/api/yl/canbin_sec/API.MD

@@ -0,0 +1,38 @@
+## 灿彬全国2号
+
+### 正式环境:
+- 话费下单地址:http://8.154.19.179:16188/plat/api/hf/submitorder
+- 查询地址:http://8.154.19.179:16188/plat/api/queryorder
+- 查询余额地址:http://8.154.19.179:16188/plat/api/querybalance
+
+- 客户端地址:http://8.154.19.179:16188/plat/login
+- 账号:南泰全国2
+- 密码:nt123456
+- 客户ID:100004
+- 密钥:9dcb870c4fa74dc4abbaf9152c572c5a
+
+### 对接文档地址:
+> https://docs.qq.com/doc/DWEhQWEhDVEJIdUVC
+
+### 店铺账号
+- canbin_sec
+- nantai_sec67890
+
+### 产品编码
+```angular2html
+全国2账户产品 移动50-200 折扣97
+全国移动200元 1000200
+全国移动100元 1000100
+全国移动50元 1000050
+
+全国2账户 联通30-200 折扣94.6
+全国联通200元 2000200
+全国联通100元 2000100
+全国联通50元 2000050
+全国联通30元 2000030
+
+全国2账户产品 电信50-200 折扣97.2
+全国电信200元 3000200
+全国电信100元 3000100
+全国电信50元 3000050
+```

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

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

@@ -0,0 +1,146 @@
+<?php
+
+namespace refill\canbin_sec;
+
+require_once(BASE_HELPER_RAPI_PATH . '/canbin_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);
+    }
+}

+ 46 - 0
helper/refill/api/yl/canbin_sec/config.php

@@ -0,0 +1,46 @@
+<?php
+
+
+namespace refill\canbin_sec;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://8.154.19.179:16188/plat/api/hf/submitorder';
+    const QUERY_URL= 'http://8.154.19.179:16188/plat/api/queryorder';
+    const BALANCE_URL = 'http://8.154.19.179:16188/plat/api/querybalance';
+
+    const USER_ID= '100004';
+    const KEY = '9dcb870c4fa74dc4abbaf9152c572c5a';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_canbin_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 => [
+            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_canbin.php

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

+ 4 - 0
mobile/callback/refill_canbin_fs.php

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

+ 4 - 0
mobile/callback/refill_canbin_jingdong.php

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

+ 4 - 0
mobile/callback/refill_canbin_sec.php

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