Browse Source

椰子,微三活普充

zhaoming 1 year ago
parent
commit
caced53a9b

+ 69 - 23
data/config/xyz/refill.ini.php

@@ -10065,35 +10065,80 @@ $beirui_sec_phone = ['name' => 'beirui_sec', 'store_id' => 382, 'qualitys' => '1
 //        ]
 //        ]
     ],
     ],
     'official_sn' => true, 'refill_type' => 'api'];
     'official_sn' => true, 'refill_type' => 'api'];
-//
-//$beirui_trd_phone = ['name' => 'beirui_trd', 'store_id' => 383, 'qualitys' => '1',
-//    'amount' => [
-////        10 => [
-////            ['goods_id' => 9001, 'price' => 9.68, 'quality' => 1, 'card_type' => 'chinamobile'],
-////        ],
-////        20 => [
-////            ['goods_id' => 9002, 'price' => 19.36, 'quality' => 1, 'card_type' => 'chinamobile'],
-////        ],
-////        30 => [
-////            ['goods_id' => 9003, 'price' => 29.04, 'quality' => 1, 'card_type' => 'chinamobile'],
-////        ],
-////        50 => [
-////            ['goods_id' => 9004, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinamobile'],
-////        ],
+
+$beirui_trd_phone = ['name' => 'beirui_trd', 'store_id' => 383, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 9001, 'price' => 9.68, 'quality' => 1, 'card_type' => 'chinamobile'],
+//        ],
+//        20 => [
+//            ['goods_id' => 9002, 'price' => 19.36, 'quality' => 1, 'card_type' => 'chinamobile'],
+//        ],
+//        30 => [
+//            ['goods_id' => 9003, 'price' => 29.04, 'quality' => 1, 'card_type' => 'chinamobile'],
+//        ],
+//        50 => [
+//            ['goods_id' => 9004, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//        ],
 //        100 => [
 //        100 => [
 //            ['goods_id' => 9005, 'price' => 96.5, 'quality' => 1, 'card_type' => 'chinamobile'],
 //            ['goods_id' => 9005, 'price' => 96.5, 'quality' => 1, 'card_type' => 'chinamobile'],
 //        ],
 //        ],
 //        200 => [
 //        200 => [
 //            ['goods_id' => 9006, 'price' => 193, 'quality' => 1, 'card_type' => 'chinamobile'],
 //            ['goods_id' => 9006, 'price' => 193, 'quality' => 1, 'card_type' => 'chinamobile'],
 //        ],
 //        ],
-////        300 => [
-////            ['goods_id' => 9007, 'price' => 290.4, 'quality' => 1, 'card_type' => 'chinamobile'],
-////        ],
-////        500 => [
-////            ['goods_id' => 9008, 'price' => 484, 'quality' => 1, 'card_type' => 'chinamobile'],
-////        ]
-//    ],
-//    'official_sn' => true, 'refill_type' => 'api'];
+//        300 => [
+//            ['goods_id' => 9007, 'price' => 290.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+//        ],
+//        500 => [
+//            ['goods_id' => 9008, 'price' => 484, 'quality' => 1, 'card_type' => 'chinamobile'],
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+$weisanhuo_phone = ['name' => 'weisanhuo', 'store_id' => 384, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 9009, 'price' => 9.68, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9009, 'price' => 9.4, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9009, 'price' => 9.57, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 9010, 'price' => 19.36, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9010, 'price' => 18.8, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9010, 'price' => 19.14, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        30 => [
+//            ['goods_id' => 9011, 'price' => 29.04, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9011, 'price' => 28.2, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9011, 'price' => 28.71, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        50 => [
+//            ['goods_id' => 9012, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9012, 'price' => 47, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9012, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+        100 => [
+            ['goods_id' => 9013, 'price' => 95.2, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9013, 'price' => 94, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9013, 'price' => 95, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 9014, 'price' => 190.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9014, 'price' => 188, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9014, 'price' => 190, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 9015, 'price' => 285.6, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9015, 'price' => 282, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9015, 'price' => 287.1, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 9016, 'price' => 476, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9016, 'price' => 470, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9016, 'price' => 478.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
 
 
 $phone_providers = [
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_p hone],
 //    ['name' => 'beixt', 'cfg' => $beixt_p hone],
@@ -10399,6 +10444,7 @@ $phone_providers = [
     ['name' => 'miaoxt_tax_seco', 'cfg' => $miaoxt_tax_seco_phone],
     ['name' => 'miaoxt_tax_seco', 'cfg' => $miaoxt_tax_seco_phone],
     ['name' => 'beirui_sec', 'cfg' => $beirui_sec_phone],
     ['name' => 'beirui_sec', 'cfg' => $beirui_sec_phone],
 //    ['name' => 'beirui_trd', 'cfg' => $beirui_trd_phone],
 //    ['name' => 'beirui_trd', 'cfg' => $beirui_trd_phone],
+        ['name' => 'weisanhuo', 'cfg' => $weisanhuo_phone],
 ];
 ];
 $config['phone_providers'] = $phone_providers;
 $config['phone_providers'] = $phone_providers;
 
 

+ 34 - 0
helper/refill/api/xyz/weisanhuo/API.MD

@@ -0,0 +1,34 @@
+
+## 微三活 普充
+
+### 账号:
+- 用户名:bjfqs
+- 密码:bjfqs@2023
+- 密钥ID(secretId):231c9717118f4413b1611a3a87221795
+- 密钥值(secretKey):0109d2f30b414832a0f1e8c29720eff3
+### 后台地址:
+> http://124.70.69.117:50080
+
+## 店铺
+- 账号:weisanhuo
+- 密码:weisanhuo67890
+
+### 编码
+序号 商品名称 商品代码 面值 商品类型 品牌
+1 全国电信200元 k-dx-200 200 元 手机话费 电信
+2 全国电信100元 k-dx-100 100 元 手机话费 电信
+3 全国电信50元 k-dx-50 50 元 手机话费 电信
+4 全国电信30元 k-dx-30 30 元 手机话费 电信
+5 全国移动500元 k-yd-500 500 元 手机话费 移动
+6 全国移动300元 k-yd-300 300 元 手机话费 移动
+7 全国移动200元 k-yd-200 200 元 手机话费 移动
+8 全国移动100元 k-yd-100 100 元 手机话费 移动
+9 全国移动50元 k-yd-50 50 元 手机话费 移动
+10 全国移动30元 k-yd-30 30 元 手机话费 移动
+11 全国联通200元 k-lt-200 200 元 手机话费 联通
+12 全国联通100元 k-lt-100 100 元 手机话费 联通
+13 全国联通50元 k-lt-50 50 元 手机话费 联通
+14 全国联通30元 k-lt-30 30 元 手机话费 联通
+
+### 测试代码
+- cshf1

+ 40 - 0
helper/refill/api/xyz/weisanhuo/RefillCallBack.php

@@ -0,0 +1,40 @@
+<?php
+namespace refill\weisanhuo;
+
+require_once(BASE_HELPER_RAPI_PATH . '/weisanhuo/config.php');
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = config::sign($params, ['sign']);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public function notify($params): array
+    {
+        $status = $params['status'];
+        $order_sn = $params['outTradeNo'];
+        $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 == 'success') {
+            $official_sn = $params['inTradeNo'];
+            Model('refill_order')->edit($order_id, ['official_sn' => $official_sn, 'ch_trade_no' => $params['orderId']]);
+            return [$order_id, true, false, true, $official_sn];
+        } elseif ($status == 'failed') {
+            return [$order_id, false, true, true, ''];
+        } else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 132 - 0
helper/refill/api/xyz/weisanhuo/RefillPhone.php

@@ -0,0 +1,132 @@
+<?php
+
+namespace refill\weisanhuo;
+
+require_once(BASE_HELPER_RAPI_PATH . '/weisanhuo/config.php');
+
+use refill;
+use Log;
+use refill\util;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $card_no, int $card_type, string $order_sn, int $amount): array
+    {
+        $params['outTradeNo'] = $order_sn;
+        $params['secretId'] = config::SECRET_ID;
+        $params['account'] = $card_no;
+
+        $product_id = config::ProductIdS[$card_type][$amount] ?? false;
+        if ($product_id === false){
+            return [];
+        }
+        $params['packageCode'] = $product_id;
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
+    {
+        $params = $this->req_params($card_no, $card_type, $params['order_sn'], $amount);
+        $sign = config::sign($params,['outTradeNo']);
+        $params['sign'] = $sign;
+
+        $params = json_encode($params);
+        $resp = http_post_data(config::ORDER_URL, $params , 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];
+            }
+            if ($resp['success'] === false){
+                return [false, $resp['returnMessage'], false];
+            }
+
+            $status = $resp['data']['status'];
+            if ($status == 'waiting') {
+                return [true, $resp['data']['inTradeNo'], false];
+            } else {
+                return [false, $resp['data']['statusDesc'], false];
+            }
+        }
+    }
+
+    public function query($refill_info): array
+    {
+        $params['secretId'] = config::SECRET_ID;
+        $params['outTradeNo'] = $refill_info['order_sn'];
+
+        $sign = config::sign($params, ['outTradeNo']);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::QUERY_URL, $params, 'GET');
+        if (empty($resp)) {
+            return [false, '网络错误', ''];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+
+            $resp = json_decode($resp, true);
+            if (empty($resp))
+            {
+                return [false, '网络错误', ''];
+            }
+            elseif ($resp['success'] === true)
+            {
+                $offical_sn = '';
+
+                $status = $resp['data']['status'];
+                if ($status == 'success') {
+                    $offical_sn = $resp['data']['inTradeNo'];
+                    Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $offical_sn]);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status == 'failed') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status == 'waiting') {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $status, $offical_sn];
+                }
+                return [true, $order_state, $offical_sn];
+            }
+            else
+            {
+                return [false, $resp['returnMessage'], ''];
+            }
+        }
+    }
+
+    public function balance(): array
+    {
+        $params['secretId'] = config::SECRET_ID;
+
+        $sign = config::sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::BALANCE_URL, $params, 'GET');
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+
+            $resp = json_decode($resp, true);
+            if ($resp['success'] === true) {
+                return [true, $resp['data']];
+            } else {
+                return [false, $resp['returnMessage']];
+            }
+        }
+    }
+}

BIN
helper/refill/api/xyz/weisanhuo/code.xlsx


+ 70 - 0
helper/refill/api/xyz/weisanhuo/config.php

@@ -0,0 +1,70 @@
+<?php
+namespace refill\weisanhuo;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://124.70.69.117:50050/api/v1/rest/multi/charge/single';
+    const QUERY_URL = 'http://124.70.69.117:50050/api/v1/rest/multi/charge/report/query';
+    const BALANCE_URL = 'http://124.70.69.117:50050/api/v1/rest/multi/charge/balance';
+
+    const SECRET_ID = '231c9717118f4413b1611a3a87221795';
+    const SECRET_KEY = '0109d2f30b414832a0f1e8c29720eff3';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_weisanhuo.php";
+    const ExtHeaders = ['Content-Type: application/json;charset=UTF-8'];
+
+    const ProductIdS = [
+        mtopcard\ChinaMobileCard =>
+            [
+                30 => 'k-yd-30',
+                50 => 'k-yd-50',
+                100 => 'k-yd-100',
+                200 => 'k-yd-200',
+                300 => 'k-yd-300',
+                500 => 'k-yd-500'
+            ],
+        mtopcard\ChinaUnicomCard =>
+            [
+                30 => 'k-lt-30',
+                50 => 'k-lt-50',
+                100 => 'k-lt-100',
+                200 => 'k-lt-200'
+            ],
+        mtopcard\ChinaTelecomCard =>
+            [
+                30 => 'k-dx-30',
+                50 => 'k-dx-50',
+                100 => 'k-dx-100',
+                200 => 'k-dx-200'
+            ]
+    ];
+
+    public static function sign(array $params, array $ignore = []): string
+    {
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if (in_array($key, $ignore)) {
+                continue;
+            }
+
+            if(self::check_empty($value) === false) {
+                $key = strtolower($key);
+                $value = urlencode($value);
+                $content .= "$key=$value&";
+            }
+        }
+        $content .= "secretkey=" . config::SECRET_KEY;
+        return md5($content);
+    }
+
+    public static function check_empty($value): bool
+    {
+        if (!isset($value))
+            return true;
+        if (trim($value) === "null")
+            return true;
+
+        return false;
+    }
+}

BIN
helper/refill/api/xyz/weisanhuo/help.doc


+ 6 - 0
mobile/callback/refill_weisanhuo.php

@@ -0,0 +1,6 @@
+<?php
+$content = $_SERVER['post_content'] ?? [];
+$input = json_decode($content,true);
+refill\util::push_notify('weisanhuo',$input);
+
+echo ('success');

+ 15 - 0
test/TestRefill.php

@@ -5806,6 +5806,21 @@ class TestRefill extends TestCase
         $provider = $this->getProvider('beirui_trd');
         $provider = $this->getProvider('beirui_trd');
         $resp = $provider->balance();
         $resp = $provider->balance();
     }
     }
+
+    public function testweisanhuo()
+    {
+        $provider = $this->getProvider('weisanhuo');
+        $resp = $provider->balance();
+        $resp = $provider->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
+        $resp = $provider->query(['order_sn' => '24271700815859899563']);
+
+        $post = '{"operatorTradeNo":"","statusDesc":"交易成功","phone":"18780103116","outTradeNo":"202309250000000006","sign":"d793406757c1bb920fe518e9673a28ea","inTradeNo":"202309251766523539","status":"success","reportTime":"1695607732705"}';
+        $data = json_decode($post, true);
+        $provider = $this->getProvider('weisanhuo', 'RefillCallBack');
+
+        $ret = $provider->verify($data);
+//        $resp = $provider->notify($data);
+    }
 }
 }