支付宝插件 , 更换地图 , 支付订单入账佣金账号

This commit is contained in:
2026-03-26 09:44:12 +08:00
parent b355f0364c
commit 34cf179254
2 changed files with 15 additions and 14 deletions

View File

@@ -11,6 +11,8 @@ import org.springblade.modules.common.pojo.entity.CommonUserOrderEntity;
import org.springblade.modules.common.service.ICommonUserOrderService; import org.springblade.modules.common.service.ICommonUserOrderService;
import org.springblade.modules.market.pojo.entity.*; import org.springblade.modules.market.pojo.entity.*;
import org.springblade.modules.market.service.*; import org.springblade.modules.market.service.*;
import org.springframework.aop.framework.AopContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -23,6 +25,7 @@ import java.util.Date;
@Slf4j @Slf4j
@Component @Component
@AllArgsConstructor @AllArgsConstructor
@EnableAspectJAutoProxy(exposeProxy = true)
public class StatsCommissionAccountListener { public class StatsCommissionAccountListener {
private final ICommonUserOrderService userOrderService; private final ICommonUserOrderService userOrderService;
@@ -34,17 +37,7 @@ public class StatsCommissionAccountListener {
private final IMarketCommissionOperationLogService operationLogService; private final IMarketCommissionOperationLogService operationLogService;
private final IMarketCommissionServiceProviderLogService serviceProviderLogService; private final IMarketCommissionServiceProviderLogService serviceProviderLogService;
// 自注入,用于在异步方法中调用带 @Transactional 的内部方法
private StatsCommissionAccountListener self;
// Spring 容器初始化后注入自身代理对象
@Resource
private org.springframework.context.ApplicationContext applicationContext;
@jakarta.annotation.PostConstruct
public void init() {
this.self = applicationContext.getBean(StatsCommissionAccountListener.class);
}
private static final Long GOODS_COST_ACCOUNT_ID = 2017485441885196290L; private static final Long GOODS_COST_ACCOUNT_ID = 2017485441885196290L;
private static final Long OPERATION_ACCOUNT_ID = 2017486179294171138L; private static final Long OPERATION_ACCOUNT_ID = 2017486179294171138L;
@@ -57,13 +50,20 @@ public class StatsCommissionAccountListener {
@EventListener @EventListener
public void callbackSuccessPayment(StatsCommissionAccountEvent event) { public void callbackSuccessPayment(StatsCommissionAccountEvent event) {
try { try {
if (self == null) { // 【关键优化】使用 AopContext 获取当前代理对象,避免循环依赖
log.error("自注入失败,无法开启事务,订单 ID: {}", event.getId()); // 必须确保启动类或配置类上有 @EnableAspectJAutoProxy(exposeProxy = true)
self = this; StatsCommissionAccountListener proxy;
try {
proxy = (StatsCommissionAccountListener) AopContext.currentProxy();
} catch (IllegalStateException e) {
log.warn("AopContext 未开启 (exposeProxy=false),降级为直接调用,事务可能失效!请检查启动类配置。", e);
proxy = this;
} }
self.processCommissionInternal(event);
proxy.processCommissionInternal(event);
} catch (Exception e) { } catch (Exception e) {
log.error("统计佣金入账处理异常,订单 ID: {}, 错误信息:{}", event.getId(), e.getMessage(), e); log.error("统计佣金入账处理异常,订单 ID: {}, 错误信息:{}", event.getId(), e.getMessage(), e);
// 生产环境建议:此处可记录到死信表或发送告警
} }
} }

View File

@@ -247,6 +247,7 @@ blade:
- /app-common/send-forget-pwd-sms - /app-common/send-forget-pwd-sms
- /app-common/retrieve-password - /app-common/retrieve-password
- /app-eco/list - /app-eco/list
- /app-eco/detail
- /app-tourism-spot/list - /app-tourism-spot/list
- /app-tourism-spot/top-list - /app-tourism-spot/top-list
- /app-news/category-list - /app-news/category-list