use of com.whoiszxl.cqrs.vo.PurchaseOrderItemVO in project shopzz by whoiszxl.
the class PurchaseInboundWmsStockUpdater method updateProductStock.
/**
* 更新商品库存
*/
@Override
protected void updateProductStock() {
// 1. 拿到采购入库单条目并进行遍历
List<PurchaseOrderItemVO> items = purchaseOrderResponse.getItems();
for (PurchaseOrderItemVO item : items) {
// 2. 从数据库中通过sku_id拿到当前的条目库存
WarehouseSkuStock warehouseProductStock = warehouseSkuStockService.getOrSaveBySkuId(item.getSkuId());
// 3. 更新可用库存数量
warehouseProductStock.setAvailableStockQuantity(warehouseProductStock.getAvailableStockQuantity() + item.getArrivalCount());
warehouseSkuStockService.updateById(warehouseProductStock);
}
}
use of com.whoiszxl.cqrs.vo.PurchaseOrderItemVO in project shopzz by whoiszxl.
the class PurchaseOrderServiceImpl method updatePurchaseOrder.
@Override
@Transactional
public void updatePurchaseOrder(PurchaseOrderSaveCommand purchaseOrderSaveCommand) {
// 1. 更新采购订单
PurchaseOrder purchaseOrder = dozerUtils.map(purchaseOrderSaveCommand, PurchaseOrder.class);
purchaseOrder.setPurchaseOrderStatus(PurchaseOrderStatusEnum.EDITING.getCode());
this.updateById(purchaseOrder);
// 2. 删除原来的订单商品详情
purchaseOrderItemService.remove(new UpdateWrapper<PurchaseOrderItem>().eq("purchase_order_id", purchaseOrder.getId()));
// 2. 新增订单商品详情
List<PurchaseOrderItemVO> items = purchaseOrderSaveCommand.getItems();
items.forEach(item -> item.setPurchaseOrderId(purchaseOrder.getId()));
List<PurchaseOrderItem> purchaseOrderItems = BeanCopierUtils.copyListProperties(items, PurchaseOrderItem::new);
purchaseOrderItemService.saveBatch(purchaseOrderItems);
}
use of com.whoiszxl.cqrs.vo.PurchaseOrderItemVO in project shopzz by whoiszxl.
the class PurchaseOrderServiceImpl method savePurchaseOrder.
@Override
public void savePurchaseOrder(PurchaseOrderSaveCommand purchaseOrderSaveCommand) {
PurchaseOrder purchaseOrder = dozerUtils.map(purchaseOrderSaveCommand, PurchaseOrder.class);
// 1. 新增采购订单
purchaseOrder.setPurchaseOrderStatus(PurchaseOrderStatusEnum.EDITING.getCode());
this.save(purchaseOrder);
// 2. 批量新增采购订单中的商品详情
List<PurchaseOrderItemVO> items = purchaseOrderSaveCommand.getItems();
for (PurchaseOrderItemVO item : items) {
item.setPurchaseOrderId(purchaseOrder.getId());
}
List<PurchaseOrderItem> purchaseOrderItems = dozerUtils.mapList(items, PurchaseOrderItem.class);
purchaseOrderItemService.saveBatch(purchaseOrderItems);
}
use of com.whoiszxl.cqrs.vo.PurchaseOrderItemVO in project shopzz by whoiszxl.
the class PurchaseOrderServiceImpl method getPurchaseOrderById.
@Override
public PurchaseOrderResponse getPurchaseOrderById(Long id) {
// 1. 查询采购订单
PurchaseOrder purchaseOrder = this.getById(id);
PurchaseOrderResponse purchaseOrderResponse = dozerUtils.map(purchaseOrder, PurchaseOrderResponse.class);
// 2. 查询采购订单中的商品详情,将详情添加到采购订单对象中去
List<PurchaseOrderItem> purchaseOrderItemList = purchaseOrderItemService.list(new LambdaQueryWrapper<PurchaseOrderItem>().eq(PurchaseOrderItem::getPurchaseOrderId, id));
List<PurchaseOrderItemVO> purchaseOrderItemVOList = dozerUtils.mapList(purchaseOrderItemList, PurchaseOrderItemVO.class);
purchaseOrderResponse.setItems(purchaseOrderItemVOList);
return purchaseOrderResponse;
}
Aggregations