use of com.whoiszxl.dto.PurchaseInboundOnItemDTO in project shopzz by whoiszxl.
the class PurchaseInboundWmsStockUpdater method updateProductAllocationStock.
/**
* 更新商品货位库存
*/
@Override
protected void updateProductAllocationStock() {
// 1. 拿到采购入库单条目并进行遍历
for (PurchaseOrderItemDTO item : purchaseOrder.getItems()) {
// 2. 再从入库单条目中拿到上架条目
for (PurchaseInboundOnItemDTO onItemDTO : item.getOnItems()) {
// 3. 获取商品货位库存,如果货位不存在则新建一个
ProductAllocationStock productAllocationStock = productAllocationStockService.getOrSave(onItemDTO.getProductAllocationId(), onItemDTO.getProductSkuId());
// 4. 累加可用库存数量并更新
productAllocationStock.setAvailableStockQuantity(productAllocationStock.getAvailableStockQuantity() + onItemDTO.getPutOnShelvesCount());
productAllocationStockService.updateById(productAllocationStock);
}
}
}
Aggregations