浏览代码

menggu and menggu_hf

xiaoyu 3 年之前
父节点
当前提交
1564fd8df5

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

@@ -217,6 +217,13 @@ $xunyinoil_oil = ['name' => 'xunyinoil', 'store_id' => 109,'qualitys' => '2',
     ],
     'period' => [], 'refill_type' => 'api'];
 
+$menggu_oil = ['name' => 'menggu', 'store_id' => 130, 'qualitys' => '2',
+    'amount' => [
+        500 => [['goods_id' => 7128, 'price' => 499, 'quality' => 2, 'card_type' => 'sinopec']],
+        1000 => [['goods_id' => 7129, 'price' => 998, 'quality' => 2, 'card_type' => 'sinopec']]
+    ],
+    'period' => [], 'refill_type' => 'api'];
+
 $oil_providers = [
 //    ['name' => 'tianjt', 'cfg' => $tianjt_oil],
 //    ['name' => 'suhctm', 'cfg' => $suhctm_oil],
@@ -235,7 +242,8 @@ $oil_providers = [
     ['name' => 'yingdian', 'cfg' => $yingdian_oil],
     ['name' => 'fetch_zanzan', 'cfg' => $fetch_zanzan_oil],
     ['name' => 'fetch_lingzh', 'cfg' => $fetch_lingzh_oil],
-    ['name' => 'xunyinoil', 'cfg' => $xunyinoil_oil]
+    ['name' => 'xunyinoil', 'cfg' => $xunyinoil_oil],
+    ['name' => 'menggu', 'cfg' => $menggu_oil]
 ];
 $config['oil_providers'] = $oil_providers;
 
@@ -2571,6 +2579,43 @@ $yuanta_phone = ['name' => 'yuanta', 'store_id' => 128, 'qualitys' => '5',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$menggu_hf_phone = ['name' => 'menggu_hf', 'store_id' => 131,'qualitys' => '2',
+    'amount' => [
+        10 => [
+            ['goods_id' => 7131, 'price' => 9.995, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7131, 'price' => 9.99, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        20 => [
+            ['goods_id' => 7132, 'price' => 19.99, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7132, 'price' => 19.98, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        30 => [
+            ['goods_id' => 7133, 'price' => 29.985, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7133, 'price' => 29.97, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        50 => [
+            ['goods_id' => 7134, 'price' => 49.975, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7134, 'price' => 49.95, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        100 => [
+            ['goods_id' => 7135, 'price' => 99.95, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7135, 'price' => 99.9, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        200 => [
+            ['goods_id' => 7136, 'price' => 199.9, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7136, 'price' => 199.8, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        300 => [
+            ['goods_id' => 7137, 'price' => 299.85, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7137, 'price' => 299.7, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        500 => [
+            ['goods_id' => 7138, 'price' => 499.75, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7138, 'price' => 499.5, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2669,6 +2714,7 @@ $phone_providers = [
     ['name' => 'hangtong', 'cfg' => $hangtong_phone],
     ['name' => 'dashang', 'cfg' => $dashang_phone],
     ['name' => 'yuanta', 'cfg' => $yuanta_phone],
+    ['name' => 'menggu_hf', 'cfg' => $menggu_hf_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -217,6 +217,13 @@ $xunyinoil_oil = ['name' => 'xunyinoil', 'store_id' => 109,'qualitys' => '2',
     ],
     'period' => [], 'refill_type' => 'api'];
 
+$menggu_oil = ['name' => 'menggu', 'store_id' => 130, 'qualitys' => '2',
+    'amount' => [
+        500 => [['goods_id' => 7128, 'price' => 499, 'quality' => 2, 'card_type' => 'sinopec']],
+        1000 => [['goods_id' => 7129, 'price' => 998, 'quality' => 2, 'card_type' => 'sinopec']]
+    ],
+    'period' => [], 'refill_type' => 'api'];
+
 $oil_providers = [
 //    ['name' => 'tianjt', 'cfg' => $tianjt_oil],
 //    ['name' => 'suhctm', 'cfg' => $suhctm_oil],
@@ -235,7 +242,8 @@ $oil_providers = [
     ['name' => 'yingdian', 'cfg' => $yingdian_oil],
     ['name' => 'fetch_zanzan', 'cfg' => $fetch_zanzan_oil],
     ['name' => 'fetch_lingzh', 'cfg' => $fetch_lingzh_oil],
-    ['name' => 'xunyinoil', 'cfg' => $xunyinoil_oil]
+    ['name' => 'xunyinoil', 'cfg' => $xunyinoil_oil],
+    ['name' => 'menggu', 'cfg' => $menggu_oil]
 ];
 $config['oil_providers'] = $oil_providers;
 
@@ -2571,6 +2579,43 @@ $yuanta_phone = ['name' => 'yuanta', 'store_id' => 128, 'qualitys' => '5',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$menggu_hf_phone = ['name' => 'menggu_hf', 'store_id' => 131,'qualitys' => '2',
+    'amount' => [
+        10 => [
+            ['goods_id' => 7131, 'price' => 9.995, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7131, 'price' => 9.99, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        20 => [
+            ['goods_id' => 7132, 'price' => 19.99, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7132, 'price' => 19.98, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        30 => [
+            ['goods_id' => 7133, 'price' => 29.985, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7133, 'price' => 29.97, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        50 => [
+            ['goods_id' => 7134, 'price' => 49.975, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7134, 'price' => 49.95, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        100 => [
+            ['goods_id' => 7135, 'price' => 99.95, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7135, 'price' => 99.9, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        200 => [
+            ['goods_id' => 7136, 'price' => 199.9, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7136, 'price' => 199.8, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        300 => [
+            ['goods_id' => 7137, 'price' => 299.85, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7137, 'price' => 299.7, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        500 => [
+            ['goods_id' => 7138, 'price' => 499.75, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7138, 'price' => 499.5, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2669,6 +2714,7 @@ $phone_providers = [
     ['name' => 'hangtong', 'cfg' => $hangtong_phone],
     ['name' => 'dashang', 'cfg' => $dashang_phone],
     ['name' => 'yuanta', 'cfg' => $yuanta_phone],
+    ['name' => 'menggu_hf', 'cfg' => $menggu_hf_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -217,6 +217,13 @@ $xunyinoil_oil = ['name' => 'xunyinoil', 'store_id' => 109,'qualitys' => '2',
     ],
     'period' => [], 'refill_type' => 'api'];
 
+$menggu_oil = ['name' => 'menggu', 'store_id' => 130, 'qualitys' => '2',
+    'amount' => [
+        500 => [['goods_id' => 7128, 'price' => 499, 'quality' => 2, 'card_type' => 'sinopec']],
+        1000 => [['goods_id' => 7129, 'price' => 998, 'quality' => 2, 'card_type' => 'sinopec']]
+    ],
+    'period' => [], 'refill_type' => 'api'];
+
 $oil_providers = [
 //    ['name' => 'tianjt', 'cfg' => $tianjt_oil],
 //    ['name' => 'suhctm', 'cfg' => $suhctm_oil],
@@ -235,7 +242,8 @@ $oil_providers = [
     ['name' => 'yingdian', 'cfg' => $yingdian_oil],
     ['name' => 'fetch_zanzan', 'cfg' => $fetch_zanzan_oil],
     ['name' => 'fetch_lingzh', 'cfg' => $fetch_lingzh_oil],
-    ['name' => 'xunyinoil', 'cfg' => $xunyinoil_oil]
+    ['name' => 'xunyinoil', 'cfg' => $xunyinoil_oil],
+    ['name' => 'menggu', 'cfg' => $menggu_oil]
 ];
 $config['oil_providers'] = $oil_providers;
 
@@ -2571,6 +2579,43 @@ $yuanta_phone = ['name' => 'yuanta', 'store_id' => 128, 'qualitys' => '5',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$menggu_hf_phone = ['name' => 'menggu_hf', 'store_id' => 131,'qualitys' => '2',
+    'amount' => [
+        10 => [
+            ['goods_id' => 7131, 'price' => 9.995, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7131, 'price' => 9.99, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        20 => [
+            ['goods_id' => 7132, 'price' => 19.99, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7132, 'price' => 19.98, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        30 => [
+            ['goods_id' => 7133, 'price' => 29.985, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7133, 'price' => 29.97, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        50 => [
+            ['goods_id' => 7134, 'price' => 49.975, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7134, 'price' => 49.95, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        100 => [
+            ['goods_id' => 7135, 'price' => 99.95, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7135, 'price' => 99.9, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        200 => [
+            ['goods_id' => 7136, 'price' => 199.9, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7136, 'price' => 199.8, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        300 => [
+            ['goods_id' => 7137, 'price' => 299.85, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7137, 'price' => 299.7, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ],
+        500 => [
+            ['goods_id' => 7138, 'price' => 499.75, 'quality' => 2, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7138, 'price' => 499.5, 'quality' => 2, 'card_type' => 'chinaunicom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2669,6 +2714,7 @@ $phone_providers = [
     ['name' => 'hangtong', 'cfg' => $hangtong_phone],
     ['name' => 'dashang', 'cfg' => $dashang_phone],
     ['name' => 'yuanta', 'cfg' => $yuanta_phone],
+    ['name' => 'menggu_hf', 'cfg' => $menggu_hf_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 1 - 1
helper/refill/api/xyz/dashang/RefillPhone.php

@@ -136,7 +136,7 @@ class RefillPhone extends refill\IRefillPhone
             if (empty($resp)) {
                 return [false, '网络错误'];
             } elseif ($resp['status'] === 'success' && $resp['code'] === '00') {
-                return [true, $resp['balance']];
+                return [true, $resp['balance']/1000];
             } else {
                 return [false, $resp['code']];
             }

+ 82 - 0
helper/refill/api/xyz/menggu/RefillCallBack.php

@@ -0,0 +1,82 @@
+<?php
+namespace refill\menggu;
+
+require_once(BASE_HELPER_RAPI_PATH . '/menggu/config.php');
+use Log;
+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) {
+            Log::record("mengu sms:{$params['ext1']}",Log::DEBUG);
+            Model('')->table('refill_ext')->insert(['order_id' => $order_id, 'sms' => $params['ext1']]);
+            $official_sn = $this->substr_content($params['ext1']);
+            $data['official_sn'] = strtolower($official_sn) == 'null' ? '' : $official_sn;
+            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];
+        }
+    }
+
+    private function substr_content($content)
+    {
+        $data = explode(':',$content);
+        if(count($data) > 1) {
+            return $data[1];
+        } else {
+            return '';
+        }
+    }
+}

+ 151 - 0
helper/refill/api/xyz/menggu/RefillOil.php

@@ -0,0 +1,151 @@
+<?php
+
+namespace refill\menggu;
+
+require_once(BASE_HELPER_RAPI_PATH . '/menggu/config.php');
+
+use refill;
+use Log;
+
+class RefillOil extends refill\IRefillOil
+{
+    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['amount'] = 1;
+        $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'], [-22, -23, -99])) {
+                $net_errno = "HTTP-{$resp['code']}";
+                return [false, $resp['msg'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    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 = intval($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;
+                } 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);
+    }
+}

+ 23 - 0
helper/refill/api/xyz/menggu/config.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace refill\menggu;
+
+use mtopcard;
+
+class config
+{
+    const ORDER_URL = 'http://120.26.80.21:8911/api/order/submit';
+    const QUERY_URL = 'http://120.26.80.21:8911/api/order/query';
+    const BALANCE_URL = 'http://120.26.80.21:8911/api/account/balance';
+
+    const APP_ID = '1hqLCRUja7';
+    const APP_SECRET = 'UbZBPJdeXcWaJtgy';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_menggu.php";
+    const PRODUCT = [
+        mtopcard\SinopecCard => [
+            500 => 100004,
+            1000 => 100005
+        ]
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+}

+ 24 - 0
helper/refill/api/xyz/menggu/开户信息.txt

@@ -0,0 +1,24 @@
+后台地址:http://120.26.80.21:8888
+帐号:bjgyhf
+密码:761897
+二级密码:wrwA4990
+appId:1hqLCRUja7
+appSecret:UbZBPJdeXcWaJtgy
+接口服务器:120.26.80.21
+http端口:8911,https端口:8443
+后台-接口文档,可查看及下载接口文档
+后台-商品列表,可查看已配置商品信息
+后台-安全中心,可配置IP白名单
+
+
+在线文档:https://www.showdoc.com.cn/900133176881927?page_id=4798465261069610
+
+
+直充下单地址:http://120.26.80.21:8911/api/order/submit
+提卡下单地址:http://120.26.80.21:8911/api/card/get
+查单地址:http://120.26.80.21:8911/api/order/query
+余额地址:http://120.26.80.21:8911/api/account/balance
+
+对接好请绑定ip白名单(可自助)
+回调地址接口传不用绑
+

+ 69 - 0
helper/refill/api/xyz/menggu_hf/RefillCallBack.php

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

+ 151 - 0
helper/refill/api/xyz/menggu_hf/RefillPhone.php

@@ -0,0 +1,151 @@
+<?php
+
+namespace refill\menggu_hf;
+
+require_once(BASE_HELPER_RAPI_PATH . '/menggu_hf/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['amount'] = 1;
+        $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'], [-22, -23, -99])) {
+                $net_errno = "HTTP-{$resp['code']}";
+                return [false, $resp['msg'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    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 = intval($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;
+                } 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);
+    }
+}

+ 33 - 0
helper/refill/api/xyz/menggu_hf/config.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace refill\menggu_hf;
+
+use mtopcard;
+
+class config
+{
+    const ORDER_URL = 'http://120.26.80.21:8911/api/order/submit';
+    const QUERY_URL = 'http://120.26.80.21:8911/api/order/query';
+    const BALANCE_URL = 'http://120.26.80.21:8911/api/account/balance';
+
+    const APP_ID = '1hqLCRUja7';
+    const APP_SECRET = 'UbZBPJdeXcWaJtgy';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_menggu_hf.php";
+    const PRODUCT = [
+        mtopcard\ChinaUnicomCard => [
+            50  => 100091,
+            100 => 100092,
+            200 => 100093,
+            300 => 100094,
+            500 => 100095
+        ],
+        mtopcard\ChinaTelecomCard => [
+            50  => 100108,
+            100 => 100109,
+            200 => 100110,
+            300 => 100111,
+            500 => 100112
+        ],
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+}

+ 24 - 0
helper/refill/api/xyz/menggu_hf/开户信息.txt

@@ -0,0 +1,24 @@
+后台地址:http://120.26.80.21:8888
+帐号:bjgyhf
+密码:761897
+二级密码:wrwA4990
+appId:1hqLCRUja7
+appSecret:UbZBPJdeXcWaJtgy
+接口服务器:120.26.80.21
+http端口:8911,https端口:8443
+后台-接口文档,可查看及下载接口文档
+后台-商品列表,可查看已配置商品信息
+后台-安全中心,可配置IP白名单
+
+
+在线文档:https://www.showdoc.com.cn/900133176881927?page_id=4798465261069610
+
+
+直充下单地址:http://120.26.80.21:8911/api/order/submit
+提卡下单地址:http://120.26.80.21:8911/api/card/get
+查单地址:http://120.26.80.21:8911/api/order/query
+余额地址:http://120.26.80.21:8911/api/account/balance
+
+对接好请绑定ip白名单(可自助)
+回调地址接口传不用绑
+

+ 4 - 0
mobile/callback/refill_menggu.php

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

+ 4 - 0
mobile/callback/refill_menggu_hf.php

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

+ 27 - 0
test/TestRefill.php

@@ -1035,6 +1035,33 @@ class TestRefill extends TestCase
 //        $resp = $providers->query(['order_sn' => '61501631786913519186']);
     }
 
+    public function testMenggu()
+    {
+//        $providers = $this->getProvider('menggu','RefillOil');
+//        $resp = $providers->add(1000111100021211884, 2, 500, ['order_sn' => $this->make_sn()]);
+//        $resp = $providers->query(['order_sn' => '63021632301956855605']);
+
+        $body = '{"orderId":"210922171242123506","appId":"1hqLCRUja7","outOrderId":"63021632301956855605","sign":"f3f0b48657bb4e3b993aa284159c6565","orderStatus":"2","completeTime":"20210922171306","orderDesc":"\u8ba2\u5355\u6210\u529f","ext1":"\u3010\u4e2d\u56fd\u77f3\u5316\u3011\u60a8\u5c3e\u53f7\u4e3a211884\u7684\u52a0\u6cb9\u5361\u4e8e09\u670822\u65e5 17\u65f612\u5206\u5145\u503c\u6210\u529f,\u91d1\u989d500\u5143,\u8ba2\u5355\u53f7:2521092217126714"}';
+        $params = json_decode($body, true);
+        $providers = $this->getProvider('menggu','RefillCallBack');
+        $ret = $providers->verify($params);
+        $resp = $providers->notify($params);
+    }
+
+    public function testMenggu_hf()
+    {
+        $providers = $this->getProvider('menggu_hf');
+//        $resp = $providers->balance();
+        $resp = $providers->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
+//        $resp = $providers->query(['order_sn' => '24481632298991701065']);
+
+//        $body = '{"orderId":"210922162318123069","appId":"1hqLCRUja7","outOrderId":"24481632298991701065","sign":"73faefba3e179641af0df6f59becce8f","orderStatus":"3","completeTime":"20210922162451","orderDesc":"\u8ba2\u5355\u5931\u8d25"}';
+//        $params = json_decode($body, true);
+//        $providers = $this->getProvider('menggu_hf','RefillCallBack');
+//        $ret = $providers->verify($params);
+//        $resp = $providers->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $providers = new refill\amingjd\RefillPhone([]);