use of com.whoiszxl.entity.vo.ReceiveProductVO in project shopzz by whoiszxl.
the class PurchaseOrderController method receive.
@PutMapping("/receive")
@ApiOperation(value = "接收采购商发送过来的货物", notes = "更新合格商品数与到货的商品数", response = ResponseResult.class)
public ResponseResult<Boolean> receive(@RequestBody ReceiveProductVO receiveProducts) {
// 采购单状态判断
Long purchaseOrderId = null;
for (ReceiveProductVO.ReceiveItem receiveItem : receiveProducts.getReceiveItems()) {
Long itemId = receiveItem.getId();
PurchaseOrderItem purchaseOrderItem = purchaseOrderItemService.getById(itemId);
if (purchaseOrderItem == null) {
return ResponseResult.buildError("采购单条目不存在");
}
purchaseOrderId = purchaseOrderItem.getPurchaseOrderId();
PurchaseOrder purchaseOrder = purchaseOrderService.getById(purchaseOrderId);
if (purchaseOrder == null || !purchaseOrder.getPurchaseOrderStatus().equals(PurchaseOrderStatusConstants.WAIT_FOR_INBOUND)) {
return ResponseResult.buildError("采购单不为待入库状态");
}
}
// 更新采购入库单条目的合格数量和到货数量
List<PurchaseOrderItem> purchaseOrderItems = BeanCopierUtils.copyListProperties(receiveProducts.getReceiveItems(), PurchaseOrderItem::new);
boolean saveFlag = purchaseOrderItemService.updateBatchById(purchaseOrderItems);
// 更新采购入库单的到货时间
PurchaseOrder purchaseOrder = new PurchaseOrder();
purchaseOrder.setId(purchaseOrderId);
purchaseOrder.setArrivalTime(receiveProducts.getArrivalTime());
boolean updateFlag = purchaseOrderService.updateById(purchaseOrder);
return ResponseResult.buildByFlag(saveFlag && updateFlag);
}
Aggregations