|
|
|
@@ -564,27 +564,30 @@ public class WxCouponServiceImpl implements WxCouponService { |
|
|
|
} |
|
|
|
|
|
|
|
if (record.getValidType() != null) { |
|
|
|
if (record.getValidType().equals(EnumCouponValidType.FOREVER.getCode())){ |
|
|
|
record.setValidStartDate(null); |
|
|
|
record.setValidEndDate(null); |
|
|
|
record.setValidDays(null); |
|
|
|
}else if( record.getValidType().equals(EnumCouponValidType.DAYS_AFTER_RECEIVING.getCode())) { |
|
|
|
record.setValidStartDate(null); |
|
|
|
record.setValidEndDate(null); |
|
|
|
} else if (record.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())) { |
|
|
|
record.setValidDays(null); |
|
|
|
|
|
|
|
if(record.getSoldStartTime() != null && record.getSoldEndTime() != null){ |
|
|
|
if(record.getValidStartDate().before(record.getSoldStartTime())){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "有效时间需在售卖期之后"); |
|
|
|
} |
|
|
|
if(record.getValidEndDate().before(record.getSoldEndTime())){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "有效时间需在售卖期之后"); |
|
|
|
switch (EnumCouponValidType.getEnum(record.getValidType())) { |
|
|
|
case FOREVER: |
|
|
|
record.setValidStartDate(null); |
|
|
|
record.setValidEndDate(null); |
|
|
|
record.setValidDays(null); |
|
|
|
break; |
|
|
|
case DAYS_AFTER_RECEIVING: |
|
|
|
record.setValidStartDate(null); |
|
|
|
record.setValidEndDate(null); |
|
|
|
break; |
|
|
|
case BETWEEN_TWO_TIME: |
|
|
|
record.setValidDays(null); |
|
|
|
case TIME_AND_DAYS: |
|
|
|
if (record.getSoldStartTime() != null && record.getSoldEndTime() != null) { |
|
|
|
if (record.getValidStartDate().before(record.getSoldStartTime())) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "有效时间需在售卖期之后"); |
|
|
|
} |
|
|
|
if (record.getValidEndDate().before(record.getSoldEndTime())) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "有效时间需在售卖期之后"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请填写有效时间类型"); |
|
|
|
break; |
|
|
|
default: |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请填写有效时间类型"); |
|
|
|
} |
|
|
|
|
|
|
|
if(!this.validCouponDate(record)) { |
|
|
|
@@ -1400,7 +1403,16 @@ public class WxCouponServiceImpl implements WxCouponService { |
|
|
|
if(!wxCoupon.getValidDays().equals(oldCoupon.getValidDays())) { |
|
|
|
bChanged = true; |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else if (oldCoupon.getValidType().equals(EnumCouponValidType.TIME_AND_DAYS.getCode())) { |
|
|
|
if(wxCoupon.getValidEndDate().before(oldCoupon.getValidEndDate()) || wxCoupon.getValidDays() < oldCoupon.getValidDays()) { |
|
|
|
// 券有效期只可增加 |
|
|
|
logger.error("券有效期只可增加"); |
|
|
|
return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR.getCode(), "券有效期只可增加"); |
|
|
|
} |
|
|
|
if(!wxCoupon.getValidEndDate().equals(oldCoupon.getValidEndDate()) || !wxCoupon.getValidDays().equals(oldCoupon.getValidDays())) { |
|
|
|
bChanged = true; |
|
|
|
} |
|
|
|
} else{ |
|
|
|
wxCoupon.setValidStartDate(null); |
|
|
|
wxCoupon.setValidEndDate(null); |
|
|
|
wxCoupon.setValidDays(null); |
|
|
|
|