xiaoyu 3 年之前
父节点
当前提交
ecf6e43cdf

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

@@ -3455,6 +3455,52 @@ $dongyefs_phone = ['name' => 'dongyefs', 'store_id' => 163, 'qualitys' => '2',
         500 => [['goods_id' => 7389, 'price' => 499.5, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
+
+$baixuan_phone = ['name' => 'baixuan', 'store_id' => 164,'qualitys' => '1',
+    'amount' => [
+        10 => [
+            ['goods_id' => 7390, 'price' => 9.59, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7390, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7390, 'price' => 9.58, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        20 => [
+            ['goods_id' => 7391, 'price' => 19.18, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7391, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7391, 'price' => 19.16, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        30 => [
+            ['goods_id' => 7392, 'price' => 28.77, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7392, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7392, 'price' => 28.74, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 7393, 'price' => 47.95, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7393, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7393, 'price' => 47.9, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7394, 'price' => 95.9, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7394, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7394, 'price' => 95.8, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7395, 'price' => 191.8, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7395, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7395, 'price' => 191.6, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 7396, 'price' => 287.7, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7396, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7396, 'price' => 287.4, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 7397, 'price' => 479.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7397, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7397, 'price' => 479, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -3582,6 +3628,7 @@ $phone_providers = [
     ['name' => 'fuyuan', 'cfg' => $fuyuan_phone],
     ['name' => 'dongye', 'cfg' => $dongye_phone],
     ['name' => 'dongyefs', 'cfg' => $dongyefs_phone],
+    ['name' => 'baixuan', 'cfg' => $baixuan_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -3455,6 +3455,52 @@ $dongyefs_phone = ['name' => 'dongyefs', 'store_id' => 163, 'qualitys' => '2',
         500 => [['goods_id' => 7389, 'price' => 499.5, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
+
+$baixuan_phone = ['name' => 'baixuan', 'store_id' => 164,'qualitys' => '1',
+    'amount' => [
+        10 => [
+            ['goods_id' => 7390, 'price' => 9.59, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7390, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7390, 'price' => 9.58, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        20 => [
+            ['goods_id' => 7391, 'price' => 19.18, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7391, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7391, 'price' => 19.16, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        30 => [
+            ['goods_id' => 7392, 'price' => 28.77, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7392, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7392, 'price' => 28.74, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 7393, 'price' => 47.95, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7393, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7393, 'price' => 47.9, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7394, 'price' => 95.9, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7394, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7394, 'price' => 95.8, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7395, 'price' => 191.8, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7395, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7395, 'price' => 191.6, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 7396, 'price' => 287.7, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7396, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7396, 'price' => 287.4, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 7397, 'price' => 479.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7397, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7397, 'price' => 479, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -3582,6 +3628,7 @@ $phone_providers = [
     ['name' => 'fuyuan', 'cfg' => $fuyuan_phone],
     ['name' => 'dongye', 'cfg' => $dongye_phone],
     ['name' => 'dongyefs', 'cfg' => $dongyefs_phone],
+    ['name' => 'baixuan', 'cfg' => $baixuan_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -3455,6 +3455,52 @@ $dongyefs_phone = ['name' => 'dongyefs', 'store_id' => 163, 'qualitys' => '2',
         500 => [['goods_id' => 7389, 'price' => 499.5, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
+
+$baixuan_phone = ['name' => 'baixuan', 'store_id' => 164,'qualitys' => '1',
+    'amount' => [
+        10 => [
+            ['goods_id' => 7390, 'price' => 9.59, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7390, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7390, 'price' => 9.58, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        20 => [
+            ['goods_id' => 7391, 'price' => 19.18, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7391, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7391, 'price' => 19.16, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        30 => [
+            ['goods_id' => 7392, 'price' => 28.77, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7392, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7392, 'price' => 28.74, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 7393, 'price' => 47.95, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7393, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7393, 'price' => 47.9, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7394, 'price' => 95.9, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7394, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7394, 'price' => 95.8, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7395, 'price' => 191.8, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7395, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7395, 'price' => 191.6, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 7396, 'price' => 287.7, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7396, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7396, 'price' => 287.4, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 7397, 'price' => 479.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7397, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7397, 'price' => 479, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -3582,6 +3628,7 @@ $phone_providers = [
     ['name' => 'fuyuan', 'cfg' => $fuyuan_phone],
     ['name' => 'dongye', 'cfg' => $dongye_phone],
     ['name' => 'dongyefs', 'cfg' => $dongyefs_phone],
+    ['name' => 'baixuan', 'cfg' => $baixuan_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -0,0 +1,67 @@
+<?php
+namespace refill\baixuan;
+
+require_once(BASE_HELPER_RAPI_PATH . '/baixuan/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')->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['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/baixuan/RefillPhone.php

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

+ 44 - 0
helper/refill/api/xyz/baixuan/config.php

@@ -0,0 +1,44 @@
+<?php
+
+
+namespace refill\baixuan;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://119.23.174.34:8911/api/hf/order/submit';
+    const QUERY_URL = 'http://119.23.174.34:8911/api/order/query';
+    const BALANCE_URL = 'http://119.23.174.34:8911/api/account/balance';
+
+    const APP_ID = 'Hs2pvfcPTK';
+    const APP_SECRET = 'WYUvuzPpFNnBfQZm';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_baixuan.php";
+    const PRODUCT = [
+        mtopcard\ChinaMobileCard => [
+            30  => 100067,
+            50  => 100025,
+            100 => 100026,
+            200 => 100027,
+            300 => 100028,
+            500 => 100029,
+        ],
+        mtopcard\ChinaUnicomCard => [
+            30  => 100086,
+            50  => 100087,
+            100 => 100088,
+            200 => 100090,
+            300 => 100091,
+            500 => 100089,
+        ],
+        mtopcard\ChinaTelecomCard => [
+            30  => 100062,
+            50  => 100022,
+            100 => 100023,
+            200 => 100024,
+            300 => 100084,
+            500 => 100085,
+        ],
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ERRCODES = ['-10', '-12', '-13', '-14', '-15', '-16', '-18', '-21'];
+}

+ 20 - 0
helper/refill/api/xyz/baixuan/商品编码.txt

@@ -0,0 +1,20 @@
+高价移动30          100067
+高价移动50          100025
+高价移动100         100026
+高价移动200         100027
+高价移动300         100028
+高价移动500         100029
+
+高价联通30          100086
+高价联通50          100087
+高价联通100         100088
+高价联通300         100090
+高价联通500         100091
+高价联通200         100089
+
+高价电信30          100062
+高价电信50          100022
+高价电信100         100023
+高价电信200         100024
+高价电信300         100084
+高价电信500         100085

+ 13 - 0
helper/refill/api/xyz/baixuan/开户信息.txt

@@ -0,0 +1,13 @@
+后台地址:http://119.23.174.34:8888
+帐号:YZ02
+密码:717750
+二级密码:nKyQ2049
+appId:Hs2pvfcPTK
+appSecret:WYUvuzPpFNnBfQZm
+后台-商品列表,可查看已配置商品信息
+后台-安全中心,可配置IP白名单
+接口文档:https://www.showdoc.com.cn/1686453783298366/7925312871840290
+下单接口地址:http://119.23.174.34:8911/api/hf/order/submit
+查单接口地址:http://119.23.174.34:8911/api/order/query
+余额接口地址:http://119.23.174.34:8911/api/account/balance
+提卡接口地址:http://119.23.174.34:8911/api/card/get

+ 4 - 0
mobile/callback/refill_baixuan.php

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

+ 14 - 0
test/TestRefill.php

@@ -1497,6 +1497,20 @@ class TestRefill extends TestCase
         $resp = $provider->query(['order_sn' => '24461638757715661527']);
     }
 
+    public function testBaixuan()
+    {
+//        $provider = $this->getProvider('baixuan');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '22241638773647636323']);
+
+        $body = '{"orderId":"211206145422241449","appId":"Hs2pvfcPTK","outOrderId":"22241638773647636323","sign":"acdd4cdbf6c9ad8d1eec12070caef9c7","orderStatus":"3","completeTime":"20211206145422","orderDesc":"\u8ba2\u5355\u5931\u8d25"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('baixuan','RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);