diff --git a/ruoyi-admin/src/main/resources/templates/trx2Energy/exchange/trx.html b/ruoyi-admin/src/main/resources/templates/trx2Energy/exchange/trx.html
index c582a9228..868d7b9c3 100644
--- a/ruoyi-admin/src/main/resources/templates/trx2Energy/exchange/trx.html
+++ b/ruoyi-admin/src/main/resources/templates/trx2Energy/exchange/trx.html
@@ -95,6 +95,8 @@
var tranferCountDatas = [[${@dict.getType('sys_transfer_number')}]];
var sysEnergyBusiTypeDatas = [[${@dict.getType('sys_energy_busi_type')}]];
var lockPeriodDatas = [[${@dict.getType('sys_lock_period')}]];
+ var trxAmountUnitDatas = [[${@dict.getType('sys_monitor_type')}]];
+ var resourceCodeDatas = [[${@dict.getType('sys_trx_exchange')}]];
$(function () {
var options = {
url: prefix + "/list",
@@ -161,12 +163,33 @@
},
{
field: 'trxAmount',
- title: '转入TRX'
+ title: '转入金额',
+ formatter: function (value, row, index) {
+ if (value == null) {
+ return value;
+ }
+ return value + ' ' + row['trxAmountUnit'];
+ }
+ },
+ {
+ field: 'trxAmountUnit',
+ title: '转入单位',
+ formatter: function(value, row, index) {
+ return $.table.selectDictLabel(trxAmountUnitDatas, value);
+ },
+ visible: false
},
{
field: 'delegateAmountTrx',
title: '支出TRX'
},
+ {
+ field: 'resourceCode',
+ title: '资源类型',
+ formatter: function(value, row, index) {
+ return $.table.selectDictLabel(resourceCodeDatas, value);
+ }
+ },
{
field: 'delegateTxId',
title: '能量交易订单',
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/TrxExchangeInfo.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/TrxExchangeInfo.java
index b3957d4d6..f62e6b33d 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/TrxExchangeInfo.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/TrxExchangeInfo.java
@@ -34,8 +34,8 @@ public class TrxExchangeInfo extends BaseEntity
@Sensitive(desensitizedType = DesensitizedType.WALLET_ADDRESS)
private String toAddress;
- @Excel(name = "监听账户别名")
- private String monitorAddressName;
+ /* @Excel(name = "监听账户别名")
+ private String monitorAddressName;*/
/** 实际出账账户 */
@Excel(name = "实际出账账户")
@@ -54,6 +54,8 @@ public class TrxExchangeInfo extends BaseEntity
@Excel(name = "笔数")
private Long tranferCount;
+
+
/** 业务类型 */
@Excel(name = "业务类型")
private String energyBusiType;
@@ -63,10 +65,19 @@ public class TrxExchangeInfo extends BaseEntity
@Excel(name = "转入金额")
private Long trxAmount;
+ /** 转入单位 */
+ @Excel(name = "转入单位")
+ private String trxAmountUnit;
+
/** 兑换支出能量 */
@Excel(name = "兑换支出能量")
private Long delegateAmountTrx;
+ /** 资源类型 */
+ @Excel(name = "资源类型")
+ private String resourceCode;
+
+
/** 能量交易订单hash */
@Excel(name = "能量交易订单")
private String delegateTxId;
@@ -102,164 +113,5 @@ public class TrxExchangeInfo extends BaseEntity
@Excel(name = "更新用户")
private String lcu;
- public void setIdTrxExchangeInfo(Long idTrxExchangeInfo)
- {
- this.idTrxExchangeInfo = idTrxExchangeInfo;
- }
- public Long getIdTrxExchangeInfo()
- {
- return idTrxExchangeInfo;
- }
- public void setFromAddress(String fromAddress)
- {
- this.fromAddress = fromAddress;
- }
-
- public String getFromAddress()
- {
- return fromAddress;
- }
- public void setToAddress(String toAddress)
- {
- this.toAddress = toAddress;
- }
-
- public String getToAddress()
- {
- return toAddress;
- }
- public void setAccountAddress(String accountAddress)
- {
- this.accountAddress = accountAddress;
- }
-
- public String getAccountAddress()
- {
- return accountAddress;
- }
- public void setPrice(Long price)
- {
- this.price = price;
- }
-
- public Long getPrice()
- {
- return price;
- }
- public void setTrxTxId(String trxTxId)
- {
- this.trxTxId = trxTxId;
- }
-
- public String getTrxTxId()
- {
- return trxTxId;
- }
- public void setTrxAmount(Long trxAmount)
- {
- this.trxAmount = trxAmount;
- }
-
- public Long getTrxAmount()
- {
- return trxAmount;
- }
- public void setDelegateAmountTrx(Long delegateAmountTrx)
- {
- this.delegateAmountTrx = delegateAmountTrx;
- }
-
- public Long getDelegateAmountTrx()
- {
- return delegateAmountTrx;
- }
- public void setDelegateTxId(String delegateTxId)
- {
- this.delegateTxId = delegateTxId;
- }
-
- public String getDelegateTxId()
- {
- return delegateTxId;
- }
- public void setLockPeriod(Long lockPeriod)
- {
- this.lockPeriod = lockPeriod;
- }
-
- public Long getLockPeriod()
- {
- return lockPeriod;
- }
- public void setDelegateStatus(String delegateStatus)
- {
- this.delegateStatus = delegateStatus;
- }
-
- public String getDelegateStatus()
- {
- return delegateStatus;
- }
- public void setUnDelegateTxId(String unDelegateTxId)
- {
- this.unDelegateTxId = unDelegateTxId;
- }
-
- public String getUnDelegateTxId()
- {
- return unDelegateTxId;
- }
- public void setFcd(Date fcd)
- {
- this.fcd = fcd;
- }
-
- public Date getFcd()
- {
- return fcd;
- }
- public void setFcu(String fcu)
- {
- this.fcu = fcu;
- }
-
- public String getFcu()
- {
- return fcu;
- }
- public void setLcd(Date lcd)
- {
- this.lcd = lcd;
- }
-
- public Date getLcd()
- {
- return lcd;
- }
- public void setLcu(String lcu)
- {
- this.lcu = lcu;
- }
-
- public String getLcu()
- {
- return lcu;
- }
-
- public Long getTranferCount() {
- return tranferCount;
- }
-
- public void setTranferCount(Long tranferCount) {
- this.tranferCount = tranferCount;
- }
-
- public String getEnergyBusiType() {
- return energyBusiType;
- }
-
- public void setEnergyBusiType(String energyBusiType) {
- this.energyBusiType = energyBusiType;
- }
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TrxExchange.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TrxExchange.java
index 37e760763..1eeb5043b 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TrxExchange.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TrxExchange.java
@@ -1,6 +1,7 @@
package com.ruoyi.system.domain;
import com.ruoyi.common.core.domain.BaseEntity;
+import lombok.Data;
/**
@@ -9,7 +10,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* @author dorion
* @date 2024-04-13
*/
-
+@Data
public class TrxExchange extends BaseEntity
{
private static final long serialVersionUID = 1L;
@@ -23,6 +24,8 @@ public class TrxExchange extends BaseEntity
private String monitorAddress;
+ private String resourceCode;
+
private Long transferNumber;
private Long lockNum;
@@ -30,51 +33,7 @@ public class TrxExchange extends BaseEntity
private Long price;
- public String getMonitorAddress() {
- return monitorAddress;
- }
- public void setMonitorAddress(String monitorAddress) {
- this.monitorAddress = monitorAddress;
- }
- public Long getPrice() {
- return price;
- }
- public void setPrice(Long price) {
- this.price = price;
- }
-
- public String getFromAddress() {
- return fromAddress;
- }
-
- public void setFromAddress(String fromAddress) {
- this.fromAddress = fromAddress;
- }
-
- public String getAccountAddress() {
- return accountAddress;
- }
-
- public void setAccountAddress(String accountAddress) {
- this.accountAddress = accountAddress;
- }
-
- public Long getTransferNumber() {
- return transferNumber;
- }
-
- public void setTransferNumber(Long transferNumber) {
- this.transferNumber = transferNumber;
- }
-
- public Long getLockNum() {
- return lockNum;
- }
-
- public void setLockNum(Long lockNum) {
- this.lockNum = lockNum;
- }
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TrxExchangeMonitorAccountInfo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TrxExchangeMonitorAccountInfo.java
index 7b8099e2a..5b13eb838 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TrxExchangeMonitorAccountInfo.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TrxExchangeMonitorAccountInfo.java
@@ -41,6 +41,8 @@ public class TrxExchangeMonitorAccountInfo implements Serializable {
*/
private Long delegateAmountTrx;
+ private String resourceCode;
+
/**
*
*/
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TrxExchangeInfoVO.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TrxExchangeInfoVO.java
new file mode 100644
index 000000000..1c4b740e6
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TrxExchangeInfoVO.java
@@ -0,0 +1,113 @@
+package com.ruoyi.system.domain.vo;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class TrxExchangeInfoVO {
+ /**
+ *
+ */
+ private String idTrxExchangeInfo;
+
+ /**
+ *
+ */
+ private String fromAddress;
+
+ /**
+ *
+ */
+ private String toAddress;
+
+ /**
+ *
+ */
+ private String monitorAddressName;
+
+ /**
+ *
+ */
+ private String accountAddress;
+
+ /**
+ *
+ */
+ private Integer price;
+
+ /**
+ *
+ */
+ private String trxTxId;
+
+ /**
+ *
+ */
+ private String tranferCount;
+
+ /**
+ *
+ */
+ private String energyBusiType;
+
+ /**
+ *
+ */
+ private String trxAmount;
+
+ /**
+ *
+ */
+ private String trxAmountUnit;
+
+ /**
+ *
+ */
+ private String delegateAmountTrx;
+
+ /**
+ *
+ */
+ private String resourceCode;
+
+ /**
+ *
+ */
+ private String delegateTxId;
+
+ /**
+ *
+ */
+ private String lockPeriod;
+
+ /**
+ *
+ */
+ private String delegateStatus;
+
+ /**
+ *
+ */
+ private String unDelegateTxId;
+
+ /**
+ *
+ */
+ private Date fcd;
+
+ /**
+ *
+ */
+ private String fcu;
+
+ /**
+ *
+ */
+ private Date lcd;
+
+ /**
+ *
+ */
+ private String lcu;
+}
\ No newline at end of file
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/dto/AccountResourceResponse.java b/ruoyi-system/src/main/java/com/ruoyi/system/dto/AccountResourceResponse.java
index 6c6725fce..09d41289c 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/dto/AccountResourceResponse.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/dto/AccountResourceResponse.java
@@ -21,6 +21,8 @@ public class AccountResourceResponse implements Serializable {
private Long TotalEnergyLimit;
private Long TotalEnergyWeight;
+ private Integer NetUsed;
+
}
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 fd295e9e8..d0662e9db 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
@@ -270,7 +270,7 @@ public class TRX2EneryTransferHandler {
tenantInfo.setDelegatedDays(tenantInfo.getDelegatedDays() + 1);
//取包天的套餐锁定时间和交易笔数
- lockPeriod = 24;
+ lockPeriod = 24;
sysEnergyBusiType = DictUtils.getDictValue("sys_energy_busi_type", "天数套餐");
transferCount = tenantInfo.getTransferCount();
price = tenantInfo.getPrice();
@@ -316,7 +316,7 @@ public class TRX2EneryTransferHandler {
}
- calcBalanceAndDelegate(txID, apiWrapper, accountAddress, transferCount, ownerAddress, lockPeriod, toAddress, price, sysEnergyBusiType, amount, "system");
+ calcBalanceAndDelegate(txID, apiWrapper, accountAddress, transferCount, ownerAddress, lockPeriod, toAddress, price, sysEnergyBusiType, amount,"TRX","system",Common.ResourceCode.ENERGY.name());
//持久化之后放redis
redisTemplate.opsForValue().set("transfer_trx_" + txID, txID, 1, TimeUnit.DAYS);
if (tenantInfo != null) {
@@ -327,30 +327,32 @@ public class TRX2EneryTransferHandler {
/**
- * @param txID 转账交易订单号
- * @param apiWrapper apiWrapper
- * @param accountAddress 出账地址
- * @param transferCount 转账笔数
- * @param ownerAddress 转入地址
- * @param lockPeriod 锁定周期
- * @param toAddress 监听地址
- * @param price 单价
- * @param sysEnergyBusiType 业务类型
- * @param amount 转入金额
- * @param currentUser 当前处理人
+ * @param txID 转账交易订单号
+ * @param apiWrapper apiWrapper
+ * @param accountAddress 出账地址
+ * @param transferCount 转账笔数
+ * @param ownerAddress 转入地址
+ * @param lockPeriod 锁定周期
+ * @param toAddress 监听地址
+ * @param price 单价
+ * @param sysEnergyBusiType 业务类型
+ * @param amount 转入金额
+ * @param currentUser 当前处理人
* @throws Exception 异常
*/
public void calcBalanceAndDelegate(String txID,
- ApiWrapper apiWrapper,
- String accountAddress,
- long transferCount,
- String ownerAddress,
- long lockPeriod,
- String toAddress,
- Long price,
- String sysEnergyBusiType,
- Long amount,
- String currentUser) throws Exception {
+ ApiWrapper apiWrapper,
+ String accountAddress,
+ long transferCount,
+ String ownerAddress,
+ long lockPeriod,
+ String toAddress,
+ Long price,
+ String sysEnergyBusiType,
+ Long amount,
+ String trxAmountUnit,
+ String currentUser,
+ String resourceCode) throws Exception {
String systronApiSwitch = configService.selectConfigByKey("sys.tron.api");
Long balance = null;
@@ -359,11 +361,11 @@ public class TRX2EneryTransferHandler {
Response.AccountResourceMessage accountResource = apiWrapper.getAccountResource(accountAddress);
//总用于质押换取能量的trx上限
- balance = getBalance(accountResource, transferCount);
+ balance = getBalance(accountResource, transferCount, resourceCode);
/* lock_period: 锁定周期,以区块时间(3s)为单位,表示锁定多少个区块的时间,当lock为true时,该字段有效。如果代理锁定期为1天,则lock_period为:28800*/
- delegateResourceTxid = getDelegateResourceTxid(apiWrapper, accountAddress, balance, ownerAddress, lockPeriod);
+ delegateResourceTxid = getDelegateResourceTxid(apiWrapper, accountAddress, balance, ownerAddress, resourceCode);
}
String fromAddress = AddressUtil.hexToBase58(ownerAddress);
@@ -376,7 +378,9 @@ public class TRX2EneryTransferHandler {
.tranferCount(transferCount)
.energyBusiType(sysEnergyBusiType)
.trxAmount(amount)
+ .trxAmountUnit(trxAmountUnit)
.delegateAmountTrx(balance)
+ .resourceCode(resourceCode)
.delegateTxId(delegateResourceTxid)
.lockPeriod(lockPeriod)
.delegateStatus("0")
@@ -387,7 +391,7 @@ public class TRX2EneryTransferHandler {
.build();
trxExchangeInfoMapper.insertTrxExchangeInfo(trxExchangeInfo);
- String sysenTrxTransferNotice = configService.selectConfigByKey("sys.energy.transaction.notice");
+ String sysenTrxTransferNotice = configService.selectConfigByKey("sys.energy.transaction.notice");
String sysTgGroupChatId = configService.selectConfigByKey("sys.tg.group.chat.id");
if (longPollingBot != null && StringUtils.isNotEmpty(sysenTrxTransferNotice) && StringUtils.isNotEmpty(sysTgGroupChatId)) {
/*
@@ -404,7 +408,7 @@ public class TRX2EneryTransferHandler {
arguments.put("transferCount", transferCount);
arguments.put("FromAddress", fromAddress.replaceAll("(.{6})(.*)(.{8})", "$1********$3"));
arguments.put("txId", StringUtils.isEmpty(txID) ? "" : txID.replaceAll("(.{6})(.*)(.{8})", "$1*******************$3"));
- arguments.put("txTime", DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
+ arguments.put("txTime", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
// String message = MessageFormat.format(sysUsdtTranferNotice, arguments);
StrSubstitutor substitutor = new StrSubstitutor(arguments, "{", "}");
String message = substitutor.replace(sysenTrxTransferNotice);
@@ -417,25 +421,32 @@ public class TRX2EneryTransferHandler {
}
- private long getBalance(Response.AccountResourceMessage accountResource, long energyNum) {
- long totalEnergyLimit = accountResource.getTotalEnergyLimit();
- //已经用于质押换取能量的trx
- long totalEnergyWeight = accountResource.getTotalEnergyWeight();
+ private long getBalance(Response.AccountResourceMessage accountResource, long transferCount, String resourceCode) {
+ Long balance = null;
+ if (resourceCode.equals(Common.ResourceCode.ENERGY.name())) {
+ long totalEnergyLimit = accountResource.getTotalEnergyLimit();
+ //已经用于质押换取能量的trx
+ long totalEnergyWeight = accountResource.getTotalEnergyWeight();
- //系数 保留一位或者保留2位,算出trx往上进一位
- BigDecimal trxToFreezeEnergyTimes = BigDecimal.valueOf(totalEnergyLimit).divide(BigDecimal.valueOf(totalEnergyWeight), 2, BigDecimal.ROUND_DOWN);
- //计算代理的数量
+ //系数 保留一位或者保留2位,算出trx往上进一位
+ BigDecimal trxToFreezeEnergyTimes = BigDecimal.valueOf(totalEnergyLimit).divide(BigDecimal.valueOf(totalEnergyWeight), 2, BigDecimal.ROUND_DOWN);
+ //计算代理的数量
// long balance = energyNum * 32000 / 12;
- long balance = BigDecimal.valueOf(energyNum * 32000).divide(trxToFreezeEnergyTimes, 0, BigDecimal.ROUND_UP).longValue();
+ balance = BigDecimal.valueOf(transferCount * 32000).divide(trxToFreezeEnergyTimes, 0, BigDecimal.ROUND_UP).longValue();
+ }else {
+
+ balance = transferCount * 350;
+ }
return balance;
}
- private String getDelegateResourceTxid(ApiWrapper apiWrapper, String accountAddress, long balance, String ownerAddress, long lockPeriod) throws IllegalException {
- Response.TransactionExtention transactionExtention = apiWrapper.delegateResourceV2(accountAddress, balance * 1000000, Common.ResourceCode.ENERGY_VALUE, ownerAddress, false,0);
+ private String getDelegateResourceTxid(ApiWrapper apiWrapper, String accountAddress, long balance, String ownerAddress, String resourceCode) throws IllegalException {
+ Response.TransactionExtention transactionExtention = apiWrapper.delegateResourceV2(accountAddress, balance * 1000000, Common.ResourceCode.valueOf(resourceCode).getNumber(), ownerAddress, false, 0);
Chain.Transaction transaction = apiWrapper.signTransaction(transactionExtention);
String delegateResourceTxid = apiWrapper.broadcastTransaction(transaction);
return delegateResourceTxid;
}
+
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/handler/UndelegateEnergyHandler.java b/ruoyi-system/src/main/java/com/ruoyi/system/handler/UndelegateEnergyHandler.java
index aa8d3168a..60786da73 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/handler/UndelegateEnergyHandler.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/handler/UndelegateEnergyHandler.java
@@ -86,14 +86,27 @@ public class UndelegateEnergyHandler {
if (accountResource == null){
return;
}
- Integer energyUsed = accountResource.getEnergyUsed();
- if (energyUsed == null){
- return;
- }
- long energyUsedCount = energyUsed / 30000;
- if (energyUsedCount < trxExchangeMonitorAccountInfo.getTranferCount()){
- return;
+ String resourceCode = trxExchangeMonitorAccountInfo.getResourceCode();
+ if (resourceCode.equals(Common.ResourceCode.ENERGY.name())) {
+ Integer energyUsed = accountResource.getEnergyUsed();
+ if (energyUsed == null){
+ return;
+ }
+
+ long energyUsedCount = energyUsed / 30000;
+ if (energyUsedCount < trxExchangeMonitorAccountInfo.getTranferCount()){
+ return;
+ }
+ }else {
+ Integer netUsed = accountResource.getNetUsed();
+ if (netUsed == null){
+ return;
+ }
+ int bandWidthUsedCount = netUsed / 250;
+ if (bandWidthUsedCount < trxExchangeMonitorAccountInfo.getTranferCount()){
+ return;
+ }
}
}
@@ -223,7 +236,7 @@ public class UndelegateEnergyHandler {
long balance = trxExchangeMonitorAccountInfo.getDelegateAmountTrx() * 1000000;
Response.TransactionExtention transactionExtention = apiWrapper.undelegateResource(accountAddress,
- balance, Common.ResourceCode.ENERGY_VALUE, fromAddress);
+ balance, Common.ResourceCode.valueOf(trxExchangeMonitorAccountInfo.getResourceCode()).getNumber(), fromAddress);
Chain.Transaction transaction = apiWrapper.signTransaction(transactionExtention);
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 ccb043094..4bb2929c0 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
@@ -4,6 +4,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 com.ruoyi.system.domain.vo.TrxExchangeInfoVO;
import java.util.List;
@@ -67,5 +68,5 @@ public interface TrxExchangeInfoMapper
List
selectTransactionLogVO();
- List selectTrxExchangeInfoAndMonitorNameList(TrxExchangeInfo trxExchangeInfo);
+ List selectTrxExchangeInfoAndMonitorNameList(TrxExchangeInfo trxExchangeInfo);
}
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 047192c84..9816ea938 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
@@ -4,6 +4,7 @@ package com.ruoyi.system.service;
import com.ruoyi.common.core.domain.entity.TrxExchangeInfo;
import com.ruoyi.system.domain.TrxExchange;
import com.ruoyi.system.domain.TrxExchangeMonitorAccountInfo;
+import com.ruoyi.system.domain.vo.TrxExchangeInfoVO;
import java.util.List;
@@ -25,11 +26,11 @@ public interface ITrxExchangeInfoService
/**
* 查询trx兑能量记录列表
- *
+ *
* @param trxExchangeInfo trx兑能量记录
* @return trx兑能量记录集合
*/
- public List selectTrxExchangeInfoList(TrxExchangeInfo trxExchangeInfo);
+ public List selectTrxExchangeInfoList(TrxExchangeInfo trxExchangeInfo);
/**
* 新增trx兑能量记录
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 7dcef642b..15231a2ac 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
@@ -14,6 +14,7 @@ import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.TrxExchange;
+import com.ruoyi.system.domain.vo.TrxExchangeInfoVO;
import com.ruoyi.system.mapper.AccountAddressInfoMapper;
import com.ruoyi.system.mapper.MonitorAddressInfoMapper;
import com.ruoyi.system.mapper.TenantInfoMapper;
@@ -28,13 +29,12 @@ import java.util.List;
/**
* 租户Service业务层处理
- *
+ *
* @author dorion
* @date 2024-04-14
*/
@Service
-public class TenantInfoServiceImpl implements ITenantInfoService
-{
+public class TenantInfoServiceImpl implements ITenantInfoService {
@Autowired
private TenantInfoMapper tenantInfoMapper;
@@ -44,46 +44,49 @@ public class TenantInfoServiceImpl implements ITenantInfoService
private MonitorAddressInfoMapper monitorAddressInfoMapper;
@Autowired
private AccountAddressInfoMapper accountAddressInfoMapper;
+
/**
* 查询租户
- *
+ *
* @param idTenantInfo 租户主键
* @return 租户
*/
@Override
- public TenantInfo selectTenantInfoByIdTenantInfo(Long idTenantInfo)
- {
+ public TenantInfo selectTenantInfoByIdTenantInfo(Long idTenantInfo) {
return tenantInfoMapper.selectTenantInfoByIdTenantInfo(idTenantInfo);
}
/**
* 查询租户列表
- *
+ *
* @param tenantInfo 租户
* @return 租户
*/
@Override
@DataScope(userAlias = "u")
- public List selectTenantInfoList(TenantInfo tenantInfo)
- {
+ public List selectTenantInfoList(TenantInfo tenantInfo) {
return tenantInfoMapper.selectTenantInfoList(tenantInfo);
}
/**
* 新增租户
- *
+ *
* @param tenantInfo 租户
* @return 结果
*/
@Override
- public int insertTenantInfo(TenantInfo tenantInfo)
- {
+ public int insertTenantInfo(TenantInfo tenantInfo) {
TenantInfo tenantInfoExample = new TenantInfo();
tenantInfoExample.setReceiverAddress(tenantInfo.getReceiverAddress());
List tenantInfoList = tenantInfoMapper.selectTenantInfoList(tenantInfoExample);
-
- Preconditions.checkState(CollectionUtil.isEmpty(tenantInfoList), "该接收能量地址已存在,请勿重复添加");
+ boolean exists = false;
+ if (CollectionUtil.isEmpty(tenantInfoList)) {
+ exists = !tenantInfoList.stream().anyMatch(tenantInfo1 -> {
+ return tenantInfo1.getStatus().equals(DictUtils.getDictValue("sys_tenant_status", "生效中"));
+ });
+ }
+ Preconditions.checkState( !exists, "该接收能量地址已存在,请勿重复添加");
Long price = tenantInfo.getPrice();
Long transferCount = tenantInfo.getTransferCount();
@@ -113,13 +116,12 @@ public class TenantInfoServiceImpl implements ITenantInfoService
/**
* 修改租户
- *
+ *
* @param tenantInfo 租户
* @return 结果
*/
@Override
- public int updateTenantInfo(TenantInfo tenantInfo)
- {
+ public int updateTenantInfo(TenantInfo tenantInfo) {
Long price = tenantInfo.getPrice();
Long transferCount = tenantInfo.getTransferCount();
Long period = tenantInfo.getPeriod();
@@ -137,25 +139,23 @@ public class TenantInfoServiceImpl implements ITenantInfoService
/**
* 批量删除租户
- *
+ *
* @param idTenantInfos 需要删除的租户主键
* @return 结果
*/
@Override
- public int deleteTenantInfoByIdTenantInfos(String idTenantInfos)
- {
+ public int deleteTenantInfoByIdTenantInfos(String idTenantInfos) {
return tenantInfoMapper.deleteTenantInfoByIdTenantInfos(Convert.toStrArray(idTenantInfos));
}
/**
* 删除租户信息
- *
+ *
* @param idTenantInfo 租户主键
* @return 结果
*/
@Override
- public int deleteTenantInfoByIdTenantInfo(Long idTenantInfo)
- {
+ public int deleteTenantInfoByIdTenantInfo(Long idTenantInfo) {
return tenantInfoMapper.deleteTenantInfoByIdTenantInfo(idTenantInfo);
}
@@ -169,18 +169,18 @@ public class TenantInfoServiceImpl implements ITenantInfoService
Preconditions.checkState(status.equals(tenantInfo.getStatus()), "该租户不是生效中状态,不能发起委托任务");
String dictValue = DictUtils.getDictValue("sys_delegate_status", "已委托");
- String sysEnergyBusiType = DictUtils.getDictValue("sys_energy_busi_type", "天数套餐");
+ String sysEnergyBusiType = DictUtils.getDictValue("sys_energy_busi_type", "天数套餐");
TrxExchangeInfo trxExchangeInfo = TrxExchangeInfo.builder().fromAddress(tenantInfo.getReceiverAddress())
.delegateStatus(dictValue)
.energyBusiType(sysEnergyBusiType)
.build();
- List trxExchangeInfos = trxExchangeInfoService.selectTrxExchangeInfoList(trxExchangeInfo);
+ List trxExchangeInfos = trxExchangeInfoService.selectTrxExchangeInfoList(trxExchangeInfo);
Preconditions.checkState(CollectionUtil.isEmpty(trxExchangeInfos), "该接收能量地址已在任务中,请勿重复发起");
- doDelegateEnergy(tenantInfo,null);
+ doDelegateEnergy(tenantInfo, null);
}
return 1;
@@ -190,7 +190,7 @@ public class TenantInfoServiceImpl implements ITenantInfoService
public void doDelegateEnergy(TenantInfo tenantInfo, String userName) throws Exception {
String accountAddress = null;
String monitorAddress = null;
- if (StringUtils.isNotEmpty(tenantInfo.getMonitorAddress())){
+ if (StringUtils.isNotEmpty(tenantInfo.getMonitorAddress())) {
MonitorAddressInfo monitorAddressInfoExample = new MonitorAddressInfo();
monitorAddressInfoExample.setMonitorAddress(tenantInfo.getMonitorAddress());
monitorAddressInfoExample.setIsValid(UserConstants.YES);
@@ -201,7 +201,7 @@ public class TenantInfoServiceImpl implements ITenantInfoService
accountAddress = monitorAddressInfo.getAccountAddress();
monitorAddress = monitorAddressInfo.getMonitorAddress();
- }else {
+ } else {
AccountAddressInfo accountAddressInfo = new AccountAddressInfo();
accountAddressInfo.setIsValid("Y");
List accountAddressInfoList = accountAddressInfoMapper.selectAccountAddressInfoList(accountAddressInfo);
@@ -227,7 +227,7 @@ public class TenantInfoServiceImpl implements ITenantInfoService
userName = userName == null ? ShiroUtils.getLoginName() : userName;
- trxExchangeInfoService.delegate(trxExchange, true,userName);
+ trxExchangeInfoService.delegate(trxExchange, true, userName);
tenantInfo.setDelegatedDays(tenantInfo.getDelegatedDays() + 1);
tenantInfo.setLcd(new Date());
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 74c8a5939..4749eb17a 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
@@ -7,6 +7,7 @@ import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.TrxExchange;
import com.ruoyi.system.domain.TrxExchangeMonitorAccountInfo;
+import com.ruoyi.system.domain.vo.TrxExchangeInfoVO;
import com.ruoyi.system.handler.TRX2EneryTransferHandler;
import com.ruoyi.system.mapper.ErrorLogMapper;
import com.ruoyi.system.mapper.TenantInfoMapper;
@@ -67,7 +68,7 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
* @return trx兑能量记录
*/
@Override
- public List selectTrxExchangeInfoList(TrxExchangeInfo trxExchangeInfo) {
+ public List selectTrxExchangeInfoList(TrxExchangeInfo trxExchangeInfo) {
// return trxExchangeInfoMapper.selectTrxExchangeInfoList(trxExchangeInfo);
return trxExchangeInfoMapper.selectTrxExchangeInfoAndMonitorNameList(trxExchangeInfo);
}
@@ -156,7 +157,9 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
trxExchange.getPrice(),
sysEnergyBusiType,
null,
- userName);
+ null,
+ userName,
+ trxExchange.getResourceCode());
return 1;
}
diff --git a/ruoyi-system/src/main/resources/mapper/exchange/TrxExchangeInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/exchange/TrxExchangeInfoMapper.xml
index ea50efc12..89a66cfe0 100644
--- a/ruoyi-system/src/main/resources/mapper/exchange/TrxExchangeInfoMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/exchange/TrxExchangeInfoMapper.xml
@@ -3,7 +3,30 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -14,12 +37,13 @@
+
+
-
@@ -27,12 +51,12 @@
- select id_trx_exchange_info, from_address, to_address, account_address, price, trx_tx_id, tranfer_count, energy_busi_type, trx_amount, delegate_amount_trx, delegate_tx_id, lock_period, delegate_status, un_delegate_tx_id, fcd, fcu, lcd, lcu from trx_exchange_info
+ select id_trx_exchange_info, from_address, to_address, account_address, price, trx_tx_id, tranfer_count, energy_busi_type, trx_amount, trx_amount_unit, delegate_amount_trx, resource_code, delegate_tx_id, lock_period, delegate_status, un_delegate_tx_id, fcd, fcu, lcd, lcu from trx_exchange_info
@@ -71,7 +95,9 @@
tranfer_count,
energy_busi_type,
trx_amount,
+ trx_amount_unit,
delegate_amount_trx,
+ resource_code,
delegate_tx_id,
lock_period,
delegate_status,
@@ -90,12 +116,13 @@
#{tranferCount},
#{energyBusiType},
#{trxAmount},
+ #{trxAmountUnit},
#{delegateAmountTrx},
+ #{resourceCode},
#{delegateTxId},
#{lockPeriod},
#{delegateStatus},
#{unDelegateTxId},
-
#{fcd},
#{fcu},
#{lcd},
@@ -114,7 +141,9 @@
tranfer_count = #{tranferCount},
energy_busi_type = #{energyBusiType},
trx_amount = #{trxAmount},
+ trx_amount_unit = #{trxAmountUnit},
delegate_amount_trx = #{delegateAmountTrx},
+ resource_code = #{resourceCode},
delegate_tx_id = #{delegateTxId},
lock_period = #{lockPeriod},
delegate_status = #{delegateStatus},
@@ -147,6 +176,7 @@
+
@@ -166,6 +196,7 @@
t.tranfer_count,
t.energy_busi_type,
t.delegate_amount_trx,
+ t.resource_code,
t.lock_period,
t.delegate_status,
t.delegate_tx_id,
@@ -190,23 +221,26 @@
-