Browse Source

meixu_tax_sec

xiaoyu 2 years atrás
parent
commit
5e38d51559

+ 47 - 0
data/config/xyz/refill.ini.php

@@ -7829,6 +7829,52 @@ $meixu_tax_phone = ['name' => 'meixu_tax', 'store_id' => 287, 'qualitys' => '3',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$meixu_tax_sec_phone = ['name' => 'meixu_tax_sec', 'store_id' => 288, 'qualitys' => '3',
+    'amount' => [
+        10 => [
+            ['goods_id' => 8389, 'price' => 10.67, 'quality' => 3, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8389, 'price' => 10.52, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8389, 'price' => 10.77, 'quality' => 3, 'card_type' => 'chinatelecom']
+        ],
+        20 => [
+            ['goods_id' => 8390, 'price' => 21.34, 'quality' => 3, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8390, 'price' => 20.94, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8390, 'price' => 21.14, 'quality' => 3, 'card_type' => 'chinatelecom']
+        ],
+        30 => [
+            ['goods_id' => 8391, 'price' => 31.29, 'quality' => 3, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8391, 'price' => 31.26, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8391, 'price' => 31.29, 'quality' => 3, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 8392, 'price' => 52.6, 'quality' => 3, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8392, 'price' => 51.575, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8392, 'price' => 51.975, 'quality' => 3, 'card_type' => 'chinatelecom'],
+        ],
+        100 => [
+            ['goods_id' => 8393, 'price' => 103.15, 'quality' => 3, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8393, 'price' => 103.15, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8393, 'price' => 103.15, 'quality' => 3, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 8394, 'price' => 206.3, 'quality' => 3, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8394, 'price' => 206.3, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8394, 'price' => 206.3, 'quality' => 3, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 8395, 'price' => 309.45, 'quality' => 3, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8395, 'price' => 309.45, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8395, 'price' => 309.45, 'quality' => 3, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 8396, 'price' => 515.75, 'quality' => 3, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8396, 'price' => 515.75, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8396, 'price' => 515.75, 'quality' => 3, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -8072,6 +8118,7 @@ $phone_providers = [
     ['name' => 'douxun_sec_copy', 'cfg' => $douxun_sec_copy_phone],
     ['name' => 'ruizhi_tax_copy', 'cfg' => $ruizhi_tax_copy_phone],
     ['name' => 'meixu_tax', 'cfg' => $meixu_tax_phone],
+    ['name' => 'meixu_tax_sec', 'cfg' => $meixu_tax_sec_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 67 - 0
helper/refill/api/xyz/meixu_tax_sec/RefillCallBack.php

@@ -0,0 +1,67 @@
+<?php
+namespace refill\meixu_tax_sec;
+
+require_once(BASE_HELPER_RAPI_PATH . '/meixu_tax_sec/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['sign']);
+        $sign = $this->sign($input);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
+        return md5($content);
+    }
+
+    private function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['orderStatus']);
+        $order_sn = $params['outOrderId'];
+        $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['ext1']) == 'null' ? '' : $params['ext1'];
+            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];
+        }
+    }
+}

+ 155 - 0
helper/refill/api/xyz/meixu_tax_sec/RefillPhone.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace refill\meixu_tax_sec;
+
+require_once(BASE_HELPER_RAPI_PATH . '/meixu_tax_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, int $card_type, string $order_sn)
+    {
+        $params['appId'] = config::APP_ID;
+        $params['outOrderId'] = $order_sn;
+        $params['uuid'] = $phone;
+        $params['itemId'] = config::PRODUCT[$card_type][$amount];
+        $params['itemFace'] = $amount;
+        $params['callbackUrl'] = config::NOTIFY_URL;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        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);
+        if(empty($params['itemId'])) {
+            return [false, '商品编号错误', false];
+        }
+        $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 = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            } elseif ($resp['code'] === '00') {
+                return [true, $resp['orderId'], false];
+            } elseif (in_array($resp['code'], config::ERRCODES, true)) {
+                return [false, $resp['msg'], false];
+            } elseif (in_array($resp['code'], ['-22', '-23', '-99'], true)) {
+                $net_errno = "HTTP-{$resp['code']}";
+                return [false, $resp['msg'], true];
+            } else {
+                $net_errno = "HTTP-998";
+                return [false, $resp['msg'], true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['appId'] = config::APP_ID;
+        $params['outOrderId'] = $refill_info['order_sn'];
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
+
+        $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, '网络错误'];
+            }
+            elseif ($resp['code'] === '00')
+            {
+                $status = $resp['orderStatus'];
+                if ($status === '2') {
+                    $updata['official_sn'] = $resp['ext1'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === '3') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === '1') {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($status === '4' && (time() - $refill_info['commit_time'] >= 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            }
+            else
+            {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['appId'] = config::APP_ID;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
+
+        $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['code'] === '00') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function get_millisecond()
+    {
+        list($usec, $sec) = explode(" ", microtime());
+        return round($usec*1000);
+    }
+
+    private function sign($params)
+    {
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
+        return md5($content);
+    }
+}

+ 52 - 0
helper/refill/api/xyz/meixu_tax_sec/config.php

@@ -0,0 +1,52 @@
+<?php
+
+
+namespace refill\meixu_tax_sec;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://120.79.190.232:8911/api/hf/order/submit';
+    const QUERY_URL = 'http://120.79.190.232:8911/api/order/query';
+    const BALANCE_URL = 'http://120.79.190.232:8911/api/account/balance';
+
+    const APP_ID = 'VobyjuMrKZ';
+    const APP_SECRET = 'hJlOsvsaAVyRNVdM';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_meixu_tax_sec.php";
+
+    const PRODUCT = [
+        mtopcard\ChinaMobileCard => [
+            10  => 101032,
+            20  => 101033,
+            30  => 101034,
+            50  => 101035,
+            100 => 101036,
+            200 => 101037,
+            300 => 101038,
+            500 => 101039,
+        ],
+
+        mtopcard\ChinaUnicomCard => [
+            10  => 101040,
+            20  => 101041,
+            30  => 101042,
+            50  => 101043,
+            100 => 101044,
+            200 => 101045,
+            300 => 101046,
+            500 => 101047,
+        ],
+        mtopcard\ChinaTelecomCard => [
+            10  => 101048,
+            20  => 101049,
+            30  => 101050,
+            50  => 101051,
+            100 => 101052,
+            200 => 101053,
+            300 => 101054,
+            500 => 101055,
+        ]
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ERRCODES = ['-10', '-12', '-13', '-14', '-15', '-16', '-18', '-21'];
+}

+ 41 - 0
helper/refill/api/xyz/meixu_tax_sec/开户信息.txt

@@ -0,0 +1,41 @@
+后台地址:http://120.79.190.232:8888
+帐号:GYHF
+密码:925399
+二级密码:AqaJ4486
+appId:VobyjuMrKZ
+appSecret:hJlOsvsaAVyRNVdM
+后台-商品列表,可查看已配置商品信息
+后台-安全中心,可配置IP白名单
+接口文档:https://www.showdoc.com.cn/1686453783298366/7925312871840290
+话费直充接口:http://120.79.190.232:8911/api/hf/order/submit
+通用直充接口:http://120.79.190.232:8911/api/order/submit
+查询接口接口:http://120.79.190.232:8911/api/order/query
+余额查询接口:http://120.79.190.232:8911/api/account/balance
+
+
+101032  次月票全国移动话费10元
+101033  次月票全国移动话费20元
+101034  次月票全国移动话费30元
+101035  次月票全国移动话费50元
+[101036]次月票全国移动话费100元
+[101037]次月票全国移动话费200元
+[101038]次月票全国移动话费300元
+[101039]次月票全国移动话费500元
+
+101040 次月票全国联通掌厅话费10元
+101041 次月票全国联通掌厅话费20元
+101042 次月票全国联通掌厅话费30元
+[101043]次月票全国联通掌厅话费50元
+[101044]次月票全国联通掌厅话费100元
+[101045]次月票全国联通掌厅话费200元
+[101046]次月票全国联通掌厅话费300元
+[101047]次月票全国联通掌厅话费500元
+
+101048 次月票全国电信话费10元
+101049 次月票全国电信话费20元
+101050 次月票全国电信话费30元
+101051  次月票全国电信话费50元
+[101052]次月票全国电信话费100元
+[101053]次月票全国电信话费200元
+[101054]次月票全国电信话费300元
+[101055]次月票全国电信话费500元

+ 4 - 0
mobile/callback/refill_meixu_tax_sec.php

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

+ 5 - 0
test/TestRefill.php

@@ -3030,7 +3030,12 @@ class TestRefill extends TestCase
         $provider = $this->getProvider('meixu_tax', 'RefillCallBack');
         $ret = $provider->verify($params);
         $resp = $provider->notify($params);
+    }
 
+    public function testMeixu_tax_sec()
+    {
+        $provider = $this->getProvider('meixu_tax_sec');
+        $resp = $provider->balance();
     }
 
     public function testAmingjd()