From cede181bc0f1c8d25da96a12080e9fff6f8f96b5 Mon Sep 17 00:00:00 2001 From: misworga831 Date: Mon, 17 Jun 2024 15:13:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=9F=E6=88=90=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=BA=97=E9=93=BA=E5=95=86=E5=93=81=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E4=BC=98=E6=83=A0=E5=88=B8=E5=88=A4=E6=96=AD=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E8=A1=A5=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/PromotionGoodsService.java | 3 +-- .../PromotionGoodsServiceImpl.java | 23 ++----------------- .../serviceimpl/EsGoodsIndexServiceImpl.java | 7 ++++-- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/PromotionGoodsService.java b/framework/src/main/java/cn/lili/modules/promotion/service/PromotionGoodsService.java index 33f6d57ca..528746f91 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/PromotionGoodsService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/PromotionGoodsService.java @@ -4,7 +4,6 @@ import cn.lili.cache.CachePrefix; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.vo.PageVO; import cn.lili.modules.goods.entity.dos.GoodsSku; -import cn.lili.modules.goods.entity.dto.GoodsSkuDTO; import cn.lili.modules.promotion.entity.dos.PromotionGoods; import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -52,7 +51,7 @@ public interface PromotionGoodsService extends IService { * @param skus 商品skuId * @return 促销商品集合 */ - List findSkuValidPromotions(List skus); + List findSkuValidPromotions(List skus); /** * 分页获取促销商品信息 diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java index 170866c2d..fa3436e5c 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/PromotionGoodsServiceImpl.java @@ -1,15 +1,12 @@ package cn.lili.modules.promotion.serviceimpl; -import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; -import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import cn.lili.cache.Cache; import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.vo.PageVO; import cn.lili.modules.goods.entity.dos.GoodsSku; -import cn.lili.modules.goods.entity.dto.GoodsSkuDTO; import cn.lili.modules.goods.entity.vos.GoodsVO; import cn.lili.modules.goods.service.GoodsService; import cn.lili.modules.goods.service.GoodsSkuService; @@ -34,7 +31,6 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -52,11 +48,6 @@ public class PromotionGoodsServiceImpl extends ServiceImpl findSkuValidPromotions(List skus) { - List categories = skus.stream().map(GoodsSku::getCategoryPath).collect(Collectors.toList()); - List skuIds = skus.stream().map(GoodsSku::getId).collect(Collectors.toList()); - List categoriesPath = new ArrayList<>(); - categories.forEach(i -> { - if (CharSequenceUtil.isNotEmpty(i)) { - categoriesPath.addAll(Arrays.asList(i.split(","))); - } - } - ); + public List findSkuValidPromotions(List skuIds) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.and(i -> i.or(j -> j.in(SKU_ID_COLUMN, skuIds)) .or(n -> n.eq("scope_type", PromotionsScopeTypeEnum.ALL.name())) - .or(n -> n.and(k -> k.eq("scope_type", PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name()) - .and(l -> l.in(CollUtil.isNotEmpty(categoriesPath), "scope_id", categoriesPath))))); + .or(n -> n.and(k -> k.eq("scope_type", PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name())))); queryWrapper.and(i -> i.or(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.START)).or(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.NEW))); return this.list(queryWrapper); } diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java index a5a95d062..291efa1ad 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java @@ -196,7 +196,8 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements if (skuIPage == null || CollUtil.isEmpty(skuIPage.getRecords())) { break; } - List skuValidPromotions = promotionGoodsService.findSkuValidPromotions(skuIPage.getRecords()); + List skuIds = skuIPage.getRecords().stream().map(GoodsSku::getId).collect(Collectors.toList()); + List skuValidPromotions = promotionGoodsService.findSkuValidPromotions(skuIds); List brandIds = new ArrayList<>(); @@ -248,7 +249,9 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements (CharSequenceUtil.isNotEmpty(j.getSkuId()) && j.getSkuId().equals(goodsSku.getId())) || (j.getScopeType().equals(PromotionsScopeTypeEnum.ALL.name()) && j.getStoreId().equals("0")) || (j.getScopeType().equals(PromotionsScopeTypeEnum.ALL.name()) && j.getStoreId().equals(esGoodsIndex.getStoreId())) || - (j.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name()) && j.getScopeId().contains(goodsSku.getCategoryPath()))) + (j.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name()) && j.getStoreId().equals("0") && j.getScopeId().contains(goodsSku.getCategoryPath()))|| + (j.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name()) && j.getStoreId().equals(goodsSku.getStoreId()) && j.getScopeId().contains(goodsSku.getCategoryPath())) + ) .collect(Collectors.toList()); if (CollUtil.isNotEmpty(promotionGoods)) { esGoodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(promotionService.wrapperPromotionMapList(promotionGoods)));