监听账户页面实现查询trx和usdt余额

pull/520/head
dorion 2024-05-25 02:11:25 +08:00
parent dabd9aefb6
commit 46f199145f
21 changed files with 724 additions and 242 deletions

View File

@ -8,6 +8,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DictUtils; import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.vo.MonitorAddressInfoVO;
import com.ruoyi.system.service.IAccountAddressInfoService; import com.ruoyi.system.service.IAccountAddressInfoService;
import com.ruoyi.system.service.IMonitorAddressInfoService; import com.ruoyi.system.service.IMonitorAddressInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
@ -52,7 +53,7 @@ public class Trx2EnergyMonitorAddressInfoController extends BaseController
{ {
startPage(); startPage();
monitorAddressInfo.setBusiType(DictUtils.getDictValue("sys_busi_type", "TRX兑能量")); monitorAddressInfo.setBusiType(DictUtils.getDictValue("sys_busi_type", "TRX兑能量"));
List<MonitorAddressInfo> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo); List<MonitorAddressInfoVO> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo);
return getDataTable(list); return getDataTable(list);
} }
@ -66,8 +67,8 @@ public class Trx2EnergyMonitorAddressInfoController extends BaseController
public AjaxResult export(MonitorAddressInfo monitorAddressInfo) public AjaxResult export(MonitorAddressInfo monitorAddressInfo)
{ {
monitorAddressInfo.setBusiType(DictUtils.getDictValue("sys_busi_type", "TRX兑能量")); monitorAddressInfo.setBusiType(DictUtils.getDictValue("sys_busi_type", "TRX兑能量"));
List<MonitorAddressInfo> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo); List<MonitorAddressInfoVO> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo);
ExcelUtil<MonitorAddressInfo> util = new ExcelUtil<MonitorAddressInfo>(MonitorAddressInfo.class); ExcelUtil<MonitorAddressInfoVO> util = new ExcelUtil<MonitorAddressInfoVO>(MonitorAddressInfoVO.class);
return util.exportExcel(list, "监听账户入账数据"); return util.exportExcel(list, "监听账户入账数据");
} }

View File

@ -8,6 +8,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DictUtils; import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.vo.MonitorAddressInfoVO;
import com.ruoyi.system.service.IAccountAddressInfoService; import com.ruoyi.system.service.IAccountAddressInfoService;
import com.ruoyi.system.service.IMonitorAddressInfoService; import com.ruoyi.system.service.IMonitorAddressInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
@ -52,7 +53,7 @@ public class Usdt2TrxMonitorAddressInfoController extends BaseController
{ {
startPage(); startPage();
monitorAddressInfo.setBusiType(DictUtils.getDictValue("sys_busi_type", "USDT兑TRX")); monitorAddressInfo.setBusiType(DictUtils.getDictValue("sys_busi_type", "USDT兑TRX"));
List<MonitorAddressInfo> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo); List<MonitorAddressInfoVO> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo);
return getDataTable(list); return getDataTable(list);
} }
@ -66,8 +67,8 @@ public class Usdt2TrxMonitorAddressInfoController extends BaseController
public AjaxResult export(MonitorAddressInfo monitorAddressInfo) public AjaxResult export(MonitorAddressInfo monitorAddressInfo)
{ {
monitorAddressInfo.setBusiType(DictUtils.getDictValue("sys_busi_type", "USDT兑TRX")); monitorAddressInfo.setBusiType(DictUtils.getDictValue("sys_busi_type", "USDT兑TRX"));
List<MonitorAddressInfo> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo); List<MonitorAddressInfoVO> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo);
ExcelUtil<MonitorAddressInfo> util = new ExcelUtil<MonitorAddressInfo>(MonitorAddressInfo.class); ExcelUtil<MonitorAddressInfoVO> util = new ExcelUtil<MonitorAddressInfoVO>(MonitorAddressInfoVO.class);
return util.exportExcel(list, "监听账户入账数据"); return util.exportExcel(list, "监听账户入账数据");
} }

View File

@ -71,7 +71,13 @@
}, },
{ {
field: 'address', field: 'address',
title: '地址' title: '地址',
formatter: function (value, row, index) {
if (value == null) {
return value;
}
return "<a href='https://www.oklink.com/zh-hans/trx/address/" + value + "' target='_blank'>" + value + "</a>";
}
}, { }, {
field: 'busiType', field: 'busiType',
title: '业务类型', title: '业务类型',

View File

@ -1,197 +1,226 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"> <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head> <head>
<th:block th:include="include :: header('监听账户入账列表')" /> <th:block th:include="include :: header('监听账户入账列表')"/>
</head> </head>
<body class="gray-bg"> <body class="gray-bg">
<div class="container-div"> <div class="container-div">
<div class="row"> <div class="row">
<div class="col-sm-12 search-collapse"> <div class="col-sm-12 search-collapse">
<form id="formId"> <form id="formId">
<div class="select-list"> <div class="select-list">
<ul> <ul>
<li> <li>
<label>监听地址:</label> <label>监听地址:</label>
<input type="text" name="monitorAddress"/> <input type="text" name="monitorAddress"/>
</li> </li>
<li> <li>
<label>出账地址:</label> <label>出账地址:</label>
<input type="text" name="accountAddress"/> <input type="text" name="accountAddress"/>
</li> </li>
<!-- <li> <!-- <li>
<label>单位:</label> <label>单位:</label>
<input type="text" name="price"/> <input type="text" name="price"/>
</li>--> </li>-->
<li> <li>
<label>是否有效:</label> <label>是否有效:</label>
<select class="form-control" name="isValid" th:with="type=${@dict.getType('sys_yes_no')}"> <select class="form-control" name="isValid" th:with="type=${@dict.getType('sys_yes_no')}">
<option value="">所有</option> <option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option> <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
</select> th:value="${dict.dictValue}"></option>
</li> </select>
<li> </li>
<label>监听类型:</label> <li>
<select class="form-control" name="monitorType" th:with="type=${@dict.getType('sys_monitor_type')}"> <label>监听类型:</label>
<option value="">所有</option> <select class="form-control" name="monitorType"
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option> th:with="type=${@dict.getType('sys_monitor_type')}">
</select> <option value="">所有</option>
</li> <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
<li class="select-time"> th:value="${dict.dictValue}"></option>
<label>创建时间:</label> </select>
<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginFcd]"/> </li>
<span>-</span> <li class="select-time">
<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endFcd]"/> <label>创建时间:</label>
</li> <input type="text" class="time-input" id="startTime" placeholder="开始时间"
<li> name="params[beginFcd]"/>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a> <span>-</span>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a> <input type="text" class="time-input" id="endTime" placeholder="结束时间"
</li> name="params[endFcd]"/>
</ul> </li>
</div> <li>
</form> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
</div> class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group"> <div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="trx2Energy:monitor:add"> <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="trx2Energy:monitor:add">
<i class="fa fa-plus"></i> 添加 <i class="fa fa-plus"></i> 添加
</a> </a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="trx2Energy:monitor:edit"> <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
<i class="fa fa-edit"></i> 修改 shiro:hasPermission="trx2Energy:monitor:edit">
</a> <i class="fa fa-edit"></i> 修改
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="trx2Energy:monitor:remove"> </a>
<i class="fa fa-remove"></i> 删除 <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
</a> shiro:hasPermission="trx2Energy:monitor:remove">
<!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="trx2Energy:monitor:export"> <i class="fa fa-remove"></i> 删除
<i class="fa fa-download"></i> 导出 </a>
</a>--> <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="trx2Energy:monitor:export">
</div> <i class="fa fa-download"></i> 导出
<div class="col-sm-12 select-table table-striped"> </a>-->
<table id="bootstrap-table"></table> </div>
</div> <div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div> </div>
</div> </div>
<th:block th:include="include :: footer" /> </div>
<script th:inline="javascript"> <th:block th:include="include :: footer"/>
var editFlag = [[${@permission.hasPermi('trx2Energy:monitor:edit')}]]; <script th:inline="javascript">
var removeFlag = [[${@permission.hasPermi('trx2Energy:monitor:remove')}]]; var editFlag = [[${@permission.hasPermi('trx2Energy:monitor:edit')}]];
var prefix = ctx + "trx2Energy/monitor"; var removeFlag = [[${@permission.hasPermi('trx2Energy:monitor:remove')}]];
var datas = [[${@dict.getType('sys_yes_no')}]]; var prefix = ctx + "trx2Energy/monitor";
var apiKeyDatas = [[${@dict.getType('sys_tron_api_key')}]]; var datas = [[${@dict.getType('sys_yes_no')}]];
var busiTypeDatas = [[${@dict.getType('sys_busi_type')}]]; var apiKeyDatas = [[${@dict.getType('sys_tron_api_key')}]];
var bindPeriodDatas = [[${@dict.getType('sys_lock_period')}]]; var busiTypeDatas = [[${@dict.getType('sys_busi_type')}]];
$(function() { var bindPeriodDatas = [[${@dict.getType('sys_lock_period')}]];
var options = { $(function () {
url: prefix + "/list", var options = {
createUrl: prefix + "/add", url: prefix + "/list",
updateUrl: prefix + "/edit/{id}", createUrl: prefix + "/add",
removeUrl: prefix + "/remove", updateUrl: prefix + "/edit/{id}",
exportUrl: prefix + "/export", removeUrl: prefix + "/remove",
modalName: "监听账户入账", exportUrl: prefix + "/export",
columns: [{ modalName: "监听账户入账",
checkbox: true columns: [{
}, checkbox: true
},
{ {
field: 'idMonitorAddress', field: 'idMonitorAddress',
title: '主键', title: '主键',
visible: false visible: false
}, },
{ {
field: 'monitorAddressName', field: 'monitorAddressName',
title: '地址别名' title: '地址别名'
}, },
{ {
field: 'monitorAddress', field: 'monitorAddress',
title: '监听地址' title: '监听地址',
formatter: function (value, row, index) {
if (value == null) {
return value;
}
return "<a href='https://www.oklink.com/zh-hans/trx/address/" + value + "' target='_blank'>" + value + "</a>";
}
},
{
field: 'trxBalance',
title: 'TRX余额'
},
{
field: 'usdtBalance',
title: 'USDT余额'
}, { }, {
field: 'busiType', field: 'busiType',
title: '业务类型', title: '业务类型',
formatter: function(value, row, index) { formatter: function (value, row, index) {
return $.table.selectDictLabel(busiTypeDatas, value); return $.table.selectDictLabel(busiTypeDatas, value);
},
visible: false
}, },
visible: false
},
{ {
field: 'accountAddress', field: 'accountAddress',
title: '出账地址' title: '出账地址',
formatter: function (value, row, index) {
if (value == null) {
return value;
}
return "<a href='https://www.oklink.com/zh-hans/trx/address/" + value + "' target='_blank'>" + value + "</a>";
}
}, },
{ {
field: 'trxPrice', field: 'trxPrice',
title: 'TRX兑换单价', title: 'TRX兑换单价',
formatter: function(value, row, index) { formatter: function (value, row, index) {
if (value == null) { if (value == null) {
return value; return value;
} }
return value + ' TRX'; return value + ' TRX';
},
}, },
{ },
field: 'usdtPrice', {
title: 'USDT兑换单价', field: 'usdtPrice',
formatter: function(value, row, index) { title: 'USDT兑换单价',
if (value == null) { formatter: function (value, row, index) {
return value; if (value == null) {
} return value;
return value + ' USDT'; }
}, return value + ' USDT';
}, },
},
{ {
field: 'apiKey', field: 'apiKey',
title: 'API_KEY', title: 'API_KEY',
formatter: function(value, row, index) { formatter: function (value, row, index) {
return $.table.selectDictLabel(apiKeyDatas, value); return $.table.selectDictLabel(apiKeyDatas, value);
} }
}, { }, {
field: 'bindPeriod', field: 'bindPeriod',
title: '绑定时长', title: '绑定时长',
formatter: function(value, row, index) { formatter: function (value, row, index) {
return $.table.selectDictLabel(bindPeriodDatas, value); return $.table.selectDictLabel(bindPeriodDatas, value);
} }
}, },
{ {
field: 'isValid', field: 'isValid',
title: '是否有效', title: '是否有效',
formatter: function(value, item, index) { formatter: function (value, item, index) {
return $.table.selectDictLabel(datas, item.isValid); return $.table.selectDictLabel(datas, item.isValid);
} }
}, { }, {
field: 'comment', field: 'comment',
title: '备注' title: '备注'
}, },
{ {
field: 'fcd', field: 'fcd',
title: '创建时间', title: '创建时间',
visible: false visible: false
}, },
{ {
field: 'fcu', field: 'fcu',
title: '创建用户', title: '创建用户',
visible: false visible: false
}, },
{ {
field: 'lcd', field: 'lcd',
title: '更新时间', title: '更新时间',
visible: false visible: false
}, },
{ {
field: 'lcu', field: 'lcu',
title: '更新用户', title: '更新用户',
visible: false visible: false
}, },
{ {
title: '操作', title: '操作',
align: 'center', align: 'center',
formatter: function(value, row, index) { formatter: function (value, row, index) {
var actions = []; var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.idMonitorAddress + '\')"><i class="fa fa-edit"></i>编辑</a> '); actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.idMonitorAddress + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.idMonitorAddress + '\')"><i class="fa fa-remove"></i>删除</a>'); actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.idMonitorAddress + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join(''); return actions.join('');
} }
}] }]
}; };
$.table.init(options); $.table.init(options);
}); });
</script> </script>
</body> </body>
</html> </html>

View File

@ -98,7 +98,13 @@
}, },
{ {
field: 'receiverAddress', field: 'receiverAddress',
title: '接收能量地址' title: '接收能量地址',
formatter: function (value, row, index) {
if (value == null) {
return value;
}
return "<a href='https://www.oklink.com/zh-hans/trx/address/" + value + "' target='_blank'>" + value + "</a>";
}
}, },
{ {
field: 'monitorAddress', field: 'monitorAddress',

View File

@ -71,7 +71,13 @@
}, },
{ {
field: 'address', field: 'address',
title: '地址' title: '地址',
formatter: function (value, row, index) {
if (value == null) {
return value;
}
return "<a href='https://www.oklink.com/zh-hans/trx/address/" + value + "' target='_blank'>" + value + "</a>";
}
}, { }, {
field: 'busiType', field: 'busiType',
title: '业务类型', title: '业务类型',

View File

@ -101,8 +101,22 @@
}, },
{ {
field: 'monitorAddress', field: 'monitorAddress',
title: '监听地址' title: '监听地址',
}, { formatter: function (value, row, index) {
if (value == null) {
return value;
}
return "<a href='https://www.oklink.com/zh-hans/trx/address/" + value + "' target='_blank'>" + value + "</a>";
}
},
{
field: 'trxBalance',
title: 'TRX余额'
},
{
field: 'usdtBalance',
title: 'USDT余额'
}, {
field: 'busiType', field: 'busiType',
title: '业务类型', title: '业务类型',
formatter: function(value, row, index) { formatter: function(value, row, index) {
@ -111,7 +125,13 @@
}, },
{ {
field: 'accountAddress', field: 'accountAddress',
title: '出账地址' title: '出账地址',
formatter: function (value, row, index) {
if (value == null) {
return value;
}
return "<a href='https://www.oklink.com/zh-hans/trx/address/" + value + "' target='_blank'>" + value + "</a>";
}
}, },
{ {

View File

@ -0,0 +1,7 @@
package com.ruoyi.system.api;
import com.ruoyi.system.api.entity.tronscan.AccountResponse;
public interface ITronScanApi {
AccountResponse getAccount(String monitorAddress);
}

View File

@ -0,0 +1,64 @@
package com.ruoyi.system.api.entity.tronscan;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class AccountResponse implements Serializable {
private static final long serialVersionUID = 1L;
private long totalFrozenV2;
private int transactions_out;
private long frozenForEnergyV2;
private int rewardNum;
private int delegatedFrozenV2BalanceForBandwidth;
private OwnerPermission ownerPermission;
private String redTag;
private int delegateFrozenForEnergy;
private long balance;
private long frozenForBandWidthV2;
private int canWithdrawAmountV2;
private int transactions_in;
private int totalTransactionCount;
private Representative representative;
private String announcement;
private List<String> allowExchange;
private int accountType;
private List<String> exchanges;
private Frozen frozen;
private int transactions;
private long delegatedFrozenV2BalanceForEnergy;
private String name;
private int frozenForEnergy;
private double energyCost;
private List<ActivePermissions> activePermissions;
private int acquiredDelegatedFrozenV2BalanceForBandwidth;
private double netCost;
private int acquiredDelegateFrozenForBandWidth;
private String greyTag;
private String publicTag;
private List<WithPriceTokens> withPriceTokens;
private int unfreezeV2;
private boolean feedbackRisk;
private int voteTotal;
private int totalFrozen;
private long latest_operation_time;
private int frozenForBandWidth;
private int reward;
private String addressTagLogo;
private String address;
private List<String> frozen_supply;
private Bandwidth bandwidth;
private long date_created;
private long acquiredDelegatedFrozenV2BalanceForEnergy;
private String blueTag;
private int witness;
private long freezing;
private int delegateFrozenForBandWidth;
private boolean activated;
private int acquiredDelegateFrozenForEnergy;
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.system.api.entity.tronscan;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class ActivePermissions implements Serializable {
private static final long serialVersionUID = 1L;
private String operations;
private List<Keys> keys;
private int threshold;
private int id;
private String type;
private String permission_name;
}

View File

@ -0,0 +1,32 @@
package com.ruoyi.system.api.entity.tronscan;
import lombok.Data;
import java.io.Serializable;
@Data
public class Bandwidth implements Serializable {
private static final long serialVersionUID = 1L;
private long energyRemaining;
private long totalEnergyLimit;
private long totalEnergyWeight;
private int netUsed;
private int storageLimit;
private int storagePercentage;
private double netPercentage;
private int storageUsed;
private int storageRemaining;
private int freeNetLimit;
private long energyUsed;
private int freeNetRemaining;
private int netLimit;
private int netRemaining;
private long energyLimit;
private int freeNetUsed;
private long totalNetWeight;
private int freeNetPercentage;
private double energyPercentage;
private long totalNetLimit;
}

View File

@ -0,0 +1,14 @@
package com.ruoyi.system.api.entity.tronscan;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class Frozen implements Serializable {
private static final long serialVersionUID = 1L;
private int total;
private List<String> balances;
}

View File

@ -0,0 +1,15 @@
package com.ruoyi.system.api.entity.tronscan;
import lombok.Data;
import java.io.Serializable;
@Data
public class Keys implements Serializable {
private static final long serialVersionUID = 1L;
private String address;
private int weight;
}

View File

@ -0,0 +1,16 @@
package com.ruoyi.system.api.entity.tronscan;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class OwnerPermission implements Serializable {
private static final long serialVersionUID = 1L;
private List<Keys> keys;
private int threshold;
private String permission_name;
}

View File

@ -0,0 +1,17 @@
package com.ruoyi.system.api.entity.tronscan;
import lombok.Data;
import java.io.Serializable;
@Data
public class Representative implements Serializable {
private static final long serialVersionUID = 1L;
private int lastWithDrawTime;
private int allowance;
private boolean enabled;
private String url;
}

View File

@ -0,0 +1,23 @@
package com.ruoyi.system.api.entity.tronscan;
import lombok.Data;
import java.io.Serializable;
@Data
public class WithPriceTokens implements Serializable {
private static final long serialVersionUID = 1L;
private String amount;
private int tokenPriceInTrx;
private String tokenId;
private String balance;
private String tokenName;
private int tokenDecimal;
private String tokenAbbr;
private int tokenCanShow;
private String tokenType;
private boolean vip;
private String tokenLogo;
}

View File

@ -0,0 +1,58 @@
package com.ruoyi.system.api.impl;
import com.ruoyi.common.utils.http.RestTemplateUtils;
import com.ruoyi.system.api.ITronScanApi;
import com.ruoyi.system.api.entity.tronscan.AccountResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@Component
@Slf4j
public class TronScanApiImpl implements ITronScanApi {
private static List<String> apiKeyList = new ArrayList();
static {
apiKeyList.add("3ee210c5-6508-4868-8feb-c1199cec9599");
apiKeyList.add("6c06ab7f-5020-4ddd-9502-1c8fb708a16b");
apiKeyList.add("830092eb-82b3-4f75-a9d7-a75cd5ce3bec");
}
@Override
public AccountResponse getAccount(String monitorAddress) {
Random random = new Random();
int i = random.nextInt(3);
HttpHeaders headers = new HttpHeaders();
// Collections.shuffle(apiKeyList);
String headerValue = apiKeyList.get(i);
log.info("tronscan api key:{}", headerValue);
headers.add("TRON-PRO-API-KEY", headerValue);
ResponseEntity<AccountResponse> responseResponseEntity = RestTemplateUtils.get("https://apilist.tronscanapi.com/api/accountv2?address=" + monitorAddress, headers, AccountResponse.class);
if (responseResponseEntity == null) {
return null;
}
HttpStatus statusCode = responseResponseEntity.getStatusCode();
if (statusCode != HttpStatus.OK) {
log.error("获取trx交易信息失败:{}", monitorAddress);
return null;
}
AccountResponse body = responseResponseEntity.getBody();
if (body == null) {
return null;
}
return body;
}
}

View File

@ -0,0 +1,97 @@
package com.ruoyi.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.Date;
/**
* monitor_address_info
*
* @author dorion
* @date 2024-04-14
*/
@Data
@Accessors(chain = true)
public class MonitorAddressInfoVO
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long idMonitorAddress;
/** 业务类型 */
@Excel(name = "业务类型")
private String busiType;
/** 地址别名 */
@Excel(name = "地址别名")
private String monitorAddressName;
/** 监听地址 */
@Excel(name = "监听地址")
private String monitorAddress;
@Excel(name = "TRX余额")
private BigDecimal trxBalance;
@Excel(name = "USDT余额")
private BigDecimal usdtBalance;
/** 出账地址 */
@Excel(name = "出账地址")
private String accountAddress;
/** trx兑换单价 */
@Excel(name = "trx兑换单价")
private Long trxPrice;
/** usdt兑换单价 */
@Excel(name = "usdt兑换单价")
private BigDecimal usdtPrice;
/** trx或者usdt */
@Excel(name = "trx或者usdt")
private String monitorType;
/** API_KEY */
@Excel(name = "API_KEY")
private String apiKey;
/** 是否有效 */
@Excel(name = "是否有效")
private String isValid;
/** 绑定时长 */
@Excel(name = "绑定时长")
private String bindPeriod;
/** 备注 */
@Excel(name = "备注")
private String comment;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date fcd;
/** 创建用户 */
@Excel(name = "创建用户")
private String fcu;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date lcd;
/** 更新用户 */
@Excel(name = "更新用户")
private String lcu;
}

View File

@ -1,116 +1,125 @@
package com.ruoyi.system.domain.vo; package com.ruoyi.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Sensitive;
import com.ruoyi.common.enums.DesensitizedType;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
@Data @Data
public class TrxExchangeInfoVO { public class TrxExchangeInfoVO {
/**
*
*/
private String idTrxExchangeInfo;
/** private static final long serialVersionUID = 1L;
*
*/ /** trx进账表 */
private Long idTrxExchangeInfo;
/** 转出账户 */
@Excel(name = "付款账户")
private String fromAddress; private String fromAddress;
/** /**
* *
*/ */
private String toAddress; @Excel(name = "收款账户别名")
/**
*
*/
private String monitorAddressName; private String monitorAddressName;
/** /** 转入账户 */
* @Excel(name = "转入账户")
*/ @Sensitive(desensitizedType = DesensitizedType.WALLET_ADDRESS)
private String toAddress;
/* @Excel(name = "监听账户别名")
private String monitorAddressName;*/
/** 实际出账账户 */
@Excel(name = "实际出账账户")
@Sensitive(desensitizedType = DesensitizedType.WALLET_ADDRESS)
private String accountAddress; private String accountAddress;
/** /** 单位 */
* @Excel(name = "单价")
*/ private Long price;
private Integer price;
/** /** 订单hash */
* @Excel(name = "TRX订单")
*/
private String trxTxId; private String trxTxId;
/** /** 笔数 */
* @Excel(name = "笔数")
*/ private Long tranferCount;
private String tranferCount;
/**
*
*/ /** 业务类型 */
@Excel(name = "业务类型")
private String energyBusiType; private String energyBusiType;
/**
*
*/
private String trxAmount;
/** /** 转入金额 */
* @Excel(name = "转入金额")
*/ private Long trxAmount;
/** 转入单位 */
@Excel(name = "转入单位")
private String trxAmountUnit; private String trxAmountUnit;
/** /** 兑换支出能量 */
* @Excel(name = "兑换支出TRX")
*/ private Long delegateAmountTrx;
private String delegateAmountTrx;
/** /** 资源类型 */
* @Excel(name = "资源类型")
*/
private String resourceCode; private String resourceCode;
/**
* /** 能量交易订单hash */
*/ @Excel(name = "能量交易订单")
private String delegateTxId; private String delegateTxId;
/** /** 锁定周期 */
* @Excel(name = "锁定周期")
*/ private Long lockPeriod;
private String lockPeriod;
/** /** 资源委托状态 */
* @Excel(name = "资源状态")
*/
private String delegateStatus; private String delegateStatus;
/** 笔数计算规则 */
@Excel(name = "笔数计算规则")
private String calcRule;
/** /** 回收资源交易id */
* @Excel(name = "回收资源交易")
*/
private String unDelegateTxId; private String unDelegateTxId;
/**
* /** 创建时间 */
*/ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date fcd; private Date fcd;
/** /** 创建用户 */
* @Excel(name = "创建用户")
*/
private String fcu; private String fcu;
/** /** 更新时间 */
* @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
*/ @Excel(name = "更新时间", width = 30, dateFormat ="yyyy-MM-dd HH:mm:ss")
private Date lcd; private Date lcd;
/** /** 更新用户 */
* @Excel(name = "更新用户")
*/
private String lcu; private String lcu;
private String calcRule;
} }

View File

@ -3,6 +3,7 @@ package com.ruoyi.system.service;
import com.ruoyi.common.core.domain.entity.MonitorAddressInfo; import com.ruoyi.common.core.domain.entity.MonitorAddressInfo;
import com.ruoyi.system.domain.MonitorAddressAccount; import com.ruoyi.system.domain.MonitorAddressAccount;
import com.ruoyi.system.domain.vo.MonitorAddressInfoVO;
import java.util.List; import java.util.List;
@ -28,7 +29,7 @@ public interface IMonitorAddressInfoService
* @param monitorAddressInfo * @param monitorAddressInfo
* @return * @return
*/ */
public List<MonitorAddressInfo> selectMonitorAddressInfoList(MonitorAddressInfo monitorAddressInfo); public List<MonitorAddressInfoVO> selectMonitorAddressInfoList(MonitorAddressInfo monitorAddressInfo);
/** /**
* *

View File

@ -3,14 +3,24 @@ package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.domain.entity.MonitorAddressInfo; import com.ruoyi.common.core.domain.entity.MonitorAddressInfo;
import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.system.api.ITronScanApi;
import com.ruoyi.system.api.entity.tronscan.AccountResponse;
import com.ruoyi.system.api.entity.tronscan.WithPriceTokens;
import com.ruoyi.system.domain.MonitorAddressAccount; import com.ruoyi.system.domain.MonitorAddressAccount;
import com.ruoyi.system.domain.vo.MonitorAddressInfoVO;
import com.ruoyi.system.mapper.MonitorAddressInfoMapper; import com.ruoyi.system.mapper.MonitorAddressInfoMapper;
import com.ruoyi.system.service.IMonitorAddressInfoService; import com.ruoyi.system.service.IMonitorAddressInfoService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/** /**
* Service * Service
@ -24,6 +34,9 @@ public class MonitorAddressInfoServiceImpl implements IMonitorAddressInfoService
@Autowired @Autowired
private MonitorAddressInfoMapper monitorAddressInfoMapper; private MonitorAddressInfoMapper monitorAddressInfoMapper;
@Autowired
private ITronScanApi tronScanApi;
/** /**
* *
@ -43,8 +56,37 @@ public class MonitorAddressInfoServiceImpl implements IMonitorAddressInfoService
* @return * @return
*/ */
@Override @Override
public List<MonitorAddressInfo> selectMonitorAddressInfoList(MonitorAddressInfo monitorAddressInfo) { public List<MonitorAddressInfoVO> selectMonitorAddressInfoList(MonitorAddressInfo monitorAddressInfo) {
return monitorAddressInfoMapper.selectMonitorAddressInfoList(monitorAddressInfo); List<MonitorAddressInfo> monitorAddressInfoList = monitorAddressInfoMapper.selectMonitorAddressInfoList(monitorAddressInfo);
List<MonitorAddressInfoVO> monitorAddressInfoVOList = new ArrayList<>();
monitorAddressInfoList.parallelStream().forEach(monitorAddressInfo1 -> {
AccountResponse accountResponse = tronScanApi.getAccount(monitorAddressInfo1.getMonitorAddress());
Optional.ofNullable(accountResponse).ifPresent(accountResponse1 -> {
MonitorAddressInfoVO monitorAddressInfoVO = new MonitorAddressInfoVO();
BeanUtils.copyProperties(monitorAddressInfo1,monitorAddressInfoVO);
List<WithPriceTokens> withPriceTokens = accountResponse1.getWithPriceTokens();
Optional.ofNullable(withPriceTokens).ifPresent(withPriceTokens1 -> {
withPriceTokens1.forEach(withPriceToken -> {
String tokenType = withPriceToken.getTokenType();
String balance = withPriceToken.getBalance();
BigDecimal finalBalance = new BigDecimal(balance).movePointLeft(withPriceToken.getTokenDecimal());
if ("trc10".equals(tokenType)){
monitorAddressInfoVO.setTrxBalance(finalBalance);
}else if ("trc20".equals(tokenType)){
monitorAddressInfoVO.setUsdtBalance(finalBalance);
}
});
});
monitorAddressInfoVOList.add(monitorAddressInfoVO);
});
});
List<MonitorAddressInfoVO> sortedMonitorAddressInfoVOList = monitorAddressInfoVOList.stream().sorted(Comparator.comparingLong(MonitorAddressInfoVO::getIdMonitorAddress))
.collect(Collectors.toList());
return sortedMonitorAddressInfoVOList;
} }
/** /**