Sfoglia il codice sorgente

椰林普充 德欣分省

lowkeyman 5 giorni fa
parent
commit
19d2189eef

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

@@ -3321,6 +3321,43 @@ $benyu_sec_phone = [
 //        ]
     ]
 ];
+$dexin_fs_phone = [
+    'name' => 'dexin_fs', 'store_id' => 380, 'qualitys' => '1', 'official_sn' => true, 'refill_type' => 'api',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 9058, 'price' => 10, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9058, 'price' => 10, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 9059, 'price' => 20, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9059, 'price' => 20, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        30 => [
+//            ['goods_id' => 9060, 'price' => 30, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9060, 'price' => 30, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+        50 => [
+            ['goods_id' => 9061, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9061, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 9062, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9062, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 9063, 'price' => 191, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9063, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+//        300 => [
+//            ['goods_id' => 9064, 'price' => 300, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9064, 'price' => 300, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        500 => [
+//            ['goods_id' => 9065, 'price' => 500, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9065, 'price' => 500, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ]
+    ]
+];
 
 $phone_providers = [
 	[ 'name' => 'zhongst', 'cfg' => $zhongst_phone ],
@@ -3425,4 +3462,5 @@ $phone_providers = [
     [ 'name' => 'xinguande_sec', 'cfg' => $xinguande_sec_phone ],
     [ 'name' => 'fengsheng_fs', 'cfg' => $fengsheng_fs_phone ],
     [ 'name' => 'benyu_sec', 'cfg' => $benyu_sec_phone ],
+    [ 'name' => 'dexin_fs', 'cfg' => $dexin_fs_phone ],
 	];

BIN
helper/refill/api/yl/dexin_fs/20250414_price.png


+ 19 - 0
helper/refill/api/yl/dexin_fs/API.MD

@@ -0,0 +1,19 @@
+## 德欣分省
+
+### 正式环境:
+- 话费下单地址:http://8.136.129.136:10181/plat/api/hf/submitorder
+- 查询地址:http://8.136.129.136:10181/plat/api/queryorder
+- 查询余额地址:http://8.136.129.136:10181/plat/api/querybalance
+
+- 客户端地址:http://8.136.129.136:10181/plat/login
+- 账号:xj-fs
+- 密码:123456
+- 客户ID:200078
+- 密钥:dac29f95c5e644fa808eddce5989ec80
+
+### 对接文档地址:
+> https://docs.qq.com/doc/DWEhQWEhDVEJIdUVC
+
+### 店铺账号
+- dexin_fs
+- dexin_fs67890

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

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

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

BIN
helper/refill/api/yl/dexin_fs/code.xlsx


+ 164 - 0
helper/refill/api/yl/dexin_fs/config.php

@@ -0,0 +1,164 @@
+<?php
+
+
+namespace refill\dexin_fs;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://8.136.129.136:10181/plat/api/hf/submitorder';
+    const QUERY_URL= 'http://8.136.129.136:10181/plat/api/queryorder';
+    const BALANCE_URL = 'http://8.136.129.136:10181/plat/api/querybalance';
+
+    const USER_ID= '200078';
+    const KEY = 'dac29f95c5e644fa808eddce5989ec80';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_dexin_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 => [
+            //宁夏
+            30 => [
+                50  => 1640050,
+                100 => 1640100,
+                200 => 1640200,
+            ],
+            //青海
+            29 => [
+                50  => 1630050,
+                100 => 1630100,
+                200 => 1630200,
+            ],
+            //陕西
+            27 => [
+                50  => 1610050,
+                100 => 1610100,
+                200 => 1610200,
+            ],
+            //福建
+            13 => [
+                50  => 1350050,
+                100 => 1350100,
+                200 => 1350200,
+            ],
+            //江苏
+            10 => [
+                50  => 1320050,
+                100 => 1320100,
+                200 => 1320200,
+            ],
+
+        ],
+        mtopcard\ChinaUnicomCard => [
+
+        ],
+        mtopcard\ChinaTelecomCard => [
+            //甘肃
+            28 => [
+                50  => 3620050,
+                100 => 3620100,
+                200 => 3620200,
+            ],
+            //云南
+            25 => [
+                50  => 3530050,
+                100 => 3530100,
+                200 => 3530200,
+            ],
+            //四川
+            23 => [
+                50  => 3510050,
+                100 => 3510100,
+                200 => 3510200,
+            ],
+            //海南
+            21 => [
+                50  => 3460050,
+                100 => 3460100,
+                200 => 3460200,
+            ],
+            //广西
+            20 => [
+                50  => 3450050,
+                100 => 3450100,
+                200 => 3450200,
+            ],
+            //广东
+            19 => [
+                50  => 3440050,
+                100 => 3440100,
+                200 => 3440200,
+            ],
+            //湖北
+            17 => [
+                50  => 3420050,
+                100 => 3420100,
+                200 => 3420200,
+            ],
+            //山东
+            15 => [
+                50  => 3370050,
+                100 => 3370100,
+                200 => 3370200,
+            ],
+            //江西
+            14 => [
+                50  => 3360050,
+                100 => 3360100,
+                200 => 3360200,
+            ],
+            //福建
+            13 => [
+                50  => 3350050,
+                100 => 3350100,
+                200 => 3350200,
+            ],
+            //江苏
+            10 => [
+                50  => 3320050,
+                100 => 3320100,
+                200 => 3320200,
+            ],
+            //天津
+            2 => [
+                50  => 3120050,
+                100 => 3120100,
+                200 => 3120200,
+            ],
+        ]
+    ];
+
+    //key格式 卡类型-面值-regin_no
+    const Price = [
+        //移动
+        "4-50-30" => 47.75, "4-100-30" => 95.5, "4-200-30" => 191, //宁夏
+        "4-50-29" => 47.75, "4-100-29" => 95.5, "4-200-29" => 191, //青海
+        "4-50-27" => 47.75, "4-100-27" => 95.5, "4-200-27" => 191, //陕西
+        "4-50-13" => 47.75, "4-100-13" => 95.5, "4-200-13" => 191, //福建
+        "4-50-10" => 47.75, "4-100-10" => 95.5, "4-200-10" => 191, //江苏
+
+        //电信
+        "6-50-28" => 47.65, "6-100-28" => 95.3, "6-200-28" => 190.6, //甘肃
+        "6-50-25" => 47.65, "6-100-25" => 95.3, "6-200-25" => 190.6, //云南
+        "6-50-23" => 47.65, "6-100-23" => 95.3, "6-200-23" => 190.6, //四川
+        "6-50-21" => 47.65, "6-100-21" => 95.3, "6-200-21" => 190.6, //海南
+        "6-50-20" => 47.65, "6-100-20" => 95.3, "6-200-20" => 190.6, //广西
+        "6-50-19" => 47.65, "6-100-19" => 95.3, "6-200-19" => 190.6, //广东
+        "6-50-17" => 47.65, "6-100-17" => 95.3, "6-200-17" => 190.6, //湖北
+        "6-50-15" => 47.65, "6-100-15" => 95.3, "6-200-15" => 190.6, //山东
+        "6-50-14" => 47.65, "6-100-14" => 95.3, "6-200-14" => 190.6, //江西
+        "6-50-13" => 47.65, "6-100-13" => 95.3, "6-200-13" => 190.6, //福建
+        "6-50-10" => 47.65, "6-100-10" => 95.3, "6-200-10" => 190.6, //江苏
+        "6-50-2" => 47.65, "6-100-2" => 95.3, "6-200-2" => 190.6, //天津
+    ];
+}

+ 4 - 0
mobile/callback/refill_dexin_fs.php

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

+ 6 - 0
test/TestRefill.php

@@ -6620,6 +6620,12 @@ class TestRefill extends TestCase
         $provider = $this->getProvider('benyu_sec');
         $resp = $provider->balance();
     }
+
+    public function testdexin_fs()
+    {
+        $provider = $this->getProvider('dexin_fs');
+        $resp = $provider->balance();
+    }
 }