Showing
1 changed file
with
7 additions
and
2 deletions
@@ -67,14 +67,19 @@ public class ProductServiceImpl implements ProductService{ | @@ -67,14 +67,19 @@ public class ProductServiceImpl implements ProductService{ | ||
67 | productInfo.setLeastPrice(new BigDecimal(0)); | 67 | productInfo.setLeastPrice(new BigDecimal(0)); |
68 | setBrand(productInfo, product.getBrandId()); | 68 | setBrand(productInfo, product.getBrandId()); |
69 | setSeries(productInfo, product.getSeriesId()); | 69 | setSeries(productInfo, product.getSeriesId()); |
70 | + productInfo.setLeastPrice(null); | ||
71 | + | ||
70 | 72 | ||
71 | List<GoodsBO> goodsBOList = getGoodsList(product.getId()); | 73 | List<GoodsBO> goodsBOList = getGoodsList(product.getId()); |
72 | if (!CollectionUtils.isEmpty(goodsBOList) && goodsBOList.get(0) != null) { | 74 | if (!CollectionUtils.isEmpty(goodsBOList) && goodsBOList.get(0) != null) { |
73 | GoodsBO goodsBO = goodsBOList.get(0); | 75 | GoodsBO goodsBO = goodsBOList.get(0); |
74 | List<GoodsSize> goodsSizes = goodsBO.getSizeList(); | 76 | List<GoodsSize> goodsSizes = goodsBO.getSizeList(); |
75 | if (!CollectionUtils.isEmpty(goodsSizes)) { | 77 | if (!CollectionUtils.isEmpty(goodsSizes)) { |
76 | - BigDecimal leastPrice = goodsSizes.stream().map(GoodsSize::getLeastPrice).filter(Objects::nonNull).min((p1, p2) -> (p1.compareTo(p2))).get(); | ||
77 | - productInfo.setLeastPrice(leastPrice); | 78 | + List<BigDecimal> leastPriceList = goodsSizes.stream().map(GoodsSize::getLeastPrice).filter(Objects::nonNull).collect(Collectors.toList()); |
79 | + if (!CollectionUtils.isEmpty(leastPriceList)) { | ||
80 | + BigDecimal leastPrice = leastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get(); | ||
81 | + productInfo.setLeastPrice(leastPrice); | ||
82 | + } | ||
78 | goodsSizes.sort(Comparator.comparing(GoodsSize::getOrderBy)); | 83 | goodsSizes.sort(Comparator.comparing(GoodsSize::getOrderBy)); |
79 | } | 84 | } |
80 | } | 85 | } |
-
Please register or login to post a comment