瀏覽代碼

weisanhou

zb727 1 年之前
父節點
當前提交
5097e13253

+ 31 - 0
data/config/mh/refill.ini.php

@@ -106,6 +106,36 @@ $suhu_wozhifu = ['name' => 'suhu_wozhifu', 'store_id' => 380,'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$weisanhuo_normal = ['name' => 'weisanhuo_normal', 'store_id' => 383, 'qualitys' => '1',
+    'amount' => [
+        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'],
+        ],
+        500 => [
+            ['goods_id' => 9016, 'price' => 476,    'quality' => 1, 'card_type' => 'chinamobile'],
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
 
 $yushang_normal = ['name' => 'yushang_normal', 'store_id' => 381,'qualitys' => '1',
     'amount' => [
@@ -144,6 +174,7 @@ $phone_providers = [
     ['name' => 'dixin_slow', 'cfg' => $dixin_slow],
     ['name' => 'suhu_normal', 'cfg' => $suhu_normal],
     ['name' => 'suhu_wozhifu', 'cfg' => $suhu_wozhifu],
+    ['name' => 'weisanhuo_phone', 'cfg' => $weisanhuo_normal],
     ['name' => 'yushang_normal', 'cfg' => $yushang_normal]
 ];
 

+ 34 - 0
helper/refill/api/mh/weisanhuo_normal/API.MD

@@ -0,0 +1,34 @@
+
+## 微三活 普充
+
+### 账号:
+- 用户名:bjmh
+- 密码:bjmh@2023
+- 密钥ID(secretId):9aebda54f899419a80f315b33b6ed395
+- 密钥值(secretKey):14d56f3637ba4618b50e91f444d1a029
+### 后台地址:
+> http://124.70.69.117:50080
+
+## 店铺
+- 账号:weisanhuo
+- 密码:weisanhuo@888
+
+### 编码
+序号 商品名称 商品代码 面值 商品类型 品牌
+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/mh/weisanhuo_normal/RefillCallBack.php

@@ -0,0 +1,40 @@
+<?php
+namespace refill\weisanhuo_normal;
+
+require_once(BASE_HELPER_RAPI_PATH . '/weisanhuo_normal/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['operatorTradeNo'];
+            Model('refill_order')->edit($order_id, ['official_sn' => $official_sn, 'ch_trade_no' => $params['inTradeNo']]);
+            return [$order_id, true, false, true, $official_sn];
+        } elseif ($status == 'failed') {
+            return [$order_id, false, true, true, ''];
+        } else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 147 - 0
helper/refill/api/mh/weisanhuo_normal/RefillPhone.php

@@ -0,0 +1,147 @@
+<?php
+
+namespace refill\weisanhuo_normal;
+
+require_once(BASE_HELPER_RAPI_PATH . '/weisanhuo_normal/config.php');
+
+use refill;
+use Log;
+
+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);
+        if (empty($params)){
+            return [false, '产品编码错误', false];
+        }
+
+        $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 = '';
+
+                if(!empty($resp['data']))
+                {
+                    $status = $resp['data']['status'];
+                    if ($status == 'success') {
+                        $offical_sn = $resp['data']['operatorTradeNo'];
+                        $ch_trade_no = $resp['data']['inTradeNo'];
+                        Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $offical_sn,'ch_trade_no' => $ch_trade_no]);
+                        $order_state = ORDER_STATE_SUCCESS;
+                    } elseif ($status == 'failed') {
+                        $ch_trade_no = $resp['data']['inTradeNo'];
+                        Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $ch_trade_no]);
+                        $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];
+                }
+                elseif ((time() - $refill_info['commit_time']) >= 600) {
+                    return [true, ORDER_STATE_NOEXIST, $offical_sn];
+                }
+                else {
+                    return [true, ORDER_STATE_SEND, $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);
+
+        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']];
+            }
+        }
+    }
+}

二進制
helper/refill/api/mh/weisanhuo_normal/code.xlsx


+ 70 - 0
helper/refill/api/mh/weisanhuo_normal/config.php

@@ -0,0 +1,70 @@
+<?php
+namespace refill\weisanhuo_normal;
+
+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 = '9aebda54f899419a80f315b33b6ed395';
+    const SECRET_KEY = '14d56f3637ba4618b50e91f444d1a029';
+    const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/mh/weisanhuo_normal.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;
+    }
+}

二進制
helper/refill/api/mh/weisanhuo_normal/help.doc


二進制
helper/refill/api/mh/weisanhuo_normal/~$help.doc


+ 8 - 0
racc/callback/mh/weisanhuo_normal.php

@@ -0,0 +1,8 @@
+<?php
+$content = $_SERVER['post_content'] ?? [];
+Log::record("weissanhuo_normal content=$content",Log::DEBUG);
+
+$input = json_decode($content,true);
+refill\util::push_notify('weisanhuo_normal',$input);
+
+echo ('success');