Browse Source

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

stanley-king 2 weeks ago
parent
commit
af01439973

+ 38 - 0
data/config/yl/phone.ini.php

@@ -3255,6 +3255,43 @@ $xinguande_sec_phone = [
 //        ]
     ]
 ];
+$fengsheng_fs_phone = [
+    'name' => 'fengsheng_fs', 'store_id' => 378, 'qualitys' => '1', 'official_sn' => true, 'refill_type' => 'api',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 9042, 'price' => 10, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9042, 'price' => 10, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 9043, 'price' => 20, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9043, 'price' => 20, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        30 => [
+//            ['goods_id' => 9044, 'price' => 30, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9044, 'price' => 30, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+        50 => [
+            ['goods_id' => 9045, 'price' => 47.25, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9045, 'price' => 47.1, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 9046, 'price' => 94.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9046, 'price' => 94.2, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 9047, 'price' => 189, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9047, 'price' => 188.4, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+//        300 => [
+//            ['goods_id' => 9048, 'price' => 300, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9048, 'price' => 300, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        500 => [
+//            ['goods_id' => 9049, 'price' => 500, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9049, 'price' => 500, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ]
+    ]
+];
 
 $phone_providers = [
 	[ 'name' => 'zhongst', 'cfg' => $zhongst_phone ],
@@ -3357,4 +3394,5 @@ $phone_providers = [
     [ 'name' => 'nruifeng_jd', 'cfg' => $nruifeng_jd_phone ],
     [ 'name' => 'nyingyang_km', 'cfg' => $nyingyang_km_phone ],
     [ 'name' => 'xinguande_sec', 'cfg' => $xinguande_sec_phone ],
+    [ 'name' => 'fengsheng_fs', 'cfg' => $fengsheng_fs_phone ],
 	];

+ 54 - 0
helper/refill/api/yl/fengsheng_fs/API.MD

@@ -0,0 +1,54 @@
+## 风生分省
+
+### 正式环境:
+- 话费下单地址:http://47.98.53.152:16188/plat/api/hf/submitorder
+- 查询地址:http://47.98.53.152:16188/plat/api/queryorder
+- 查询余额地址:http://47.98.53.152:16188/plat/api/querybalance
+
+- 客户端地址:http://47.98.53.152:16188/plat/login
+- 账号:fqs4
+- 密码:123456
+- 客户ID:100010
+- 密钥:d5e286e4bcfa4866b93c8f81e97e1307
+
+### 对接文档地址:
+> https://docs.qq.com/doc/DWEhQWEhDVEJIdUVC
+
+### 店铺账号
+- fengsheng_fs
+- fengsheng_fs67890
+
+### 产品编码
+```angular2html
+移动
+陕西
+编码 1610050 面值50:折扣94.5
+编码 1610100 面值100:折扣94.5
+编码 1610200 面值200:折扣94.5
+
+电信
+甘肃
+编码 3620050 面值50 折扣94.2
+编码 3620100 面值100 折扣94.2
+编码 3620200 面值200 折扣94.2
+
+天津
+编码 3120050 面值50 折扣94.2
+编码 3120100 面值100 折扣94.2
+编码 3120200 面值200 折扣94.2
+
+广东
+编码 3440050 面值50 折扣94.2
+编码 3440100 面值100 折扣94.2
+编码 3440200 面值200 折扣94.2
+
+湖南
+编码 3430050 面值50 折扣94.2
+编码 3430100 面值100 折扣94.2
+编码 3430200 面值200 折扣94.2
+
+江西
+编码 3360050 面值50 折扣94.2
+编码 3360100 面值100 折扣94.2
+编码 3360200 面值200 折扣94.2
+```

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

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

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

+ 86 - 0
helper/refill/api/yl/fengsheng_fs/config.php

@@ -0,0 +1,86 @@
+<?php
+
+
+namespace refill\fengsheng_fs;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://47.98.53.152:16188/plat/api/hf/submitorder';
+    const QUERY_URL= 'http://47.98.53.152:16188/plat/api/queryorder';
+    const BALANCE_URL = 'http://47.98.53.152:16188/plat/api/querybalance';
+
+    const USER_ID= '100010';
+    const KEY = 'd5e286e4bcfa4866b93c8f81e97e1307';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_fengsheng_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,
+            ],
+        ],
+        mtopcard\ChinaUnicomCard => [
+
+        ],
+        mtopcard\ChinaTelecomCard => [
+            //甘肃
+            28 => [
+                50  => 3620050,
+                100 => 3620100,
+                200 => 3620200,
+            ],
+            //天津
+            2 => [
+                50  => 3120050,
+                100 => 3120100,
+                200 => 3120200,
+            ],
+            //广东
+            19 => [
+                50  => 3440050,
+                100 => 3440100,
+                200 => 3440200,
+            ],
+            //湖南
+            18 => [
+                50  => 3430050,
+                100 => 3430100,
+                200 => 3430200,
+            ],
+            //江西
+            14 => [
+                50  => 3360050,
+                100 => 3360100,
+                200 => 3360200,
+            ],
+        ]
+    ];
+
+    //key格式 卡类型-面值-regin_no
+    const Price = [
+        //移动
+        "4-50-27" => 47.25, "4-100-27" => 94.5, "4-200-27" => 189, //陕西
+
+        //电信
+        "6-50-28" => 47.1, "6-100-28" => 94.2, "6-200-28" => 188.4, //甘肃
+        "6-50-2" => 47.1, "6-100-2" => 94.2, "6-200-2" => 188.4, //天津
+        "6-50-19" => 47.1, "6-100-19" => 94.2, "6-200-19" => 188.4, //广东
+        "6-50-18" => 47.1, "6-100-18" => 94.2, "6-200-18" => 188.4, //湖南
+        "6-50-14" => 47.1, "6-100-14" => 94.2, "6-200-14" => 188.4, //江西
+    ];
+}

+ 4 - 0
mobile/callback/refill_fengsheng_fs.php

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

+ 6 - 0
test/TestRefill.php

@@ -6608,6 +6608,12 @@ class TestRefill extends TestCase
         $provider = $this->getProvider('zhixinzhuanch');
         $resp = $provider->balance();
     }
+
+    public function testfengsheng_fs()
+    {
+        $provider = $this->getProvider('fengsheng_fs');
+        $resp = $provider->balance();
+    }
 }