wesmiler il y a 7 heures
Parent
commit
3b34e3fdd3
1 fichiers modifiés avec 18 ajouts et 15 suppressions
  1. 18 15
      app/Services/Api/GoodsService.php

+ 18 - 15
app/Services/Api/GoodsService.php

@@ -275,24 +275,27 @@ class GoodsService extends BaseService
             $couponStatus = isset($couponInfo['status'])?$couponInfo['status'] : 0;
             $startTime = isset($couponInfo['start_time'])?$couponInfo['start_time'] : 0;
             $endTime = isset($couponInfo['end_time'])?$couponInfo['end_time'] : 0;
-            if(empty($couponInfo) || $couponType<=0){
-                $this->error = '优惠券无效';
-                return false;
-            }
+            // 下单需验证
+            if($orderNo){
+                if(empty($couponInfo) || $couponType<=0){
+                    $this->error = '优惠券无效';
+                    return false;
+                }
 
-            if($couponStatus != 1){
-                $this->error = '该优惠券已使用,请刷新后重试~';
-                return false;
-            }
+                if($couponStatus != 1){
+                    $this->error = '该优惠券已使用,请刷新后重试~';
+                    return false;
+                }
 
-            if($startTime > time()){
-                $this->error = '该优惠券使用时间未到~';
-                return false;
-            }
+                if($startTime > time()){
+                    $this->error = '该优惠券使用时间未到~';
+                    return false;
+                }
 
-            if($endTime && $endTime < time()){
-                $this->error = '该优惠券已过期~';
-                return false;
+                if($endTime && $endTime < time()){
+                    $this->error = '该优惠券已过期~';
+                    return false;
+                }
             }
         }