| | |
| | | return AjaxResult.success(listPage); |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | @ApiOperation("发货审批,更新发货审批状态") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult update(@RequestBody ShipmentApproval req) { |
| | | |
| | | // 查询发货审批 |
| | | ShipmentApproval shipmentApproval = shipmentApprovalMapper.selectById(req.getId()); |
| | | if (shipmentApproval == null) { |
| | | return AjaxResult.error("发货审批不存在"); |
| | | } |
| | | |
| | | // 更新发货审批状态 |
| | | shipmentApproval.setApproveStatus(req.getApproveStatus()); |
| | | boolean update = shipmentApprovalService.updateById(shipmentApproval); |
| | | if (!update) { |
| | | // 事务回滚 |
| | | throw new ServiceException("发货审批更新失败"); |
| | | } |
| | | // 查询关联的销售台账产品 |
| | | SalesLedgerProduct salesLedgerProduct = salesLedgerProductService.getById(shipmentApproval.getSalesLedgerProductId()); |
| | | if (salesLedgerProduct == null) { |
| | | // 抛异常事务回滚 |
| | | throw new ServiceException("销售台账不存在,审批回滚"); |
| | | } |
| | | |
| | | // 同步更新销售台账产品的审批状态 |
| | | salesLedgerProduct.setApproveStatus(req.getApproveStatus()); |
| | | salesLedgerProductService.updateById(salesLedgerProduct); |
| | | |
| | | // 审批通过 |
| | | if (req.getApproveStatus() == 3) { |
| | | // // 查询采购入库记录 |
| | | // LambdaQueryWrapper<ProcurementRecordStorage> lambdaQueryWrapper = new LambdaQueryWrapper<ProcurementRecordStorage>() |
| | | // .eq(ProcurementRecordStorage::getSalesLedgerProductId, req.getSalesLedgerProductId()); |
| | | // ProcurementRecordStorage procurementRecordStorage = procurementRecordStorageService.getOne(lambdaQueryWrapper); |
| | | // |
| | | // if (procurementRecordStorage == null) { |
| | | // // 保证前面的修改全部回滚 |
| | | // throw new ServiceException("采购记录不存在,审批回滚"); |
| | | // } |
| | | |
| | | |
| | | //出库 |
| | | stockUtils.addStock(salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), req.getId()); |
| | | } |
| | | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 导出发货信息管理 |
| | | */ |