fix(payment): 修复支付回调地址配置逻辑
- 新增 apiUrl 配置属性,支持通过 API 网关地址访问回调 - 优先使用 apiUrl 拼接回调地址,确保回调服务公网可访问 - 兼容原有 serverUrl 配置,作为备用回调地址使用 - 移除默认注释,明确支付回调地址的选择逻辑
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.gxwebsoft.common.core.service;
|
package com.gxwebsoft.common.core.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.gxwebsoft.common.system.entity.Payment;
|
import com.gxwebsoft.common.system.entity.Payment;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -26,6 +27,9 @@ public class EnvironmentAwarePaymentService {
|
|||||||
@Value("${config.server-url:}")
|
@Value("${config.server-url:}")
|
||||||
private String serverUrl;
|
private String serverUrl;
|
||||||
|
|
||||||
|
@Value("${config.api-url:}")
|
||||||
|
private String apiUrl;
|
||||||
|
|
||||||
// 开发环境回调地址配置
|
// 开发环境回调地址配置
|
||||||
@Value("${payment.dev.notify-url:http://frps-10550.s209.websoft.top/api/shop/shop-order/notify}")
|
@Value("${payment.dev.notify-url:http://frps-10550.s209.websoft.top/api/shop/shop-order/notify}")
|
||||||
private String devNotifyUrl;
|
private String devNotifyUrl;
|
||||||
@@ -73,8 +77,8 @@ public class EnvironmentAwarePaymentService {
|
|||||||
// 生产环境使用生产回调地址
|
// 生产环境使用生产回调地址
|
||||||
return prodNotifyUrl;
|
return prodNotifyUrl;
|
||||||
} else {
|
} else {
|
||||||
// 默认使用配置的服务器地址
|
// 默认使用 API 网关地址(支付回调需要公网可访问的 API 地址)
|
||||||
return serverUrl + "/shop/shop-order/notify";
|
return (StrUtil.isNotBlank(apiUrl) ? apiUrl : serverUrl) + "/shop/shop-order/notify";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user