Bläddra i källkod

椰子 晟翀全国2号,椰林 晟翀全国1号 晟翀分省

晟翀分省未开启,未提供产品编码和折扣
lowkeyman 5 månader sedan
förälder
incheckning
fc49865d53

+ 46 - 1
data/config/xyz/phone.ini.php

@@ -3658,7 +3658,51 @@ $jiahu_fs_phone = [
 			]
 		]
 	];
-
+$chengchong_sec_phone = [
+    'name' => 'chengchong_sec', 'store_id' => 422, 'qualitys' => '1', 'official_sn' => true, 'refill_type' => 'api',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 9328, 'price' => 10, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9328, 'price' => 10, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9328, 'price' => 10, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 9329, 'price' => 20, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9329, 'price' => 20, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9329, 'price' => 20, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+        30 => [
+//            ['goods_id' => 9330, 'price' => 30, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9330, 'price' => 28.41, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9330, 'price' => 30, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 9331, 'price' => 48.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9331, 'price' => 47.35, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9331, 'price' => 48.6, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 9332, 'price' => 97, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9332, 'price' => 94.7, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9332, 'price' => 97.2, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 9333, 'price' => 194, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9333, 'price' => 189.4, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9333, 'price' => 194.4, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+//            ['goods_id' => 9334, 'price' => 300, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9334, 'price' => 300, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9334, 'price' => 291.6, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+//        500 => [
+//            ['goods_id' => 9335, 'price' => 500, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9335, 'price' => 500, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9335, 'price' => 501, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ]
+    ]
+];
 
 $phone_providers = [
 	[ 'name' => 'xunyin', 'cfg' => $xunyin_phone ],
@@ -3769,4 +3813,5 @@ $phone_providers = [
 	[ 'name' => 'xinbao_small', 'cfg' => $xinbao_small_phone ],
 	[ 'name' => 'zhixin', 'cfg' => $zhixin_phone ],
 	[ 'name' => 'jiahu_fs', 'cfg' => $jiahu_fs_phone ],
+    [ 'name' => 'chengchong_sec', 'cfg' => $chengchong_sec_phone ],
 	];

+ 92 - 1
data/config/yl/phone.ini.php

@@ -4559,7 +4559,96 @@ $yuankun_phone = [
         ]
     ]
 ];
-
+$chengchong_phone = [
+    'name' => 'chengchong', 'store_id' => 338, 'qualitys' => '1', 'official_sn' => true, 'refill_type' => 'api',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 8713, 'price' => 10, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8713, 'price' => 10, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8713, 'price' => 10, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 8714, 'price' => 20, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8714, 'price' => 20, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8714, 'price' => 20, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+        30 => [
+            ['goods_id' => 8715, 'price' => 29.04, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8715, 'price' => 28.26, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8715, 'price' => 30, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 8716, 'price' => 48.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8716, 'price' => 47.1, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8716, 'price' => 48.6, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 8717, 'price' => 96.8, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8717, 'price' => 94.2, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8717, 'price' => 97.2, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 8718, 'price' => 193.6, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8718, 'price' => 188.4, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8718, 'price' => 194.4, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+//            ['goods_id' => 8719, 'price' => 300, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8719, 'price' => 300, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8719, 'price' => 291.6, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+//        500 => [
+//            ['goods_id' => 8720, 'price' => 500, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8720, 'price' => 500, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8720, 'price' => 501, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ]
+    ]
+];
+$chengchong_fs_phone = [
+    'name' => 'chengchong_fs', 'store_id' => 339, 'qualitys' => '1', 'official_sn' => true, 'refill_type' => 'api',
+    'amount' => [
+        10 => [
+            ['goods_id' => 8721, 'price' => 10, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8721, 'price' => 10, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8721, 'price' => 10, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        20 => [
+            ['goods_id' => 8722, 'price' => 20, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8722, 'price' => 20, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8722, 'price' => 20, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        30 => [
+            ['goods_id' => 8723, 'price' => 30, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8723, 'price' => 30, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8723, 'price' => 30, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 8724, 'price' => 50, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8724, 'price' => 40, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8724, 'price' => 40, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 8725, 'price' => 100, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8725, 'price' => 100, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8725, 'price' => 100, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 8726, 'price' => 200, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8726, 'price' => 200, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8726, 'price' => 200, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 8727, 'price' => 300, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8727, 'price' => 300, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8727, 'price' => 300, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 8728, 'price' => 500, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8728, 'price' => 500, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8728, 'price' => 500, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ]
+    ]
+];
 
 $phone_providers = [
     ['name' => 'yunling', 'cfg' => $yunling_phone],
@@ -4730,4 +4819,6 @@ $phone_providers = [
     ['name' => 'miaofeng', 'cfg' => $miaofeng_phone],
     ['name' => 'miaofeng_fs', 'cfg' => $miaofeng_fs_phone],
     ['name' => 'yuankun', 'cfg' => $yuankun_phone],
+    ['name' => 'chengchong', 'cfg' => $chengchong_phone],
+//    ['name' => 'chengchong_fs', 'cfg' => $chengchong_fs_phone],
 ];

+ 35 - 0
helper/refill/api/xyz/chengchong_sec/API.MD

@@ -0,0 +1,35 @@
+## 晟翀全国2号
+
+### 正式环境:
+- 话费下单地址:http://121.41.62.169:16188/plat/api/hf/submitorder
+- 查询地址:http://121.41.62.169:16188/plat/api/queryorder
+- 查询余额地址:http://121.41.62.169:16188/plat/api/querybalance
+
+- 客户端地址:http://121.41.62.169:16188/plat/login
+- 账号:炫捷全国2
+- 密码:xj123456
+- 客户ID:100003
+- 密钥:fb3e8a79f7074387a48dfd66c6868277
+
+### 对接文档地址:
+> https://docs.qq.com/doc/DWEhQWEhDVEJIdUVC
+
+### 店铺账号
+- chengchong_sec
+- chengchong_sec67890
+
+### 产品编码
+炫捷全国2账户产品:
+全国移动200元 1000200 折扣97
+全国移动100元 1000100
+全国移动50元 1000050
+
+全国联通200元 2000200 折扣94.7
+全国联通100元 2000100
+全国联通50元 2000050
+全国联通30元 2000030
+
+全国电信300元 3000300 折扣97.2
+全国电信200元 3000200
+全国电信100元 3000100
+全国电信50元 3000050

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

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

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

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

+ 36 - 0
helper/refill/api/yl/chengchong/API.MD

@@ -0,0 +1,36 @@
+## 晟翀全国1号
+
+### 正式环境:
+- 话费下单地址:http://121.41.62.169:16188/plat/api/hf/submitorder
+- 查询地址:http://121.41.62.169:16188/plat/api/queryorder
+- 查询余额地址:http://121.41.62.169:16188/plat/api/querybalance
+
+- 客户端地址:http://121.41.62.169:16188/plat/login
+- 账号:炫捷全国1
+- 密码:xj123456
+- 客户ID:100002
+- 密钥:7c42b26ba4434275b81aae266b97e982
+
+### 对接文档地址:
+> https://docs.qq.com/doc/DWEhQWEhDVEJIdUVC
+
+### 店铺账号
+- chengchong
+- chengchong67890
+
+### 产品编码
+全国移动30-200 折扣96.8
+全国移动200元 1000200
+全国移动100元 1000100
+全国移动50元 1000050
+全国移动30元 1000030
+
+全国联通200元 2000200 折扣94.2
+全国联通100元 2000100
+全国联通50元 2000050
+全国联通30元 2000030
+
+全国电信300元 3000300 折扣97.2
+全国电信200元 3000200
+全国电信100元 3000100
+全国电信50元 3000050

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

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

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

+ 48 - 0
helper/refill/api/yl/chengchong/config.php

@@ -0,0 +1,48 @@
+<?php
+
+
+namespace refill\chengchong;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://121.41.62.169:16188/plat/api/hf/submitorder';
+    const QUERY_URL= 'http://121.41.62.169:16188/plat/api/queryorder';
+    const BALANCE_URL = 'http://121.41.62.169:16188/plat/api/querybalance';
+
+    const USER_ID= '100002';
+    const KEY = '7c42b26ba4434275b81aae266b97e982';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_chengchong.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,
+            300 => 3000300,
+        ],
+    ];
+}

+ 21 - 0
helper/refill/api/yl/chengchong_fs/API.MD

@@ -0,0 +1,21 @@
+## 晟翀分省
+
+### 正式环境:
+- 话费下单地址:http://121.41.62.169:16188/plat/api/hf/submitorder
+- 查询地址:http://121.41.62.169:16188/plat/api/queryorder
+- 查询余额地址:http://121.41.62.169:16188/plat/api/querybalance
+
+- 客户端地址:http://121.41.62.169:16188/plat/login
+- 账号:炫捷分省
+- 密码:xj123456
+- 客户ID:100004
+- 密钥:89b643da842b40f4b867fb4707dbdda0
+
+### 对接文档地址:
+> https://docs.qq.com/doc/DWEhQWEhDVEJIdUVC
+
+### 店铺账号
+- chengchong_fs
+- chengchong_fs67890
+
+### 产品编码

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

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

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

+ 44 - 0
helper/refill/api/yl/chengchong_fs/config.php

@@ -0,0 +1,44 @@
+<?php
+
+
+namespace refill\chengchong_fs;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://121.41.62.169:16188/plat/api/hf/submitorder';
+    const QUERY_URL= 'http://121.41.62.169:16188/plat/api/queryorder';
+    const BALANCE_URL = 'http://121.41.62.169:16188/plat/api/querybalance';
+
+    const USER_ID= '100004';
+    const KEY = '89b643da842b40f4b867fb4707dbdda0';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_chengchong_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 => [
+
+        ],
+        mtopcard\ChinaUnicomCard => [
+
+        ],
+        mtopcard\ChinaTelecomCard => [
+
+        ]
+    ];
+
+    //key格式 卡类型-面值-regin_no
+    const Price = [
+
+    ];
+}

+ 4 - 0
mobile/callback/refill_chengchong.php

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

+ 4 - 0
mobile/callback/refill_chengchong_fs.php

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

+ 4 - 0
mobile/callback/refill_chengchong_sec.php

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

+ 18 - 0
test/TestRefill.php

@@ -6273,6 +6273,24 @@ class TestRefill extends TestCase
         $provider = $this->getProvider('jiahu_fs');
         $resp = $provider->balance();
     }
+
+    public function testchengchong()
+    {
+        $provider = $this->getProvider('chengchong');
+        $resp = $provider->balance();
+    }
+
+    public function testchengchong_sec()
+    {
+        $provider = $this->getProvider('chengchong_sec');
+        $resp = $provider->balance();
+    }
+
+    public function testchengchong_fs()
+    {
+        $provider = $this->getProvider('chengchong_fs');
+        $resp = $provider->balance();
+    }
 }