Explorar o código

yl yangchi_fs

xiaoyu %!s(int64=2) %!d(string=hai) anos
pai
achega
e419aa7428

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

@@ -6834,6 +6834,19 @@ $yangchi_phone = ['name' => 'yangchi', 'store_id' => 253, 'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$yangchi_fs_phone = ['name' => 'yangchi_fs', 'store_id' => 254, 'qualitys' => '1',
+    'amount' => [
+//        10 => [['goods_id' => 8115, 'price' => 9.5, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+//        20 => [['goods_id' => 8116, 'price' => 19, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+        30 => [['goods_id' => 8117, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+        50 => [['goods_id' => 8118, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+        100 => [['goods_id' => 8119, 'price' => 95, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+        200 => [['goods_id' => 8120, 'price' => 190, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+//        300 => [['goods_id' => 8121, 'price' => 285, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']],
+//        500 => [['goods_id' => 8122, 'price' => 475, 'quality' => 1, 'card_type' => 'chinamobile,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -7048,6 +7061,7 @@ $phone_providers = [
     ['name' => 'bier', 'cfg' => $bier_phone],
     ['name' => 'youhe_fs', 'cfg' => $youhe_fs_phone],
     ['name' => 'yangchi', 'cfg' => $yangchi_phone],
+    ['name' => 'yangchi_fs', 'cfg' => $yangchi_fs_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 50 - 0
helper/refill/api/yl/yangchi_fs/RefillCallBack.php

@@ -0,0 +1,50 @@
+<?php
+namespace refill\yangchi_fs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yangchi_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) {
+            $data['official_sn'] = strtolower($params['szRtnMsg']) == 'null' ? '' : $params['szRtnMsg'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 3) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 161 - 0
helper/refill/api/yl/yangchi_fs/RefillPhone.php

@@ -0,0 +1,161 @@
+<?php
+
+namespace refill\yangchi_fs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yangchi_fs/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    public function goods($quality,int $amount,int $card_type,$regin_no,$other)
+    {
+        [$goods_id, $price] = parent::goods($quality,$amount,$card_type,$regin_no,$other);
+        if($goods_id <= 0) return [0,0];
+        $key = "{$card_type}-{$amount}-{$regin_no}";
+        $price = config::Price[$key];
+        if(empty($price)) {
+            Log::record("channel cannot find price where name={$this->mName}, goods_id = {$goods_id} card_type={$card_type} amount={$amount} regin_no={$regin_no}",Log::ERR);
+            return [0,0];
+        } else {
+            return [$goods_id,ncPriceFormat($price)];
+        }
+    }
+
+    private function req_params(int $phone, int $amount, int $card_type, string $order_sn, $regin_no)
+    {
+        $params['szAgentId'] = config::USER_ID;
+        $params['szOrderId'] = $order_sn;
+        $params['szPhoneNum'] = $phone;
+        $params['nMoney'] = $amount;
+        $params['nSortType'] = config::operator[$card_type];
+        $params['szProductId'] = config::Product[$card_type][$regin_no][$amount];
+        $params['nProductClass'] = 1;
+        $params['nProductType'] = 1;
+        $params['szTimeStamp'] = date("Y-m-d H:i:s");
+        $params['szNotifyUrl'] = config::NOTIFY_URL;
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $order_sn = $params['order_sn'];
+        $regin_no = $params['regin_no'] ?? -1;
+
+        if($regin_no <= 0) {
+            return [false, '省份获取错误', false];
+        }
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn, $regin_no);
+
+        $sign = $this->sign($params);
+        $params['szVerifyString'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
+
+        if (empty($resp)) {
+            return [false, '网络错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+
+            $nRtn = $resp['nRtn'];
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            } elseif ($nRtn === 0) {
+                return [true, '', false];
+            } elseif (in_array($nRtn, config::ERR_NOS, true)) {
+                return [false, $resp['szRtnCode'], false];
+            } elseif (in_array($nRtn, [2050, 999], true)) {
+                $net_errno = "HTTP-{$nRtn}";
+                return [false, $resp['szRtnCode'], true];
+            } else {
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resp['szRtnCode'], true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['szAgentId'] = config::USER_ID;
+        $params['szOrderId'] = $refill_info['order_sn'];
+        $key = config::KEY;
+        $content = "szAgentId={$params['szAgentId']}&szOrderId={$params['szOrderId']}&szKey={$key}";
+        $params['szVerifyString'] = md5($content);
+
+        $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            }
+
+            $status = $resp['nRtn'];
+            if ($status === 5012) {
+                $updata['official_sn'] = $resp['szRtnMsg'];
+                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];
+        }
+    }
+
+    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);
+    }
+}

+ 63 - 0
helper/refill/api/yl/yangchi_fs/api.txt

@@ -0,0 +1,63 @@
+正式环境:
+话费下单地址:http://47.118.37.113:10186/plat/api/old/submitorder
+查询地址:http://47.118.37.113:10186/plat/api/old/queryorder
+查询余额地址:http://47.118.37.113:10186/plat/api/old/queryBalance
+
+商户登录地址:http://47.118.37.113:10186/plat
+ID:200038
+秘钥:583fb02cff1f487b879cdedd2365ac54
+账户:dyyfs2 密码:123456
+
+对接文档地址:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
+
+
+贵州移动30元	1520030
+贵州移动50元	1520050
+贵州移动100元	1520100
+贵州移动200元	1520200
+
+福建移动30元	1350030
+福建移动50元	1350050
+福建移动100元	1350100
+福建移动200元	1350200
+
+山东移动30元	1370030
+山东移动50元	1370050
+山东移动100元	1370100
+山东移动200元	1370200
+
+江苏移动30元	1320030
+江苏移动50元	1320050
+江苏移动100元	1320100
+江苏移动200元	1320200
+
+广东移动50元	1440050
+广东移动100元	1440100
+广东移动200元	1440200
+
+
+
+天津电信30元	3120030
+天津电信50元	3120050
+天津电信100元	3120100
+天津电信200元	3120200
+
+四川电信30元	3510030
+四川电信50元	3510050
+四川电信100元	3510100
+四川电信200元	3510200
+
+上海电信30元	3310030
+上海电信50元	3310050
+上海电信100元	3310100
+上海电信200元	3310200
+
+山东电信30元	3370030
+山东电信50元	3370050
+山东电信100元	3370100
+山东电信200元	3370200
+
+广东电信30元	3440030
+广东电信50元	3440050
+广东电信100元	3440100
+广东电信200元	3440200

+ 121 - 0
helper/refill/api/yl/yangchi_fs/config.php

@@ -0,0 +1,121 @@
+<?php
+
+
+namespace refill\yangchi_fs;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://47.118.37.113:10186/plat/api/old/submitorder';
+    const QUERY_URL= 'http://47.118.37.113:10186/plat/api/old/queryorder';
+    const BALANCE_URL = 'http://47.118.37.113:10186/plat/api/old/queryBalance';
+
+    const USER_ID= '200038';
+    const KEY = '583fb02cff1f487b879cdedd2365ac54';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yangchi_fs.php";
+
+    const operator = [
+        mtopcard\ChinaMobileCard  => 1,
+        mtopcard\ChinaUnicomCard  => 2,
+        mtopcard\ChinaTelecomCard => 3
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+
+    const ERR_NOS = [
+        1000,1001,1003,1004,2001,2002,2003,2020,2021,1006,2030,3003
+    ];
+
+    const Product = [
+        mtopcard\ChinaMobileCard => [
+            //贵州
+            24 => [
+                30  => 1520030,
+                50  => 1520050,
+                100 => 1520100,
+                200 => 1520200,
+            ],
+            //福建
+            13 => [
+                30  => 1350030,
+                50  => 1350050,
+                100 => 1350100,
+                200 => 1350200,
+            ],
+            //山东
+            15 => [
+                30  => 1370030,
+                50  => 1370050,
+                100 => 1370100,
+                200 => 1370200,
+            ],
+            //江苏
+            10 => [
+                30  => 1320030,
+                50  => 1320050,
+                100 => 1320100,
+                200 => 1320200,
+            ],
+            //广东
+            19 => [
+                50  => 1440050,
+                100 => 1440100,
+                200 => 1440200,
+            ],
+        ],
+        mtopcard\ChinaTelecomCard => [
+            //天津
+            2 => [
+                30  => 3120030,
+                50  => 3120050,
+                100 => 3120100,
+                200 => 3120200,
+            ],
+            //四川
+            23 => [
+                30  => 3510030,
+                50  => 3510050,
+                100 => 3510100,
+                200 => 3510200,
+            ],
+            //上海
+            9 => [
+                30  => 3310030,
+                50  => 3310050,
+                100 => 3310100,
+                200 => 3310200,
+            ],
+            //山东
+            15 => [
+                30  => 3370030,
+                50  => 3370050,
+                100 => 3370100,
+                200 => 3370200,
+            ],
+            //广东
+            19 => [
+                30  => 3440030,
+                50  => 3440050,
+                100 => 3440100,
+                200 => 3440200,
+            ],
+        ],
+    ];
+
+    //key格式 卡类型-面值-regin_no
+    const Price = [
+        //移动
+        "4-30-24" => 27.78, "4-50-24" => 46.3, "4-100-24" => 92.6, "4-200-24" => 185.2,//贵州 24
+        "4-30-13" => 28.5, "4-50-13" => 47.5, "4-100-13" => 95, "4-200-13" => 190,//福建 13
+        "4-30-15" => 28.65, "4-50-15" => 47.75, "4-100-15" => 95.5, "4-200-15" => 191,//山东 15
+        "4-30-10" => 28.2, "4-50-10" => 47, "4-100-10" => 94, "4-200-10" => 188,//江苏 10
+        "4-50-19" => 47.35, "4-100-19" => 94.7, "4-200-19" => 189.4,//广东 19
+
+        //电信
+        "6-30-2" => 28.05, "6-50-2" => 46.75, "6-100-2" => 93.5, "6-200-2" => 187,//天津 2
+        "6-30-23" => 28.05, "6-50-23" => 46.75, "6-100-23" => 93.5, "6-200-23" => 187,//四川 23
+        "6-30-9" => 28.35, "6-50-9" => 47.25, "6-100-9" => 94.5, "6-200-9" => 189,//上海 9
+        "6-30-15" => 28.35, "6-50-15" => 47.25, "6-100-15" => 94.5, "6-200-15" => 189,//山东 15
+        "6-30-19" => 28.5, "6-50-19" => 47.5, "6-100-19" => 95, "6-200-19" => 190,//广东 19
+    ];
+
+}