活动时间校验问题处理
This commit is contained in:
parent
74cc360900
commit
f12c8a1aec
@ -234,17 +234,18 @@ public enum ResultCode {
|
|||||||
/**
|
/**
|
||||||
* 活动
|
* 活动
|
||||||
*/
|
*/
|
||||||
PROMOTION_GOODS_NOT_EXIT(40001, "当前促销商品不存在!"),
|
PROMOTION_GOODS_NOT_EXIT(40000, "当前促销商品不存在!"),
|
||||||
PROMOTION_SAME_ACTIVE_EXIST(40002,"当前时间内已存在同类活动"),
|
PROMOTION_SAME_ACTIVE_EXIST(40001, "当前时间内已存在同类活动"),
|
||||||
PROMOTION_START_TIME_ERROR(40003,"活动起始时间不能小于当前时间"),
|
PROMOTION_START_TIME_ERROR(40002, "活动起始时间不能小于当前时间"),
|
||||||
PROMOTION_TIME_ERROR(40004,"活动起始时间必须大于当前时间"),
|
PROMOTION_END_TIME_ERROR(40003, "活动结束时间不能小于当前时间"),
|
||||||
PROMOTION_SAME_ERROR(40005,"当前时间段已存在相同活动!"),
|
PROMOTION_TIME_ERROR(40004, "活动起始时间必须大于结束时间"),
|
||||||
PROMOTION_GOODS_ERROR(40006,"请选择要参与活动的商品"),
|
PROMOTION_SAME_ERROR(40005, "当前时间段已存在相同活动!"),
|
||||||
PROMOTION_STATUS_END(40007,"当前活动已停止"),
|
PROMOTION_GOODS_ERROR(40006, "请选择要参与活动的商品"),
|
||||||
PROMOTION_UPDATE_ERROR(40008,"当前活动已开始/结束,无法编辑!"),
|
PROMOTION_STATUS_END(40007, "当前活动已停止"),
|
||||||
PROMOTION_ACTIVITY_GOODS_ERROR(40009,"当前活动已经开始无法添加商品"),
|
PROMOTION_UPDATE_ERROR(40008, "当前活动已开始/结束,无法编辑!"),
|
||||||
PROMOTION_ACTIVITY_ERROR(40009,"当前促销活动不存在"),
|
PROMOTION_ACTIVITY_GOODS_ERROR(40009, "当前活动已经开始无法添加商品"),
|
||||||
PROMOTION_LOG_EXIST(40010,"活动已参加,已发重复参加"),
|
PROMOTION_ACTIVITY_ERROR(400010, "当前促销活动不存在"),
|
||||||
|
PROMOTION_LOG_EXIST(40011, "活动已参加,已发重复参加"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 优惠券
|
* 优惠券
|
||||||
|
@ -297,6 +297,7 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
|
|||||||
*/
|
*/
|
||||||
private void checkParam(CouponVO coupon) {
|
private void checkParam(CouponVO coupon) {
|
||||||
|
|
||||||
|
//优惠券限制领取数量
|
||||||
if (coupon.getCouponLimitNum() < 0) {
|
if (coupon.getCouponLimitNum() < 0) {
|
||||||
throw new ServiceException(ResultCode.COUPON_LIMIT_NUM_LESS_THAN_0);
|
throw new ServiceException(ResultCode.COUPON_LIMIT_NUM_LESS_THAN_0);
|
||||||
}
|
}
|
||||||
@ -304,18 +305,21 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
|
|||||||
if (coupon.getPublishNum() != 0 && coupon.getCouponLimitNum() > coupon.getPublishNum()) {
|
if (coupon.getPublishNum() != 0 && coupon.getCouponLimitNum() > coupon.getPublishNum()) {
|
||||||
throw new ServiceException(ResultCode.COUPON_LIMIT_GREATER_THAN_PUBLISH);
|
throw new ServiceException(ResultCode.COUPON_LIMIT_GREATER_THAN_PUBLISH);
|
||||||
}
|
}
|
||||||
|
//打折优惠券大于10折
|
||||||
boolean discountCoupon = (coupon.getCouponType().equals(CouponTypeEnum.DISCOUNT.name())
|
boolean discountCoupon = (coupon.getCouponType().equals(CouponTypeEnum.DISCOUNT.name())
|
||||||
&& (coupon.getCouponDiscount() < 0 && coupon.getCouponDiscount() > 10));
|
&& (coupon.getCouponDiscount() < 0 && coupon.getCouponDiscount() > 10));
|
||||||
if (discountCoupon) {
|
if (discountCoupon) {
|
||||||
throw new ServiceException(ResultCode.COUPON_DISCOUNT_ERROR);
|
throw new ServiceException(ResultCode.COUPON_DISCOUNT_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//优惠券为固定时间类型
|
||||||
if (coupon.getRangeDayType() != null && coupon.getRangeDayType().equals(CouponRangeDayEnum.FIXEDTIME.name())) {
|
if (coupon.getRangeDayType() != null && coupon.getRangeDayType().equals(CouponRangeDayEnum.FIXEDTIME.name())) {
|
||||||
long nowTime = DateUtil.getDateline() * 1000;
|
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());
|
PromotionTools.checkPromotionTime(coupon.getStartTime().getTime(), coupon.getEndTime().getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user