diff --git a/framework/src/main/java/cn/lili/common/enums/ResultCode.java b/framework/src/main/java/cn/lili/common/enums/ResultCode.java index 61875238..5b364610 100644 --- a/framework/src/main/java/cn/lili/common/enums/ResultCode.java +++ b/framework/src/main/java/cn/lili/common/enums/ResultCode.java @@ -234,17 +234,18 @@ public enum ResultCode { /** * 活动 */ - PROMOTION_GOODS_NOT_EXIT(40001, "当前促销商品不存在!"), - PROMOTION_SAME_ACTIVE_EXIST(40002,"当前时间内已存在同类活动"), - PROMOTION_START_TIME_ERROR(40003,"活动起始时间不能小于当前时间"), - PROMOTION_TIME_ERROR(40004,"活动起始时间必须大于当前时间"), - PROMOTION_SAME_ERROR(40005,"当前时间段已存在相同活动!"), - PROMOTION_GOODS_ERROR(40006,"请选择要参与活动的商品"), - PROMOTION_STATUS_END(40007,"当前活动已停止"), - PROMOTION_UPDATE_ERROR(40008,"当前活动已开始/结束,无法编辑!"), - PROMOTION_ACTIVITY_GOODS_ERROR(40009,"当前活动已经开始无法添加商品"), - PROMOTION_ACTIVITY_ERROR(40009,"当前促销活动不存在"), - PROMOTION_LOG_EXIST(40010,"活动已参加,已发重复参加"), + PROMOTION_GOODS_NOT_EXIT(40000, "当前促销商品不存在!"), + PROMOTION_SAME_ACTIVE_EXIST(40001, "当前时间内已存在同类活动"), + PROMOTION_START_TIME_ERROR(40002, "活动起始时间不能小于当前时间"), + PROMOTION_END_TIME_ERROR(40003, "活动结束时间不能小于当前时间"), + PROMOTION_TIME_ERROR(40004, "活动起始时间必须大于结束时间"), + PROMOTION_SAME_ERROR(40005, "当前时间段已存在相同活动!"), + PROMOTION_GOODS_ERROR(40006, "请选择要参与活动的商品"), + PROMOTION_STATUS_END(40007, "当前活动已停止"), + PROMOTION_UPDATE_ERROR(40008, "当前活动已开始/结束,无法编辑!"), + PROMOTION_ACTIVITY_GOODS_ERROR(40009, "当前活动已经开始无法添加商品"), + PROMOTION_ACTIVITY_ERROR(400010, "当前促销活动不存在"), + PROMOTION_LOG_EXIST(40011, "活动已参加,已发重复参加"), /** * 优惠券 diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java index e12c770f..cbed7771 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java @@ -297,6 +297,7 @@ public class CouponServiceImpl extends ServiceImpl impleme */ private void checkParam(CouponVO coupon) { + //优惠券限制领取数量 if (coupon.getCouponLimitNum() < 0) { throw new ServiceException(ResultCode.COUPON_LIMIT_NUM_LESS_THAN_0); } @@ -304,18 +305,21 @@ public class CouponServiceImpl extends ServiceImpl impleme if (coupon.getPublishNum() != 0 && coupon.getCouponLimitNum() > coupon.getPublishNum()) { throw new ServiceException(ResultCode.COUPON_LIMIT_GREATER_THAN_PUBLISH); } + //打折优惠券大于10折 boolean discountCoupon = (coupon.getCouponType().equals(CouponTypeEnum.DISCOUNT.name()) && (coupon.getCouponDiscount() < 0 && coupon.getCouponDiscount() > 10)); if (discountCoupon) { throw new ServiceException(ResultCode.COUPON_DISCOUNT_ERROR); } + //优惠券为固定时间类型 if (coupon.getRangeDayType() != null && coupon.getRangeDayType().equals(CouponRangeDayEnum.FIXEDTIME.name())) { long nowTime = DateUtil.getDateline() * 1000; - if (coupon.getStartTime().getTime() < nowTime && coupon.getEndTime().getTime() > nowTime) { - throw new ServiceException(ResultCode.PROMOTION_TIME_ERROR); + //固定时间的优惠券不能小于当前时间 + if (coupon.getEndTime().getTime() < nowTime) { + throw new ServiceException(ResultCode.PROMOTION_END_TIME_ERROR); } - + //促销通用时间校验 PromotionTools.checkPromotionTime(coupon.getStartTime().getTime(), coupon.getEndTime().getTime()); }