From c4786844ef75025cd27cc3833a0f7cd86ad80781 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期一, 24 十一月 2025 12:01:04 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/user_action' into user_action

---
 buyer-api/src/main/java/cn/lili/controller/goods/GoodsBuyerController.java               |    2 +-
 framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java |   44 ++++++++++++++++++++++++++++++++++++++++++++
 framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsIndexServiceImpl.java  |    2 +-
 3 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/buyer-api/src/main/java/cn/lili/controller/goods/GoodsBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/goods/GoodsBuyerController.java
index c53850b..5ba34ae 100644
--- a/buyer-api/src/main/java/cn/lili/controller/goods/GoodsBuyerController.java
+++ b/buyer-api/src/main/java/cn/lili/controller/goods/GoodsBuyerController.java
@@ -126,7 +126,7 @@
     public ResultMessage<Page<EsGoodsIndex>> getGoodsByPageFromEs(EsGoodsSearchDTO goodsSearchParams, PageVO pageVO) {
         pageVO.setNotConvert(true);
         Page<EsGoodsIndex> ePage = goodsSearchService.searchGoodsByPage(goodsSearchParams, pageVO);
-        ePage.getRecords().forEach(item -> {
+        ePage.getRecords().stream().filter(Objects::nonNull).forEach(item -> {
             String small = item.getSmall();
             String thumbnail = item.getThumbnail();
             String goodsVideo = item.getGoodsVideo();
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 72e92e0..60eaa71 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
@@ -199,7 +199,7 @@
                     }
                     List<String> skuIds = skuIPage.getRecords().stream().map(GoodsSku::getId).collect(Collectors.toList());
                     List<PromotionGoods> skuValidPromotions = promotionGoodsService.findSkuValidPromotions(skuIds);
-
+                    log.info("鑾峰彇浼樻儬鍗蜂俊鎭棩蹇�---------------->{}",JSON.toJSONString(skuValidPromotions));
                     List<String> brandIds = new ArrayList<>();
 
                     List<String> categoryPaths = new ArrayList<>();
diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java
index b860033..d2dc77c 100644
--- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java
@@ -6,12 +6,16 @@
 import cn.lili.base.Result;
 import cn.lili.cache.Cache;
 import cn.lili.cache.CachePrefix;
+import cn.lili.common.enums.PromotionTypeEnum;
 import cn.lili.common.exception.ServiceException;
 import cn.lili.common.security.context.UserContext;
 import cn.lili.common.vo.PageVO;
 import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
 import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
 import cn.lili.modules.lmk.domain.query.VideoGoodsEsQuery;
+import cn.lili.modules.promotion.entity.dos.Coupon;
+import cn.lili.modules.promotion.entity.enums.PromotionsScopeTypeEnum;
+import cn.lili.modules.promotion.service.CouponService;
 import cn.lili.modules.search.entity.dos.EsGoodsIndex;
 import cn.lili.modules.search.entity.dos.EsGoodsRelatedInfo;
 import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO;
@@ -20,6 +24,7 @@
 import cn.lili.modules.search.service.EsGoodsSearchService;
 import cn.lili.modules.search.utils.SqlFilter;
 import com.alibaba.druid.util.StringUtils;
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.lucene.search.join.ScoreMode;
@@ -88,6 +93,9 @@
     @Autowired
     private Cache<Object> cache;
 
+    @Autowired
+    private CouponService couponService;
+
     @Override
     public SearchPage<EsGoodsIndex> searchGoods(EsGoodsSearchDTO searchDTO, PageVO pageVo) {
 
@@ -112,6 +120,42 @@
 
     @Override
     public Page<EsGoodsIndex> searchGoodsByPage(EsGoodsSearchDTO searchDTO, PageVO pageVo) {
+        if (PromotionTypeEnum.COUPON.name().equals(searchDTO.getPromotionType())) {
+            Coupon coupon = couponService.getById(searchDTO.getPromotionsId());
+            if (coupon != null) {
+                if (PromotionsScopeTypeEnum.ALL.name().equals(coupon.getScopeType())) {
+                    searchDTO.setPromotionType(null);
+                    searchDTO.setPromotionsId(null);
+                } else if (PromotionsScopeTypeEnum.PORTION_GOODS.name().equals(coupon.getScopeType())) {
+                    String promotionsId = coupon.getScopeId();
+                    if (cn.lili.common.utils.StringUtils.isNotBlank(promotionsId)) {
+                        List<String> skuIds = new ArrayList<>(Arrays.asList(promotionsId.split(",")));
+                        Page<EsGoodsIndex> resultPage = new Page<>();
+                        List<EsGoodsIndex> esGoodsBySkuIds = getEsGoodsBySkuIds(skuIds, pageVo);
+                        System.err.println(JSON.toJSONString(esGoodsBySkuIds));
+                        resultPage.setRecords(esGoodsBySkuIds);
+                        resultPage.setPages(1);
+                        resultPage.setCurrent(1);
+                        resultPage.setSize(1);
+                        resultPage.setTotal(esGoodsBySkuIds.size());
+                        return resultPage;
+                    }
+                } else if (PromotionsScopeTypeEnum.PORTION_SHOP_CATEGORY.name().equals(coupon.getScopeType())) {
+                    searchDTO.setPromotionType(null);
+                    searchDTO.setCategoryId(searchDTO.getPromotionsId());
+                    searchDTO.setPromotionsId(null);
+                } else if (PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name().equals(coupon.getScopeType())) {
+                    String promotionsId = searchDTO.getPromotionsId();
+                    if (cn.lili.common.utils.StringUtils.isNotBlank(promotionsId)) {
+                        searchDTO.setPromotionType(null);
+                        searchDTO.setCategoryId(coupon.getScopeId());
+                        searchDTO.setPromotionsId(null);
+                    }
+                }
+
+            }
+
+        }
         // 鍒ゆ柇鍟嗗搧绱㈠紩鏄惁瀛樺湪
         if (!restTemplate.indexOps(EsGoodsIndex.class).exists()) {
             return null;

--
Gitblit v1.8.0