package com.ruoyi.system.event;
|
|
import com.ruoyi.payment.domain.event.PaymentSuccessEvent;
|
import com.ruoyi.payment.domain.model.PaymentOrder;
|
import com.ruoyi.payment.domain.model.PaymentTransaction;
|
import com.ruoyi.system.service.ISysTaskPaymentService;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.context.event.EventListener;
|
import org.springframework.stereotype.Component;
|
|
/**
|
* 支付成功事件监听器
|
* 将支付模块的事件回调转换为业务表更新
|
*/
|
@Component
|
public class PaymentSuccessEventListener {
|
|
private static final Logger log = LoggerFactory.getLogger(PaymentSuccessEventListener.class);
|
|
@Autowired
|
private ISysTaskPaymentService taskPaymentService;
|
|
/**
|
* 监听 dryad-payment 的支付成功事件
|
*/
|
@EventListener
|
public void handlePaymentSuccess(PaymentSuccessEvent event) {
|
PaymentOrder order = event.getOrder();
|
PaymentTransaction transaction = event.getTransaction();
|
|
String outTradeNo = order.getBizOrderId();
|
String tradeNo = order.getChannelTradeNo();
|
String channel = order.getChannel();
|
String provider = "WECHAT";
|
if ("ALIPAY".equalsIgnoreCase(channel)) {
|
provider = "ALIPAY";
|
}
|
|
try {
|
boolean success = taskPaymentService.handlePaymentCallback(outTradeNo, tradeNo, provider);
|
if (success) {
|
log.info("[事件监听] 业务支付更新成功: bizOrderId={}, tradeNo={}, provider={}", outTradeNo, tradeNo, provider);
|
} else {
|
log.warn("[事件监听] 业务支付更新失败: bizOrderId={}, tradeNo={}, provider={}", outTradeNo, tradeNo, provider);
|
}
|
} catch (Exception e) {
|
log.error("[事件监听] 处理支付成功事件异常", e);
|
}
|
}
|
}
|