wlzboy
2025-11-27 668e570bd1db6bd00e4293b6977e6d3d051053ce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.ruoyi.payment.domain.event;
 
import com.ruoyi.payment.domain.model.PaymentOrder;
import com.ruoyi.payment.domain.model.PaymentTransaction;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;
 
/**
 * 支付成功事件
 * 
 * 使用方式:
 * 1. 作为jar包集成时,在主项目中监听此事件:
 *    @EventListener
 *    public void handlePaymentSuccess(PaymentSuccessEvent event) {
 *        PaymentOrder order = event.getOrder();
 *        PaymentTransaction transaction = event.getTransaction();
 *        // 处理业务逻辑
 *    }
 * 
 * 2. 或者实现 PaymentCallback 接口进行回调
 * 
 * @author ruoyi
 */
@Getter
public class PaymentSuccessEvent extends ApplicationEvent {
 
    private static final long serialVersionUID = 1L;
 
    /**
     * 支付订单
     */
    private final PaymentOrder order;
 
    /**
     * 支付交易
     */
    private final PaymentTransaction transaction;
 
    /**
     * 支付渠道(WECHAT/ALIPAY)
     */
    private final String channel;
 
    public PaymentSuccessEvent(Object source, PaymentOrder order, PaymentTransaction transaction) {
        super(source);
        this.order = order;
        this.transaction = transaction;
        this.channel = order.getChannel();
    }
}