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 fc5a5f0d..19caa3e0 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 @@ -18,14 +18,13 @@ import cn.lili.modules.search.service.HotWordsService; import cn.lili.modules.statistics.aop.PageViewPoint; import cn.lili.modules.statistics.aop.enums.PageViewEnum; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.elasticsearch.core.SearchPage; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -104,10 +103,9 @@ public class GoodsBuyerController { @ApiOperation(value = "从ES中获取商品信息") @GetMapping("/es") - public ResultMessage> getGoodsByPageFromEs(EsGoodsSearchDTO goodsSearchParams, PageVO pageVO) { + public ResultMessage> getGoodsByPageFromEs(EsGoodsSearchDTO goodsSearchParams, PageVO pageVO) { pageVO.setNotConvert(true); - SearchPage esGoodsIndices = goodsSearchService.searchGoods(goodsSearchParams, pageVO); - return ResultUtil.data(esGoodsIndices); + return ResultUtil.data(goodsSearchService.searchGoodsByPage(goodsSearchParams, pageVO)); } @ApiOperation(value = "从ES中获取相关商品品牌名称,分类名称及属性") diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 692e3ade..e8949915 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -343,6 +343,7 @@ public class GoodsMessageListener implements RocketMQListener { searchParams.setGoodsId(goods.getId()); searchParams.setPageNumber(i); searchParams.setPageSize(BATCH_SIZE); + searchParams.setGeQuantity(0); IPage goodsSkuByPage = this.goodsSkuService.getGoodsSkuByPage(searchParams); if (goodsSkuByPage == null || goodsSkuByPage.getRecords().isEmpty()) { break; diff --git a/framework/pom.xml b/framework/pom.xml index 8e631d65..bfcd88a3 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -460,6 +460,14 @@ system ${project.basedir}/src/main/resources/maven-repository/SF-CSIM-EXPRESS-SDK-V2.1.7.jar + + + io.netty + netty-resolver-dns-native-macos + 4.1.90.Final + runtime + osx-aarch_64 + 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 eddecde6..80227ee1 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 @@ -103,7 +103,7 @@ public class CouponSearchParams extends BasePromotionsSearchParams implements Se } if (this.getStartTime() != null) { - queryWrapper.ge("start_time", new Date(this.getEndTime())); + queryWrapper.ge("start_time", new Date(this.getStartTime())); } if (this.getEndTime() != null) { queryWrapper.le("end_time", new Date(this.getEndTime())); diff --git a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsSearchService.java b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsSearchService.java index 22b46a27..61930be0 100644 --- a/framework/src/main/java/cn/lili/modules/search/service/EsGoodsSearchService.java +++ b/framework/src/main/java/cn/lili/modules/search/service/EsGoodsSearchService.java @@ -4,6 +4,7 @@ import cn.lili.common.vo.PageVO; import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.entity.dos.EsGoodsRelatedInfo; import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.data.elasticsearch.core.SearchPage; import java.util.List; @@ -25,6 +26,15 @@ public interface EsGoodsSearchService { */ SearchPage searchGoods(EsGoodsSearchDTO searchDTO, PageVO pageVo); + /** + * 商品搜索 + * + * @param searchDTO 搜索参数 + * @param pageVo 分页参数 + * @return 搜索结果 + */ + Page searchGoodsByPage(EsGoodsSearchDTO searchDTO, PageVO pageVo); + /** * 获取筛选器 * 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 3c12ceef..a8848ff8 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 @@ -167,6 +167,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements skuQueryWrapper.eq("gs.auth_flag", GoodsAuthEnum.PASS.name()); skuQueryWrapper.eq("gs.market_enable", GoodsStatusEnum.UPPER.name()); skuQueryWrapper.eq("gs.delete_flag", false); + skuQueryWrapper.gt("gs.quantity", 0); Map resultMap = (Map) cache.get(CachePrefix.INIT_INDEX_PROCESS.getPrefix()); @@ -176,6 +177,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements skuCountQueryWrapper.eq("auth_flag", GoodsAuthEnum.PASS.name()); skuCountQueryWrapper.eq("market_enable", GoodsStatusEnum.UPPER.name()); skuCountQueryWrapper.eq("delete_flag", false); + skuCountQueryWrapper.ge("quantity", 0); resultMap = new HashMap<>(); resultMap.put(KEY_SUCCESS, 0L); resultMap.put(KEY_FAIL, 0L); @@ -606,7 +608,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements } private void executeUpdateEsGoodsIndexAll(BasePromotions promotion, String key) { - for (int i = 1; ; i++) { + for (int i = 0; ; i++) { List skuIds; //如果storeId不为空,则表示是店铺活动 if (promotion.getStoreId() != null && !promotion.getStoreId().equals(PromotionTools.PLATFORM_ID)) { 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 669e6241..114109f8 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 @@ -17,6 +17,7 @@ import cn.lili.modules.search.entity.dto.SelectorOptions; import cn.lili.modules.search.service.EsGoodsSearchService; import cn.lili.modules.search.utils.SqlFilter; import com.alibaba.druid.util.StringUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.extern.slf4j.Slf4j; import org.apache.lucene.search.join.ScoreMode; import org.elasticsearch.common.lucene.search.function.FieldValueFactorFunction; @@ -37,15 +38,13 @@ import org.elasticsearch.search.sort.SortOrder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; -import org.springframework.data.elasticsearch.core.ElasticsearchOperations; -import org.springframework.data.elasticsearch.core.SearchHitSupport; -import org.springframework.data.elasticsearch.core.SearchHits; -import org.springframework.data.elasticsearch.core.SearchPage; +import org.springframework.data.elasticsearch.core.*; import org.springframework.data.elasticsearch.core.query.NativeSearchQuery; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.stereotype.Service; import java.util.*; +import java.util.stream.Collectors; /** * ES商品搜索业务层实现 @@ -95,6 +94,20 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { return SearchHitSupport.searchPageFor(search, searchQuery.getPageable()); } + @Override + public Page searchGoodsByPage(EsGoodsSearchDTO searchDTO, PageVO pageVo) { + SearchPage esGoodsIndices = this.searchGoods(searchDTO, pageVo); + Page resultPage = new Page<>(); + if (esGoodsIndices != null && !esGoodsIndices.getContent().isEmpty()) { + List collect = esGoodsIndices.getSearchHits().getSearchHits().stream().map(SearchHit::getContent).collect(Collectors.toList()); + resultPage.setRecords(collect); + resultPage.setPages(esGoodsIndices.getTotalPages()); + resultPage.setCurrent(esGoodsIndices.getNumber() + 1L); + resultPage.setSize(esGoodsIndices.getSize()); + resultPage.setTotal(esGoodsIndices.getTotalElements()); + } + return resultPage; + } @Override public EsGoodsRelatedInfo getSelector(EsGoodsSearchDTO goodsSearch, PageVO pageVo) { diff --git a/pom.xml b/pom.xml index 29fcaf50..84a36127 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ 2.2.2 0.11.2 4.0.0 - 1.2.8 + 1.2.16 1.0.3 4.7.2 4.7.2