rabin 3 anni fa
parent
commit
13848bf974
2 ha cambiato i file con 8 aggiunte e 7 eliminazioni
  1. 2 2
      learn/active/database/order.php
  2. 6 5
      learn/active/lib/Active.php

+ 2 - 2
learn/active/database/order.php

@@ -287,11 +287,11 @@ return array
                 'mid' => 'yes',
                 'uid'  => 'yes',
                 'active_id' => 'yes',
-                'status' =>2,
+                'status' => array('yes', 'in'),
                 'state' => 1,
             ),
             'type' => 'one',
-            'col' => 'sum(num) as total',
+            'col' => 'sum(num-refund_num) as total',
         ),
         'getAll' => array
         (

+ 6 - 5
learn/active/lib/Active.php

@@ -45,7 +45,7 @@ class Active
 				}
 			}
 		}
-		$order = Dever::db('active/order')->getNum(array('uid'=>$uid,'active_id'=>$active_id));
+		$order = Dever::db('active/order')->getNum(array('uid'=>$uid,'active_id'=>$active_id,'status' => '2,4,5'));
 		$member = Dever::load('active/lib/user')->agent($user);
 		if ($data['status'] == 2) {
 			
@@ -66,10 +66,11 @@ class Active
 				}
 			}
 		} else {
-			if ($order && $order['total'] && $order['total'] >= $data['num']) {
-				Dever::alert('您已超过限购数量');
-			}
-			if ($num > $data['num'] ) {
+			if ($order) {
+				if ($order['total'] && ($order['total'] + $num) > $data['num']) {
+					Dever::alert('您已超过限购数量');
+				}
+			} elseif ($num > $data['num'] ) {
 				Dever::alert('您已超过限购数量');
 			}
 		}