Search in sources :

Example 1 with PurchaseOrderHandler

use of com.whoiszxl.factory.handler.PurchaseOrderHandler 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();
}
Also used : PurchaseOrderResponse(com.whoiszxl.cqrs.response.PurchaseOrderResponse) PurchaseOrderHandler(com.whoiszxl.factory.handler.PurchaseOrderHandler) PurchaseOrder(com.whoiszxl.entity.PurchaseOrder) ApiOperation(io.swagger.annotations.ApiOperation) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

PurchaseOrderResponse (com.whoiszxl.cqrs.response.PurchaseOrderResponse)1 PurchaseOrder (com.whoiszxl.entity.PurchaseOrder)1 PurchaseOrderHandler (com.whoiszxl.factory.handler.PurchaseOrderHandler)1 ApiOperation (io.swagger.annotations.ApiOperation)1 Transactional (org.springframework.transaction.annotation.Transactional)1