| | |
| | | import cn.iocoder.yudao.module.crm.dal.mysql.refund.CrmRefundMapper; |
| | | import cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants; |
| | | import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; |
| | | import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; |
| | | import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; |
| | | import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum; |
| | | import cn.iocoder.yudao.module.system.api.approval.ApprovalConfigApi; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| | |
| | | */ |
| | | private static final String REFUND_APPROVE_BIZ_TYPE = "refund_approve"; |
| | | |
| | | /** |
| | | * CRM 退费单审批的 BPM 流程定义 Key |
| | | */ |
| | | private static final String REFUND_APPROVE_PROCESS_KEY = "refund_approve"; |
| | | |
| | | @Resource |
| | | private CrmRefundMapper refundMapper; |
| | | @Resource |
| | |
| | | private AdminUserApi adminUserApi; |
| | | @Resource |
| | | private ApprovalConfigApi approvalConfigApi; |
| | | @Resource |
| | | private BpmProcessInstanceApi bpmProcessInstanceApi; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | if (refundMapper.submitAndResetAuditInfo(id, CrmAuditStatusEnum.PROCESS.getStatus()) != 1) { |
| | | throw exception(ErrorCodeConstants.CRM_REFUND_SUBMIT_FAIL_NOT_EDITABLE); |
| | | } |
| | | |
| | | // 4. 创建 BPM 流程实例,使审批出现在「协同办公 - 我的流程」 |
| | | bpmProcessInstanceApi.createProcessInstance(getLoginUserId(), |
| | | new BpmProcessInstanceCreateReqDTO() |
| | | .setProcessDefinitionKey(REFUND_APPROVE_PROCESS_KEY) |
| | | .setBusinessKey(String.valueOf(id))); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateRefundAuditStatus(Long id, Integer bpmStatus, String reason) { |
| | | // BPM 审批结果映射为退费单审核状态:通过=20 / 不通过=30 / 取消=40 |
| | | Integer auditStatus; |
| | | if (BpmTaskStatusEnum.APPROVE.getStatus().equals(bpmStatus)) { |
| | | auditStatus = CrmAuditStatusEnum.APPROVE.getStatus(); |
| | | } else if (BpmTaskStatusEnum.REJECT.getStatus().equals(bpmStatus)) { |
| | | auditStatus = CrmAuditStatusEnum.REJECT.getStatus(); |
| | | } else if (BpmTaskStatusEnum.CANCEL.getStatus().equals(bpmStatus)) { |
| | | auditStatus = CrmAuditStatusEnum.CANCEL.getStatus(); |
| | | } else { |
| | | return; |
| | | } |
| | | if (refundMapper.updateAuditStatusByBpm(id, auditStatus, reason) != 1) { |
| | | log.warn("[updateRefundAuditStatus] 退费单({}) 不处于审批中状态,忽略 BPM 结果({})", id, bpmStatus); |
| | | } |
| | | } |
| | | |
| | | private CrmRefundDO validateRefundExists(Long id) { |
| | | CrmRefundDO refund = refundMapper.selectById(id); |
| | | if (refund == null) { |