添加返回支付地址

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