stanley-king 2 lat temu
rodzic
commit
90a30f294f

+ 11 - 0
helper/mtopcard/mtopcard.php

@@ -2,6 +2,8 @@
 
 namespace mtopcard;
 
+use login\pub_userinfo_log;
+
 require_once(BASE_HELPER_PATH . '/mtopcard/card_query.php');
 require_once(BASE_HELPER_PATH . '/mtopcard/topcard.php');
 require_once(BASE_HELPER_PATH . '/mtopcard/user_topcards.php');
@@ -156,6 +158,15 @@ function month_stamp($time=null) : int {
     return $stamp;
 }
 
+function scard_region($region)
+{
+    if(array_key_exists($region,ProvinceList)) {
+        return ProvinceList[$region];
+    } else {
+        return '';
+    }
+}
+
 function topcard_type($str_type)
 {
     if(empty($str_type)) {

racc/control/lzbase.php → racc/control/base.php


+ 0 - 379
racc/control/lzrefill.php

@@ -1,379 +0,0 @@
-<?php
-
-class lzrefillControl extends lzbaseControl
-{
-    public function __construct()
-    {
-        parent::__construct();
-    }
-
-    public function goodsOp()
-    {
-        $result = refill\RefillFactory::instance()->goods();
-        $sorter = function (array $items) {
-            $ret = [];
-            foreach ($items as $key => $val) {
-                sort($val);
-                $ret[$key] = $val;
-            }
-            return $ret;
-        };
-
-        $result = $sorter($result);
-        return self::outsuccess($result);
-    }
-
-    private function check_params($params)
-    {
-        if(empty($params['mob'])) {
-            return -9;
-        }
-        if(empty($params['amt'])) {
-            return -9;
-        }
-
-        $card_no = $params['mob'];
-        if(empty($card_no)) {
-            return -11;
-        }
-
-        if(empty($params['notifyurl'])) {
-            return -9;
-        }
-
-        if(empty($params['ord'])) {
-            return -9;
-        }
-
-        if(empty($params['tim'])) {
-            return -9;
-        }
-
-        $tim = strtotime($params['tim']);
-        if($tim === false) {
-            return -9;
-        }
-
-        $cur = time();
-        $start = strtotime(date('Y-m-d',$cur - 1800));
-        if($tim < $start || $tim > $cur + 1800) {
-            return -9;
-        }
-
-        return true;
-    }
-
-    public function add_mobOp()
-    {
-        $code = $this->check_params($_GET);
-        if($code !== true) {
-            return self::outerr($code,$this->merchant_available);
-        }
-
-        $amount = intval($_GET['amt']);
-        $card_no = $_GET['mob'];
-        $notify_url = $_GET['notifyurl'];
-        $mch_order = $_GET['ord']; //对方的order编号
-        $quality = $_GET['quality'] ?? 0;
-
-        //此处判断是对的
-        if($amount > $this->member_available) {
-            return self::outerr(4,$this->merchant_available);
-        }
-
-        if(!$this->check_mchorder($this->mchid(),$mch_order)) {
-            return self::outerr(11,$this->merchant_available);
-        }
-
-//        if(!$this->can_refill($card_no)) {
-//            return self::outerr(10,$this->merchant_available);
-//        }
-
-        $params = [ 'mchid' => $this->mchid(),
-            'buyer_id' => $this->adminid(),
-            'amount' => $amount,
-            'card_no' => $card_no,
-            'mch_order' => $mch_order,
-            'notify_url' => $notify_url,
-            'org_quality' => $quality
-        ];
-        refill\util::push_queue_order($this->mchid(), $mch_order, ORDER_STATE_QUEUE);
-        Model('refill_order')->add_detail($this->mchid(),$mch_order,$params,ORDER_STATE_QUEUE);
-
-        $ret = refill\util::push_add($params);
-        if ($ret) {
-            return self::outsuccess($this->merchant_available);
-        } else {
-            refill\util::del_queue_order($this->mchid(),$mch_order);
-            Model('refill_order')->del_detail($this->mchid(),$mch_order);
-
-            return self::outerr(-6, $this->merchant_available);
-        }
-    }
-
-    private function check_third($params)
-    {
-        if(empty($params['product_code'])) {
-            Log::record("check_third product_code",Log::ERR);
-            return -9;
-        }
-        $pcode = $params['product_code'];
-        if($this->check_pcode($pcode) == false) {
-            Log::record("check_third check_pcode",Log::ERR);
-            return -10;
-        }
-
-        if(empty($params['quantity']) || intval($params['quantity']) < 1) {
-            Log::record("check_third quantity",Log::ERR);
-            return -9;
-        }
-
-        $card_no = $params['mob'];
-        if(empty($card_no)) {
-            Log::record("check_third mob",Log::ERR);
-            return -9;
-        }
-
-        $third_card_type = $params['card_type'];
-        if(empty($third_card_type)) {
-            Log::record("check_third card_type",Log::ERR);
-            return -9;
-        }
-
-        if(empty($params['notifyurl'])) {
-            Log::record("check_third notifyurl",Log::ERR);
-            return -9;
-        }
-
-        if(empty($params['ord'])) {
-            Log::record("check_third ord",Log::ERR);
-            return -9;
-        }
-
-        if(empty($params['tim'])) {
-            Log::record("check_third tim",Log::ERR);
-            return -9;
-        }
-
-        $tim = strtotime($params['tim']);
-        if($tim === false) {
-            Log::record("check_third strtotime tim",Log::ERR);
-            return -9;
-        }
-
-        $cur = time();
-        $start = strtotime(date('Y-m-d',$cur - 1800));
-        if($tim < $start || $tim > $cur + 1800) {
-            Log::record("check_third check tim",Log::ERR);
-            return -9;
-        }
-
-        return true;
-    }
-
-    private function check_pcode($pcode)
-    {
-        $mod_third = Model('thrid_refill');
-        $product = $mod_third->getProduct(['system_code' => $pcode]);
-        return !empty($product);
-    }
-
-    public function add_thirdOp()
-    {
-        $code = $this->check_third($_GET);
-        if($code !== true) {
-            return self::outerr($code,$this->merchant_available);
-        }
-
-        $amount = refill\util::ThirdRefillAmount;
-        $mch_order = $_GET['ord'];
-        $notify_url = $_GET['notifyurl'];
-
-        //三方充值没有质量
-        $quality = 1;
-        $card_type = mtopcard\ThirdRefillCard;
-
-        $product_code = $_GET['product_code'];
-        $card_no = $_GET['mob'];
-        $quantity = $_GET['quantity'];
-        $third_card_type = $_GET['card_type'];
-
-        //此处判断是对的
-        if($this->member_available <= 0) {
-            return self::outerr(4,$this->merchant_available);
-        }
-
-        if(!$this->check_mchorder($this->mchid(),$mch_order)) {
-            return self::outerr(11,$this->merchant_available);
-        }
-
-        $params = [ 'mchid' => $this->mchid(),
-            'buyer_id' => $this->adminid(),
-            'amount' => $amount,
-            'mch_order' => $mch_order,
-            'notify_url' => $notify_url,
-            'org_quality' => $quality,
-            'card_type' => $card_type,
-            'card_no' => $card_no,
-            'product_code' => $product_code,
-            'quantity' => $quantity,
-            'third_card_type' => $third_card_type
-        ];
-        
-        refill\util::push_queue_order($this->mchid(), $mch_order, ORDER_STATE_QUEUE);
-        Model('refill_order')->add_detail($this->mchid(),$mch_order,$params,ORDER_STATE_QUEUE);
-        $ret = refill\util::push_addthird($params);
-        if($ret) {
-            return self::outsuccess($this->merchant_available);
-        }
-        else {
-            refill\util::del_queue_order($this->mchid(),$mch_order);
-            Model('refill_order')->del_detail($this->mchid(),$mch_order);
-
-            return self::outerr(-6,$this->merchant_available);
-        }
-    }
-
-    private function can_refill($cardno)
-    {
-        $card_info = refill\util::read_card($cardno);
-        if(empty($card_info)) return false;
-
-        return intval($card_info['black_card']) === 0;
-    }
-
-    private function check_mchorder($mchid,$mch_order)
-    {
-        if (empty($mch_order)) {
-            return false;
-        } else {
-            $refill_order = Model('refill_order');
-            $ret = $refill_order->exist($mchid, $mch_order);
-            return ($ret == false);
-        }
-    }
-
-    public function balanceOp()
-    {
-        $uid = $this->adminid();
-        $minfo = new member_info($uid);
-        $available = $minfo->available_predeposit();
-
-        $content = "0|".ncPriceFormat($available)."|0.00";
-        echo $content;
-        return true;
-    }
-
-    public function queryOp()
-    {
-        $mchid = $this->mchid();
-        $order_sn = $_GET['ord']; //用户方的订单号,对应数据库中的mch_order
-
-        if(empty($order_sn)) {
-            return self::outerr(-9,$this->merchant_available);
-        }
-
-        $order_state = refill\util::query_queue_order($mchid,$order_sn);
-        if ($order_state == ORDER_STATE_QUEUE || $order_state == ORDER_STATE_SEND) {
-            Log::record("query_state in queue mchid={$mchid} mch_order={$order_sn} order_state={$order_state}" ,Log::DEBUG);
-
-            $state = 0;
-            $msg = "{$order_sn}-充值中";
-            $remark = "";
-            $content = "|{$state}|{$msg}|{$remark}";
-            echo $content;
-            $this->query_request($mchid,$order_sn);
-
-            return true;
-        }
-        else
-        {
-            $mod_refill = Model('refill_order');
-            $refill_info = $mod_refill->getOrderInfo(['mch_order' => $order_sn,'mchid' => $mchid,'inner_status' => 0]);
-
-            if(empty($refill_info))
-            {
-                Log::record("query_state in db no order mchid={$mchid} mch_order={$order_sn}" ,Log::DEBUG);
-
-                $state = 3;
-                $msg = "{$order_sn}-无此订单";
-                $remark = "";
-                $content = "|{$state}|{$msg}|{$remark}";
-                echo $content;
-                return true;
-            }
-            else
-            {
-                $vr_order = Model('vr_order');
-                $order_info = $vr_order->getOrderInfo(['order_sn' => $refill_info['order_sn']]);
-                $order_state = $order_info['order_state'];
-
-                Log::record("query_state in db mchid={$mchid} mch_order={$order_sn} order_state={$order_state}" ,Log::DEBUG);
-
-                if ($order_state == ORDER_STATE_CANCEL) {
-                    $state = 2;
-                    $msg = "{$order_sn}-充值失败";
-                    $remark = "";
-                }
-                elseif($order_state == ORDER_STATE_SUCCESS) {
-                    $state = 1;
-                    $msg = "{$order_sn}-充值成功";
-                    $remark = "{$refill_info['official_sn']}";
-                }
-                else {
-                    $state = 0;
-                    $msg = "{$order_sn}-充值中";
-                    $remark = "";
-                }
-
-                if($refill_info['card_type'] == mtopcard\ThirdRefillCard) {
-                    $remark = $this->third_remark($refill_info);
-                }
-
-                $content = "|{$state}|{$msg}|{$remark}";
-                echo $content;
-
-                return true;
-            }
-        }
-    }
-
-    private function query_request($mchid,$order_sn)
-    {
-        $mod_refill = Model('refill_order');
-        $refill_info = $mod_refill->getOrderInfo(['mch_order' => $order_sn,'mchid' => $mchid,'inner_status' => 0]);
-
-        if(!empty($refill_info))
-        {
-            $vr_order = Model('vr_order');
-            $order_info = $vr_order->getOrderInfo(['order_sn' => $refill_info['order_sn']]);
-
-            if(!empty($order_info) && $order_info['order_state'] == ORDER_STATE_SEND) {
-                QueueClient::push("QueryRefillState",['order_id' => $refill_info['order_id']]);
-            }
-        }
-    }
-
-
-    private function third_remark($refill_info)
-    {
-        $mchinfo = Model('merchant')->getMerchantInfo(['mchid' => $this->mchid()]);
-        $mod_third = Model('thrid_refill');
-        $thrid_info = $mod_third->getThird($refill_info['order_id']);
-        $secure_key = $mchinfo['secure_key'];
-
-        $remark = '';
-        if (!empty($thrid_info))
-        {
-            $card_info = $thrid_info['card_info'];
-            if (!empty($card_info)) {
-                $encrypt = openssl_encrypt($card_info,'AES-128-CBC',$secure_key);
-                if($encrypt != false) {
-                    $remark = $encrypt;
-                }
-            }
-        }
-
-        return $remark;
-    }
-}

+ 21 - 0
vapi/control/base.php

@@ -0,0 +1,21 @@
+<?php
+
+class baseControl
+{
+    public function __construct()
+    {
+
+    }
+
+    public static function outsuccess($data)
+    {
+        joutput_data($data);
+        return true;
+    }
+
+    public static function outerr($code, $msg = '')
+    {
+        joutput_error($code, $msg);
+        return true;
+    }
+}

+ 20 - 2
vapi/control/card.php

@@ -3,17 +3,35 @@
 require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
 require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
 require_once(BASE_HELPER_PATH . '/model/member_info.php');
+require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
+
 
 //商家充值接口中心
 class cardControl extends merchantControl
 {
+    const phone_legth = 11;
     public function __construct()
     {
         parent::__construct();
     }
 
-    public function checkOp()
+    public function queryOp()
     {
-        return self::outsuccess(['result' => 'OK']);
+        $card_no = $_GET['cardno'] ?? '';
+        $card_no = trim($card_no);
+        if(empty($card_no) || strlen($card_no) != self::phone_legth) {
+            return self::outerr(301,"号码长度不正确.");
+        }
+
+        [$validate,$card_type,$regin_no,$isTransfer,$card_state,$black] = mtopcard\valid_phone($card_no);
+
+        $result = ['card_type' => mtopcard\scard_type($card_type),
+            'region' => mtopcard\scard_region($regin_no),
+            'is_transfer' => $isTransfer ? 1 : 0,
+            'card_state' => $card_state,
+            'black' => $black ? 1 : 0
+        ];
+
+        return self::outsuccess($result);
     }
 }

+ 0 - 151
vapi/control/lzbase.php

@@ -1,151 +0,0 @@
-<?php
-
-class lzbaseControl
-{
-    private $mMchid;
-    private $mAdminid;
-    private $mUseKey;
-    protected $merchant_available;
-    protected $member_available;
-
-    public function __construct()
-    {
-        $mchid = $_POST['usr'];
-        $mchinfo = Model('merchant')->getMerchantInfo(['mchid' => $mchid]);
-        if(empty($mchinfo)) {
-            throw new LzException(self::text_content(-5,0));
-        }
-        else {
-            $this->mAdminid = intval($mchinfo['admin_id']);
-        }
-
-        $mchinfo = Model('merchant')->getMerchantInfo(['mchid' => $mchid]);
-
-        $mod_member = Model('member');
-        $minfo = $mod_member->getMemberInfo(['member_id' => $this->mAdminid], '*', true);
-        $this->merchant_available = ncPriceFormat($minfo['available_predeposit'] - $mchinfo['credit_bonus']);
-        $this->member_available = $minfo['available_predeposit'];
-
-
-        if ($mchinfo['merchant_state'] != 1) {
-            throw new LzException(self::text_content(-7,$this->merchant_available));
-        }
-
-        $ips = unserialize($mchinfo['ip_white_list']);
-        if(!empty($ips)) {
-            $addr = $_SERVER['REMOTE_ADDR'];
-            Log::record("request ip:{$addr}",Log::DEBUG);
-
-            if(!in_array($addr,$ips)) {
-                throw new LzException(self::text_content(-12,$this->merchant_available));
-            }
-        }
-
-        $this->mUseKey = intval($mchinfo['use_key']);
-        if($this->mUseKey && !$this->verify_md5($mchinfo['secure_key'])) {
-            throw new LzException(self::text_content(-4,$this->merchant_available));
-        }
-
-        $this->mMchid = intval($mchid);
-    }
-
-    public function mchid() : int
-    {
-        return $this->mMchid;
-    }
-    public function adminid() : int {
-        return $this->mAdminid;
-    }
-
-
-    private function verify_md5($key)
-    {
-        $input = $_GET;
-        $sign = $input['sgn'];
-
-        $body = $this->sign_body($input);
-        if($this->mUseKey) {
-            $body .= $key;
-        }
-
-        return ($sign == strtoupper(md5($body)));
-    }
-
-    private function sign_body($params)
-    {
-        $op = $params['op'];
-        if($op == 'add_mob') {
-            $content = $params['usr'] . $params['ord'] . $params['mob'] . $params['amt'] . $params['tim'];
-        }
-        elseif($op == 'balance') {
-            $content = $params['usr'];
-        }
-        elseif($op == 'query') {
-            $content = $params['usr'] . $params['ord'];
-        }
-        elseif($op == 'add_third') {
-            $content = $params['usr'] . $params['ord'] . $params['mob'] . $params['product_code'] . $params['tim'];
-        }
-        else {
-            $content = 'error';
-        }
-        return $content;
-    }
-
-    public static function msg($code)
-    {
-        static $msgs = [0 => '订单提交成功',
-            2 => '运营商充值账户余额不足',
-            4 => '账户余额不足',
-            6 => '暂不支持此商品',
-            7 => '连接该运营商设备失败',
-            8 => '在规定时间内不得重复提交同一号码',
-            10 => '该帐号不能在此计算机缴费',
-            11 => '流水号重复',
-            30 => '面值不符',
-            41 => '该地区维护',
-            42 => '运营商设备忙',
-            43 => '暂不支持该面额的缴费',
-            44 => '无该地区缴费权限',
-            -2 => '命令已发送,请查看交易流水是否有缴费成功(这种情况是服务器在排队等待处理,间隔10-20分钟后查单核实)',
-            -3 => '数据添加失败',
-            -4 => '签名错误',
-            -5 => '没有此代理商',
-            -6 => '提交失败',
-            -7 => '无此接口权限',
-            -8 => '提交日期不是当天日期',
-            -9 => '参数不对',
-            -11 => '手机号码位数不符',
-            -12 => '绑定IP不符',
-            1001 => '销售数量请大于0',
-            1002 => '该商品库存维护',
-            1003 => '该供货商品库存维护'];
-
-        if(array_key_exists($code,$msgs)) {
-            return $msgs[$code];
-        }
-        else {
-            return '';
-        }
-    }
-
-    public static function text_content($code,$available)
-    {
-        $msg = self::msg($code);
-        $available = ncPriceFormat($available);
-        $content = "{$code}|{$msg}|{$available}";
-        return $content;
-    }
-
-    public static function outsuccess($available)
-    {
-        echo self::text_content(0,$available);
-        return true;
-    }
-
-    public static function outerr($code,$available)
-    {
-        echo self::text_content($code,$available);
-        return true;
-    }
-}

+ 0 - 379
vapi/control/lzrefill.php

@@ -1,379 +0,0 @@
-<?php
-
-class lzrefillControl extends lzbaseControl
-{
-    public function __construct()
-    {
-        parent::__construct();
-    }
-
-    public function goodsOp()
-    {
-        $result = refill\RefillFactory::instance()->goods();
-        $sorter = function (array $items) {
-            $ret = [];
-            foreach ($items as $key => $val) {
-                sort($val);
-                $ret[$key] = $val;
-            }
-            return $ret;
-        };
-
-        $result = $sorter($result);
-        return self::outsuccess($result);
-    }
-
-    private function check_params($params)
-    {
-        if(empty($params['mob'])) {
-            return -9;
-        }
-        if(empty($params['amt'])) {
-            return -9;
-        }
-
-        $card_no = $params['mob'];
-        if(empty($card_no)) {
-            return -11;
-        }
-
-        if(empty($params['notifyurl'])) {
-            return -9;
-        }
-
-        if(empty($params['ord'])) {
-            return -9;
-        }
-
-        if(empty($params['tim'])) {
-            return -9;
-        }
-
-        $tim = strtotime($params['tim']);
-        if($tim === false) {
-            return -9;
-        }
-
-        $cur = time();
-        $start = strtotime(date('Y-m-d',$cur - 1800));
-        if($tim < $start || $tim > $cur + 1800) {
-            return -9;
-        }
-
-        return true;
-    }
-
-    public function add_mobOp()
-    {
-        $code = $this->check_params($_GET);
-        if($code !== true) {
-            return self::outerr($code,$this->merchant_available);
-        }
-
-        $amount = intval($_GET['amt']);
-        $card_no = $_GET['mob'];
-        $notify_url = $_GET['notifyurl'];
-        $mch_order = $_GET['ord']; //对方的order编号
-        $quality = $_GET['quality'] ?? 0;
-
-        //此处判断是对的
-        if($amount > $this->member_available) {
-            return self::outerr(4,$this->merchant_available);
-        }
-
-        if(!$this->check_mchorder($this->mchid(),$mch_order)) {
-            return self::outerr(11,$this->merchant_available);
-        }
-
-//        if(!$this->can_refill($card_no)) {
-//            return self::outerr(10,$this->merchant_available);
-//        }
-
-        $params = [ 'mchid' => $this->mchid(),
-            'buyer_id' => $this->adminid(),
-            'amount' => $amount,
-            'card_no' => $card_no,
-            'mch_order' => $mch_order,
-            'notify_url' => $notify_url,
-            'org_quality' => $quality
-        ];
-        refill\util::push_queue_order($this->mchid(), $mch_order, ORDER_STATE_QUEUE);
-        Model('refill_order')->add_detail($this->mchid(),$mch_order,$params,ORDER_STATE_QUEUE);
-
-        $ret = refill\util::push_add($params);
-        if ($ret) {
-            return self::outsuccess($this->merchant_available);
-        } else {
-            refill\util::del_queue_order($this->mchid(),$mch_order);
-            Model('refill_order')->del_detail($this->mchid(),$mch_order);
-
-            return self::outerr(-6, $this->merchant_available);
-        }
-    }
-
-    private function check_third($params)
-    {
-        if(empty($params['product_code'])) {
-            Log::record("check_third product_code",Log::ERR);
-            return -9;
-        }
-        $pcode = $params['product_code'];
-        if($this->check_pcode($pcode) == false) {
-            Log::record("check_third check_pcode",Log::ERR);
-            return -10;
-        }
-
-        if(empty($params['quantity']) || intval($params['quantity']) < 1) {
-            Log::record("check_third quantity",Log::ERR);
-            return -9;
-        }
-
-        $card_no = $params['mob'];
-        if(empty($card_no)) {
-            Log::record("check_third mob",Log::ERR);
-            return -9;
-        }
-
-        $third_card_type = $params['card_type'];
-        if(empty($third_card_type)) {
-            Log::record("check_third card_type",Log::ERR);
-            return -9;
-        }
-
-        if(empty($params['notifyurl'])) {
-            Log::record("check_third notifyurl",Log::ERR);
-            return -9;
-        }
-
-        if(empty($params['ord'])) {
-            Log::record("check_third ord",Log::ERR);
-            return -9;
-        }
-
-        if(empty($params['tim'])) {
-            Log::record("check_third tim",Log::ERR);
-            return -9;
-        }
-
-        $tim = strtotime($params['tim']);
-        if($tim === false) {
-            Log::record("check_third strtotime tim",Log::ERR);
-            return -9;
-        }
-
-        $cur = time();
-        $start = strtotime(date('Y-m-d',$cur - 1800));
-        if($tim < $start || $tim > $cur + 1800) {
-            Log::record("check_third check tim",Log::ERR);
-            return -9;
-        }
-
-        return true;
-    }
-
-    private function check_pcode($pcode)
-    {
-        $mod_third = Model('thrid_refill');
-        $product = $mod_third->getProduct(['system_code' => $pcode]);
-        return !empty($product);
-    }
-
-    public function add_thirdOp()
-    {
-        $code = $this->check_third($_GET);
-        if($code !== true) {
-            return self::outerr($code,$this->merchant_available);
-        }
-
-        $amount = refill\util::ThirdRefillAmount;
-        $mch_order = $_GET['ord'];
-        $notify_url = $_GET['notifyurl'];
-
-        //三方充值没有质量
-        $quality = 1;
-        $card_type = mtopcard\ThirdRefillCard;
-
-        $product_code = $_GET['product_code'];
-        $card_no = $_GET['mob'];
-        $quantity = $_GET['quantity'];
-        $third_card_type = $_GET['card_type'];
-
-        //此处判断是对的
-        if($this->member_available <= 0) {
-            return self::outerr(4,$this->merchant_available);
-        }
-
-        if(!$this->check_mchorder($this->mchid(),$mch_order)) {
-            return self::outerr(11,$this->merchant_available);
-        }
-
-        $params = [ 'mchid' => $this->mchid(),
-            'buyer_id' => $this->adminid(),
-            'amount' => $amount,
-            'mch_order' => $mch_order,
-            'notify_url' => $notify_url,
-            'org_quality' => $quality,
-            'card_type' => $card_type,
-            'card_no' => $card_no,
-            'product_code' => $product_code,
-            'quantity' => $quantity,
-            'third_card_type' => $third_card_type
-        ];
-        
-        refill\util::push_queue_order($this->mchid(), $mch_order, ORDER_STATE_QUEUE);
-        Model('refill_order')->add_detail($this->mchid(),$mch_order,$params,ORDER_STATE_QUEUE);
-        $ret = refill\util::push_addthird($params);
-        if($ret) {
-            return self::outsuccess($this->merchant_available);
-        }
-        else {
-            refill\util::del_queue_order($this->mchid(),$mch_order);
-            Model('refill_order')->del_detail($this->mchid(),$mch_order);
-
-            return self::outerr(-6,$this->merchant_available);
-        }
-    }
-
-    private function can_refill($cardno)
-    {
-        $card_info = refill\util::read_card($cardno);
-        if(empty($card_info)) return false;
-
-        return intval($card_info['black_card']) === 0;
-    }
-
-    private function check_mchorder($mchid,$mch_order)
-    {
-        if (empty($mch_order)) {
-            return false;
-        } else {
-            $refill_order = Model('refill_order');
-            $ret = $refill_order->exist($mchid, $mch_order);
-            return ($ret == false);
-        }
-    }
-
-    public function balanceOp()
-    {
-        $uid = $this->adminid();
-        $minfo = new member_info($uid);
-        $available = $minfo->available_predeposit();
-
-        $content = "0|".ncPriceFormat($available)."|0.00";
-        echo $content;
-        return true;
-    }
-
-    public function queryOp()
-    {
-        $mchid = $this->mchid();
-        $order_sn = $_GET['ord']; //用户方的订单号,对应数据库中的mch_order
-
-        if(empty($order_sn)) {
-            return self::outerr(-9,$this->merchant_available);
-        }
-
-        $order_state = refill\util::query_queue_order($mchid,$order_sn);
-        if ($order_state == ORDER_STATE_QUEUE || $order_state == ORDER_STATE_SEND) {
-            Log::record("query_state in queue mchid={$mchid} mch_order={$order_sn} order_state={$order_state}" ,Log::DEBUG);
-
-            $state = 0;
-            $msg = "{$order_sn}-充值中";
-            $remark = "";
-            $content = "|{$state}|{$msg}|{$remark}";
-            echo $content;
-            $this->query_request($mchid,$order_sn);
-
-            return true;
-        }
-        else
-        {
-            $mod_refill = Model('refill_order');
-            $refill_info = $mod_refill->getOrderInfo(['mch_order' => $order_sn,'mchid' => $mchid,'inner_status' => 0]);
-
-            if(empty($refill_info))
-            {
-                Log::record("query_state in db no order mchid={$mchid} mch_order={$order_sn}" ,Log::DEBUG);
-
-                $state = 3;
-                $msg = "{$order_sn}-无此订单";
-                $remark = "";
-                $content = "|{$state}|{$msg}|{$remark}";
-                echo $content;
-                return true;
-            }
-            else
-            {
-                $vr_order = Model('vr_order');
-                $order_info = $vr_order->getOrderInfo(['order_sn' => $refill_info['order_sn']]);
-                $order_state = $order_info['order_state'];
-
-                Log::record("query_state in db mchid={$mchid} mch_order={$order_sn} order_state={$order_state}" ,Log::DEBUG);
-
-                if ($order_state == ORDER_STATE_CANCEL) {
-                    $state = 2;
-                    $msg = "{$order_sn}-充值失败";
-                    $remark = "";
-                }
-                elseif($order_state == ORDER_STATE_SUCCESS) {
-                    $state = 1;
-                    $msg = "{$order_sn}-充值成功";
-                    $remark = "{$refill_info['official_sn']}";
-                }
-                else {
-                    $state = 0;
-                    $msg = "{$order_sn}-充值中";
-                    $remark = "";
-                }
-
-                if($refill_info['card_type'] == mtopcard\ThirdRefillCard) {
-                    $remark = $this->third_remark($refill_info);
-                }
-
-                $content = "|{$state}|{$msg}|{$remark}";
-                echo $content;
-
-                return true;
-            }
-        }
-    }
-
-    private function query_request($mchid,$order_sn)
-    {
-        $mod_refill = Model('refill_order');
-        $refill_info = $mod_refill->getOrderInfo(['mch_order' => $order_sn,'mchid' => $mchid,'inner_status' => 0]);
-
-        if(!empty($refill_info))
-        {
-            $vr_order = Model('vr_order');
-            $order_info = $vr_order->getOrderInfo(['order_sn' => $refill_info['order_sn']]);
-
-            if(!empty($order_info) && $order_info['order_state'] == ORDER_STATE_SEND) {
-                QueueClient::push("QueryRefillState",['order_id' => $refill_info['order_id']]);
-            }
-        }
-    }
-
-
-    private function third_remark($refill_info)
-    {
-        $mchinfo = Model('merchant')->getMerchantInfo(['mchid' => $this->mchid()]);
-        $mod_third = Model('thrid_refill');
-        $thrid_info = $mod_third->getThird($refill_info['order_id']);
-        $secure_key = $mchinfo['secure_key'];
-
-        $remark = '';
-        if (!empty($thrid_info))
-        {
-            $card_info = $thrid_info['card_info'];
-            if (!empty($card_info)) {
-                $encrypt = openssl_encrypt($card_info,'AES-128-CBC',$secure_key);
-                if($encrypt != false) {
-                    $remark = $encrypt;
-                }
-            }
-        }
-
-        return $remark;
-    }
-}

+ 4 - 13
vapi/control/merchant.php

@@ -1,12 +1,15 @@
 <?php
 
-class merchantControl
+class merchantControl extends baseControl
 {
     private $mMchid;
     private $mAdminid;
     private $mUseKey;
+
     public function __construct()
     {
+        parent::__construct();
+
         $mchid = $_POST['mchid'];
         $mchinfo = Model('merchant')->getMerchantInfo(['mchid' => $mchid]);
         if(empty($mchinfo)) {
@@ -97,16 +100,4 @@ class merchantControl
 
         return $content;
     }
-
-    public static function outsuccess($data)
-    {
-        joutput_data($data);
-        return true;
-    }
-
-    public static function outerr($code, $msg = '')
-    {
-        joutput_error($code, $msg);
-        return true;
-    }
 }

+ 1 - 1
vapi/index.php

@@ -5,5 +5,5 @@
  *
  */
 
+require_once(BASE_PATH . '/control/base.php');
 require_once(BASE_PATH . '/control/merchant.php');
-require_once(BASE_PATH . '/control/lzbase.php');