use of com.whoiszxl.entity.ProductStock in project shopzz by whoiszxl.
the class AbstractStockUpdaterFactory method createProductStocks.
/**
* 创建商品库存DO对象集合
* @param productSkuIds 商品sku id集合
* @return 商品库存DO对象集合
*/
private List<ProductStock> createProductStocks(List<Long> productSkuIds) {
List<ProductStock> productStocks = new ArrayList<>(productSkuIds.size());
for (Long skuId : productSkuIds) {
ProductStock productStock = productStockService.getProductStockBySkuId(skuId);
if (productStock == null) {
productStock = createProductStock(skuId);
productStockService.save(productStock);
}
productStocks.add(productStock);
}
return productStocks;
}
use of com.whoiszxl.entity.ProductStock in project shopzz by whoiszxl.
the class AbstractStockUpdaterFactory method createProductStock.
/**
* 创建商品库存对象
* @param productSkuId 商品sku id
* @return 商品库存对象
*/
private ProductStock createProductStock(Long productSkuId) {
ProductStock productStock = new ProductStock();
productStock.setProductSkuId(productSkuId);
productStock.setSaleStockQuantity(0);
productStock.setLockedStockQuantity(0);
productStock.setSaledStockQuantity(0);
productStock.setStockStatus(StockStatus.NOT_IN_STOCK);
return productStock;
}
use of com.whoiszxl.entity.ProductStock in project shopzz by whoiszxl.
the class PurchaseInboundStockUpdater method updateStock.
@Override
protected boolean updateStock() {
// 采购入库,只要新增销售库存就OK
for (PurchaseOrderItemDTO purchaseOrderItemDTO : itemDTOMap.values()) {
// 查询当前sku在库存中心是否存在,不存在则创建
ProductStock productStock = productStockService.getProductStockBySkuId(purchaseOrderItemDTO.getProductSkuId());
if (productStock == null) {
productStock = new ProductStock();
productStock.setProductSkuId(purchaseOrderItemDTO.getProductSkuId());
productStock.setSaleStockQuantity(purchaseOrderItemDTO.getPurchaseQuantity());
productStock.setLockedStockQuantity(0);
productStock.setSaledStockQuantity(0);
productStock.setStockStatus(StockStatus.IN_STOCK);
productStockService.save(productStock);
} else {
productStockService.addSaleStock(purchaseOrderItemDTO.getPurchaseQuantity(), purchaseOrderItemDTO.getProductSkuId());
}
}
return true;
}
Aggregations