自动删除优惠券存在时间类型问题,修正这个问题
This commit is contained in:
parent
8982db255d
commit
8ba0212f37
@ -1,5 +1,6 @@
|
|||||||
package cn.lili.timetask.handler.impl.coupon;
|
package cn.lili.timetask.handler.impl.coupon;
|
||||||
|
|
||||||
|
import cn.lili.common.utils.DateUtil;
|
||||||
import cn.lili.modules.promotion.entity.dos.MemberCoupon;
|
import cn.lili.modules.promotion.entity.dos.MemberCoupon;
|
||||||
import cn.lili.modules.promotion.entity.enums.MemberCouponStatusEnum;
|
import cn.lili.modules.promotion.entity.enums.MemberCouponStatusEnum;
|
||||||
import cn.lili.modules.promotion.service.MemberCouponService;
|
import cn.lili.modules.promotion.service.MemberCouponService;
|
||||||
@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,7 +24,7 @@ public class CouponExecute implements EveryDayExecute {
|
|||||||
/**
|
/**
|
||||||
* 过期常量,过期后或者使用后一定时间内,删除无效的优惠券,物理删除
|
* 过期常量,过期后或者使用后一定时间内,删除无效的优惠券,物理删除
|
||||||
*/
|
*/
|
||||||
static final int EXPIRATION_DAY = 7;
|
static final int EXPIRATION_DAY = 3;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MemberCouponService memberCouponService;
|
private MemberCouponService memberCouponService;
|
||||||
@ -40,12 +42,16 @@ public class CouponExecute implements EveryDayExecute {
|
|||||||
.set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.EXPIRE.name());
|
.set(MemberCoupon::getMemberCouponStatus, MemberCouponStatusEnum.EXPIRE.name());
|
||||||
this.memberCouponService.update(updateWrapper);
|
this.memberCouponService.update(updateWrapper);
|
||||||
|
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.set(Calendar.DAY_OF_MONTH,calendar.get(Calendar.DAY_OF_MONTH)+EXPIRATION_DAY);
|
||||||
|
Date removeTime = calendar.getTime();
|
||||||
//删除过期/已使用的优惠券
|
//删除过期/已使用的优惠券
|
||||||
LambdaUpdateWrapper<MemberCoupon> deleteWrapper = new LambdaUpdateWrapper<MemberCoupon>()
|
LambdaUpdateWrapper<MemberCoupon> deleteWrapper = new LambdaUpdateWrapper<MemberCoupon>()
|
||||||
//如果结束时间小于 当前时间增加指定删除日期,则删除
|
//如果结束时间小于 当前时间增加指定删除日期,则删除
|
||||||
.le(MemberCoupon::getEndTime, System.currentTimeMillis() + 24 * 60 * 60 * 1000 * EXPIRATION_DAY);
|
.le(MemberCoupon::getEndTime, removeTime);
|
||||||
this.memberCouponService.remove(deleteWrapper);
|
this.memberCouponService.remove(deleteWrapper);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user