|
@@ -18,6 +18,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -76,7 +77,21 @@ public class PmsPortalProductServiceImpl implements PmsPortalProductService {
|
|
|
} else if (sort == 4) {
|
|
|
example.setOrderByClause("price desc");
|
|
|
}
|
|
|
- return productMapper.selectByExample(example);
|
|
|
+ List<PmsProduct> pmsProducts = productMapper.selectByExample(example);
|
|
|
+ List<Long> productIdList = pmsProducts.stream().map(PmsProduct::getId).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(productIdList)) {
|
|
|
+ return pmsProducts;
|
|
|
+ }
|
|
|
+ PmsSkuStockExample skuExample = new PmsSkuStockExample();
|
|
|
+ skuExample.createCriteria().andProductIdIn(productIdList);
|
|
|
+ List<PmsSkuStock> skuStockList = skuStockMapper.selectByExample(skuExample);
|
|
|
+ Map<Long, List<PmsSkuStock>> collect = skuStockList.stream()
|
|
|
+ .collect(Collectors.groupingBy(PmsSkuStock::getProductId));
|
|
|
+ for (PmsProduct pmsProduct : pmsProducts) {
|
|
|
+ pmsProduct.setSkuStockList(collect.get(pmsProduct.getId()));
|
|
|
+ }
|
|
|
+ return pmsProducts;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|