Prechádzať zdrojové kódy

fix 修改优惠券

zoujiajian 3 rokov pred
rodič
commit
8cd2268f3c

+ 17 - 14
netflix-service/src/main/java/com/cyksj/service/mange/coupon/impl/CouponCommonServiceImpl.java

@@ -225,22 +225,25 @@ public class CouponCommonServiceImpl implements CouponCommonService {
 					}
 				});
 			}
-			if (coupon.getIsValidTime()) {
-				if (coupon.getValidStartTime() == null || coupon.getValidEndTime() == null || (coupon.getValidStartTime().getTime() > coupon.getValidEndTime().getTime())) {
-					throw BusinessRuntimeException.getInstance("请输入正确的有效起始和截止时间");
-				}
-			} else {
-				if (coupon.getValidDays() == null && coupon.getValidHours() == null) {
-					throw BusinessRuntimeException.getInstance("请选择对应领取后有效时间");
-				}
+		}
+		if (coupon.getIsValidTime() == null) {
+			coupon.setIsValidTime(false);
+		}
+		if (coupon.getIsValidTime()) {
+			if (coupon.getValidStartTime() == null || coupon.getValidEndTime() == null || (coupon.getValidStartTime().getTime() > coupon.getValidEndTime().getTime())) {
+				throw BusinessRuntimeException.getInstance("请输入正确的有效起始和截止时间");
+			}
+		} else {
+			if (coupon.getValidDays() == null && coupon.getValidHours() == null) {
+				throw BusinessRuntimeException.getInstance("请选择对应领取后有效时间");
+			}
 
-				if (coupon.getValidDays() != null || coupon.getValidDays() < 0) {
-					throw BusinessRuntimeException.getInstance("请输入正确的有效天数");
-				}
+			if (coupon.getValidDays() != null && coupon.getValidDays() < 0) {
+				throw BusinessRuntimeException.getInstance("请输入正确的有效天数");
+			}
 
-				if (coupon.getValidHours() != null || coupon.getValidHours() < 0) {
-					throw BusinessRuntimeException.getInstance("请输入正确的有效小时");
-				}
+			if (coupon.getValidHours() != null && coupon.getValidHours() < 0) {
+				throw BusinessRuntimeException.getInstance("请输入正确的有效小时");
 			}
 		}
 		if (StrUtil.isNotEmpty(coupon.getExCode())) {