dever 3 vuotta sitten
vanhempi
commit
f0dbb76c10
2 muutettua tiedostoa jossa 13 lisäystä ja 2 poistoa
  1. 12 1
      app/shop/lib/Coupon.php
  2. 1 1
      app/shop/src/Buy.php

+ 12 - 1
app/shop/lib/Coupon.php

@@ -66,6 +66,13 @@ class Coupon
             return false;
         }
 
+        $coupon = Dever::db('goods/coupon')->find($data['coupon_id']);
+
+        if (!$coupon) {
+            Dever::alert('优惠券不存在');
+            return false;
+        }
+
         if ($data['total'] <= 0) {
             return false;
         }
@@ -88,7 +95,11 @@ class Coupon
             }
 
             # 验证是否已经领取,一周内不能再次领取
-            $user = Dever::db('shop/user_coupon')->getOne(array('uid' => $uid, 'shop_coupon_id' => $shop_coupon_id));
+            if ($coupon['method'] == 3) {
+                $user = Dever::db('shop/user_coupon')->getOne(array('uid' => $uid, 'shop_coupon_id' => $shop_coupon_id));
+            } else {
+                $user = Dever::db('shop/user_coupon')->getOne(array('uid' => $uid, 'coupon_id' => $coupon['id']));
+            }
 
             if ($user && time() - $user['cdate'] < 86400*7) {
                 Dever::alert('您已领取过该优惠劵');

+ 1 - 1
app/shop/src/Buy.php

@@ -55,7 +55,7 @@ class Buy extends Core
 	}
 
 	# 领取优惠券 也得判断一下用户是否有权限领取
-	public function takeCoupon()
+	public function takeCoupon_commit()
 	{
 		$act_id = Dever::input('act_id', 1);
 		# 验证这个券是否可以领取