From bf5f52656e128f578ed42c7979c31cf4b476ce46 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期六, 31 十月 2026 19:04:40 +0800
Subject: [PATCH] feat: 优化业务导入及工艺流程管理

---
 yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/refund/listener/CrmRefundStatusListener.java |   46 +++++++++++++++++++---------------------------
 1 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/refund/listener/CrmRefundStatusListener.java b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/refund/listener/CrmRefundStatusListener.java
index a7ed588..c599c87 100644
--- a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/refund/listener/CrmRefundStatusListener.java
+++ b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/refund/listener/CrmRefundStatusListener.java
@@ -1,54 +1,46 @@
 package cn.iocoder.yudao.module.crm.service.refund.listener;
 
 import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEvent;
-import cn.iocoder.yudao.module.crm.dal.dataobject.refund.CrmRefundDO;
-import cn.iocoder.yudao.module.crm.dal.mysql.refund.CrmRefundMapper;
-import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum;
+import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEventListener;
 import cn.iocoder.yudao.module.crm.service.refund.CrmRefundService;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.context.ApplicationListener;
 import org.springframework.stereotype.Component;
 
 /**
- * 閫�璐瑰鎵圭殑缁撴灉鐩戝惉鍣ㄥ疄鐜扮被
+ * CRM 閫�璐瑰崟瀹℃壒鐘舵�佺洃鍚櫒
  *
- * 閫氳繃 businessKey锛堥��璐瑰崟ID锛夊尮閰嶏紝鑰屼笉鏄浐瀹氱殑娴佺▼瀹氫箟 Key锛�
- * 杩欐牱鍙互鏀寔鍒嗙被涓嬩换鎰� Key 鐨勬祦绋嬫ā鍨嬨��
+ * 鐩戝惉 BPM 瀹℃壒缁撴灉锛屽洖鍐欓��璐瑰崟瀹℃牳鐘舵�侊紝浣块��璐瑰鎵圭粺涓�鍦ㄣ�屽崗鍚屽姙鍏� - 鎴戠殑娴佺▼銆嶄腑娴佽浆銆�
  */
 @Component
 @Slf4j
-public class CrmRefundStatusListener implements ApplicationListener<BpmProcessInstanceStatusEvent> {
+public class CrmRefundStatusListener extends BpmProcessInstanceStatusEventListener {
+
+    private static final String PROCESS_DEFINITION_KEY = "refund_approve";
 
     @Resource
     private CrmRefundService refundService;
-    @Resource
-    private CrmRefundMapper refundMapper;
 
     @Override
-    public void onApplicationEvent(BpmProcessInstanceStatusEvent event) {
-        // 閫氳繃 businessKey 鏌ヨ閫�璐瑰崟
+    protected String getProcessDefinitionKey() {
+        return PROCESS_DEFINITION_KEY;
+    }
+
+    @Override
+    protected void onEvent(BpmProcessInstanceStatusEvent event) {
         Long refundId;
         try {
             refundId = Long.parseLong(event.getBusinessKey());
         } catch (NumberFormatException e) {
-            return; // businessKey 涓嶆槸鏁板瓧锛屽拷鐣�
-        }
-
-        CrmRefundDO refund = refundMapper.selectById(refundId);
-        if (refund == null) {
-            return; // 涓嶆槸閫�璐瑰崟锛屽拷鐣�
-        }
-
-        // 鍙湁瀹℃壒涓姸鎬佺殑閫�璐瑰崟鎵嶅鐞�
-        if (!CrmAuditStatusEnum.PROCESS.getStatus().equals(refund.getAuditStatus())) {
-            log.warn("[onApplicationEvent] 閫�璐瑰崟({}) 涓嶅浜庡鎵逛腑鐘舵�侊紝褰撳墠鐘舵��: {}", refundId, refund.getAuditStatus());
+            log.warn("[onEvent] businessKey({}) 涓嶆槸鏈夋晥鐨勯��璐瑰崟缂栧彿", event.getBusinessKey());
             return;
         }
-
-        log.info("[onApplicationEvent] 閫�璐瑰崟({}) 瀹℃壒鐘舵�佹洿鏂�: {}", refundId, event.getStatus());
-        // 鏇存柊瀹℃壒鐘舵��
-        refundService.updateRefundAuditStatus(refundId, event.getStatus());
+        log.info("[onEvent] 鏀跺埌閫�璐瑰崟瀹℃壒浜嬩欢锛宺efundId={}, status={}", refundId, event.getStatus());
+        try {
+            refundService.updateRefundAuditStatus(refundId, event.getStatus(), event.getReason());
+        } catch (Exception e) {
+            log.error("[onEvent] 鍥炲啓閫�璐瑰崟瀹℃壒鐘舵�佸け璐ワ紝refundId={}", refundId, e);
+        }
     }
 
 }

--
Gitblit v1.9.3