Browse Source

xyz meixu_kami

xiaoyu 2 years ago
parent
commit
433cc810fd

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

@@ -7185,6 +7185,43 @@ $qianqian_fs_gd_phone = ['name' => 'qianqian_fs_gd', 'store_id' => 265, 'quality
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$meixu_kami_phone = ['name' => 'meixu_kami', 'store_id' => 266, 'qualitys' => '2',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 8215, 'price' => 10.05, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8215, 'price' => 10.09, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 8216, 'price' => 20.1, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8216, 'price' => 20.18, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+//        30 => [
+//            ['goods_id' => 8217, 'price' => 30.15, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8217, 'price' => 30.27, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+        50 => [
+            ['goods_id' => 8218, 'price' => 50.25, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8218, 'price' => 50.45, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 8219, 'price' => 100.5, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8219, 'price' => 100.9, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+//        200 => [
+//            ['goods_id' => 8220, 'price' => 201, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8220, 'price' => 201.8, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+//        300 => [
+//            ['goods_id' => 8221, 'price' => 301.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8221, 'price' => 302.7, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        500 => [
+//            ['goods_id' => 8222, 'price' => 502.5, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8222, 'price' => 504.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -7407,6 +7444,7 @@ $phone_providers = [
     ['name' => 'meixu_fs', 'cfg' => $meixu_fs_phone],
     ['name' => 'dazhanggui_fs_gd', 'cfg' => $dazhanggui_fs_gd_phone],
     ['name' => 'qianqian_fs_gd', 'cfg' => $qianqian_fs_gd_phone],
+    ['name' => 'meixu_kami', 'cfg' => $meixu_kami_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 48 - 0
helper/refill/api/xyz/meixu_kami/RefillCallBack.php

@@ -0,0 +1,48 @@
+<?php
+namespace refill\meixu_kami;
+
+require_once(BASE_HELPER_RAPI_PATH . '/meixu_kami/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&orderid={$params['orderid']}&sporderid={$params['sporderid']}&merchantsubmittime={$params['merchantsubmittime']}";
+        $content .= "&resultno={$params['resultno']}&key={$key}";
+        return strtoupper(md5($content));
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['resultno']);
+        $order_sn = $params['sporderid'];
+        $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 === 1) {
+            $data['official_sn'] = strtolower($params['remark1']) == 'null' ? '' : $params['remark1'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true];
+        } elseif ($status === 9) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 152 - 0
helper/refill/api/xyz/meixu_kami/RefillPhone.php

@@ -0,0 +1,152 @@
+<?php
+
+namespace refill\meixu_kami;
+
+require_once(BASE_HELPER_RAPI_PATH . '/meixu_kami/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, $card_type, string $order_sn)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['productid'] = config::ProductId[$card_type][$amount];
+        $params['price'] = $amount;
+        $params['num'] = 1;
+        $params['mobile'] = $phone;
+        $params['spordertime'] = date("YmdHis");
+        $params['sporderid'] = $order_sn;
+        $params['back_url'] = config::NOTIFY_URL;
+        $params['paytype'] = config::operator[$card_type];
+
+        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);
+
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, [], $net_errno);
+
+        if (empty($resp)) {
+            return [false, '网络错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            }
+
+            $resultno = $resp['resultno'];
+            if (in_array($resultno, ['0', '1', '2'], true)) {
+                return [true, $resp['orderid'], false];
+            } elseif (in_array($resultno, config::ERR_NOS, true)) {
+                return [false, $resultno, false];
+            } elseif (in_array($resultno, ['9999', '5006'], true)) {
+                $net_errno = "HTTP-{$resultno}";
+                return [false, $resultno, true];
+            } else {
+                //未知结果码
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resultno, true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['sporderid'] = $refill_info['order_sn'];
+
+        $resp = http_request(config::QUERY_URL, $params, 'POST');
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp))
+            {
+                return [false, '网络错误'];
+            }
+            else
+            {
+                $resultno = $resp['resultno'];
+                if ($resultno === '1') {
+                    $updata['official_sn'] = $resp['remark1'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($resultno === '9') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($resultno, ['0','2'], true)) {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($resultno === '5007' && (time() - $refill_info['commit_time'] > 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resultno];
+                }
+
+                return [true, $order_state];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['userid'] = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&key={$key}";
+        $params['sign'] = md5($content);
+
+        $resp = http_request(config::BALANCE_URL, $params, 'POST');
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['resultno'] === '1') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['resultno']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&productid={$params['productid']}&price={$params['price']}&num={$params['num']}&mobile={$params['mobile']}&spordertime={$params['spordertime']}";
+        $content .= "&sporderid={$params['sporderid']}&key={$key}";
+        return md5($content);
+    }
+
+    public function xmlToArray($xml)
+    {
+        $replace_str = str_replace(' ','','encoding="gb2312"');
+        $xml = mb_convert_encoding($xml,"UTF-8","gb2312");
+        $xml = str_replace($replace_str, "encoding='utf-8'", $xml);
+        return refill\util::xmlToArray($xml);
+    }
+}

+ 37 - 0
helper/refill/api/xyz/meixu_kami/config.php

@@ -0,0 +1,37 @@
+<?php
+
+
+namespace refill\meixu_kami;
+
+use mtopcard;
+class config
+{
+    //https://docs.qq.com/doc/DR2lpVUdGY3JEU25k
+    const ORDER_URL = 'http://123.57.216.254:9086/onlinepay.do';
+    const QUERY_URL= 'http://123.57.216.254:9086/searchpay.do';
+    const BALANCE_URL = 'http://123.57.216.254:9086/searchbalance.do';
+
+    const USER_ID= '10005583';
+    const KEY = '8HTYCQjJyRepKxnfFJirTsW5SX5YM2fh';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_meixu_kami.php";
+    const operator = [
+        mtopcard\ChinaMobileCard  => 'yd',
+        mtopcard\ChinaUnicomCard  => 'lt',
+        mtopcard\ChinaTelecomCard => 'dx'
+    ];
+    const ERR_NOS = [
+        '5001','5002','5003','5004','5005','5008','5009','5010','5011','5012'
+    ];
+    const ProductId = [
+        mtopcard\ChinaMobileCard => [
+            50 => 100357,
+            100 => 100358,
+        ],
+        mtopcard\ChinaUnicomCard => [
+        ],
+        mtopcard\ChinaTelecomCard => [
+            50 => 100363,
+            100 => 100364,
+        ],
+    ];
+}

+ 17 - 0
helper/refill/api/xyz/meixu_kami/对接文档-yezi.txt

@@ -0,0 +1,17 @@
+在线对接文档:http://www.firstsup.net/showdoc
+后台登录地址:http://123.57.216.254:7080/
+登录名:GYKM
+初始密码:sup123456
+
+用户编号:10005583
+密钥:8HTYCQjJyRepKxnfFJirTsW5SX5YM2fh
+充值地址:http://123.57.216.254:9086/onlinepay.do
+查询地址:http://123.57.216.254:9086/searchpay.do
+余额地址:http://123.57.216.254:9086/searchbalance.do
+
+
+100357	全国移动卡密话费50元
+100358	全国移动卡密话费100元
+
+100363	全国电信卡密话费50元
+100364	全国电信卡密话费100元

+ 3 - 0
mobile/callback/refill_meixu_kami.php

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

+ 6 - 0
test/TestRefill.php

@@ -2805,6 +2805,12 @@ class TestRefill extends TestCase
         $resp = $provider->notify($params);
     }
 
+    public function testMeixu_kami()
+    {
+        $provider = $this->getProvider('meixu_kami');
+        $resp = $provider->balance();
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);