diff --git a/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/command/pay/web/PayWebPlaceAnOrderCmdExe.java b/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/command/pay/web/PayWebPlaceAnOrderCmdExe.java index 37c014b8..d319c6b8 100644 --- a/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/command/pay/web/PayWebPlaceAnOrderCmdExe.java +++ b/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/command/pay/web/PayWebPlaceAnOrderCmdExe.java @@ -26,6 +26,7 @@ import com.red.circle.tool.core.num.ArithmeticUtils; import com.red.circle.tool.core.sequence.IdWorkerUtils; import com.red.circle.tool.core.text.StringUtils; import com.red.circle.other.inner.endpoint.user.region.UserRegionClient; +import com.red.circle.order.app.common.PayerMaxProperties; import java.math.BigDecimal; import java.util.List; import java.util.Objects; @@ -44,7 +45,7 @@ import org.springframework.stereotype.Component; public class PayWebPlaceAnOrderCmdExe { private final PayProperties payProperties; - private final UserRegionClient userRegionClient; + private final PayerMaxProperties payerMaxProperties; private final PayCountryService payCountryService; private final SysCountryCodeClient sysCountryCodeClient; private final PayApplicationService payApplicationService; @@ -131,6 +132,12 @@ public class PayWebPlaceAnOrderCmdExe { * @return 汇率 */ private BigDecimal getRealTimeExchangeRate(PayCountry payCountry) { + // 检查是否启用实时汇率 + if (!Boolean.TRUE.equals(payerMaxProperties.getEnableRealTimeExchangeRate())) { + log.info("Real-time exchange rate is disabled, using configured rate for country {}", payCountry.getId()); + return payCountry.getUsdExchangeRate(); + } + BigDecimal realTimeRate = null; try { // 调用实时汇率查询 - 这里假设目标币种是payCountry对应的币种 diff --git a/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/common/PayerMaxProperties.java b/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/common/PayerMaxProperties.java index e372daf6..eac94037 100644 --- a/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/common/PayerMaxProperties.java +++ b/rc-service/rc-service-order/order-application/src/main/java/com/red/circle/order/app/common/PayerMaxProperties.java @@ -21,6 +21,11 @@ public class PayerMaxProperties { private String platformRsaPublicKey; private String appId; + /** + * 是否启用实时汇率,默认为false(关闭) + */ + private Boolean enableRealTimeExchangeRate = false; + public String getSecretKey() { return secretKey; } @@ -68,4 +73,12 @@ public class PayerMaxProperties { public void setAppId(String appId) { this.appId = appId; } + + public Boolean getEnableRealTimeExchangeRate() { + return enableRealTimeExchangeRate; + } + + public void setEnableRealTimeExchangeRate(Boolean enableRealTimeExchangeRate) { + this.enableRealTimeExchangeRate = enableRealTimeExchangeRate; + } }