|
|
@ -7,6 +7,7 @@ import cc.hiver.core.entity.User; |
|
|
import cc.hiver.mall.common.constant.PurchaseConstant; |
|
|
import cc.hiver.mall.common.constant.PurchaseConstant; |
|
|
import cc.hiver.mall.dao.mapper.ProductMapper; |
|
|
import cc.hiver.mall.dao.mapper.ProductMapper; |
|
|
import cc.hiver.mall.entity.Product; |
|
|
import cc.hiver.mall.entity.Product; |
|
|
|
|
|
import cc.hiver.mall.entity.Stock; |
|
|
import cc.hiver.mall.pojo.dto.SaleDetailDTO; |
|
|
import cc.hiver.mall.pojo.dto.SaleDetailDTO; |
|
|
import cc.hiver.mall.pojo.dto.SaleDetailQueryDTO; |
|
|
import cc.hiver.mall.pojo.dto.SaleDetailQueryDTO; |
|
|
import cc.hiver.mall.pojo.dto.SaleQueryDTO; |
|
|
import cc.hiver.mall.pojo.dto.SaleQueryDTO; |
|
|
@ -16,6 +17,7 @@ import cc.hiver.mall.productpicture.entity.ProductPicture; |
|
|
import cc.hiver.mall.productpicture.service.ProductPictureService; |
|
|
import cc.hiver.mall.productpicture.service.ProductPictureService; |
|
|
import cc.hiver.mall.service.mybatis.ProductCategoryService; |
|
|
import cc.hiver.mall.service.mybatis.ProductCategoryService; |
|
|
import cc.hiver.mall.service.mybatis.ProductService; |
|
|
import cc.hiver.mall.service.mybatis.ProductService; |
|
|
|
|
|
import cc.hiver.mall.service.mybatis.StockService; |
|
|
import cn.hutool.json.JSONObject; |
|
|
import cn.hutool.json.JSONObject; |
|
|
import cn.hutool.json.JSONUtil; |
|
|
import cn.hutool.json.JSONUtil; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
@ -44,6 +46,9 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ProductCategoryService productCategoryService; |
|
|
private ProductCategoryService productCategoryService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private StockService stockService; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public IPage<ProductPageVO> getShareList(ProductPageQuery productPageQuery) { |
|
|
public IPage<ProductPageVO> getShareList(ProductPageQuery productPageQuery) { |
|
|
final Page<ProductPageVO> page = new Page<>(productPageQuery.getPageNum(), productPageQuery.getPageSize()); |
|
|
final Page<ProductPageVO> page = new Page<>(productPageQuery.getPageNum(), productPageQuery.getPageSize()); |
|
|
@ -72,6 +77,21 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl |
|
|
productPageVO.setProductPictures(productPictureMap.get(productId)); |
|
|
productPageVO.setProductPictures(productPictureMap.get(productId)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
// 获取商品均色均码的库存数
|
|
|
|
|
|
List<Stock> stockList = stockService.getDefaultStockCount(productIdList); |
|
|
|
|
|
// 处理为map, key为productId
|
|
|
|
|
|
final Map<String, Stock> stockMap = new HashMap<>(); |
|
|
|
|
|
for (Stock stock : stockList) { |
|
|
|
|
|
stockMap.put(stock.getProductId(), stock); |
|
|
|
|
|
} |
|
|
|
|
|
for (ProductPageVO productPageVO : list) { |
|
|
|
|
|
final String productId = productPageVO.getId(); |
|
|
|
|
|
if (stockMap.containsKey(productId)) { |
|
|
|
|
|
productPageVO.setDefaultStockCount(stockMap.get(productId).getStockCount()); |
|
|
|
|
|
}else{ |
|
|
|
|
|
productPageVO.setDefaultStockCount(0); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
page.setRecords(list); |
|
|
page.setRecords(list); |
|
|
return page; |
|
|
return page; |
|
|
|