use of com.whoiszxl.entity.PurchaseOrderItem in project shopzz by whoiszxl.
the class PurchaseOrderServiceImpl method savePurchaseOrder.
@Transactional
@Override
public boolean savePurchaseOrder(PurchaseOrderVO purchaseOrderVO) {
// 1. 新增采购订单
purchaseOrderVO.setPurchaseOrderStatus(PurchaseOrderStatusEnum.EDITING.getCode());
PurchaseOrder purchaseOrder = purchaseOrderVO.clone(PurchaseOrder.class);
boolean orderFlag = this.save(purchaseOrder);
// 2. 新增采购订单中的商品详情
List<PurchaseOrderItemVO> items = purchaseOrderVO.getItems();
for (PurchaseOrderItemVO item : items) {
item.setPurchaseOrderId(purchaseOrder.getId());
}
List<PurchaseOrderItem> purchaseOrderItems = BeanCopierUtils.copyListProperties(items, PurchaseOrderItem::new);
boolean itemFlag = purchaseOrderItemService.saveBatch(purchaseOrderItems);
return orderFlag && itemFlag;
}
use of com.whoiszxl.entity.PurchaseOrderItem 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);
}
use of com.whoiszxl.entity.PurchaseOrderItem in project shopzz by whoiszxl.
the class PurchaseOrderController method batchOnShelves.
@PutMapping("/shelves/on")
@ApiOperation(value = "批量新增采购入库单的上架条目", notes = "批量新增采购入库单的上架条目", response = ResponseResult.class)
public ResponseResult<Boolean> batchOnShelves(@RequestBody List<PurchaseInboundOnItemVO> putOnItems) {
// 采购入库单状态判断
for (PurchaseInboundOnItemVO putOnItem : putOnItems) {
Long purchaseOrderItemId = putOnItem.getPurchaseOrderItemId();
PurchaseOrderItem purchaseOrderItem = purchaseOrderItemService.getById(purchaseOrderItemId);
if (purchaseOrderItem == null) {
return ResponseResult.buildError("采购单条目不存在");
}
ProductAllocation productAllocation = productAllocationService.getById(putOnItem.getProductAllocationId());
if (productAllocation == null) {
return ResponseResult.buildError("采购单条目上架的货位不存在");
}
if (putOnItem.getPutOnShelvesCount() > purchaseOrderItem.getPurchaseQuantity()) {
return ResponseResult.buildError(putOnItem.getProductSkuId() + "上架条目数量大于采购数量");
}
}
List<PurchaseInboundOnItem> items = BeanCopierUtils.copyListProperties(putOnItems, PurchaseInboundOnItem::new);
boolean saveFlag = purchaseInboundOnItemService.saveBatch(items);
return ResponseResult.buildByFlag(saveFlag);
}
use of com.whoiszxl.entity.PurchaseOrderItem in project shopzz by whoiszxl.
the class PurchaseOrderServiceImpl method updatePurchaseOrder.
@Transactional
@Override
public Boolean updatePurchaseOrder(PurchaseOrderVO purchaseOrderVO) {
// 1. 更新采购订单
purchaseOrderVO.setPurchaseOrderStatus(PurchaseOrderStatusEnum.EDITING.getCode());
PurchaseOrder purchaseOrder = purchaseOrderVO.clone(PurchaseOrder.class);
boolean orderFlag = this.updateById(purchaseOrder);
// 2. 删除原来的订单商品详情
boolean removeFlag = purchaseOrderItemService.remove(new UpdateWrapper<PurchaseOrderItem>().eq("purchase_order_id", purchaseOrderVO.getId()));
// 2. 新增订单商品详情
List<PurchaseOrderItemVO> items = purchaseOrderVO.getItems();
items.forEach(item -> item.setPurchaseOrderId(purchaseOrder.getId()));
List<PurchaseOrderItem> purchaseOrderItems = BeanCopierUtils.copyListProperties(items, PurchaseOrderItem::new);
boolean itemFlag = purchaseOrderItemService.saveBatch(purchaseOrderItems);
if (!orderFlag || !removeFlag || !itemFlag) {
ExceptionCatcher.catchDatabaseFailEx();
}
return true;
}
use of com.whoiszxl.entity.PurchaseOrderItem in project shopzz by whoiszxl.
the class PurchaseOrderController method receive.
@PutMapping("/receive")
@ApiOperation(value = "接收采购商发送过来的货物", notes = "更新合格商品数与到货的商品数", response = ResponseResult.class)
public ResponseResult<Boolean> receive(@RequestBody ReceiveProductCommand receiveProductCommand) {
// 采购单状态判断
Long purchaseOrderId = null;
for (ReceiveProductCommand.ReceiveItem receiveItem : receiveProductCommand.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 = dozerUtils.mapList(receiveProductCommand.getReceiveItems(), PurchaseOrderItem.class);
boolean saveFlag = purchaseOrderItemService.updateBatchById(purchaseOrderItems);
// 更新采购入库单的到货时间
PurchaseOrder purchaseOrder = new PurchaseOrder();
purchaseOrder.setId(purchaseOrderId);
purchaseOrder.setArrivalTime(receiveProductCommand.getArrivalTime());
boolean updateFlag = purchaseOrderService.updateById(purchaseOrder);
return ResponseResult.buildByFlag(saveFlag && updateFlag);
}
Aggregations