添加返回支付地址

This commit is contained in:
lu7213 committed 2026-10-17 00:48:44 -04:00
1 parent 361bfd6421
commit 3161365ec8
4 files changed
+23 -2

No files matched your search

@@ -133,6 +133,8 @@ payment:
apps-private-key-encryption-key: ${APP_PRIVATE_KEY_ENCRYPTION_KEY:} apps-private-key-encryption-key: ${APP_PRIVATE_KEY_ENCRYPTION_KEY:}
# 1 USDT 对应的业务货币金额;订单实际支付 USDT = amount / 此汇率,向下保留 2 位。 # 1 USDT 对应的业务货币金额;订单实际支付 USDT = amount / 此汇率,向下保留 2 位。
usdt-exchange-rate: ${USDT_EXCHANGE_RATE:1} usdt-exchange-rate: ${USDT_EXCHANGE_RATE:1}
# 开放API创建订单成功后返回的公共收银台地址。
checkout-url: ${PAYMENT_CHECKOUT_URL:http://192.168.3.103/public/usdtCheckout}
# 钱包链上操作资源预算配置。 # 钱包链上操作资源预算配置。
tron: tron:
@@ -16,14 +16,17 @@ public class PaymentOrderCreateResult {
private BigDecimal paymentAmount; private BigDecimal paymentAmount;
@JsonProperty("expiration_time") @JsonProperty("expiration_time")
private Date expirationTime; private Date expirationTime;
/** 商户可引导用户访问的公共收银台地址。 */
private String url;
public PaymentOrderCreateResult(String orderId, String tradeId, String paymentAddress, public PaymentOrderCreateResult(String orderId, String tradeId, String paymentAddress,
BigDecimal paymentAmount, Date expirationTime) { BigDecimal paymentAmount, Date expirationTime, String url) {
this.orderId = orderId; this.orderId = orderId;
this.tradeId = tradeId; this.tradeId = tradeId;
this.paymentAddress = paymentAddress; this.paymentAddress = paymentAddress;
this.paymentAmount = paymentAmount; this.paymentAmount = paymentAmount;
this.expirationTime = expirationTime; this.expirationTime = expirationTime;
this.url = url;
} }
public String getOrderId() { return orderId; } public String getOrderId() { return orderId; }
@@ -31,4 +34,5 @@ public class PaymentOrderCreateResult {
public String getPaymentAddress() { return paymentAddress; } public String getPaymentAddress() { return paymentAddress; }
public BigDecimal getPaymentAmount() { return paymentAmount; } public BigDecimal getPaymentAmount() { return paymentAmount; }
public Date getExpirationTime() { return expirationTime; } public Date getExpirationTime() { return expirationTime; }
public String getUrl() { return url; }
} }
@@ -55,6 +55,9 @@ public class PaymentOrderOpenApiService {
/** 1 USDT 对应的业务货币金额,例如 7.20 表示 1 USDT = 7.20 业务货币。 */ /** 1 USDT 对应的业务货币金额,例如 7.20 表示 1 USDT = 7.20 业务货币。 */
@Value("${payment.usdt-exchange-rate:1}") @Value("${payment.usdt-exchange-rate:1}")
private BigDecimal usdtExchangeRate; private BigDecimal usdtExchangeRate;
/** 对外创建订单成功后返回的公共收银台入口。 */
@Value("${payment.checkout-url:http://192.168.3.103/public/usdtCheckout}")
private String checkoutUrl;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public PaymentOrderCreateResult createOrder(DecryptResult request) { public PaymentOrderCreateResult createOrder(DecryptResult request) {
@@ -220,7 +223,8 @@ public class PaymentOrderOpenApiService {
private PaymentOrderCreateResult result(UsdtOrdersPlus order) { private PaymentOrderCreateResult result(UsdtOrdersPlus order) {
return new PaymentOrderCreateResult(order.getOrderId(), order.getTradeId(), order.getToken(), return new PaymentOrderCreateResult(order.getOrderId(), order.getTradeId(), order.getToken(),
order.getActualAmount(), new Date(order.getCreatedAt().getTime() + ORDER_TTL_MILLIS)); order.getActualAmount(), new Date(order.getCreatedAt().getTime() + ORDER_TTL_MILLIS),
checkoutUrl);
} }
private Map<String, String> parseParameters(String plainData) { private Map<String, String> parseParameters(String plainData) {
@@ -1,10 +1,12 @@
package com.ruoyi.system.service; package com.ruoyi.system.service;
import com.ruoyi.common.exception.CustomException; import com.ruoyi.common.exception.CustomException;
import com.ruoyi.system.domain.vo.PaymentOrderCreateResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
/** 支付订单业务金额与 USDT 实付金额换算测试。 */ /** 支付订单业务金额与 USDT 实付金额换算测试。 */
public class PaymentOrderOpenApiServiceTest { public class PaymentOrderOpenApiServiceTest {
@@ -25,4 +27,13 @@ public class PaymentOrderOpenApiServiceTest {
public void shouldRejectInvalidExchangeRate() { public void shouldRejectInvalidExchangeRate() {
PaymentOrderOpenApiService.calculateActualAmount(BigDecimal.ONE, BigDecimal.ZERO); PaymentOrderOpenApiService.calculateActualAmount(BigDecimal.ONE, BigDecimal.ZERO);
} }
@Test
public void shouldExposeConfiguredCheckoutUrlInCreateResult() {
String checkoutUrl = "http://192.168.3.103/public/usdtCheckout";
PaymentOrderCreateResult result = new PaymentOrderCreateResult(
"order-1", "trade-1", "TAddress", BigDecimal.ONE, new Date(), checkoutUrl);
Assert.assertEquals(checkoutUrl, result.getUrl());
}
} }