use of com.whoiszxl.cqrs.response.PurchaseOrderResponse 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.cqrs.response.PurchaseOrderResponse in project shopzz by whoiszxl.
the class PurchaseOrderController method approve.
@SaCheckLogin
@Transactional
@PutMapping("/approve/{id}/{status}")
@ApiOperation(value = "审核采购单", notes = "审核采购单", response = ResponseResult.class)
public ResponseResult<Boolean> approve(@PathVariable Long id, @PathVariable Integer status) {
// 校验参数是否正常
PurchaseOrderResponse purchaseOrderResponse = purchaseOrderService.getPurchaseOrderById(id);
if (purchaseOrderResponse == null || !purchaseOrderResponse.getPurchaseOrderStatus().equals(PurchaseOrderStatusConstants.WAIT_FOR_APPROVE)) {
return ResponseResult.buildError("采购单不存在或者状态不为待审核中");
}
boolean resultFlag = PurchaseOrderApproveEnum.PASSED.getCode().equals(status) ? purchaseOrderService.updateStatus(id, PurchaseOrderStatusEnum.APPROVED.getCode()) : purchaseOrderService.updateStatus(id, PurchaseOrderStatusEnum.EDITING.getCode());
// 更新采购单状态为待入库
if (PurchaseOrderApproveEnum.PASSED.getCode().equals(status)) {
purchaseOrderService.updateStatus(id, PurchaseOrderStatusConstants.WAIT_FOR_INBOUND);
}
return ResponseResult.buildByFlag(resultFlag);
}
use of com.whoiszxl.cqrs.response.PurchaseOrderResponse 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