Prechádzať zdrojové kódy

活动报名,限制购买

lizhen 1 deň pred
rodič
commit
7f7fccb8f3

+ 2 - 1
addons/unishop/behavior/Order.php

@@ -73,7 +73,8 @@ class Order
     {
 
         $specs = [''];
-        $numbers = [$extra['number']];
+//        $numbers = [$extra['number']];
+        $numbers = [1]; //强制一个
         $productIds = [$extra['product_id']];
 
         if (count($specs) !== count($numbers) || count($specs) !== count($productIds)) {

+ 9 - 0
addons/unishop/controller/Order.php

@@ -233,6 +233,15 @@ class Order extends Base
                 throw new Exception($validate->getError());
             }
 
+            //限制购买
+            $buy_count = Db::name('unishop_order')->alias('order')
+                ->join('unishop_order_product op','order.id = op.order_id','LEFT')
+                ->where('op.product_id',$data['product_id'])->where('order.book_mobile',$data['book_mobile'])->where('order.have_paid','gt',0)
+                ->find();
+            if ($buy_count) {
+                throw new Exception('该手机号已报名本活动');
+            }
+
             Db::startTrans();
 
             // 判断创建订单的条件