Browse Source

feat:修改停车劵过期流程

release_toaliyun_real
xmzhao71 2 years ago
parent
commit
f73c9f05cf
3 changed files with 42 additions and 23 deletions
  1. +8
    -2
      mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java
  2. +1
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumCouponValidType.java
  3. +33
    -21
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java

+ 8
- 2
mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java View File

@@ -517,7 +517,6 @@ public class WxCoupon extends TenantEntity {
return false;
}
public Date getOuterRealValidDate(Date curr) {
Date valid_date = null;
if (this.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())) {
@@ -525,7 +524,14 @@ public class WxCoupon extends TenantEntity {
} else if (this.getValidType().equals(EnumCouponValidType.DAYS_AFTER_RECEIVING.getCode())) {
int limit_days = this.getValidDays();
valid_date = DateUtils.getTimeAfterDays(limit_days, curr);
} else {
} else if (this.getValidType().equals(EnumCouponValidType.TIME_AND_DAYS.getCode())) {
// 时间范围和过期天数共存,最终过期时间以最小的为主
int limit_days = this.getValidDays();
valid_date = limit_days != 0 ? DateUtils.getTimeAfterDays(limit_days, curr) : DateUtils.getDayEnd(curr);
if (this.getValidEndDate().before(valid_date)) {
valid_date = this.getValidEndDate();
}
} else {
//永久有效
}
return valid_date;


+ 1
- 0
mallinkService/src/main/java/com/iformall/enums/EnumCouponValidType.java View File

@@ -9,6 +9,7 @@ public enum EnumCouponValidType {
FOREVER(0, "永久有效"),
BETWEEN_TWO_TIME(1, "时间范围"),
DAYS_AFTER_RECEIVING(2, "领取后天数"),
TIME_AND_DAYS(3, "时间及天数,过期由最小的决定"),
;

public static EnumCouponValidType getEnum(Integer code) {


+ 33
- 21
mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java View File

@@ -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);


Loading…
Cancel
Save