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();
|
}
|
}
|