优化代码
This commit is contained in:
1 parent
ed738d3da6
commit
4048428169
14 files changed
+381
-309
No files matched your search
@@ -7,6 +7,9 @@ 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.TronServiceProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -21,14 +24,23 @@ import java.util.Date;
|
||||
*/
|
||||
@Component
|
||||
public class TronPaymentTask {
|
||||
private static final Logger log = LoggerFactory.getLogger(TronPaymentTask.class);
|
||||
|
||||
@Autowired
|
||||
private IUsdtOrdersService orders;
|
||||
@Autowired
|
||||
private ITronService tron;
|
||||
private TronServiceProvider tronServiceProvider;
|
||||
private final RestTemplate http = new RestTemplate();
|
||||
|
||||
@Scheduled(fixedDelay = 30000L)
|
||||
public void scan() {
|
||||
ITronService tron;
|
||||
try {
|
||||
tron = tronServiceProvider.getCurrentService();
|
||||
} catch (RuntimeException e) {
|
||||
log.warn("无法读取 TRON 全局网络配置,跳过本轮支付扫描:{}", e.getMessage());
|
||||
return;
|
||||
}
|
||||
for (UsdtOrdersPlus order : orders.list(new LambdaQueryWrapper<UsdtOrdersPlus>().eq(UsdtOrdersPlus::getStatus, 1))) {
|
||||
if (order.getToken() == null || order.getActualAmount() == null) continue;
|
||||
try {
|
||||
@@ -51,8 +63,11 @@ public class TronPaymentTask {
|
||||
orders.updateById(order);
|
||||
break;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
// 单笔订单查询失败不能中断其他订单,日志中禁止输出凭证和钱包私钥。
|
||||
log.warn("查询 TRON 支付交易失败,订单ID={},网络={}", order.getId(), tron.type());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user