Quellcode durchsuchen

椰林:盾辉全国2号

lowkeyman vor 1 Jahr
Ursprung
Commit
8f76538b86

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

@@ -8224,6 +8224,43 @@ $xinbao_phone = ['name' => 'xinbao', 'store_id' => 314, 'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$dunhui_sec_phone = ['name' => 'dunhui_sec', 'store_id' => 315, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 8531, 'price' => 10, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8531, 'price' => 10, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//        ],
+//        20 => [
+//            ['goods_id' => 8532, 'price' => 20, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8532, 'price' => 20, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//        ],
+//        30 => [
+//            ['goods_id' => 8533, 'price' => 30, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8533, 'price' => 30, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//        ],
+        50 => [
+            ['goods_id' => 8534, 'price' => 48.15, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8534, 'price' => 46.75, 'quality' => 1, 'card_type' => 'chinaunicom'],
+        ],
+        100 => [
+            ['goods_id' => 8535, 'price' => 96.3, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8535, 'price' => 93.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+        ],
+        200 => [
+            ['goods_id' => 8536, 'price' => 192.6, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8536, 'price' => 187, 'quality' => 1, 'card_type' => 'chinaunicom'],
+        ],
+//        300 => [
+//            ['goods_id' => 8537, 'price' => 300, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8537, 'price' => 300, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//        ],
+//        500 => [
+//            ['goods_id' => 8538, 'price' => 500, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8538, 'price' => 500, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -8485,6 +8522,7 @@ $phone_providers = [
     ['name' => 'menshang_fs', 'cfg' => $menshang_fs_phone],
     ['name' => 'youshilian', 'cfg' => $youshilian_phone],
     ['name' => 'xinbao', 'cfg' => $xinbao_phone],
+    ['name' => 'dunhui_sec', 'cfg' => $dunhui_sec_phone],
 ];
 
 $config['phone_providers'] = $phone_providers;

BIN
helper/refill/api/yl/dunhui_sec/20240320_yd_lt.png


+ 33 - 0
helper/refill/api/yl/dunhui_sec/API.MD

@@ -0,0 +1,33 @@
+
+## 盾辉全国2号
+
+### 账号:
+- 登陆账号:FQS2
+- 登陆密码:q123458
+- 商户号:10002645
+- 秘钥:tK4BPJNjhjKQhkXQjG7nC5FD4nmcBKbe
+### 下游客户注册和登录地址:
+> http://123.60.16.116:7080/
+- api接口文档地址:
+ - https://www.showdoc.com.cn/AQL666666/
+- 话费下单地址:
+ - http://123.60.16.116:9086/onlinepay.do
+- 订单主动查询地址:
+ - http://123.60.16.116:9086/searchpay.do
+- 余额查询:
+- http://123.60.16.116:9086/searchbalance.do
+## 店铺
+- 账号:dunhui_sec
+- 密码:dunhui_sec67890
+
+### 折扣
+![报价](20240320_yd_lt.png)
+
+### 全国产品编码
+101688    全国移动话费50元直充  
+101689    全国移动话费100元直充  
+101690    全国移动话费200元直充  
+
+101706    全国联通话费50元直充  
+101707    全国联通话费100元直充  
+101708    全国联通话费200元直充  

+ 49 - 0
helper/refill/api/yl/dunhui_sec/RefillCallBack.php

@@ -0,0 +1,49 @@
+<?php
+namespace refill\dunhui_sec;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dunhui_sec/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params): string
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&orderid={$params['orderid']}&sporderid={$params['sporderid']}&merchantsubmittime={$params['merchantsubmittime']}";
+        $content .= "&resultno={$params['resultno']}&key={$key}";
+        return strtoupper(md5($content));
+    }
+
+    public function notify($params): array
+    {
+        $status = intval($params['resultno']);
+        $order_sn = $params['sporderid'];
+        $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 === 1) {
+            $official_sn = strtolower($params['remark1']) == 'null' ? '' : $params['remark1'];
+            $data['official_sn'] = $official_sn;
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true, $official_sn];
+        } elseif ($status === 9) {
+            return [$order_id, false, true, true, ''];
+        } else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 154 - 0
helper/refill/api/yl/dunhui_sec/RefillPhone.php

@@ -0,0 +1,154 @@
+<?php
+namespace refill\dunhui_sec;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dunhui_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, $card_type, string $order_sn): array
+    {
+        $params['userid'] = config::USER_ID;
+        $params['productid'] = config::ProductIdS[$card_type][$amount];
+        $params['price'] = $amount;
+        $params['num'] = 1;
+        $params['mobile'] = $phone;
+        $params['spordertime'] = date("YmdHis");
+        $params['sporderid'] = $order_sn;
+        $params['back_url'] = config::NOTIFY_URL;
+        $params['paytype'] = config::operator[$card_type];
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
+
+        $sign = $this->sign($params);
+        $params['sign'] = $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 = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            }
+
+            $resultno = $resp['resultno'];
+            if (in_array($resultno, ['0', '2'], true)) {
+                return [true, $resp['orderid'], false];
+            } elseif (in_array($resultno, config::ERR_NOS, true)) {
+                return [false, $resultno, false];
+            } elseif ($resultno === '9999' || $resultno === '5006') {
+                $net_errno = "HTTP-{$resultno}";
+                return [false, $resultno, true];
+            } else {
+                //未知结果码
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resultno, true];
+            }
+        }
+    }
+
+    public function query($refill_info): array
+    {
+        $params['userid'] = config::USER_ID;
+        $params['sporderid'] = $refill_info['order_sn'];
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&sporderid={$params['sporderid']}&key={$key}";
+        $params['sign'] = strtoupper(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 = $this->xmlToArray($resp);
+            if (empty($resp))
+            {
+                return [false, '网络错误', ''];
+            }
+            else
+            {
+                $official_sn = !empty($resp['remark1']) ? $resp['remark1'] : '';
+
+                $resultno = $resp['resultno'];
+                if ($resultno === '1') {
+                    $updata['official_sn'] = $official_sn;
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($resultno === '9') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($resultno === '5007' && (time() - $refill_info['commit_time'] > 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    $order_state = ORDER_STATE_SEND;
+                }
+
+                return [true, $order_state, $official_sn];
+            }
+        }
+    }
+
+    public function balance(): array
+    {
+        $params['userid'] = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&key={$key}";
+        $params['sign'] = strtoupper(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 = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['resultno'] === '1') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['resultno']];
+            }
+        }
+    }
+
+    private function sign($params): string
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&productid={$params['productid']}&price={$params['price']}&num={$params['num']}&mobile={$params['mobile']}&spordertime={$params['spordertime']}";
+        $content .= "&sporderid={$params['sporderid']}&key={$key}";
+        return strtoupper(md5($content));
+    }
+
+    public function xmlToArray($xml)
+    {
+        $replace_str = str_replace(' ','','encoding="gb2312"');
+        $xml = mb_convert_encoding($xml,"UTF-8","gb2312");
+        $xml = str_replace($replace_str, "encoding='utf-8'", $xml);
+        return refill\util::xmlToArray($xml);
+    }
+}

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

@@ -0,0 +1,43 @@
+<?php
+namespace refill\dunhui_sec;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://123.60.16.116:9086/onlinepay.do';
+    const QUERY_URL= 'http://123.60.16.116:9086/searchpay.do';
+    const BALANCE_URL = 'http://123.60.16.116:9086/searchbalance.do';
+
+    const USER_ID= '10002645';
+    const KEY = 'tK4BPJNjhjKQhkXQjG7nC5FD4nmcBKbe';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_dunhui_sec.php";
+
+    const operator = [
+        mtopcard\ChinaMobileCard  => 'yd',
+        mtopcard\ChinaUnicomCard  => 'lt',
+        mtopcard\ChinaTelecomCard => 'dx'
+    ];
+    const ERR_NOS = [
+        '5001', '5002', '5003', '5004', '5005', '5008', '5009', '5010', '5011', '5012', '7001'
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;'];
+
+    const ProductIdS = [
+        mtopcard\ChinaMobileCard =>
+            [
+                50 => '101688',
+                100 => '101689',
+                200 => '101690',
+            ],
+        mtopcard\ChinaUnicomCard =>
+            [
+                50 => '101706',
+                100 => '101707',
+                200 => '101708',
+            ],
+        mtopcard\ChinaTelecomCard =>
+            [
+
+            ]
+    ];
+}

+ 4 - 0
mobile/callback/refill_dunhui_sec.php

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

+ 6 - 0
test/TestRefill.php

@@ -6045,6 +6045,12 @@ class TestRefill extends TestCase
         $provider = $this->getProvider('dunhui');
         $resp = $provider->balance();
     }
+
+    public function testdunhui_sec()
+    {
+        $provider = $this->getProvider('dunhui_sec');
+        $resp = $provider->balance();
+    }
 }