|
|
@@ -46,6 +46,7 @@ import java.util.*;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
+
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
@@ -54,33 +55,33 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 产品基础信息Service业务层处理
|
|
|
- *
|
|
|
+ * <p>
|
|
|
* 性能优化说明(针对200万级别数据量):
|
|
|
* 1. 启动时ES同步使用分页流式处理,每次只加载1000条数据
|
|
|
* 2. 提供流式查询API(selectAllListStream)避免OOM
|
|
|
* 3. 单条查询优化,建议添加缓存
|
|
|
* 4. 批量删除优化,减少数据库交互
|
|
|
- *
|
|
|
+ * <p>
|
|
|
* 数据库索引建议(必须添加):
|
|
|
* product_base表:
|
|
|
- * - idx_product_no: product_no (产品编号,唯一索引)
|
|
|
- * - idx_brand_id: brand_id (品牌ID)
|
|
|
- * - idx_category: top_category_id, medium_category_id, bottom_category_id (组合索引)
|
|
|
- * - idx_status: product_status, product_review_status (状态组合索引)
|
|
|
- * - idx_create_time: create_time (创建时间)
|
|
|
- *
|
|
|
+ * - idx_product_no: product_no (产品编号,唯一索引)
|
|
|
+ * - idx_brand_id: brand_id (品牌ID)
|
|
|
+ * - idx_category: top_category_id, medium_category_id, bottom_category_id (组合索引)
|
|
|
+ * - idx_status: product_status, product_review_status (状态组合索引)
|
|
|
+ * - idx_create_time: create_time (创建时间)
|
|
|
+ * <p>
|
|
|
* product_extend表:
|
|
|
- * - idx_product_id: product_id (外键索引)
|
|
|
- *
|
|
|
+ * - idx_product_id: product_id (外键索引)
|
|
|
+ * <p>
|
|
|
* product_price_inventory表:
|
|
|
- * - PRIMARY KEY: product_id (主键)
|
|
|
- *
|
|
|
+ * - PRIMARY KEY: product_id (主键)
|
|
|
+ * <p>
|
|
|
* product_classification表:
|
|
|
- * - idx_product_id: product_id (外键索引)
|
|
|
- * - idx_category_id: category_id (分类索引)
|
|
|
- *
|
|
|
+ * - idx_product_id: product_id (外键索引)
|
|
|
+ * - idx_category_id: category_id (分类索引)
|
|
|
+ * <p>
|
|
|
* product_customization表:
|
|
|
- * - idx_product_id: product_id (外键索引)
|
|
|
+ * - idx_product_id: product_id (外键索引)
|
|
|
*
|
|
|
* @author LionLi
|
|
|
* @date 2025-12-11
|
|
|
@@ -88,7 +89,7 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
-public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, ProductBase> implements IProductBaseService,ApplicationRunner {
|
|
|
+public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, ProductBase> implements IProductBaseService, ApplicationRunner {
|
|
|
|
|
|
//产品基础信息Mapper
|
|
|
private final ProductBaseMapper baseMapper;
|
|
|
@@ -213,7 +214,7 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
* 1. 使用联表查询减少数据库交互次数(建议在Mapper中实现)
|
|
|
* 2. 对于高频访问场景,建议添加缓存(Redis)
|
|
|
* 3. 已优化为单次主查询+关联查询,避免N+1问题
|
|
|
- *
|
|
|
+ * <p>
|
|
|
* TODO: 性能优化建议
|
|
|
* - 将分类、品牌、单位等字典数据缓存到Redis
|
|
|
* - 考虑使用@Cacheable注解实现方法级缓存
|
|
|
@@ -223,7 +224,7 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
* @return 产品基础信息
|
|
|
*/
|
|
|
@Override
|
|
|
- public ProductBaseVo queryById(Long id){
|
|
|
+ public ProductBaseVo queryById(Long id) {
|
|
|
// 1. 查询基础信息
|
|
|
ProductBaseVo vo = baseMapper.selectVoById(id);
|
|
|
if (vo == null) {
|
|
|
@@ -232,17 +233,17 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
|
|
|
//获取分类信息
|
|
|
ProductCategory productCategory = categoryMapper.selectById(vo.getBottomCategoryId());
|
|
|
- if (ObjectUtil.isNotEmpty(productCategory)){
|
|
|
+ if (ObjectUtil.isNotEmpty(productCategory)) {
|
|
|
vo.setCategoryName(productCategory.getCategoryName());
|
|
|
}
|
|
|
//获取品牌信息
|
|
|
ProductBrand productBrand = brandMapper.selectById(vo.getBrandId());
|
|
|
- if (ObjectUtil.isNotEmpty(productBrand)){
|
|
|
+ if (ObjectUtil.isNotEmpty(productBrand)) {
|
|
|
vo.setBrandName(productBrand.getBrandName());
|
|
|
}
|
|
|
//获取单位信息
|
|
|
ProductUnit productUnit = unitMapper.selectById(vo.getUnitId());
|
|
|
- if (ObjectUtil.isNotEmpty(productUnit)){
|
|
|
+ if (ObjectUtil.isNotEmpty(productUnit)) {
|
|
|
vo.setUnitName(productUnit.getUnitName());
|
|
|
}
|
|
|
// 2. 查询并填充扩展信息(product_extend表)
|
|
|
@@ -324,10 +325,10 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
}
|
|
|
}
|
|
|
//获取详情
|
|
|
- LambdaQueryWrapper<ProductPhotos> photosWrapper= Wrappers.lambdaQuery();
|
|
|
+ LambdaQueryWrapper<ProductPhotos> photosWrapper = Wrappers.lambdaQuery();
|
|
|
photosWrapper.eq(ProductPhotos::getProductId, id);
|
|
|
ProductPhotos productPhotos = photosMapper.selectOne(photosWrapper);
|
|
|
- if(ObjectUtil.isNotEmpty(productPhotos)){
|
|
|
+ if (ObjectUtil.isNotEmpty(productPhotos)) {
|
|
|
vo.setPcDetail(productPhotos.getProductDetailsPc());
|
|
|
vo.setMobileDetail(productPhotos.getProductDetailsApp());
|
|
|
}
|
|
|
@@ -345,18 +346,18 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
@Override
|
|
|
public TableDataInfo<ProductBaseVo> queryPageList(ProductBaseBo bo, PageQuery pageQuery) {
|
|
|
QueryWrapper<ProductBase> lqw = Wrappers.query();
|
|
|
- if(ObjectUtil.isNotEmpty(bo.getIds())){
|
|
|
- lqw.in( "b.id", bo.getIds().split(","));
|
|
|
+ if (ObjectUtil.isNotEmpty(bo.getIds())) {
|
|
|
+ lqw.in("b.id", bo.getIds().split(","));
|
|
|
}
|
|
|
- lqw.ge(ObjectUtil.isNotEmpty(pageQuery.getFirstSeenId()) && pageQuery.getWay() == 0,"b.id", pageQuery.getFirstSeenId());
|
|
|
- lqw.gt(ObjectUtil.isNotEmpty(pageQuery.getLastSeenId()) && pageQuery.getWay() == 1,"b.id", pageQuery.getLastSeenId());
|
|
|
- lqw.eq(ObjectUtil.isNotEmpty(bo.getBottomCategoryId()),"b.bottom_category_id", bo.getBottomCategoryId());
|
|
|
+ lqw.ge(ObjectUtil.isNotEmpty(pageQuery.getFirstSeenId()) && pageQuery.getWay() == 0, "b.id", pageQuery.getFirstSeenId());
|
|
|
+ lqw.gt(ObjectUtil.isNotEmpty(pageQuery.getLastSeenId()) && pageQuery.getWay() == 1, "b.id", pageQuery.getLastSeenId());
|
|
|
+ lqw.eq(ObjectUtil.isNotEmpty(bo.getBottomCategoryId()), "b.bottom_category_id", bo.getBottomCategoryId());
|
|
|
lqw.eq(ObjectUtil.isNotEmpty(bo.getProductStatus()), "b.product_status", bo.getProductStatus());
|
|
|
- lqw.eq(ObjectUtil.isNotEmpty(bo.getProductReviewStatus()),"b.product_review_status", bo.getProductReviewStatus());
|
|
|
- lqw.eq(ObjectUtil.isNotEmpty(bo.getDataSource()),"b.data_source", bo.getDataSource());
|
|
|
- lqw.eq(ObjectUtil.isNotEmpty(bo.getIsSelf()),"b.is_self", bo.getIsSelf());
|
|
|
- lqw.eq(ObjectUtil.isNotEmpty(bo.getProductNo()),"b.product_no", bo.getProductNo());
|
|
|
- lqw.like(ObjectUtil.isNotEmpty(bo.getBrandName()),"br.brand_name", bo.getBrandName());
|
|
|
+ lqw.eq(ObjectUtil.isNotEmpty(bo.getProductReviewStatus()), "b.product_review_status", bo.getProductReviewStatus());
|
|
|
+ lqw.eq(ObjectUtil.isNotEmpty(bo.getDataSource()), "b.data_source", bo.getDataSource());
|
|
|
+ lqw.eq(ObjectUtil.isNotEmpty(bo.getIsSelf()), "b.is_self", bo.getIsSelf());
|
|
|
+ lqw.eq(ObjectUtil.isNotEmpty(bo.getProductNo()), "b.product_no", bo.getProductNo());
|
|
|
+ lqw.like(ObjectUtil.isNotEmpty(bo.getBrandName()), "br.brand_name", bo.getBrandName());
|
|
|
// 支持分类名称模糊搜索(匹配三级分类中的任意一个)
|
|
|
if (ObjectUtil.isNotEmpty(bo.getCategoryName())) {
|
|
|
lqw.and(wrapper -> wrapper
|
|
|
@@ -367,7 +368,7 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
}
|
|
|
lqw.orderByAsc("b.id");
|
|
|
int limit = pageQuery.getPageSize() + 1;
|
|
|
- lqw.last("limit "+ limit );
|
|
|
+ lqw.last("limit " + limit);
|
|
|
List<ProductBaseVo> result = baseMapper.selectAllList(lqw);
|
|
|
// result.forEach(vo -> {
|
|
|
//
|
|
|
@@ -377,7 +378,7 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
result.remove(result.size() - 1);
|
|
|
}
|
|
|
TableDataInfo<ProductBaseVo> tableDataInfo = TableDataInfo.build(result);
|
|
|
- tableDataInfo.setTotal( size);
|
|
|
+ tableDataInfo.setTotal(size);
|
|
|
return tableDataInfo;
|
|
|
}
|
|
|
|
|
|
@@ -392,6 +393,7 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
LambdaQueryWrapper<ProductBase> lqw = buildQueryWrapper(bo);
|
|
|
return baseMapper.selectVoList(lqw);
|
|
|
}
|
|
|
+
|
|
|
private LambdaEsQueryWrapper<ProductBaseVo> buildEsQueryWrapper(ProductBaseBo bo) {
|
|
|
return new LambdaEsQueryWrapper<ProductBaseVo>()
|
|
|
.eq(ObjectUtil.isNotEmpty(bo.getProductNo()), ProductBaseVo::getProductNo, bo.getProductNo())
|
|
|
@@ -486,7 +488,7 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
}
|
|
|
|
|
|
private void saveProductDetail(ProductBaseBo bo, Long productId) {
|
|
|
- ProductPhotos productPhotos= new ProductPhotos();
|
|
|
+ ProductPhotos productPhotos = new ProductPhotos();
|
|
|
productPhotos.setProductId(productId);
|
|
|
productPhotos.setProductDetailsPc(bo.getPcDetail());
|
|
|
productPhotos.setProductDetailsApp(bo.getMobileDetail());
|
|
|
@@ -547,7 +549,7 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
}
|
|
|
|
|
|
private void updateProductDetail(ProductBaseBo bo, Long productId) {
|
|
|
- ProductPhotos productPhotos= new ProductPhotos();
|
|
|
+ ProductPhotos productPhotos = new ProductPhotos();
|
|
|
productPhotos.setProductId(productId);
|
|
|
productPhotos.setProductDetailsPc(bo.getPcDetail());
|
|
|
productPhotos.setProductDetailsApp(bo.getMobileDetail());
|
|
|
@@ -735,7 +737,7 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
/**
|
|
|
* 保存前的数据校验
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(ProductBase entity){
|
|
|
+ private void validEntityBeforeSave(ProductBase entity) {
|
|
|
// 校验产品编号唯一性(新增时)
|
|
|
if (entity.getId() == null && ObjectUtil.isNotEmpty(entity.getProductNo())) {
|
|
|
LambdaQueryWrapper<ProductBase> wrapper = Wrappers.lambdaQuery();
|
|
|
@@ -785,7 +787,7 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
+ if (isValid) {
|
|
|
// 校验是否有关联的订单或其他业务数据
|
|
|
// 性能优化:批量查询替代循环查询
|
|
|
List<ProductBase> products = baseMapper.selectBatchIds(ids);
|
|
|
@@ -992,9 +994,9 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
public ProductBaseVo updateProductShelfState(Long productId) {
|
|
|
ProductBaseVo productBase = baseMapper.selectVoById(productId);
|
|
|
|
|
|
- if(productBase.getProductStatus().equals(1)){
|
|
|
+ if (productBase.getProductStatus().equals(1)) {
|
|
|
productBase.setProductStatus(0);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
productBase.setProductStatus(1);
|
|
|
}
|
|
|
baseMapper.update(Wrappers.lambdaUpdate(ProductBase.class)
|
|
|
@@ -1065,8 +1067,8 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 商品审核
|
|
|
- * */
|
|
|
+ * 商品审核
|
|
|
+ */
|
|
|
@Override
|
|
|
public void review(ProductBaseBo bo) {
|
|
|
baseMapper.update(Wrappers.lambdaUpdate(ProductBase.class)
|
|
|
@@ -1103,7 +1105,7 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
*/
|
|
|
@Override
|
|
|
public void changeProductType(ProductBaseBo bo) {
|
|
|
- if( ObjectUtil.isEmpty(bo.getProductCategory())){
|
|
|
+ if (ObjectUtil.isEmpty(bo.getProductCategory())) {
|
|
|
return;
|
|
|
}
|
|
|
baseMapper.update(Wrappers.lambdaUpdate(ProductBase.class)
|
|
|
@@ -1203,16 +1205,16 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
@Override
|
|
|
public TableDataInfo<PcProductVo> getPcProductPage(PcProductBo bo, PageQuery pageQuery) {
|
|
|
QueryWrapper<ProductBase> lqw = Wrappers.query(ProductBase.class);
|
|
|
- lqw.ge(ObjectUtil.isNotEmpty(pageQuery.getFirstSeenId()) && pageQuery.getWay() == 0,"b.id", pageQuery.getFirstSeenId());
|
|
|
- lqw.gt(ObjectUtil.isNotEmpty(pageQuery.getLastSeenId()) && pageQuery.getWay() == 1,"b.id", pageQuery.getLastSeenId());
|
|
|
+ lqw.ge(ObjectUtil.isNotEmpty(pageQuery.getFirstSeenId()) && pageQuery.getWay() == 0, "b.id", pageQuery.getFirstSeenId());
|
|
|
+ lqw.gt(ObjectUtil.isNotEmpty(pageQuery.getLastSeenId()) && pageQuery.getWay() == 1, "b.id", pageQuery.getLastSeenId());
|
|
|
lqw.eq("b.product_status", 1);
|
|
|
lqw.and(ObjectUtil.isNotEmpty(bo.getSearchKeyword())
|
|
|
, (queryWrapper) -> queryWrapper.and(qw ->
|
|
|
qw.like("b.item_name", bo.getSearchKeyword())
|
|
|
- .or().like("tc.category_name", bo.getSearchKeyword())
|
|
|
- .or().like("mc.category_name", bo.getSearchKeyword())
|
|
|
- .or().like("bc.category_name", bo.getSearchKeyword())
|
|
|
- .or().like("br.brand_name", bo.getSearchKeyword())
|
|
|
+ .or().like("tc.category_name", bo.getSearchKeyword())
|
|
|
+ .or().like("mc.category_name", bo.getSearchKeyword())
|
|
|
+ .or().like("bc.category_name", bo.getSearchKeyword())
|
|
|
+ .or().like("br.brand_name", bo.getSearchKeyword())
|
|
|
)
|
|
|
);
|
|
|
lqw.eq(ObjectUtil.isNotEmpty(bo.getBrandId()), "b.brand_id", bo.getBrandId());
|
|
|
@@ -1220,7 +1222,7 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
lqw.eq(ObjectUtil.isNotEmpty(bo.getMiddleCategoryId()), "b.middle_category_id", bo.getMiddleCategoryId());
|
|
|
lqw.eq(ObjectUtil.isNotEmpty(bo.getBottomCategoryId()), "b.bottom_category_id", bo.getBottomCategoryId());
|
|
|
lqw.eq(ObjectUtil.isNotEmpty(bo.getIsCustomize()), "e.is_customize", bo.getIsCustomize());
|
|
|
- if(bo.getPriceRange() != null){
|
|
|
+ if (bo.getPriceRange() != null) {
|
|
|
//价格区间 1:1-100 2:100-500 3:500-1000 4:1000以上
|
|
|
switch (bo.getPriceRange()) {
|
|
|
case "1":
|
|
|
@@ -1233,23 +1235,23 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
lqw.ge("b.market_price", 1000);
|
|
|
}
|
|
|
}
|
|
|
- if(bo.getSortField() != null && bo.getSortOrder() != null){
|
|
|
+ if (bo.getSortField() != null && bo.getSortOrder() != null) {
|
|
|
String[] sortFields = bo.getSortField().split(",");
|
|
|
String[] sortOrders = bo.getSortOrder().split(",");
|
|
|
for (int i = 0; i < sortFields.length; i++) {
|
|
|
switch (sortFields[i]) {
|
|
|
case "1":
|
|
|
- lqw.orderBy( true, sortOrders[i].equals("Asc"),"b.id");
|
|
|
+ lqw.orderBy(true, sortOrders[i].equals("Asc"), "b.id");
|
|
|
case "2":
|
|
|
- lqw.orderBy( true, sortOrders[i].equals("Asc"),"p.total_inventory");
|
|
|
+ lqw.orderBy(true, sortOrders[i].equals("Asc"), "p.total_inventory");
|
|
|
case "3":
|
|
|
- lqw.orderBy( true, sortOrders[i].equals("Asc"),"p.market_price");
|
|
|
+ lqw.orderBy(true, sortOrders[i].equals("Asc"), "p.market_price");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- lqw.select("b.id","b.product_image","p.market_price","p.member_price","p.min_selling_price","p.min_order_quantity","b.item_name","u.unit_name");
|
|
|
+ lqw.select("b.id", "b.product_image", "p.market_price", "p.member_price", "p.min_selling_price", "p.min_order_quantity", "b.item_name", "u.unit_name");
|
|
|
int limit = pageQuery.getPageSize() + 1;
|
|
|
- lqw.last("limit "+ limit );
|
|
|
+ lqw.last("limit " + limit);
|
|
|
List<ProductBaseVo> productBaseVos = baseMapper.selectAllList(lqw);
|
|
|
if (CollUtil.isNotEmpty(productBaseVos)) {
|
|
|
List<PcProductVo> pcProductVos = BeanUtil.copyToList(productBaseVos, PcProductVo.class);
|
|
|
@@ -1281,7 +1283,7 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
lqw.in("b.id", productIds);
|
|
|
lqw.eq("b.product_status", 1);
|
|
|
int limit = pageQuery.getPageSize() + 1;
|
|
|
- lqw.last("limit "+ limit );
|
|
|
+ lqw.last("limit " + limit);
|
|
|
List<ProductBaseVo> productBaseVos = baseMapper.selectAllList(lqw);
|
|
|
if (CollUtil.isNotEmpty(productBaseVos)) {
|
|
|
List<PcProductVo> pcProductVos = BeanUtil.copyToList(productBaseVos, PcProductVo.class);
|
|
|
@@ -1318,7 +1320,7 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
lqw.in("b.id", productIds);
|
|
|
lqw.eq("b.product_status", 1);
|
|
|
int limit = pageQuery.getPageSize() + 1;
|
|
|
- lqw.last("limit "+ limit );
|
|
|
+ lqw.last("limit " + limit);
|
|
|
List<ProductBaseVo> productBaseVos = baseMapper.selectAllList(lqw);
|
|
|
if (CollUtil.isNotEmpty(productBaseVos)) {
|
|
|
List<PcProductVo> pcProductVos = BeanUtil.copyToList(productBaseVos, PcProductVo.class);
|
|
|
@@ -1330,7 +1332,7 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
pcProductVos.remove(pcProductVos.size() - 1);
|
|
|
}
|
|
|
TableDataInfo<PcProductVo> tableDataInfo = TableDataInfo.build(pcProductVos);
|
|
|
- tableDataInfo.setTotal( size);
|
|
|
+ tableDataInfo.setTotal(size);
|
|
|
return tableDataInfo;
|
|
|
}
|
|
|
}
|
|
|
@@ -1346,16 +1348,16 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
public TableDataInfo<PcProductVo> getCategoryRecommendProductPage(Long categoryId, PageQuery pageQuery) {
|
|
|
//获取推荐的商品id
|
|
|
List<ProductCategoryRecommendedLinkVo> productCategoryRecommendedLinkVos = productCategoryRecommendedLinkMapper.selectVoList(
|
|
|
- Wrappers.lambdaQuery(ProductCategoryRecommendedLink.class)
|
|
|
- .eq(ProductCategoryRecommendedLink::getCategoryId, categoryId)
|
|
|
- );
|
|
|
+ Wrappers.lambdaQuery(ProductCategoryRecommendedLink.class)
|
|
|
+ .eq(ProductCategoryRecommendedLink::getCategoryId, categoryId)
|
|
|
+ );
|
|
|
if (CollUtil.isNotEmpty(productCategoryRecommendedLinkVos)) {
|
|
|
List<Long> productIds = productCategoryRecommendedLinkVos.stream().map(ProductCategoryRecommendedLinkVo::getProductId).toList();
|
|
|
QueryWrapper<ProductBase> lqw = Wrappers.query(ProductBase.class);
|
|
|
lqw.in("b.id", productIds);
|
|
|
lqw.eq("b.product_status", 1);
|
|
|
int limit = pageQuery.getPageSize() + 1;
|
|
|
- lqw.last("limit "+ limit );
|
|
|
+ lqw.last("limit " + limit);
|
|
|
List<ProductBaseVo> productBaseVos = baseMapper.selectAllList(lqw);
|
|
|
if (CollUtil.isNotEmpty(productBaseVos)) {
|
|
|
List<PcProductVo> pcProductVos = BeanUtil.copyToList(productBaseVos, PcProductVo.class);
|
|
|
@@ -1372,12 +1374,12 @@ public class ProductBaseServiceImpl extends ServiceImpl<ProductBaseMapper, Produ
|
|
|
* @param pageQuery
|
|
|
*/
|
|
|
@Override
|
|
|
- public TableDataInfo<PcProductVo> getProductShoppingCartPage(String id,Long userId, PageQuery pageQuery) {
|
|
|
+ public TableDataInfo<PcProductVo> getProductShoppingCartPage(String id, Long userId, PageQuery pageQuery) {
|
|
|
LambdaQueryWrapper<ProductShoppingCart> lqw = Wrappers.lambdaQuery(ProductShoppingCart.class);
|
|
|
lqw.eq(ProductShoppingCart::getUserId, userId);
|
|
|
- if (ObjectUtil.isNotEmpty(id)) {
|
|
|
- lqw.eq(ProductShoppingCart::getId, id.split(","));
|
|
|
- }
|
|
|
+ if (ObjectUtil.isNotEmpty(id)) {
|
|
|
+ lqw.in(ProductShoppingCart::getId, id.split(","));
|
|
|
+ }
|
|
|
Page<ProductShoppingCart> productShoppingCartPage = productShoppingCartMapper.selectPage(pageQuery.build(), lqw);
|
|
|
if (CollUtil.isNotEmpty(productShoppingCartPage.getRecords())) {
|
|
|
List<PcProductVo> productVos = new ArrayList<>();
|