diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml
index 5de38d30d..d8be3d724 100644
--- a/ruoyi-admin/pom.xml
+++ b/ruoyi-admin/pom.xml
@@ -147,7 +147,7 @@
-->
${project.artifactId}
-
+
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ApiController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ApiController.java
index 9eb5ea2ba..6af5fb8fa 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ApiController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ApiController.java
@@ -2,6 +2,8 @@ package com.ruoyi.web.controller.api;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.vo.TronInfoVO;
+import com.ruoyi.system.service.IApiService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -10,12 +12,15 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/api")
public class ApiController {
+ @Autowired
+ private IApiService apiService;
/**
* 获取波场数据
* @return
*/
@GetMapping("/tronInfo")
- public R getTronInfo() {
- return R.ok(new TronInfoVO());
+ public R getTronInfo() throws Exception {
+ TronInfoVO tronInfoVO = apiService.getTronInfo();
+ return R.ok(tronInfoVO);
}
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/trx2Energy/TrxExchangeInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/trx2Energy/TrxExchangeInfoController.java
index 8766730e8..f6b79c5bc 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/trx2Energy/TrxExchangeInfoController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/trx2Energy/TrxExchangeInfoController.java
@@ -90,7 +90,7 @@ public class TrxExchangeInfoController extends BaseController
@PostMapping("/delegate")
@ResponseBody
public AjaxResult delegate(TrxExchange trxExchange) throws Exception {
- return toAjax(trxExchangeInfoService.delegate(trxExchange,false));
+ return toAjax(trxExchangeInfoService.delegate(trxExchange,false,null));
}
/**
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/AccountAddressInfo.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/AccountAddressInfo.java
index 4994d0040..7ac221d57 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/AccountAddressInfo.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/AccountAddressInfo.java
@@ -45,6 +45,7 @@ public class AccountAddressInfo extends BaseEntity
/**
* 带宽资源
*/
+
private String netResource;
/**
@@ -61,6 +62,8 @@ public class AccountAddressInfo extends BaseEntity
* trx账户余额
*/
private BigDecimal trxBalance;
+ @Excel(isExport = false)
+ private long totalEnergyBalance;
//** 创建时间 *//*
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java
index cd3e41164..9d147136a 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java
@@ -1,27 +1,6 @@
package com.ruoyi.framework.config;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import javax.servlet.Filter;
-import org.apache.commons.io.IOUtils;
-import org.apache.shiro.cache.ehcache.EhCacheManager;
-import org.apache.shiro.codec.Base64;
-import org.apache.shiro.config.ConfigurationException;
-import org.apache.shiro.io.ResourceUtils;
-import org.apache.shiro.mgt.SecurityManager;
-import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
-import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
-import org.apache.shiro.web.mgt.CookieRememberMeManager;
-import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
-import org.apache.shiro.web.servlet.SimpleCookie;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
+import at.pollux.thymeleaf.shiro.dialect.ShiroDialect;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.CipherUtils;
@@ -38,7 +17,29 @@ import com.ruoyi.framework.shiro.web.filter.online.OnlineSessionFilter;
import com.ruoyi.framework.shiro.web.filter.sync.SyncOnlineSessionFilter;
import com.ruoyi.framework.shiro.web.session.OnlineWebSessionManager;
import com.ruoyi.framework.shiro.web.session.SpringSessionValidationScheduler;
-import at.pollux.thymeleaf.shiro.dialect.ShiroDialect;
+import org.apache.commons.io.IOUtils;
+import org.apache.shiro.cache.ehcache.EhCacheManager;
+import org.apache.shiro.codec.Base64;
+import org.apache.shiro.config.ConfigurationException;
+import org.apache.shiro.io.ResourceUtils;
+import org.apache.shiro.mgt.SecurityManager;
+import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
+import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
+import org.apache.shiro.web.mgt.CookieRememberMeManager;
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
+import org.apache.shiro.web.servlet.SimpleCookie;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.servlet.Filter;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.LinkedHashMap;
+import java.util.Map;
/**
* 权限配置加载
@@ -301,6 +302,7 @@ public class ShiroConfig
filterChainDefinitionMap.put("/login", "anon,captchaValidate");
// 注册相关
filterChainDefinitionMap.put("/register", "anon,captchaValidate");
+ filterChainDefinitionMap.put("/api/**", "anon");
// 系统权限列表
// filterChainDefinitionMap.putAll(SpringUtils.getBean(IMenuService.class).selectPermsAll());
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/EnergyTenantTransferTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/EnergyTenantTransferTask.java
index bc7622d6b..b8fd4b918 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/EnergyTenantTransferTask.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/EnergyTenantTransferTask.java
@@ -4,27 +4,30 @@ package com.ruoyi.quartz.task;
import com.ruoyi.common.core.domain.entity.TenantInfo;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.system.handler.EnergyTenantTransferHandler;
-import com.ruoyi.system.service.ITenantInfoService;
+import com.ruoyi.system.mapper.TenantInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
-@Component("energyTenantTransfer")
+@Component("energyTenantTransferTask")
public class EnergyTenantTransferTask {
@Autowired
- private ITenantInfoService tenantInfoService;
+ private TenantInfoMapper tenantInfoMapper;
@Autowired
private EnergyTenantTransferHandler energyTenantTransferHandler;
public void doEnergyTenantTransfer(){
TenantInfo tenantInfoExample = new TenantInfo();
- tenantInfoExample.setIsPaid("Y");
tenantInfoExample.setStatus(DictUtils.getDictValue("sys_tenant_status", "生效中"));
- List tenantInfoList = tenantInfoService.selectTenantInfoList(tenantInfoExample);
+ List tenantInfoList = tenantInfoMapper.selectTenantInfoList(tenantInfoExample);
for (TenantInfo tenantInfo : tenantInfoList) {
+ String isPaid = tenantInfo.getIsPaid();
+ if ("N".equals(isPaid)){
+ continue;
+ }
energyTenantTransferHandler.doEnergyTenantTransfer(tenantInfo);
}
}
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/UndelegateEnergyTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/UndelegateEnergyTask.java
index fd7f74b9d..5ad88a01f 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/UndelegateEnergyTask.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/UndelegateEnergyTask.java
@@ -25,14 +25,13 @@ public class UndelegateEnergyTask {
private UndelegateEnergyHandler undelegateEnergyHandler;
-
public void doUndelegateEnergy() {
String dictValue = DictUtils.getDictValue("sys_delegate_status", "已委托");
TrxExchangeInfo trxExchangeInfoExample = TrxExchangeInfo.builder()
.delegateStatus(dictValue)
- .fcd(DateUtil.offsetDay(new Date(),-1))
+ .fcd(DateUtil.offsetDay(new Date(),-2))
.build();
List trxExchangeMonitorAccountInfoList = trxExchangeInfoService.selectTrxExchangeMonitorAccountInfo(trxExchangeInfoExample);
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TransactionLogVO.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TransactionLogVO.java
index e877c9065..5164c0730 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TransactionLogVO.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TransactionLogVO.java
@@ -1,5 +1,7 @@
package com.ruoyi.system.domain.vo;
+import com.ruoyi.common.annotation.Sensitive;
+import com.ruoyi.common.enums.DesensitizedType;
import lombok.Data;
import lombok.experimental.Accessors;
@@ -13,6 +15,7 @@ public class TransactionLogVO implements Serializable {
/**
* 交易地址
*/
+ @Sensitive(desensitizedType = DesensitizedType.WALLET_ADDRESS)
private String fromAddress;
/**
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/handler/EnergyTenantTransferHandler.java b/ruoyi-system/src/main/java/com/ruoyi/system/handler/EnergyTenantTransferHandler.java
index 8f75cf99d..952947f0c 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/handler/EnergyTenantTransferHandler.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/handler/EnergyTenantTransferHandler.java
@@ -44,7 +44,7 @@ public class EnergyTenantTransferHandler {
TrxExchangeInfo trxExchangeInfo = TrxExchangeInfo.builder()
.fromAddress(tenantInfo.getReceiverAddress())
.delegateStatus(delegateStatus)
- .fcd(DateUtil.offsetDay(new Date(), -1))
+ .fcd(DateUtil.offsetDay(new Date(), -2))
.build();
List trxExchangeMonitorAccountInfoList = trxExchangeInfoMapper.selectTrxExchangeMonitorAccountInfo(trxExchangeInfo);
@@ -54,7 +54,7 @@ public class EnergyTenantTransferHandler {
}
//赠送每天的能量
- tenantInfoService.doDelegateEnergy(tenantInfo);
+ tenantInfoService.doDelegateEnergy(tenantInfo,"system");
} catch (Exception e) {
String exceptionString = LogUtils.doRecursiveReversePrintStackCause(e, 5, ForwardCounter.builder().count(0).build(), 5);
log.error("获取trx20交易列表异常:{}", exceptionString);
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/handler/TRX2EneryTransferHandler.java b/ruoyi-system/src/main/java/com/ruoyi/system/handler/TRX2EneryTransferHandler.java
index d93822139..4aa7640a9 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/handler/TRX2EneryTransferHandler.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/handler/TRX2EneryTransferHandler.java
@@ -20,9 +20,9 @@ import com.ruoyi.system.dto.TronGridResponse;
import com.ruoyi.system.dto.Value;
import com.ruoyi.system.mapper.ErrorLogMapper;
import com.ruoyi.system.mapper.TenantInfoMapper;
+import com.ruoyi.system.mapper.TrxExchangeInfoMapper;
import com.ruoyi.system.service.IAccountAddressInfoService;
import com.ruoyi.system.service.ISysConfigService;
-import com.ruoyi.system.service.impl.TrxExchangeInfoServiceImpl;
import com.ruoyi.system.util.AddressUtil;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
@@ -63,7 +63,7 @@ public class TRX2EneryTransferHandler {
@Autowired
private TenantInfoMapper tenantInfoMapper;
@Autowired
- private TrxExchangeInfoServiceImpl trxExchangeInfoMapper;
+ private TrxExchangeInfoMapper trxExchangeInfoMapper;
public void doMonitorTrxTransferByMonitorAddressInfo(MonitorAddressAccount monitorAddressAccount) {
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TrxExchangeInfoMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TrxExchangeInfoMapper.java
index 297e61d6f..d7184676b 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TrxExchangeInfoMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TrxExchangeInfoMapper.java
@@ -3,6 +3,7 @@ package com.ruoyi.system.mapper;
import com.ruoyi.common.core.domain.entity.TrxExchangeInfo;
import com.ruoyi.system.domain.TrxExchangeMonitorAccountInfo;
+import com.ruoyi.system.domain.vo.TransactionLogVO;
import java.util.List;
@@ -63,4 +64,6 @@ public interface TrxExchangeInfoMapper
public int deleteTrxExchangeInfoByIdTrxExchangeInfos(String[] idTrxExchangeInfos);
List selectTrxExchangeMonitorAccountInfo(TrxExchangeInfo trxExchangeInfo);
+
+ List selectTransactionLogVO();
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IAccountAddressInfoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IAccountAddressInfoService.java
index 907f34242..d37b18e8f 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IAccountAddressInfoService.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IAccountAddressInfoService.java
@@ -66,4 +66,6 @@ public interface IAccountAddressInfoService
String getDecryptPrivateKey(String address) throws Exception;
List selectAccountAddressInfoListByResouce(AccountAddressInfo accountAddressInfo) throws Exception;
+
+ void doQueryResourceInfo(AccountAddressInfo addressInfo) throws Exception;
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IApiService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IApiService.java
new file mode 100644
index 000000000..6d9f2b632
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IApiService.java
@@ -0,0 +1,8 @@
+package com.ruoyi.system.service;
+
+import com.ruoyi.system.domain.vo.TronInfoVO;
+
+public interface IApiService {
+ TronInfoVO getTronInfo() throws Exception;
+
+}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITenantInfoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITenantInfoService.java
index 810058451..aaf4ae9c4 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITenantInfoService.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITenantInfoService.java
@@ -63,5 +63,7 @@ public interface ITenantInfoService
int activeDataTenantInfoByIdTenantInfos(String ids) throws Exception;
- void doDelegateEnergy(TenantInfo tenantInfo) throws Exception;
+// void doDelegateEnergy(TenantInfo tenantInfo) throws Exception;
+
+ void doDelegateEnergy(TenantInfo tenantInfo, String userName) throws Exception;
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITrxExchangeInfoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITrxExchangeInfoService.java
index 9e7dba10e..047192c84 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITrxExchangeInfoService.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITrxExchangeInfoService.java
@@ -63,9 +63,10 @@ public interface ITrxExchangeInfoService
*/
public int deleteTrxExchangeInfoByIdTrxExchangeInfo(Long idTrxExchangeInfo);
- int delegate(TrxExchange trxExchange,Boolean isTenant) throws Exception;
+// int delegate(TrxExchange trxExchange,Boolean isTenant) throws Exception;
+ int delegate(TrxExchange trxExchange, Boolean isTenant, String userName) throws Exception;
List selectTrxExchangeMonitorAccountInfo(TrxExchangeInfo trxExchangeInfoExample);
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AccountAddressInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AccountAddressInfoServiceImpl.java
index 14f62db61..2b23a6b3e 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AccountAddressInfoServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AccountAddressInfoServiceImpl.java
@@ -150,57 +150,63 @@ public class AccountAddressInfoServiceImpl implements IAccountAddressInfoService
List accountAddressInfoList = accountAddressInfoMapper.selectAccountAddressInfoList(accountAddressInfo);
for (AccountAddressInfo addressInfo : accountAddressInfoList) {
- String encryptPrivateKey = addressInfo.getEncryptPrivateKey();
- String encryptKey = addressInfo.getEncryptKey();
-
- //解密获得秘钥
- String decryptPrivateKey = Dt.decrypt(encryptPrivateKey, encryptKey);
- String tronApiKey = DictUtils.getDictValue("sys_tron_api_key", "synp@outlook");
-
- ApiWrapper apiWrapper = ApiWrapper.ofMainnet(decryptPrivateKey,tronApiKey);
-
- String address = addressInfo.getAddress();
- Response.AccountResourceMessage accountResource = apiWrapper.getAccountResource(address);
-
- //免费带宽使用量
- long freeNetUsed = accountResource.getFreeNetUsed();
- //免费带宽上限
- long freeNetLimit = accountResource.getFreeNetLimit();
- //网络带宽消耗
- long netUsed = accountResource.getNetUsed();
- //网络上限
- long netLimit = accountResource.getNetLimit();
- //能量消耗
- long energyUsed = accountResource.getEnergyUsed();
- //能量上限
- long energyLimit = accountResource.getEnergyLimit();
-
- long totalNetUsed = freeNetUsed + netUsed;
-
- long taotalNetLimit = freeNetLimit + netLimit;
-
- long totalNetBalance = taotalNetLimit - totalNetUsed;
- long totalEnergyBalance = energyLimit - energyUsed;
-
- addressInfo.setNetResource(totalNetBalance + "/" + taotalNetLimit);
- addressInfo.setEnergyResource(totalEnergyBalance + "/" + energyLimit);
-
- Response.Account account = apiWrapper.getAccount(address);
-
- long balance = account.getBalance();
-
- List frozenV2List = account.getFrozenV2List();
-
- Long totalFrozen = 0L;
- for (Response.Account.FreezeV2 freezeV2 : frozenV2List) {
- totalFrozen += freezeV2.getAmount();
-
- }
- addressInfo.setTrxBalance(BigDecimal.valueOf(balance).movePointLeft(6));
- addressInfo.setTotalFrozen(BigDecimal.valueOf(totalFrozen).movePointLeft(6));
+ doQueryResourceInfo(addressInfo);
}
return accountAddressInfoList;
}
+
+ @Override
+ public void doQueryResourceInfo(AccountAddressInfo addressInfo) throws Exception {
+ String encryptPrivateKey = addressInfo.getEncryptPrivateKey();
+ String encryptKey = addressInfo.getEncryptKey();
+
+ //解密获得秘钥
+ String decryptPrivateKey = Dt.decrypt(encryptPrivateKey, encryptKey);
+ String tronApiKey = DictUtils.getDictValue("sys_tron_api_key", "synp@outlook");
+
+ ApiWrapper apiWrapper = ApiWrapper.ofMainnet(decryptPrivateKey,tronApiKey);
+
+ String address = addressInfo.getAddress();
+ Response.AccountResourceMessage accountResource = apiWrapper.getAccountResource(address);
+
+ //免费带宽使用量
+ long freeNetUsed = accountResource.getFreeNetUsed();
+ //免费带宽上限
+ long freeNetLimit = accountResource.getFreeNetLimit();
+ //网络带宽消耗
+ long netUsed = accountResource.getNetUsed();
+ //网络上限
+ long netLimit = accountResource.getNetLimit();
+ //能量消耗
+ long energyUsed = accountResource.getEnergyUsed();
+ //能量上限
+ long energyLimit = accountResource.getEnergyLimit();
+
+ long totalNetUsed = freeNetUsed + netUsed;
+
+ long taotalNetLimit = freeNetLimit + netLimit;
+
+ long totalNetBalance = taotalNetLimit - totalNetUsed;
+ long totalEnergyBalance = energyLimit - energyUsed;
+
+ addressInfo.setNetResource(totalNetBalance + "/" + taotalNetLimit);
+ addressInfo.setEnergyResource(totalEnergyBalance + "/" + energyLimit);
+ addressInfo.setTotalEnergyBalance(totalEnergyBalance);
+
+ Response.Account account = apiWrapper.getAccount(address);
+
+ long balance = account.getBalance();
+
+ List frozenV2List = account.getFrozenV2List();
+
+ Long totalFrozen = 0L;
+ for (Response.Account.FreezeV2 freezeV2 : frozenV2List) {
+ totalFrozen += freezeV2.getAmount();
+
+ }
+ addressInfo.setTrxBalance(BigDecimal.valueOf(balance).movePointLeft(6));
+ addressInfo.setTotalFrozen(BigDecimal.valueOf(totalFrozen).movePointLeft(6));
+ }
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ApiServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ApiServiceImpl.java
new file mode 100644
index 000000000..2747faa2c
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ApiServiceImpl.java
@@ -0,0 +1,84 @@
+package com.ruoyi.system.service.impl;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.github.pagehelper.PageHelper;
+import com.ruoyi.common.core.domain.entity.AccountAddressInfo;
+import com.ruoyi.common.utils.DictUtils;
+import com.ruoyi.system.domain.vo.TransactionLogVO;
+import com.ruoyi.system.domain.vo.TronInfoVO;
+import com.ruoyi.system.handler.Usdt2TrxTransferHandler;
+import com.ruoyi.system.mapper.TrxExchangeInfoMapper;
+import com.ruoyi.system.service.IAccountAddressInfoService;
+import com.ruoyi.system.service.IApiService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
+@Service
+public class ApiServiceImpl implements IApiService {
+ @Autowired
+ private IAccountAddressInfoService accountAddressInfoService;
+ @Autowired
+ private Usdt2TrxTransferHandler usdt2TrxTransferHandler;
+ @Autowired
+ private TrxExchangeInfoMapper trxExchangeInfoMapper;
+
+ @Override
+ public TronInfoVO getTronInfo() throws Exception {
+ TronInfoVO tronInfoVO = new TronInfoVO();
+
+ CompletableFuture queryTrxBalanceFuture = CompletableFuture.runAsync(() -> {
+ AccountAddressInfo accountAddressInfoExample = new AccountAddressInfo();
+ accountAddressInfoExample.setBusiType(DictUtils.getDictValue("sys_busi_type", "TRX兑能量"));
+ List accountAddressInfoList = accountAddressInfoService.selectAccountAddressInfoList(accountAddressInfoExample);
+
+
+ if (CollectionUtil.isNotEmpty(accountAddressInfoList)) {
+ AccountAddressInfo accountAddressInfo = accountAddressInfoList.get(0);
+ try {
+ accountAddressInfoService.doQueryResourceInfo(accountAddressInfo);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ long trxBalance = accountAddressInfo.getTotalEnergyBalance();
+ Long balance = trxBalance + 221000000L;
+ tronInfoVO.setEnergyRemaining(balance.toString());
+ }
+ }).exceptionally(e -> {
+ throw new RuntimeException(e);
+ });
+
+ CompletableFuture queryOkxFuture = CompletableFuture.runAsync(() -> {
+ BigDecimal oneUsdtToTrx = null;
+ try {
+ oneUsdtToTrx = usdt2TrxTransferHandler.getOneUsdtToTrx();
+// oneUsdtToTrx = BigDecimal.valueOf(7.53);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ tronInfoVO.setUsdt2TrxPrice(oneUsdtToTrx.toString());
+ }).exceptionally(e -> {
+ throw new RuntimeException(e);
+ });
+
+ CompletableFuture queryDatabaseFuture = CompletableFuture.runAsync(() -> {
+ PageHelper.startPage(0, 10).setReasonable(true);
+ List transactionLogVOList = trxExchangeInfoMapper.selectTransactionLogVO();
+ for (TransactionLogVO transactionLogVO : transactionLogVOList) {
+ transactionLogVO.setBusiType("TRX => Energy");
+ Integer energyCount = Integer.valueOf(transactionLogVO.getCount()) * 32000;
+ transactionLogVO.setCount(energyCount.toString());
+ }
+ tronInfoVO.setTransactionLogList(transactionLogVOList);
+ }).exceptionally(e -> {
+ throw new RuntimeException(e);
+ });
+
+ CompletableFuture.allOf(queryTrxBalanceFuture, queryOkxFuture, queryDatabaseFuture).join();
+
+ return tronInfoVO;
+ }
+}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TenantInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TenantInfoServiceImpl.java
index 043ff211d..7dcef642b 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TenantInfoServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TenantInfoServiceImpl.java
@@ -180,14 +180,14 @@ public class TenantInfoServiceImpl implements ITenantInfoService
Preconditions.checkState(CollectionUtil.isEmpty(trxExchangeInfos), "该接收能量地址已在任务中,请勿重复发起");
- doDelegateEnergy(tenantInfo);
+ doDelegateEnergy(tenantInfo,null);
}
return 1;
}
@Override
- public void doDelegateEnergy(TenantInfo tenantInfo) throws Exception {
+ public void doDelegateEnergy(TenantInfo tenantInfo, String userName) throws Exception {
String accountAddress = null;
String monitorAddress = null;
if (StringUtils.isNotEmpty(tenantInfo.getMonitorAddress())){
@@ -225,9 +225,12 @@ public class TenantInfoServiceImpl implements ITenantInfoService
long between = DateUtil.between(DateUtil.date(), DateUtil.endOfDay(DateUtil.date()), DateUnit.HOUR);
trxExchange.setLockNum(between + 1);
- trxExchangeInfoService.delegate(trxExchange, true);
+ userName = userName == null ? ShiroUtils.getLoginName() : userName;
+
+ trxExchangeInfoService.delegate(trxExchange, true,userName);
tenantInfo.setDelegatedDays(tenantInfo.getDelegatedDays() + 1);
+ tenantInfo.setLcd(new Date());
tenantInfoMapper.updateTenantInfo(tenantInfo);
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TrxExchangeInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TrxExchangeInfoServiceImpl.java
index 95c90c068..333678801 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TrxExchangeInfoServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TrxExchangeInfoServiceImpl.java
@@ -121,7 +121,7 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
}
@Override
- public int delegate(TrxExchange trxExchange, Boolean isTenant) throws Exception {
+ public int delegate(TrxExchange trxExchange, Boolean isTenant, String userName) throws Exception {
//转账笔数
Long transferNumber = trxExchange.getTransferNumber();
//实际锁定周期
@@ -129,7 +129,8 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
String fromAddress = trxExchange.getFromAddress();
- String userName = ShiroUtils.getLoginName();
+ userName = userName == null ? ShiroUtils.getLoginName() : userName;
+
String sysEnergyBusiType = DictUtils.getDictValue("sys_energy_busi_type", "闪兑套餐");
if (isTenant) {
sysEnergyBusiType = DictUtils.getDictValue("sys_energy_busi_type", "天数套餐");
diff --git a/ruoyi-system/src/main/resources/mapper/exchange/TrxExchangeInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/exchange/TrxExchangeInfoMapper.xml
index 3c7eb6853..ee1261fc5 100644
--- a/ruoyi-system/src/main/resources/mapper/exchange/TrxExchangeInfoMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/exchange/TrxExchangeInfoMapper.xml
@@ -183,4 +183,8 @@
and a.busi_type = 'trx2Energy'
and t.from_address = #{fromAddress}
+
+
\ No newline at end of file