监听账户页面实现查询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.utils.DictUtils;
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.IMonitorAddressInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
@ -52,7 +53,7 @@ public class Trx2EnergyMonitorAddressInfoController extends BaseController
{
startPage();
monitorAddressInfo.setBusiType(DictUtils.getDictValue("sys_busi_type", "TRX兑能量"));
List<MonitorAddressInfo> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo);
List<MonitorAddressInfoVO> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo);
return getDataTable(list);
}
@ -66,8 +67,8 @@ public class Trx2EnergyMonitorAddressInfoController extends BaseController
public AjaxResult export(MonitorAddressInfo monitorAddressInfo)
{
monitorAddressInfo.setBusiType(DictUtils.getDictValue("sys_busi_type", "TRX兑能量"));
List<MonitorAddressInfo> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo);
ExcelUtil<MonitorAddressInfo> util = new ExcelUtil<MonitorAddressInfo>(MonitorAddressInfo.class);
List<MonitorAddressInfoVO> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo);
ExcelUtil<MonitorAddressInfoVO> util = new ExcelUtil<MonitorAddressInfoVO>(MonitorAddressInfoVO.class);
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.utils.DictUtils;
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.IMonitorAddressInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
@ -52,7 +53,7 @@ public class Usdt2TrxMonitorAddressInfoController extends BaseController
{
startPage();
monitorAddressInfo.setBusiType(DictUtils.getDictValue("sys_busi_type", "USDT兑TRX"));
List<MonitorAddressInfo> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo);
List<MonitorAddressInfoVO> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo);
return getDataTable(list);
}
@ -66,8 +67,8 @@ public class Usdt2TrxMonitorAddressInfoController extends BaseController
public AjaxResult export(MonitorAddressInfo monitorAddressInfo)
{
monitorAddressInfo.setBusiType(DictUtils.getDictValue("sys_busi_type", "USDT兑TRX"));
List<MonitorAddressInfo> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo);
ExcelUtil<MonitorAddressInfo> util = new ExcelUtil<MonitorAddressInfo>(MonitorAddressInfo.class);
List<MonitorAddressInfoVO> list = monitorAddressInfoService.selectMonitorAddressInfoList(monitorAddressInfo);
ExcelUtil<MonitorAddressInfoVO> util = new ExcelUtil<MonitorAddressInfoVO>(MonitorAddressInfoVO.class);
return util.exportExcel(list, "监听账户入账数据");
}

View File

@ -71,7 +71,13 @@
},
{
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',
title: '业务类型',

View File

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

View File

@ -98,7 +98,13 @@
},
{
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',

View File

@ -71,7 +71,13 @@
},
{
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',
title: '业务类型',

View File

@ -101,8 +101,22 @@
},
{
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',
title: '业务类型',
formatter: function(value, row, index) {
@ -111,7 +125,13 @@
},
{
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;
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 java.util.Date;
@Data
public class TrxExchangeInfoVO {
/**
*
*/
private String idTrxExchangeInfo;
/**
*
*/
private static final long serialVersionUID = 1L;
/** trx进账表 */
private Long idTrxExchangeInfo;
/** 转出账户 */
@Excel(name = "付款账户")
private String fromAddress;
/**
*
*/
private String toAddress;
/**
*
*/
@Excel(name = "收款账户别名")
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 Integer price;
/** 单位 */
@Excel(name = "单价")
private Long price;
/**
*
*/
/** 订单hash */
@Excel(name = "TRX订单")
private String trxTxId;
/**
*
*/
private String tranferCount;
/** 笔数 */
@Excel(name = "笔数")
private Long tranferCount;
/**
*
*/
/** 业务类型 */
@Excel(name = "业务类型")
private String energyBusiType;
/**
*
*/
private String trxAmount;
/**
*
*/
/** 转入金额 */
@Excel(name = "转入金额")
private Long trxAmount;
/** 转入单位 */
@Excel(name = "转入单位")
private String trxAmountUnit;
/**
*
*/
private String delegateAmountTrx;
/** 兑换支出能量 */
@Excel(name = "兑换支出TRX")
private Long delegateAmountTrx;
/**
*
*/
/** 资源类型 */
@Excel(name = "资源类型")
private String resourceCode;
/**
*
*/
/** 能量交易订单hash */
@Excel(name = "能量交易订单")
private String delegateTxId;
/**
*
*/
private String lockPeriod;
/** 锁定周期 */
@Excel(name = "锁定周期")
private Long lockPeriod;
/**
*
*/
/** 资源委托状态 */
@Excel(name = "资源状态")
private String delegateStatus;
/** 笔数计算规则 */
@Excel(name = "笔数计算规则")
private String calcRule;
/**
*
*/
/** 回收资源交易id */
@Excel(name = "回收资源交易")
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;
/**
*
*/
/** 创建用户 */
@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;
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.system.domain.MonitorAddressAccount;
import com.ruoyi.system.domain.vo.MonitorAddressInfoVO;
import java.util.List;
@ -24,11 +25,11 @@ public interface IMonitorAddressInfoService
/**
*
*
*
* @param monitorAddressInfo
* @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.text.Convert;
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.vo.MonitorAddressInfoVO;
import com.ruoyi.system.mapper.MonitorAddressInfoMapper;
import com.ruoyi.system.service.IMonitorAddressInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* Service
@ -24,6 +34,9 @@ public class MonitorAddressInfoServiceImpl implements IMonitorAddressInfoService
@Autowired
private MonitorAddressInfoMapper monitorAddressInfoMapper;
@Autowired
private ITronScanApi tronScanApi;
/**
*
@ -43,8 +56,37 @@ public class MonitorAddressInfoServiceImpl implements IMonitorAddressInfoService
* @return
*/
@Override
public List<MonitorAddressInfo> selectMonitorAddressInfoList(MonitorAddressInfo monitorAddressInfo) {
return monitorAddressInfoMapper.selectMonitorAddressInfoList(monitorAddressInfo);
public List<MonitorAddressInfoVO> selectMonitorAddressInfoList(MonitorAddressInfo 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;
}
/**