mirror of
https://gitee.com/dromara/dax-pay
synced 2026-08-11 15:15:33 +08:00
refactor(payment): self 注入统一 final 构造注入; EasyPay 结果增 mchName @Trans 翻译
- PayCallbackService/RefundService 的 self 注入由 @Lazy @Autowired 字段改 final 构造注入 - RefundService 补 PayRouteService import 以解析 /// 文档链接 - GatewayTimeoutService 消除冗余 finalOrder 中转变量(lambda 直接用 current) - EasyPayOrderResult/EasyPayRefundOrderResult 增 mchName 走 @Trans 按 mchNo 翻译 - EasyPayCloseV2Service 删除未使用的 EasyPayOrderManager 依赖
This commit is contained in:
@@ -42,8 +42,7 @@ public class PayCallbackService {
|
||||
|
||||
/// 自注入: 保证 [doPayCallback] 走 Spring 事务代理
|
||||
@Lazy
|
||||
@Autowired
|
||||
private PayCallbackService self;
|
||||
private final PayCallbackService self;
|
||||
|
||||
/// 支付统一回调处理(锁外层,无事务),返回支付产品编码
|
||||
///
|
||||
@@ -65,6 +64,7 @@ public class PayCallbackService {
|
||||
Long tradeId = trade.getId();
|
||||
TryLockResult<String> result = lockExecutor.tryExecute(
|
||||
"payment:trade:" + tradeId,
|
||||
// 执行具体逻辑
|
||||
() -> self.doPayCallback(callbackData, tradeId)
|
||||
);
|
||||
if (!result.acquired()) {
|
||||
@@ -90,8 +90,10 @@ public class PayCallbackService {
|
||||
trade.setOutOrderNo(callbackData.getOutTradeNo());
|
||||
}
|
||||
if (Objects.equals(CallbackStatusEnum.SUCCESS.getCode(), callbackData.getTradeStatus())) {
|
||||
// 成功处理
|
||||
this.success(trade, callbackData);
|
||||
} else {
|
||||
// 失败处理
|
||||
this.fail(trade, callbackData);
|
||||
}
|
||||
return resolveProduct(trade);
|
||||
|
||||
@@ -49,22 +49,21 @@ public class GatewayTimeoutService {
|
||||
.contains(current.getStatus())) {
|
||||
return;
|
||||
}
|
||||
GatewayPayOrder finalOrder = current;
|
||||
// 定时/MQ 无登录上下文:按订单 mchNo 开启作用域后走租户过滤
|
||||
paymentContext.runAs(() -> {
|
||||
if (StrUtil.isBlank(finalOrder.getMchNo())) {
|
||||
if (StrUtil.isBlank(current.getMchNo())) {
|
||||
log.error("网关超时关单订单缺少 mchNo, orderNo={}", orderNo);
|
||||
return;
|
||||
}
|
||||
paymentContext.setMchNo(finalOrder.getMchNo());
|
||||
PayTrade trade = payTradeManager.findByContainerId(finalOrder.getId(), PayTradeTypeEnum.GATEWAY.getCode())
|
||||
paymentContext.setMchNo(current.getMchNo());
|
||||
PayTrade trade = payTradeManager.findByContainerId(current.getId(), PayTradeTypeEnum.GATEWAY.getCode())
|
||||
.orElse(null);
|
||||
if (trade != null) {
|
||||
// 有资金凭证: 走统一超时关单(含通道关闭)
|
||||
payCloseService.closeForTimeout(trade.getTradeNo());
|
||||
} else {
|
||||
// 仅容器: 直接过期
|
||||
payUniHandleService.gatewayOrderTimeout(finalOrder);
|
||||
payUniHandleService.gatewayOrderTimeout(current);
|
||||
}
|
||||
});
|
||||
})) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.daxpay.open.payment.trade.runtime.service.refund;
|
||||
|
||||
import cn.daxpay.open.payment.route.service.runtime.PayRouteService;
|
||||
import cn.daxpay.open.platform.core.code.CommonCode;
|
||||
import cn.daxpay.open.platform.core.code.CommonErrorCode;
|
||||
import cn.daxpay.open.platform.core.code.DaxPayErrorCode;
|
||||
@@ -53,8 +54,7 @@ public class RefundService {
|
||||
|
||||
/// 自身注入: 使 @Transactional 方法经代理调用生效(锁内层事务模式)
|
||||
@Lazy
|
||||
@Autowired
|
||||
private RefundService self;
|
||||
private final RefundService self;
|
||||
|
||||
/// 发起退款
|
||||
public RefundOrder refund(RefundParam param) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package cn.daxpay.open.plugin.easypay.result.order;
|
||||
|
||||
import cn.daxpay.open.payment.common.result.MchBaseResult;
|
||||
import cn.daxpay.open.payment.merchant.entity.info.MerchantInfo;
|
||||
import cn.daxpay.open.platform.core.annotation.Trans;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -17,6 +19,14 @@ import java.time.OffsetDateTime;
|
||||
@Schema(title = "易支付订单结果")
|
||||
public class EasyPayOrderResult extends MchBaseResult {
|
||||
|
||||
/// 商户名称(由 mchNo 翻译, 走系统 @Trans 机制)
|
||||
@Trans(
|
||||
entity = MerchantInfo.class,
|
||||
source = MchBaseResult.Fields.mchNo,
|
||||
result = MerchantInfo.Fields.mchName)
|
||||
@Schema(description = "商户名称")
|
||||
private String mchName;
|
||||
|
||||
/// 关联内核容器 ID(NormalPayOrder.id)
|
||||
@Schema(description = "关联内核容器ID")
|
||||
private Long orderId;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package cn.daxpay.open.plugin.easypay.result.order;
|
||||
|
||||
import cn.daxpay.open.payment.common.result.MchBaseResult;
|
||||
import cn.daxpay.open.payment.merchant.entity.info.MerchantInfo;
|
||||
import cn.daxpay.open.platform.core.annotation.Trans;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -17,6 +19,14 @@ import java.time.OffsetDateTime;
|
||||
@Schema(title = "易支付退款订单结果")
|
||||
public class EasyPayRefundOrderResult extends MchBaseResult {
|
||||
|
||||
/// 商户名称(由 mchNo 翻译, 走系统 @Trans 机制)
|
||||
@Trans(
|
||||
entity = MerchantInfo.class,
|
||||
source = MchBaseResult.Fields.mchNo,
|
||||
result = MerchantInfo.Fields.mchName)
|
||||
@Schema(description = "商户名称")
|
||||
private String mchName;
|
||||
|
||||
/// 关联内核退款单 ID(RefundOrder.id)
|
||||
@Schema(description = "关联内核退款单ID")
|
||||
private Long refundId;
|
||||
|
||||
@@ -22,7 +22,6 @@ public class EasyPayCloseV2Service {
|
||||
|
||||
private final EasyPayCredentialService easyPayCredentialService;
|
||||
private final EasyPayAssistService easyPayAssistService;
|
||||
private final EasyPayOrderManager easyPayOrderManager;
|
||||
private final PayCloseService payCloseService;
|
||||
|
||||
/// 关单
|
||||
|
||||
Reference in New Issue
Block a user