创建充值单后立即调用 /api/v1/order/create-transaction。

成功后自动跳转 public/usdtCheckout?tradeId=...。
收银台按交易号展示网络、金额、二维码、地址及支付状态。
失败时显示处理阶段,支持使用原单重试,避免重复创建。
This commit is contained in:
lu7213 committed 2026-10-29 03:46:59 -04:00
1 parent 76f9e62253
commit b6b9120b85
8 files changed
+203 -6

No files matched your search

@@ -0,0 +1,41 @@
package com.ruoyi.system.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.CustomException;
import com.ruoyi.system.domain.UsdtOrdersPlus;
import com.ruoyi.system.service.IUsdtOrdersService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 收银台只读入口:随机32位交易号为访问凭据,只返回付款必需字段。
* 不接受商户订单号查询,不公开用户、应用、回调地址或任何签名凭证。
*/
@RestController
public class PaymentCheckoutController {
private final IUsdtOrdersService orders;
public PaymentCheckoutController(IUsdtOrdersService orders) { this.orders = orders; }
@GetMapping("/api/v1/order/checkout/{tradeId}")
public AjaxResult detail(@PathVariable String tradeId) {
if (!tradeId.matches("[0-9a-f]{32}")) { throw new CustomException("支付信息不存在"); }
UsdtOrdersPlus order = orders.getOne(new LambdaQueryWrapper<UsdtOrdersPlus>()
.eq(UsdtOrdersPlus::getTradeId, tradeId).isNull(UsdtOrdersPlus::getDeletedAt)
.eq(UsdtOrdersPlus::getOrderType, 0).last("limit 1"));
if (order == null || order.getCreatedAt() == null) { throw new CustomException("支付信息不存在"); }
long expires = order.getCreatedAt().getTime() + 600000L;
Map<String, Object> result = new LinkedHashMap<>();
result.put("trade_id", order.getTradeId());
result.put("network", order.getPaymentNetwork());
result.put("payment_address", order.getToken());
result.put("payment_amount", order.getActualAmount());
result.put("expiration_time", expires);
result.put("status", Long.valueOf(1).equals(order.getStatus()) && expires <= System.currentTimeMillis() ? 3 : order.getStatus());
return AjaxResult.success(result);
}
}