diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/BasePromotionsSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/BasePromotionsSearchParams.java index b07aea26..0131aa3e 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/BasePromotionsSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/BasePromotionsSearchParams.java @@ -43,6 +43,19 @@ public class BasePromotionsSearchParams { private String storeId; public QueryWrapper queryWrapper() { + QueryWrapper queryWrapper = this.baseQueryWrapper(); + + if (CharSequenceUtil.isNotEmpty(promotionStatus)) { + queryWrapper.and(i -> { + for (String status : promotionStatus.split(",")) { + i.or(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.valueOf(status))); + } + }); + } + return queryWrapper; + } + + public QueryWrapper baseQueryWrapper() { QueryWrapper queryWrapper = new QueryWrapper<>(); if (CharSequenceUtil.isNotEmpty(id)) { @@ -54,13 +67,6 @@ public class BasePromotionsSearchParams { if (endTime != null) { queryWrapper.le("end_time", new Date(endTime)); } - if (CharSequenceUtil.isNotEmpty(promotionStatus)) { - queryWrapper.and(i -> { - for (String status : promotionStatus.split(",")) { - i.or(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.valueOf(status))); - } - }); - } if (CharSequenceUtil.isNotEmpty(scopeType)) { queryWrapper.eq("scope_type", scopeType); } diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/CouponSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/CouponSearchParams.java index f71a198c..eddecde6 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/CouponSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/CouponSearchParams.java @@ -60,7 +60,7 @@ public class CouponSearchParams extends BasePromotionsSearchParams implements Se @Override public QueryWrapper queryWrapper() { - QueryWrapper queryWrapper = super.queryWrapper(); + QueryWrapper queryWrapper = super.baseQueryWrapper(); if (CharSequenceUtil.isNotEmpty(couponName)) { queryWrapper.like("coupon_name", couponName); } @@ -80,24 +80,27 @@ public class CouponSearchParams extends BasePromotionsSearchParams implements Se queryWrapper.eq("get_type", CouponGetEnum.valueOf(getType).name()); } if (CharSequenceUtil.isNotEmpty(this.getPromotionStatus())) { - switch (PromotionsStatusEnum.valueOf(this.getPromotionStatus())) { - case NEW: - queryWrapper.nested(i -> i.gt(PromotionTools.START_TIME_COLUMN, new Date()).gt(PromotionTools.END_TIME_COLUMN, new Date())); - break; - case START: - queryWrapper.nested(i -> i.le(PromotionTools.START_TIME_COLUMN, new Date()).ge(PromotionTools.END_TIME_COLUMN, new Date())) - .or(i -> i.gt("effective_days", 0).eq(RANGE_DAY_TYPE_COLUMN, CouponRangeDayEnum.DYNAMICTIME.name())); - break; - case END: - queryWrapper.nested(i -> i.lt(PromotionTools.START_TIME_COLUMN, new Date()).lt(PromotionTools.END_TIME_COLUMN, new Date())); - break; - case CLOSE: - queryWrapper.nested(n -> n.nested(i -> i.isNull(PromotionTools.START_TIME_COLUMN).isNull(PromotionTools.END_TIME_COLUMN) - .eq(RANGE_DAY_TYPE_COLUMN, CouponRangeDayEnum.FIXEDTIME.name())). - or(i -> i.le("effective_days", 0).eq(RANGE_DAY_TYPE_COLUMN, CouponRangeDayEnum.DYNAMICTIME.name()))); - break; - default: - } + queryWrapper.and(p -> { + switch (PromotionsStatusEnum.valueOf(this.getPromotionStatus())) { + case NEW: + p.nested(i -> i.gt(PromotionTools.START_TIME_COLUMN, new Date()).gt(PromotionTools.END_TIME_COLUMN, new Date())); + break; + case START: + p.nested(i -> i.le(PromotionTools.START_TIME_COLUMN, new Date()).ge(PromotionTools.END_TIME_COLUMN, new Date())) + .or(i -> i.gt("effective_days", 0).eq(RANGE_DAY_TYPE_COLUMN, CouponRangeDayEnum.DYNAMICTIME.name())); + break; + case END: + p.nested(i -> i.lt(PromotionTools.START_TIME_COLUMN, new Date()).lt(PromotionTools.END_TIME_COLUMN, new Date())); + break; + case CLOSE: + p.nested(n -> n.nested(i -> i.isNull(PromotionTools.START_TIME_COLUMN).isNull(PromotionTools.END_TIME_COLUMN) + .eq(RANGE_DAY_TYPE_COLUMN, CouponRangeDayEnum.FIXEDTIME.name())). + or(i -> i.le("effective_days", 0).eq(RANGE_DAY_TYPE_COLUMN, CouponRangeDayEnum.DYNAMICTIME.name()))); + break; + default: + } + }); + } if (this.getStartTime() != null) { queryWrapper.ge("start_time", new Date(this.getEndTime())); @@ -105,7 +108,6 @@ public class CouponSearchParams extends BasePromotionsSearchParams implements Se if (this.getEndTime() != null) { queryWrapper.le("end_time", new Date(this.getEndTime())); } - queryWrapper.eq("delete_flag", false); this.betweenWrapper(queryWrapper); queryWrapper.orderByDesc("create_time"); return queryWrapper; diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/MemberCouponSearchParams.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/MemberCouponSearchParams.java index f666646c..02f1b8f0 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/MemberCouponSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dto/search/MemberCouponSearchParams.java @@ -1,8 +1,10 @@ package cn.lili.modules.promotion.entity.dto.search; import cn.hutool.core.text.CharSequenceUtil; -import cn.lili.modules.promotion.entity.enums.*; -import cn.lili.modules.promotion.tools.PromotionTools; +import cn.lili.modules.promotion.entity.enums.CouponGetEnum; +import cn.lili.modules.promotion.entity.enums.CouponTypeEnum; +import cn.lili.modules.promotion.entity.enums.MemberCouponStatusEnum; +import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -78,9 +80,6 @@ public class MemberCouponSearchParams extends BasePromotionsSearchParams impleme if (CharSequenceUtil.isNotEmpty(memberCouponStatus)) { queryWrapper.eq("member_coupon_status", MemberCouponStatusEnum.valueOf(memberCouponStatus).name()); } - if (CharSequenceUtil.isNotEmpty(this.getPromotionStatus())) { - queryWrapper.and(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.valueOf(getPromotionStatus()))); - } if (CharSequenceUtil.isNotEmpty(price)) { String[] s = price.split("_"); if (s.length > 1) { diff --git a/manager-api/src/main/java/cn/lili/ManagerApiApplication.java b/manager-api/src/main/java/cn/lili/ManagerApiApplication.java index b8a5b384..838bda79 100644 --- a/manager-api/src/main/java/cn/lili/ManagerApiApplication.java +++ b/manager-api/src/main/java/cn/lili/ManagerApiApplication.java @@ -23,8 +23,7 @@ public class ManagerApiApplication { @Primary @Bean public TaskExecutor primaryTask() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - return executor; + return new ThreadPoolTaskExecutor(); } public static void main(String[] args) {