stanley-king vor 4 Jahren
Ursprung
Commit
c3c67bbba7
2 geänderte Dateien mit 61 neuen und 40 gelöschten Zeilen
  1. 8 5
      racc/control/lzbase.php
  2. 53 35
      racc/control/lzrefill.php

+ 8 - 5
racc/control/lzbase.php

@@ -5,7 +5,8 @@ class lzbaseControl
     private $mMchid;
     private $mAdminid;
     private $mUseKey;
-    protected $available;
+    protected $merchant_available;
+    protected $member_available;
 
     public function __construct()
     {
@@ -22,10 +23,12 @@ class lzbaseControl
 
         $mod_member = Model('member');
         $minfo = $mod_member->getMemberInfo(['member_id' => $this->mAdminid], '*', true);
-        $this->available = ncPriceFormat($minfo['available_predeposit'] - $mchinfo['credit_bonus']);
+        $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->available));
+            throw new LzException(self::text_content(-7,$this->merchant_available));
         }
 
         $ips = unserialize($mchinfo['ip_white_list']);
@@ -34,13 +37,13 @@ class lzbaseControl
             Log::record("request ip:{$addr}",Log::DEBUG);
 
             if(!in_array($addr,$ips)) {
-                throw new LzException(self::text_content(-12,$this->available));
+                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->available));
+            throw new LzException(self::text_content(-4,$this->merchant_available));
         }
 
         $this->mMchid = intval($mchid);

+ 53 - 35
racc/control/lzrefill.php

@@ -67,7 +67,7 @@ class lzrefillControl extends lzbaseControl
     {
         $code = $this->check_params($_GET);
         if($code !== true) {
-            return self::outerr($code,$this->available);
+            return self::outerr($code,$this->merchant_available);
         }
 
         $amount = intval($_GET['amt']);
@@ -76,16 +76,17 @@ class lzrefillControl extends lzbaseControl
         $mch_order = $_GET['ord']; //对方的order编号
         $quality = $_GET['quality'];
 
-        if($amount > $this->available) {
-            return self::outerr(4,$this->available);
+        //此处判断是对的
+        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->available);
+            return self::outerr(11,$this->merchant_available);
         }
 
         if(!$this->can_refill($card_no)) {
-            return self::outerr(10,$this->available);
+            return self::outerr(10,$this->merchant_available);
         }
 
         $params = [ 'mchid' => $this->mchid(),
@@ -98,10 +99,10 @@ class lzrefillControl extends lzbaseControl
 
         $ret = refill\util::push_add($params);
         if($ret) {
-            return self::outsuccess($this->available);
+            return self::outsuccess($this->merchant_available);
         }
         else {
-            return self::outerr(-6,$this->available);
+            return self::outerr(-6,$this->merchant_available);
         }
     }
 
@@ -137,52 +138,69 @@ class lzrefillControl extends lzbaseControl
         return true;
     }
 
-    private function format($order_info,$refill_info)
-    {
-        $result = [];
-
-        $result['mchid'] = $refill_info['mchid'];
-        $result['trade_no'] = $refill_info['order_sn'];
-        $result['order_sn'] = $refill_info['mch_order'];
-        $result['card_no'] = $refill_info['card_no'];
-        $result['card_type'] = $refill_info['card_type'];
-        $result['refill_amount'] = $refill_info['refill_amount'];
-        $result['order_amount'] = $refill_info['mch_amount'];
-        $result['order_time'] = $refill_info['order_time'];
-        $result['success_time'] = $refill_info['notify_time'];
-        $result['order_state'] = $order_info['order_state'];
-
-        return $result;
-    }
-
     public function queryOp()
     {
         $mchid = $this->mchid();
         $order_sn = $_GET['ord']; //用户方的订单号,对应数据库中的mch_order
 
         if(empty($order_sn)) {
-            return self::outerr(-9,$this->available);
+            return self::outerr(-9,$this->merchant_available);
         }
 
         $mod_refill = Model('refill_order');
         $refill_info = $mod_refill->getOrderInfo(['mch_order' => $order_sn,'mchid' => $mchid,'inner_status' => 0]);
 
-        if(empty($refill_info)) {
-            return self::outerr(-6,$this->available);
+        if(empty($refill_info))
+        {
+            $state = 3;
+            $msg = "{$order_sn}-无此订单";
+            $remark = "";
+            $content = "|{$state}|{$msg}|{$remark}";
+            echo $content;
+            return true;
         }
 
         $vr_order = Model('vr_order');
         $order_info = $vr_order->getOrderInfo(['order_sn' => $refill_info['order_sn']]);
 
-        if(empty($order_info)) {
-            return self::outerr(-6,$this->available);
-        }
-
-        if($order_info['order_state'] == ORDER_STATE_SEND) {
+        $order_state = $order_info['order_state'];
+        if($order_state == ORDER_STATE_SEND || $order_state == ORDER_STATE_PAY || $order_state == ORDER_STATE_NEW) {
             QueueClient::push("QueryRefillState",['order_id' => $refill_info['order_id']]);
+            $state = 0;
+            $msg = "{$order_sn}-充值中";
+            $remark = "";
+        }
+        elseif($order_state == ORDER_STATE_CANCEL) {
+            $state = 2;
+            $msg = "{$order_sn}-充值失败";
+            $remark = "";
+        }
+        else {
+            $state = 1;
+            $msg = "{$order_sn}-充值成功";
+            $remark = "{$refill_info['official_sn']}";
         }
 
-        $result = $this->format($order_info,$refill_info);
-        return self::outsuccess($result);
+        $content = "|{$state}|{$msg}|{$remark}";
+        echo $content;
+        return true;
+    }
+
+    private function format($order_info,$refill_info)
+    {
+        $result = [];
+
+        $result['mchid'] = $refill_info['mchid'];
+        $result['trade_no'] = $refill_info['order_sn'];
+        $result['order_sn'] = $refill_info['mch_order'];
+        $result['card_no'] = $refill_info['card_no'];
+        $result['card_type'] = $refill_info['card_type'];
+        $result['refill_amount'] = $refill_info['refill_amount'];
+        $result['order_amount'] = $refill_info['mch_amount'];
+        $result['order_time'] = $refill_info['order_time'];
+        $result['success_time'] = $refill_info['notify_time'];
+        $result['order_state'] = $order_info['order_state'];
+
+        return $result;
     }
 }