Selaa lähdekoodia

yelin dazhanggui

xiaoyu 2 vuotta sitten
vanhempi
commit
c89f5d78a2

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

@@ -6291,6 +6291,43 @@ $guitong_yi_phone = ['name' => 'guitong_yi', 'store_id' => 232, 'qualitys' => '2
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$dazhanggui_phone = ['name' => 'dazhanggui', 'store_id' => 233, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 7947, 'price' => 9.65, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7947, 'price' => 9.5, 'quality' => 1, 'card_type' => 'chinaunicom']
+//        ],
+//        20 => [
+//            ['goods_id' => 7948, 'price' => 19.3, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7948, 'price' => 19, 'quality' => 1, 'card_type' => 'chinaunicom']
+//        ],
+        30 => [
+            ['goods_id' => 7949, 'price' => 28.95, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7949, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinaunicom']
+        ],
+        50 => [
+            ['goods_id' => 7950, 'price' => 48.25, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7950, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinaunicom']
+        ],
+        100 => [
+            ['goods_id' => 7951, 'price' => 96.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7951, 'price' => 95, 'quality' => 1, 'card_type' => 'chinaunicom']
+        ],
+        200 => [
+            ['goods_id' => 7952, 'price' => 193, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7952, 'price' => 190, 'quality' => 1, 'card_type' => 'chinaunicom']
+        ],
+//        300 => [
+//            ['goods_id' => 7953, 'price' => 289.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7953, 'price' => 285, 'quality' => 1, 'card_type' => 'chinaunicom']
+//        ],
+//        500 => [
+//            ['goods_id' => 7954, 'price' => 482.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7954, 'price' => 475, 'quality' => 1, 'card_type' => 'chinaunicom']
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -6484,6 +6521,7 @@ $phone_providers = [
     ['name' => 'xinruiheng_fs', 'cfg' => $xinruiheng_fs_phone],
     ['name' => 'ziyugui', 'cfg' => $ziyugui_phone],
     ['name' => 'guitong_yi', 'cfg' => $guitong_yi_phone],
+    ['name' => 'dazhanggui', 'cfg' => $dazhanggui_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

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

@@ -0,0 +1,50 @@
+<?php
+namespace refill\dazhanggui;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dazhanggui/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')->getOrderInfo(['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];
+        }
+    }
+}

+ 142 - 0
helper/refill/api/yl/dazhanggui/RefillPhone.php

@@ -0,0 +1,142 @@
+<?php
+
+namespace refill\dazhanggui;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dazhanggui/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, '网络错误'];
+            }
+
+            $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);
+    }
+}

+ 21 - 0
helper/refill/api/yl/dazhanggui/api.txt

@@ -0,0 +1,21 @@
+登录账号:bjyl01
+登录密码:123456
+话费下单地址:http://47.101.136.81:10186/plat/api/old/submitorder
+查询地址:http://47.101.136.81:10186/plat/api/old/queryorder
+查询余额地址:http://47.101.136.81:10186/plat/api/old/queryBalance
+
+正式ID:200009
+秘钥: 15d6fd3fde744b33a514969c10bff2fd
+
+后台登录地址:http://47.101.136.81:10186/plat/index
+对接文档地址:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
+
+全国联通200元	2000200
+全国联通100元	2000100
+全国联通50元	2000050
+全国联通30元	2000030
+
+全国移动200元	1000200
+全国移动100元	1000100
+全国移动50元	1000050
+全国移动30元	1000030

+ 43 - 0
helper/refill/api/yl/dazhanggui/config.php

@@ -0,0 +1,43 @@
+<?php
+
+
+namespace refill\dazhanggui;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://47.101.136.81:10186/plat/api/old/submitorder';
+    const QUERY_URL= 'http://47.101.136.81:10186/plat/api/old/queryorder';
+    const BALANCE_URL = 'http://47.101.136.81:10186/plat/api/old/queryBalance';
+
+    const USER_ID= '200009';
+    const KEY = '15d6fd3fde744b33a514969c10bff2fd';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_dazhanggui.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,
+        ],
+    ];
+}

+ 6 - 0
test/TestRefillYl.php

@@ -798,4 +798,10 @@ class TestRefillYl extends TestCase
         $provider = $this->getProvider('guitong_yi');
         $resp = $provider->balance();
     }
+
+    public function testDazhanggui()
+    {
+        $provider = $this->getProvider('dazhanggui');
+        $resp = $provider->balance();
+    }
 }