use of com.whoiszxl.entity.PurchaseOrder 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.PurchaseOrder in project shopzz by whoiszxl.
the class PurchaseOrderServiceImpl method updateFinishedBySupplierId.
@Override
public boolean updateFinishedBySupplierId(Long id) {
UpdateWrapper<PurchaseOrder> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("supplier_id", id);
PurchaseOrder purchaseOrder = new PurchaseOrder();
purchaseOrder.setSupplierId(id);
purchaseOrder.setPurchaseOrderStatus(PurchaseOrderStatusConstants.FINISHED);
return this.update(purchaseOrder, updateWrapper);
}
use of com.whoiszxl.entity.PurchaseOrder in project shopzz by whoiszxl.
the class PurchaseOrderController method submitPurOrderToApprove.
@SaCheckLogin
@PutMapping("/submit/approve/{id}")
@ApiOperation(value = "提交采购单去审核", notes = "提交采购单去审核", response = ResponseResult.class)
public ResponseResult<Boolean> submitPurOrderToApprove(@PathVariable Long id) {
// 1. 进行参数校验
PurchaseOrder purchaseOrder = purchaseOrderService.getById(id);
if (purchaseOrder == null || !purchaseOrder.getPurchaseOrderStatus().equals(PurchaseOrderStatusConstants.EDITING)) {
return ResponseResult.buildError("采购单不存在或者状态不为编辑中");
}
boolean updateFlag = purchaseOrderService.updateStatus(id, PurchaseOrderStatusEnum.WAIT_FOR_APPROVE.getCode());
return ResponseResult.buildByFlag(updateFlag);
}
use of com.whoiszxl.entity.PurchaseOrder in project shopzz by whoiszxl.
the class PurchaseOrderController method inboundApprove.
@Transactional
@PutMapping("/inbound/approve/{id}/{status}")
@ApiOperation(value = "审核采购单入库", notes = "审核采购单单入库", response = ResponseResult.class)
public ResponseResult inboundApprove(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
// 0. 审核入库单状态判断
PurchaseOrder purchaseOrder = purchaseOrderService.getById(id);
if (purchaseOrder == null || !purchaseOrder.getPurchaseOrderStatus().equals(PurchaseOrderStatusConstants.WAIT_FOR_APPROVE_BY_INBOUND)) {
return ResponseResult.buildError("采购单不存在或状态不为待审核入库");
}
// 1. 如果是拒绝,则更新为待入库状态
if (PurchaseInboundOrderApproveResultConstants.REJECTED.equals(status)) {
purchaseOrderService.updateStatus(id, PurchaseOrderStatusConstants.WAIT_FOR_INBOUND);
} else {
// 2. 如果是通过,则需要调用责任链来更新处理一系列信息
PurchaseOrderResponse purchaseOrderResponse = purchaseOrderService.getPurchaseOrderById(id);
if (!purchaseOrderResponse.getPurchaseOrderStatus().equals(PurchaseOrderStatusConstants.WAIT_FOR_APPROVE_BY_INBOUND)) {
return ResponseResult.buildError("采购入库单状态不为待审核入库");
}
PurchaseOrderHandler handlerChain = purchaseOrderHandlerFactory.getHandlerChain();
handlerChain.execute(purchaseOrderResponse);
}
return ResponseResult.buildSuccess();
}
use of com.whoiszxl.entity.PurchaseOrder 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