订单支付成功时,事务化写入 USDT 收入流水。

归集明细成功时,事务化写入 USDT 支出流水。
使用唯一幂等键防止订单重扫、归集重试产生重复流水。
新增按应用、币种、时间范围以及日/月/年维度的统计接口。
管理员和商户接口均改为只读,移除流水新增、修改、删除入口。
商户查询由后端强制限定当前用户。
This commit is contained in:
lu7213 committed 2026-10-13 10:32:18 -04:00
1 parent 8cc7bd0c17
commit 0ff174e872
15 files changed
+377 -254

No files matched your search

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.system.domain.UsdtOrdersPlus;
import com.ruoyi.system.service.ITronService;
import com.ruoyi.system.service.IUsdtOrdersService;
import com.ruoyi.system.service.WalletLedgerPostingService;
import com.ruoyi.system.service.TronServiceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -17,7 +18,6 @@ import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
/**
* 轮询已确认 TRC20 转账,按地址、六位金额和唯一交易哈希入账。
@@ -30,6 +30,8 @@ public class TronPaymentTask {
private IUsdtOrdersService orders;
@Autowired
private TronServiceProvider tronServiceProvider;
@Autowired
private WalletLedgerPostingService ledgerPostingService;
private final RestTemplate http = new RestTemplate();
@Scheduled(fixedDelay = 30000L)
@@ -55,13 +57,9 @@ public class TronPaymentTask {
if (value.compareTo(order.getActualAmount().setScale(6, RoundingMode.DOWN)) != 0) continue;
String hash = tx.getString("transaction_id");
if (hash == null || hash.trim().isEmpty()) continue;
if (orders.count(new LambdaQueryWrapper<UsdtOrdersPlus>().eq(UsdtOrdersPlus::getBlockTransactionId, hash)) > 0)
continue;
order.setBlockTransactionId(hash);
order.setStatus(2L);
order.setUpdatedAt(new Date());
orders.updateById(order);
break;
if (ledgerPostingService.settlePaidOrder(order.getId(), hash)) {
break;
}
}
} catch (Exception e) {
// 单笔订单查询失败不能中断其他订单,日志中禁止输出凭证和钱包私钥。