商品模块代码提交
This commit is contained in:
@@ -29,9 +29,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.czg.product.entity.table.ProductTableDef.PRODUCT;
|
||||
import static com.czg.product.entity.table.ShopProdCategoryTableDef.SHOP_PROD_CATEGORY;
|
||||
@@ -95,7 +94,22 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
@Override
|
||||
public Page<ProductDTO> getProductPage(ProductDTO param) {
|
||||
QueryWrapper queryWrapper = buildFullQueryWrapper(param);
|
||||
return super.pageAs(PageUtil.buildPage(), queryWrapper, ProductDTO.class);
|
||||
Page<ProductDTO> page = super.pageAs(PageUtil.buildPage(), queryWrapper, ProductDTO.class);
|
||||
List<ProductDTO> records = page.getRecords();
|
||||
List<Long> prodIdList = records.stream().map(ProductDTO::getId).distinct().toList();
|
||||
List<ProdSkuDTO> skuList = prodSkuMapper.selectListByQueryAs(query().in(ProdSku::getProductId, prodIdList).eq(ProdSku::getIsDel, DeleteEnum.NORMAL.value()), ProdSkuDTO.class);
|
||||
Map<Long, List<ProdSkuDTO>> collect = skuList.stream().collect(Collectors.groupingBy(ProdSkuDTO::getProductId));
|
||||
for (ProductDTO record : records) {
|
||||
List<ProdSkuDTO> list = collect.getOrDefault(record.getId(), Collections.emptyList());
|
||||
Optional<BigDecimal> lowPriceIsPresent = list.stream().map(ProdSkuDTO::getSalePrice).min(BigDecimal::compareTo);
|
||||
lowPriceIsPresent.ifPresent(record::setLowPrice);
|
||||
|
||||
Optional<BigDecimal> lowMemberPriceIsPresent = list.stream().map(ProdSkuDTO::getMemberPrice).min(BigDecimal::compareTo);
|
||||
lowMemberPriceIsPresent.ifPresent(record::setLowMemberPrice);
|
||||
|
||||
record.setSkuList(list);
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user