Search in sources :

Example 1 with PurchaseOrder

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;
}
Also used : PurchaseOrderItem(com.whoiszxl.entity.PurchaseOrderItem) PurchaseOrderItemVO(com.whoiszxl.entity.vo.PurchaseOrderItemVO) PurchaseOrder(com.whoiszxl.entity.PurchaseOrder) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with PurchaseOrder

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);
}
Also used : UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) PurchaseOrder(com.whoiszxl.entity.PurchaseOrder)

Example 3 with PurchaseOrder

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);
}
Also used : PurchaseOrder(com.whoiszxl.entity.PurchaseOrder) SaCheckLogin(cn.dev33.satoken.annotation.SaCheckLogin) ApiOperation(io.swagger.annotations.ApiOperation)

Example 4 with PurchaseOrder

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

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);
}
Also used : PurchaseOrderItem(com.whoiszxl.entity.PurchaseOrderItem) ReceiveProductVO(com.whoiszxl.entity.vo.ReceiveProductVO) PurchaseOrder(com.whoiszxl.entity.PurchaseOrder) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

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