| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.crm.service.invoice.listener; |
| | | |
| | | import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEvent; |
| | | import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEventListener; |
| | | import cn.iocoder.yudao.module.crm.service.invoice.CrmInvoiceService; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * CRM å¼ç¥¨å®¡æ¹ç¶æçå¬å¨ |
| | | * |
| | | * çå¬ BPM 审æ¹ç»æï¼ååå¼ç¥¨å®¡æ ¸ç¶æï¼ä½¿å¼ç¥¨å®¡æ¹ç»ä¸å¨ãåååå
¬ - æçæµç¨ã䏿µè½¬ã |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class CrmInvoiceStatusListener extends BpmProcessInstanceStatusEventListener { |
| | | |
| | | private static final String PROCESS_DEFINITION_KEY = "crm-invoice-audit"; |
| | | |
| | | @Resource |
| | | private CrmInvoiceService invoiceService; |
| | | |
| | | @Override |
| | | protected String getProcessDefinitionKey() { |
| | | return PROCESS_DEFINITION_KEY; |
| | | } |
| | | |
| | | @Override |
| | | protected void onEvent(BpmProcessInstanceStatusEvent event) { |
| | | Long invoiceId; |
| | | try { |
| | | invoiceId = Long.parseLong(event.getBusinessKey()); |
| | | } catch (NumberFormatException e) { |
| | | log.warn("[onEvent] businessKey({}) 䏿¯ææçå¼ç¥¨ç¼å·", event.getBusinessKey()); |
| | | return; |
| | | } |
| | | log.info("[onEvent] æ¶å°å¼ç¥¨å®¡æ¹äºä»¶ï¼invoiceId={}, status={}", invoiceId, event.getStatus()); |
| | | try { |
| | | invoiceService.updateInvoiceAuditStatus(invoiceId, event.getStatus(), event.getReason()); |
| | | } catch (Exception e) { |
| | | log.error("[onEvent] ååå¼ç¥¨å®¡æ¹ç¶æå¤±è´¥ï¼invoiceId={}", invoiceId, e); |
| | | } |
| | | } |
| | | |
| | | } |