diff --git a/src/main/java/com/gxwebsoft/common/core/service/EnvironmentAwarePaymentService.java b/src/main/java/com/gxwebsoft/common/core/service/EnvironmentAwarePaymentService.java index 2155cc9..c8bdf53 100644 --- a/src/main/java/com/gxwebsoft/common/core/service/EnvironmentAwarePaymentService.java +++ b/src/main/java/com/gxwebsoft/common/core/service/EnvironmentAwarePaymentService.java @@ -1,5 +1,6 @@ package com.gxwebsoft.common.core.service; +import cn.hutool.core.util.StrUtil; import com.gxwebsoft.common.system.entity.Payment; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -26,6 +27,9 @@ public class EnvironmentAwarePaymentService { @Value("${config.server-url:}") 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}") private String devNotifyUrl; @@ -73,8 +77,8 @@ public class EnvironmentAwarePaymentService { // 生产环境使用生产回调地址 return prodNotifyUrl; } else { - // 默认使用配置的服务器地址 - return serverUrl + "/shop/shop-order/notify"; + // 默认使用 API 网关地址(支付回调需要公网可访问的 API 地址) + return (StrUtil.isNotBlank(apiUrl) ? apiUrl : serverUrl) + "/shop/shop-order/notify"; } }