Search in sources :

Example 1 with PurchaseOrderResponse

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();
}
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)

Example 2 with PurchaseOrderResponse

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);
}
Also used : PurchaseOrderResponse(com.whoiszxl.cqrs.response.PurchaseOrderResponse) SaCheckLogin(cn.dev33.satoken.annotation.SaCheckLogin) ApiOperation(io.swagger.annotations.ApiOperation) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with PurchaseOrderResponse

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;
}
Also used : PurchaseOrderItem(com.whoiszxl.entity.PurchaseOrderItem) PurchaseOrderItemVO(com.whoiszxl.cqrs.vo.PurchaseOrderItemVO) PurchaseOrderResponse(com.whoiszxl.cqrs.response.PurchaseOrderResponse) PurchaseOrder(com.whoiszxl.entity.PurchaseOrder) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Aggregations

PurchaseOrderResponse (com.whoiszxl.cqrs.response.PurchaseOrderResponse)3 PurchaseOrder (com.whoiszxl.entity.PurchaseOrder)2 ApiOperation (io.swagger.annotations.ApiOperation)2 Transactional (org.springframework.transaction.annotation.Transactional)2 SaCheckLogin (cn.dev33.satoken.annotation.SaCheckLogin)1 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 PurchaseOrderItemVO (com.whoiszxl.cqrs.vo.PurchaseOrderItemVO)1 PurchaseOrderItem (com.whoiszxl.entity.PurchaseOrderItem)1 PurchaseOrderHandler (com.whoiszxl.factory.handler.PurchaseOrderHandler)1