商品模块代码提交
This commit is contained in:
parent
742d2df3fc
commit
90788acc58
|
|
@ -117,7 +117,21 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||||
@Override
|
@Override
|
||||||
public List<ProductDTO> getProductList(ProductDTO param) {
|
public List<ProductDTO> getProductList(ProductDTO param) {
|
||||||
QueryWrapper queryWrapper = buildFullQueryWrapper(param);
|
QueryWrapper queryWrapper = buildFullQueryWrapper(param);
|
||||||
return super.listAs(queryWrapper, ProductDTO.class);
|
List<ProductDTO> records = super.listAs(queryWrapper, ProductDTO.class);
|
||||||
|
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 records;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue