| | |
| | | import cn.iocoder.yudao.module.mes.api.mps.MesProMpsApi; |
| | | import cn.iocoder.yudao.module.mes.api.mps.dto.MesProMpsCreateReqDTO; |
| | | import cn.iocoder.yudao.module.mes.api.mps.dto.MesProMpsRespDTO; |
| | | import cn.iocoder.yudao.module.mes.api.salesnotice.MesWmSalesNoticeApi; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import com.mzt.logapi.starter.annotation.LogRecord; |
| | |
| | | private MdmItemApi mdmItemApi; |
| | | @Resource |
| | | private MesProMpsApi mpsApi; |
| | | @Resource |
| | | private MesWmSalesNoticeApi salesNoticeApi; |
| | | |
| | | @Resource |
| | | private StorageAttachmentApi storageAttachmentApi; |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void cancelSaleOrder(Long id) { |
| | | // 1.1 校验存在 |
| | | ErpSaleOrderDO saleOrder = validateSaleOrderExists(id); |
| | | ErpSaleOrderDO saleOrder = saleOrderMapper.selectByIdForUpdate(id); |
| | | if (saleOrder == null) throw exception(SALE_ORDER_NOT_EXISTS); |
| | | // 1.2 校验状态:只有已审核的订单才能作废 |
| | | if (!ErpAuditStatus.APPROVE.getStatus().equals(saleOrder.getStatus())) { |
| | | throw exception(SALE_ORDER_CANCEL_FAIL_NOT_APPROVE, saleOrder.getNo()); |
| | |
| | | throw exception(SALE_ORDER_CANCEL_FAIL_ACTIVE_MPS); |
| | | } |
| | | } |
| | | Map<Long, Boolean> noticeStatus = salesNoticeApi.checkSalesNoticeBySaleOrderIds(List.of(id)); |
| | | if (noticeStatus == null || noticeStatus.get(id) == null) throw exception(SALE_ORDER_CANCEL_FAIL_NOTICE_UNKNOWN); |
| | | if (Boolean.TRUE.equals(noticeStatus.get(id))) throw exception(SALE_ORDER_CANCEL_FAIL_NOTICE_EXISTS); |
| | | |
| | | // 2. 更新状态为已作废 |
| | | int updateCount = saleOrderMapper.updateByIdAndStatus(id, saleOrder.getStatus(), |