实现定制业务一次性只送出64k能量,按笔数计算逻辑

pull/520/head
dorion 2024-05-19 20:41:51 +08:00
parent 8ae7cabda1
commit ac9c0a7f03
23 changed files with 492 additions and 356 deletions

View File

@ -147,7 +147,7 @@
</plugin> -->
</plugins>
<finalName>${project.artifactId}</finalName>
<!-- <resources>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
@ -155,7 +155,7 @@
<exclude>*.xml</exclude>
</excludes>
</resource>
</resources>-->
</resources>
</build>

View File

@ -97,6 +97,7 @@
var lockPeriodDatas = [[${@dict.getType('sys_lock_period')}]];
var trxAmountUnitDatas = [[${@dict.getType('sys_monitor_type')}]];
var resourceCodeDatas = [[${@dict.getType('sys_trx_exchange')}]];
var calcRuleDatas = [[${@dict.getType('sys_transaction_count_calc_rule')}]];
$(function () {
var options = {
url: prefix + "/list",
@ -209,6 +210,13 @@
return $.table.selectDictLabel(datas, item.delegateStatus);
}
},
{
field: 'calcRule',
title: '笔数计算规则',
formatter: function(value, row, index) {
return $.table.selectDictLabel(calcRuleDatas, value);
}
},
{
field: 'unDelegateTxId',
title: '回收资源交易',

View File

@ -22,6 +22,14 @@
</select>
</div>
</div>-->
<div class="form-group">
<label class="col-sm-3 control-label">套餐类型:</label>
<div class="col-sm-8">
<select name="energyBusiType" class="form-control m-b" th:with="type=${@dict.getType('sys_energy_busi_type')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">单价:</label>
<div class="col-sm-8">
@ -31,9 +39,7 @@
<div class="form-group">
<label class="col-sm-3 control-label">笔数:</label>
<div class="col-sm-8">
<select name="transferCount" class="form-control m-b" th:with="type=${@dict.getType('sys_transfer_number')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
<input name="transferCount" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
@ -49,6 +55,15 @@
<div class="col-sm-8">
<select name="period" class="form-control m-b" th:with="type=${@dict.getType('sys_lock_period_day')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
<option value=""></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">计算规则:</label>
<div class="col-sm-8">
<select name="calcRule" class="form-control m-b" th:with="type=${@dict.getType('sys_transaction_count_calc_rule')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>

View File

@ -11,7 +11,7 @@
<div class="form-group">
<label class="col-sm-3 control-label">接收能量地址:</label>
<div class="col-sm-8">
<input name="receiverAddress" th:field="*{receiverAddress}" class="form-control" type="text">
<input name="receiverAddress" th:field="*{receiverAddress}" class="form-control" type="text" disabled>
</div>
</div>
<!-- <div class="form-group">
@ -23,34 +23,14 @@
</select>
</div>
</div>-->
<div class="form-group">
<label class="col-sm-3 control-label">单价:</label>
<div class="col-sm-8">
<input name="price" th:field="*{price}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">笔数:</label>
<div class="col-sm-8">
<select name="transferCount" class="form-control m-b" th:with="type=${@dict.getType('sys_transfer_number')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{transferCount}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">交易单位:</label>
<div class="col-sm-8">
<select name="exchangeUnit" class="form-control m-b" th:with="type=${@dict.getType('sys_monitor_type')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{exchangeUnit}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">交易总额:</label>
<div class="col-sm-8">
<input name="exchangeAmount" th:field="*{exchangeAmount}" class="form-control" type="text">
<input name="transferCount" th:field="*{transferCount}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">是否到账:</label>
<div class="col-sm-8">
@ -59,14 +39,16 @@
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">租期</label>
<label class="col-sm-3 control-label">计算规则</label>
<div class="col-sm-8">
<select name="period" class="form-control m-b" th:with="type=${@dict.getType('sys_lock_period_day')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{period}"></option>
<select name="calcRule" class="form-control m-b" th:with="type=${@dict.getType('sys_transaction_count_calc_rule')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{calcRule}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">状态:</label>
<div class="col-sm-8">
@ -76,8 +58,19 @@
</div>
</div>
<input name="fcd" th:value="${#dates.format(tenantInfo.fcd, 'yyyy-MM-dd HH:mm:ss')}" type="hidden">
<div class="form-group">
<label class="col-sm-3 control-label">租期:</label>
<div class="col-sm-8">
<select name="period" class="form-control m-b" th:with="type=${@dict.getType('sys_lock_period_day')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{period}"></option>
</select>
</div>
</div>
<!-- <input name="fcd" th:value="${#dates.format(tenantInfo.fcd, 'yyyy-MM-dd HH:mm:ss')}" type="hidden">-->
<input name="period" th:field="*{period}" type="hidden">
<!-- <input name="price" th:value="${price}" type="hidden">-->
<input name="price" th:field="*{price}" type="hidden">
</form>
</div>
<th:block th:include="include :: footer" />

View File

@ -18,16 +18,25 @@
<label>出账账户地址:</label>
<input type="text" name="accountAddress"/>
</li>
<li>
<!-- <li>
<label>交易单位:</label>
<select name="exchangeUnit" 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>-->
<li>
<label>状态:</label>
<select name="status" th:with="type=${@dict.getType('sys_tenant_status')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
<option value="">所有</option>
</select>
</li>
<li class="select-time">
<label>创建时间:</label>
<input type="text" class="time-input" placeholder="请选择创建时间" name="fcd"/>
<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>
@ -61,11 +70,13 @@
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('account:tenant:edit')}]];
var removeFlag = [[${@permission.hasPermi('account:tenant:remove')}]];
var transferCountDatas = [[${@dict.getType('sys_transfer_number')}]];
var exchangeUnitDatas = [[${@dict.getType('sys_monitor_type')}]];
var isPaidDatas = [[${@dict.getType('sys_is_paid')}]];
var periodDatas = [[${@dict.getType('sys_lock_period_day')}]];
var statusDatas = [[${@dict.getType('sys_tenant_status')}]];
var calcRuleDatas = [[${@dict.getType('sys_transaction_count_calc_rule')}]];
var energyBusiTypeDatas = [[${@dict.getType('sys_energy_busi_type')}]];
var prefix = ctx + "trx2Energy/tenant";
$(function() {
@ -89,19 +100,34 @@
field: 'receiverAddress',
title: '接收能量地址'
},
/* {
{
field: 'monitorAddress',
title: '监控入账地址'
},*/
title: '监控入账地址',
visible: false
},
{
field: 'energyBusiType',
title: '套餐类型',
formatter: function(value, row, index) {
return $.table.selectDictLabel(energyBusiTypeDatas, value);
}
} ,
{
field: 'price',
title: '单价'
title: '单价',
formatter: function(value, row, index) {
if (value == null) {
return value;
}
return value + ' ' + row['exchangeUnit'];
}
},
{
field: 'transferCount',
title: '笔数',
formatter: function(value, row, index) {
return $.table.selectDictLabel(transferCountDatas, value);
return value + ' 笔';
}
},
{
@ -109,11 +135,13 @@
title: '交易单位',
formatter: function(value, row, index) {
return $.table.selectDictLabel(exchangeUnitDatas, value);
}
},
visible: false
},
{
field: 'exchangeAmount',
title: '交易总额'
title: '交易总额',
visible: false
},
{
field: 'isPaid',
@ -126,6 +154,9 @@
field: 'period',
title: '租期',
formatter: function(value, row, index) {
if (value == null) {
return value;
}
return $.table.selectDictLabel(periodDatas, value);
}
},
@ -141,22 +172,36 @@
field: 'delegatedDays',
title: '已经委托天数'
},
{
field: 'totalCountUsed',
title: '已使用笔数'
},
{
field: 'calcRule',
title: '计算规则',
formatter: function(value, row, index) {
return $.table.selectDictLabel(calcRuleDatas, value);
}
},
{
field: 'fcd',
title: '创建时间'
},
/* {
{
field: 'fcu',
title: '创建用户'
title: '创建用户',
visible: false
},
{
field: 'lcd',
title: '更新时间'
title: '更新时间',
visible: false
},
{
field: 'lcu',
title: '更新用户'
},*/
title: '更新用户',
visible: false
},
{
title: '操作',
align: 'center',

View File

@ -3,6 +3,7 @@ package com.ruoyi.common.core.domain.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import java.util.Date;
@ -12,6 +13,7 @@ import java.util.Date;
* @author dorion
* @date 2024-04-14
*/
@Data
public class TenantInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
@ -27,6 +29,11 @@ public class TenantInfo extends BaseEntity
@Excel(name = "监控入账地址")
private String monitorAddress;
/** 套餐类型 */
@Excel(name = "套餐类型")
private String energyBusiType;
/** 单价 */
@Excel(name = "单价")
private Long price;
@ -65,11 +72,18 @@ public class TenantInfo extends BaseEntity
/** 已经委托天数 */
@Excel(name = "已经委托天数")
private Long delegatedDays;
/** 已使用笔数 */
@Excel(name = "已使用笔数")
private Long totalCountUsed;
/** 计算规则 */
@Excel(name = "计算规则")
private String calcRule;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date fcd;
/** 创建用户 */
@ -77,8 +91,8 @@ public class TenantInfo extends BaseEntity
private String fcu;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date lcd;
/** 更新用户 */
@ -86,178 +100,4 @@ public class TenantInfo extends BaseEntity
private String lcu;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Long getDelegatedDays() {
return delegatedDays;
}
public void setDelegatedDays(Long delegatedDays) {
this.delegatedDays = delegatedDays;
}
public void setIdTenantInfo(Long idTenantInfo)
{
this.idTenantInfo = idTenantInfo;
}
public Long getIdTenantInfo()
{
return idTenantInfo;
}
public void setReceiverAddress(String receiverAddress)
{
this.receiverAddress = receiverAddress;
}
public String getReceiverAddress()
{
return receiverAddress;
}
public void setMonitorAddress(String monitorAddress)
{
this.monitorAddress = monitorAddress;
}
public String getMonitorAddress()
{
return monitorAddress;
}
public void setPrice(Long price)
{
this.price = price;
}
public Long getPrice()
{
return price;
}
public void setTransferCount(Long transferCount)
{
this.transferCount = transferCount;
}
public Long getTransferCount()
{
return transferCount;
}
public void setExchangeUnit(String exchangeUnit)
{
this.exchangeUnit = exchangeUnit;
}
public String getExchangeUnit()
{
return exchangeUnit;
}
public void setTxId(String txId)
{
this.txId = txId;
}
public String getTxId()
{
return txId;
}
public void setExchangeAmount(Long exchangeAmount)
{
this.exchangeAmount = exchangeAmount;
}
public Long getExchangeAmount()
{
return exchangeAmount;
}
public void setIsPaid(String isPaid)
{
this.isPaid = isPaid;
}
public String getIsPaid()
{
return isPaid;
}
public void setPeriod(Long period)
{
this.period = period;
}
public Long getPeriod()
{
return period;
}
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;
}
@Override
public String toString() {
return "TenantInfo{" +
"idTenantInfo=" + idTenantInfo +
", receiverAddress='" + receiverAddress + '\'' +
", monitorAddress='" + monitorAddress + '\'' +
", price=" + price +
", transferCount=" + transferCount +
", exchangeUnit='" + exchangeUnit + '\'' +
", txId='" + txId + '\'' +
", exchangeAmount=" + exchangeAmount +
", isPaid='" + isPaid + '\'' +
", period=" + period +
", userId='" + userId + '\'' +
", status='" + status + '\'' +
", delegatedDays=" + delegatedDays +
", fcd=" + fcd +
", fcu='" + fcu + '\'' +
", lcd=" + lcd +
", lcu='" + lcu + '\'' +
'}';
}
}

View File

@ -89,6 +89,9 @@ public class TrxExchangeInfo extends BaseEntity
/** 资源委托状态 */
@Excel(name = "资源委托状态")
private String delegateStatus;
/** 笔数计算规则 */
@Excel(name = "笔数计算规则")
private String calcRule;
/** 回收资源交易id */
@Excel(name = "回收资源交易")

View File

@ -1,9 +1,11 @@
package com.ruoyi.common.utils;
import java.util.List;
import org.springframework.stereotype.Component;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.entity.SysDictData;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List;
/**
*
@ -69,6 +71,19 @@ public class DictUtils
return getDictValue(dictType, dictLabel, SEPARATOR);
}
public static String getRandomDictValue(String dictType)
{
Object cacheObj = CacheUtils.get(getCacheName(), getCacheKey(dictType));
if (StringUtils.isNotNull(cacheObj))
{
List<SysDictData> sysDictDataList = StringUtils.cast(cacheObj);
Collections.shuffle(sysDictDataList);
return sysDictDataList.get(0).getDictValue();
}
return null;
}
/**
*
*

View File

@ -21,6 +21,8 @@ public class EnergyTenantTransferTask {
public void doEnergyTenantTransfer(){
TenantInfo tenantInfoExample = new TenantInfo();
tenantInfoExample.setStatus(DictUtils.getDictValue("sys_tenant_status", "生效中"));
/* String energyBusiType = DictUtils.getDictValue("sys_energy_busi_type", "天数套餐");
tenantInfoExample.setEnergyBusiType(energyBusiType);*/
List<TenantInfo> tenantInfoList = tenantInfoMapper.selectTenantInfoList(tenantInfoExample);
for (TenantInfo tenantInfo : tenantInfoList) {

View File

@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.entity.TrxExchangeInfo;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.system.domain.TrxExchangeMonitorAccountInfo;
import com.ruoyi.system.handler.UndelegateEnergyHandler;
import com.ruoyi.system.service.ITenantInfoService;
import com.ruoyi.system.service.ITrxExchangeInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -24,9 +25,13 @@ public class UndelegateEnergyTask {
@Autowired
private UndelegateEnergyHandler undelegateEnergyHandler;
@Autowired
private ITenantInfoService tenantInfoService;
public void doUndelegateEnergy() {
String dictValue = DictUtils.getDictValue("sys_delegate_status", "已委托");
TrxExchangeInfo trxExchangeInfoExample = TrxExchangeInfo.builder()

View File

@ -32,7 +32,9 @@ public class TrxExchange extends BaseEntity
private Long price;
private String energyBusiType;
private String calcRule;

View File

@ -77,4 +77,25 @@ public class TrxExchangeMonitorAccountInfo implements Serializable {
private String unDelegateTxId;
private Integer countUsed;
private String calcRule;
/* private String status;
private String isPaid;
private Long delegatedDays;
private Long period;
private Integer maxTransferCount;
private Long idTenantInfo;*/
}

View File

@ -110,4 +110,7 @@ public class TrxExchangeInfoVO {
*
*/
private String lcu;
private String calcRule;
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.system.handler;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.ruoyi.common.core.domain.entity.ErrorLog;
import com.ruoyi.common.core.domain.entity.TenantInfo;
@ -8,6 +9,7 @@ import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.ForwardCounter;
import com.ruoyi.common.utils.LogUtils;
import com.ruoyi.system.domain.TrxExchangeMonitorAccountInfo;
import com.ruoyi.system.mapper.TenantInfoMapper;
import com.ruoyi.system.mapper.TrxExchangeInfoMapper;
import com.ruoyi.system.service.IErrorLogService;
import com.ruoyi.system.service.ITenantInfoService;
@ -30,6 +32,9 @@ public class EnergyTenantTransferHandler {
@Autowired
private ITenantInfoService tenantInfoService;
@Autowired
private TenantInfoMapper tenantInfoMapper;
@Autowired
private IErrorLogService errorLogService;
@ -40,23 +45,49 @@ public class EnergyTenantTransferHandler {
*/
public void doEnergyTenantTransfer(TenantInfo tenantInfo) {
try {
String delegateStatus = DictUtils.getDictValue("sys_delegate_status", "已委托");
//查看有没有没回收的能量,有的话先回收
TrxExchangeInfo trxExchangeInfo = TrxExchangeInfo.builder()
.fromAddress(tenantInfo.getReceiverAddress())
.delegateStatus(delegateStatus)
.energyBusiType(DictUtils.getDictValue("sys_energy_busi_type", "天数套餐"))
.fcd(DateUtil.offsetDay(new Date(), -2))
.build();
List<TrxExchangeMonitorAccountInfo> trxExchangeMonitorAccountInfoList = trxExchangeInfoMapper.selectTrxExchangeMonitorAccountInfo(trxExchangeInfo);
String eneryBusiTypeByDay = DictUtils.getDictValue("sys_energy_busi_type", "天数套餐");
for (TrxExchangeMonitorAccountInfo trxExchangeMonitorAccountInfo : trxExchangeMonitorAccountInfoList) {
undelegateEnergyHandler.unDelegateResource(trxExchangeMonitorAccountInfo);
if (tenantInfo.getEnergyBusiType().equals(eneryBusiTypeByDay)){
String delegateStatus = DictUtils.getDictValue("sys_delegate_status", "已委托");
//查看有没有没回收的能量,有的话先回收
TrxExchangeInfo trxExchangeInfo = TrxExchangeInfo.builder()
.fromAddress(tenantInfo.getReceiverAddress())
.delegateStatus(delegateStatus)
.energyBusiType(eneryBusiTypeByDay)
.fcd(DateUtil.offsetDay(new Date(), -2))
.build();
List<TrxExchangeMonitorAccountInfo> trxExchangeMonitorAccountInfoList = trxExchangeInfoMapper.selectTrxExchangeMonitorAccountInfo(trxExchangeInfo);
for (TrxExchangeMonitorAccountInfo trxExchangeMonitorAccountInfo : trxExchangeMonitorAccountInfoList) {
undelegateEnergyHandler.unDelegateResource(trxExchangeMonitorAccountInfo);
}
//赠送每天的能量
tenantInfoService.doDelegateEnergy(tenantInfo,"system");
}else{
String delegateStatus = DictUtils.getDictValue("sys_delegate_status", "已回收");
//查看有没有没回收的能量,有的话先回收
TrxExchangeInfo trxExchangeInfo = TrxExchangeInfo.builder()
.fromAddress(tenantInfo.getReceiverAddress())
.delegateStatus(delegateStatus)
.energyBusiType(eneryBusiTypeByDay)
.fcd(DateUtil.offsetDay(new Date(), -2))
.build();
List<TrxExchangeMonitorAccountInfo> trxExchangeMonitorAccountInfoList = trxExchangeInfoMapper.selectTrxExchangeMonitorAccountInfo(trxExchangeInfo);
if (CollectionUtil.isEmpty(trxExchangeMonitorAccountInfoList)){
//一笔都没有使用,每天自动扣除一笔
tenantInfo.setTotalCountUsed(tenantInfo.getTotalCountUsed()+1);
tenantInfo.setLcu("system");
tenantInfoMapper.updateTenantInfo(tenantInfo);
}
tenantInfoMapper.updateTenantInfo(tenantInfo);
}
//赠送每天的能量
tenantInfoService.doDelegateEnergy(tenantInfo,"system");
} catch (Exception e) {
String exceptionString = LogUtils.doRecursiveReversePrintStackCause(e, 5, ForwardCounter.builder().count(0).build(), 5);
log.error("获取trx20交易列表异常:{}", exceptionString);
@ -71,4 +102,6 @@ public class EnergyTenantTransferHandler {
}
}
}

View File

@ -316,7 +316,7 @@ public class TRX2EneryTransferHandler {
}
calcBalanceAndDelegate(txID, apiWrapper, accountAddress, transferCount, ownerAddress, lockPeriod, toAddress, price, sysEnergyBusiType, amount,"TRX","system",Common.ResourceCode.ENERGY.name());
calcBalanceAndDelegate(txID, apiWrapper, accountAddress, transferCount, ownerAddress, lockPeriod, toAddress, price, sysEnergyBusiType, amount,"TRX","system",Common.ResourceCode.ENERGY.name(),"energy_used");
//持久化之后放redis
redisTemplate.opsForValue().set("transfer_trx_" + txID, txID, 1, TimeUnit.DAYS);
if (tenantInfo != null) {
@ -338,6 +338,7 @@ public class TRX2EneryTransferHandler {
* @param sysEnergyBusiType
* @param amount
* @param currentUser
* @param calcRule
* @throws Exception
*/
public void calcBalanceAndDelegate(String txID,
@ -352,7 +353,7 @@ public class TRX2EneryTransferHandler {
Long amount,
String trxAmountUnit,
String currentUser,
String resourceCode) throws Exception {
String resourceCode, String calcRule) throws Exception {
String systronApiSwitch = configService.selectConfigByKey("sys.tron.api");
Long balance = null;
@ -383,6 +384,7 @@ public class TRX2EneryTransferHandler {
.resourceCode(resourceCode)
.delegateTxId(delegateResourceTxid)
.lockPeriod(lockPeriod)
.calcRule(calcRule)
.delegateStatus("0")
.fcd(new Date())
.fcu(currentUser)

View File

@ -1,8 +1,8 @@
package com.ruoyi.system.handler;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.entity.ErrorLog;
import com.ruoyi.common.core.domain.entity.TenantInfo;
import com.ruoyi.common.core.domain.entity.TrxExchangeInfo;
@ -12,6 +12,8 @@ import com.ruoyi.common.utils.encrpt.Dt;
import com.ruoyi.system.api.ITronApi;
import com.ruoyi.system.domain.TrxExchangeMonitorAccountInfo;
import com.ruoyi.system.dto.AccountResourceResponse;
import com.ruoyi.system.dto.Data;
import com.ruoyi.system.dto.TronGridResponse;
import com.ruoyi.system.mapper.TenantInfoMapper;
import com.ruoyi.system.mapper.TrxExchangeInfoMapper;
import com.ruoyi.system.service.IErrorLogService;
@ -56,61 +58,91 @@ public class UndelegateEnergyHandler {
Long lockPeriod = trxExchangeMonitorAccountInfo.getLockPeriod();
Date fcd = trxExchangeMonitorAccountInfo.getFcd();
Date now = new Date();
// long betweenSeconds = DateUtil.between(fcd, now, DateUnit.SECOND);
long betweenHours = DateUtil.between(fcd, now, DateUnit.HOUR);
String fromAddress = trxExchangeMonitorAccountInfo.getFromAddress();
if (betweenHours < lockPeriod){
//超过时间强制回收
if (betweenHours < lockPeriod) {
//定时任务判断对方转账笔数
String apiKey = trxExchangeMonitorAccountInfo.getApiKey();
apiKey = StringUtils.isEmpty(apiKey) ? DictUtils.getDictValue("sys_tron_api_key", "synp@outlook") : apiKey;
// TronGridResponse tronGridResponse = tronApi.getTronGridTrc20Response(fromAddress,false,true, apiKey,fcd.getTime());
// List<Data> dataList = tronGridResponse.getData();
// if (CollectionUtil.isEmpty(dataList)) {
// return;
// }
// String apiKey = trxExchangeMonitorAccountInfo.getApiKey();
//
// int transActionCount = dataList.size();
// if (transActionCount < trxExchangeMonitorAccountInfo.getTranferCount()){
// return;
// }
// apiKey = StringUtils.isEmpty(apiKey) ? DictUtils.getDictValue("sys_tron_api_key", "synp@outlook") : apiKey;
String apiKey = DictUtils.getRandomDictValue("sys_tron_api_key");
String calcRule = trxExchangeMonitorAccountInfo.getCalcRule();
String dictValue = DictUtils.getDictValue("sys_transaction_count_calc_rule", "实际交易法");
if (StringUtils.isNotNull(calcRule) && dictValue.equals(calcRule)) {
TronGridResponse tronGridResponse = tronApi.getTronGridTrc20Response(fromAddress, false, true, apiKey, fcd.getTime());
List<Data> dataList = tronGridResponse.getData();
if (CollectionUtil.isEmpty(dataList)) {
return;
}
//只要有交易,就进行回收
/* int transActionCount = dataList.size();
if (transActionCount < trxExchangeMonitorAccountInfo.getTranferCount()) {
return;
}*/
trxExchangeMonitorAccountInfo.setCountUsed(dataList.size());
} else {
AccountResourceResponse accountResource = tronApi.getAccountResource(fromAddress, apiKey);
if (accountResource == null) {
return;
}
String energyBusiType = trxExchangeMonitorAccountInfo.getEnergyBusiType();
String sysEnergyBusiType = DictUtils.getDictValue("sys_energy_busi_type", "闪兑套餐");
String sysEnergyBusiType1 = DictUtils.getDictValue("sys_energy_busi_type", "笔数限时套餐");
if (sysEnergyBusiType.equals(energyBusiType) || sysEnergyBusiType1.equals(energyBusiType)) {
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;
}
}
} else {
String resourceCode = trxExchangeMonitorAccountInfo.getResourceCode();
if (resourceCode.equals(Common.ResourceCode.ENERGY.name())) {
Integer energyUsed = accountResource.getEnergyUsed();
if (energyUsed == null) {
return;
}
int energyUsedCount = energyUsed / 30000;
if (energyUsedCount == 0) {
return;
}
trxExchangeMonitorAccountInfo.setCountUsed(energyUsedCount);
}
}
AccountResourceResponse accountResource = tronApi.getAccountResource(fromAddress, apiKey);
if (accountResource == null){
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;
}
}
}
//超过时间强制回收
unDelegateResource(trxExchangeMonitorAccountInfo);
}
@ -124,20 +156,33 @@ public class UndelegateEnergyHandler {
String encryptKey = trxExchangeMonitorAccountInfo.getEncryptKey();
String decryptPrivateKey = Dt.decrypt(encryptPrivateKey, encryptKey);
boolean res = lock.tryLock(3, 50, TimeUnit.SECONDS);
boolean res = lock.tryLock(1, 50, TimeUnit.SECONDS);
if (!res) {
//有其他程序正在处理则不需要再处理
return;
}
String tronApiKey = DictUtils.getDictValue("sys_tron_api_key", "synp@outlook");
ApiWrapper apiWrapper = ApiWrapper.ofMainnet(decryptPrivateKey, tronApiKey);
//再次确认记录是否已经被回收
TrxExchangeInfo trxExchangeInfo = trxExchangeInfoMapper.selectTrxExchangeInfoByIdTrxExchangeInfo(trxExchangeMonitorAccountInfo.getIdTrxExchangeInfo());
String deleagteStatus = DictUtils.getDictValue("sys_delegate_status", "已回收");
if (deleagteStatus.equals(trxExchangeInfo.getDelegateStatus())) {
//已经处理过不再处理
return;
}
// String tronApiKey = DictUtils.getDictValue("sys_tron_api_key", "synp@outlook");
String apiKey = DictUtils.getRandomDictValue("sys_tron_api_key");
ApiWrapper apiWrapper = ApiWrapper.ofMainnet(decryptPrivateKey, apiKey);
//回收能量
doUndelegateEnergy(trxExchangeMonitorAccountInfo, apiWrapper);
String sysEnergyBusiType = DictUtils.getDictValue("sys_energy_busi_type", "天数套餐");
String trxExchangeInfoBusiType = trxExchangeMonitorAccountInfo.getEnergyBusiType();
if (!sysEnergyBusiType.equals(trxExchangeInfoBusiType)) {
Integer countUsed = trxExchangeMonitorAccountInfo.getCountUsed();
if (countUsed == null || countUsed == 0){
//代表不是按照回收监控或者套餐类型的订单
return;
}
@ -152,52 +197,102 @@ public class UndelegateEnergyHandler {
tenantInfo = tenantInfoList.get(0);
if (UserConstants.NO.equals(tenantInfo.getIsPaid())) {
/* if (UserConstants.NO.equals(tenantInfo.getIsPaid())) {
return;
}
}*/
Long period = tenantInfo.getPeriod();
// long between = DateUtil.between(tenantInfoFcd, new Date(), DateUnit.DAY);
Long delegatedDays = tenantInfo.getDelegatedDays();
if (delegatedDays == period) {
//委托天数已用完不再处理,更改状态为已满期
String expire = DictUtils.getDictValue("sys_tenant_status", "已满期");
tenantInfo.setStatus(expire);
tenantInfoMapper.updateTenantInfo(tenantInfo);
}
/*
String monitorAddress = tenantInfo.getMonitorAddress();
String toAddress = trxExchangeMonitorAccountInfo.getToAddress();
if (StringUtils.isNotEmpty(toAddress) && !toAddress.equals(monitorAddress)) {
return;
}
tenantInfo.setDelegatedDays(delegatedDays + 1);
String receiverAddress = tenantInfo.getReceiverAddress();
Long totalCountUsed = tenantInfo.getTotalCountUsed();
long newTotalCountUsed = totalCountUsed + countUsed;
tenantInfo.setTotalCountUsed(newTotalCountUsed);
Long transferCount = tenantInfo.getTransferCount();
// long newLockPeriod = 24 * 1200L;
long between = DateUtil.between(DateUtil.date(), DateUtil.endOfDay(DateUtil.date()), DateUnit.HOUR);
long newLockPeriod = between + 1;
trx2EneryTransferHandler.calcBalanceAndDelegate(null,
apiWrapper,
accountAddress,
transferCount,
receiverAddress,
newLockPeriod,
monitorAddress,
tenantInfo.getPrice(),
sysEnergyBusiType,
null,
"system");*/
if (newTotalCountUsed < transferCount) {
//回收完再次赠送
trx2EneryTransferHandler.calcBalanceAndDelegate(null,
apiWrapper,
accountAddress,
2,
tenantInfo.getReceiverAddress(),
24,
null,
tenantInfo.getPrice(),
tenantInfo.getEnergyBusiType(),
null,
null,
"system",
Common.ResourceCode.ENERGY.name(), tenantInfo.getCalcRule());
} else {
Long period = tenantInfo.getPeriod();
Long delegatedDays = tenantInfo.getDelegatedDays();
String sysEnergyBusiType = DictUtils.getDictValue("sys_energy_busi_type", "天数套餐");
String trxExchangeInfoBusiType = trxExchangeMonitorAccountInfo.getEnergyBusiType();
if (trxExchangeInfoBusiType.equals(sysEnergyBusiType) ) {
if ( delegatedDays == period){
//委托天数已用完不再处理,更改状态为已满期
String expire = DictUtils.getDictValue("sys_tenant_status", "已满期");
tenantInfo.setStatus(expire);
}
}else{
//笔数套餐超过次数直接设置为耗尽
String expire = DictUtils.getDictValue("sys_tenant_status", "笔数用完");
tenantInfo.setStatus(expire);
}
tenantInfo.setTotalCountUsed(transferCount);
}
tenantInfo.setLcu("system");
tenantInfoMapper.updateTenantInfo(tenantInfo);
}
/* if (tenantInfo != null) {
tenantInfoMapper.updateTenantInfo(tenantInfo);
}*/
//查询是否是按天支付的租户,是的话需要回收完再次赠送
//
// Integer totalCountUsed = trxExchangeMonitorAccountInfo.getTotalCountUsed();
//
// if (totalCountUsed == null) {
// //不是天数或者套餐不需要再继续处理
// return;
// }
// if (UserConstants.NO.equals(trxExchangeMonitorAccountInfo.getIsPaid())) {
// return;
// }
//
//
//// if (delegatedDays == period) {
//// //委托天数已用完不再处理,更改状态为已满期
//// String expire = DictUtils.getDictValue("sys_tenant_status", "已满期");
//// tenantInfo.setStatus(expire);
//// tenantInfoMapper.updateTenantInfo(tenantInfo);
//// }
// Integer maxTransferCount = trxExchangeMonitorAccountInfo.getMaxTransferCount();
// TenantInfo tenantInfo = new TenantInfo();
// tenantInfo.setIdTenantInfo(trxExchangeMonitorAccountInfo.getIdTenantInfo());
// tenantInfo.setTotalCountUsed(trxExchangeMonitorAccountInfo.getTotalCountUsed().longValue());
// if (totalCountUsed < maxTransferCount) {
// //回收完再次赠送
//
// } else {
// Long period = trxExchangeMonitorAccountInfo.getPeriod();
// Long delegatedDays = trxExchangeMonitorAccountInfo.getDelegatedDays();
// String sysEnergyBusiType = DictUtils.getDictValue("sys_energy_busi_type", "天数套餐");
// String trxExchangeInfoBusiType = trxExchangeMonitorAccountInfo.getEnergyBusiType();
// if (trxExchangeInfoBusiType.equals(sysEnergyBusiType) ) {
// if ( delegatedDays == period){
// //委托天数已用完不再处理,更改状态为已满期
// String expire = DictUtils.getDictValue("sys_tenant_status", "已满期");
// tenantInfo.setStatus(expire);
// }
// }else{
// //笔数套餐超过次数直接设置为耗尽
// String expire = DictUtils.getDictValue("sys_tenant_status", "已满期");
// tenantInfo.setStatus(expire);
// }
// }
//
// tenantInfoMapper.updateTenantInfo(tenantInfo);
} catch (Exception e) {
log.error("回收能量业务处理异常{}", trxExchangeMonitorAccountInfo.getIdTrxExchangeInfo(), e);
@ -236,7 +331,7 @@ public class UndelegateEnergyHandler {
long balance = trxExchangeMonitorAccountInfo.getDelegateAmountTrx() * 1000000;
Response.TransactionExtention transactionExtention = apiWrapper.undelegateResource(accountAddress,
balance, Common.ResourceCode.valueOf(trxExchangeMonitorAccountInfo.getResourceCode()).getNumber(), fromAddress);
balance, Common.ResourceCode.valueOf(trxExchangeMonitorAccountInfo.getResourceCode()).getNumber(), fromAddress);
Chain.Transaction transaction = apiWrapper.signTransaction(transactionExtention);

View File

@ -164,9 +164,10 @@ public class AccountAddressInfoServiceImpl implements IAccountAddressInfoService
//解密获得秘钥
String decryptPrivateKey = Dt.decrypt(encryptPrivateKey, encryptKey);
String tronApiKey = DictUtils.getDictValue("sys_tron_api_key", "synp@outlook");
// String tronApiKey = DictUtils.getDictValue("sys_tron_api_key", "synp@outlook");
String apiKey = DictUtils.getRandomDictValue("sys_tron_api_key");
ApiWrapper apiWrapper = ApiWrapper.ofMainnet(decryptPrivateKey,tronApiKey);
ApiWrapper apiWrapper = ApiWrapper.ofMainnet(decryptPrivateKey,apiKey);
String address = addressInfo.getAddress();
Response.AccountResourceMessage accountResource = apiWrapper.getAccountResource(address);

View File

@ -75,9 +75,10 @@ public class FreezeBalanceInfoServiceImpl implements IFreezeBalanceInfoService
String address = freezeBalanceInfo.getAddress();
String decryptPrivateKey = accountAddressInfoService.getDecryptPrivateKey(address);
String tronApiKey = DictUtils.getDictValue("sys_tron_api_key", "synp@outlook");
// String tronApiKey = DictUtils.getDictValue("sys_tron_api_key", "synp@outlook");
String apiKey = DictUtils.getRandomDictValue("sys_tron_api_key");
//发起抵押
ApiWrapper apiWrapper = ApiWrapper.ofMainnet(decryptPrivateKey,tronApiKey);
ApiWrapper apiWrapper = ApiWrapper.ofMainnet(decryptPrivateKey,apiKey);
Long frozenBalance = freezeTrxAmount * 1000000L;

View File

@ -1,8 +1,6 @@
package com.ruoyi.system.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.google.common.base.Preconditions;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants;
@ -23,6 +21,7 @@ import com.ruoyi.system.service.ITrxExchangeInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.tron.trident.proto.Common;
import java.util.Date;
import java.util.List;
@ -77,16 +76,26 @@ public class TenantInfoServiceImpl implements ITenantInfoService {
@Override
public int insertTenantInfo(TenantInfo tenantInfo) {
String energyBusiType = tenantInfo.getEnergyBusiType();
Preconditions.checkState(!(energyBusiType.equals("1") || energyBusiType.equals("2")), "套餐类型不正确,定制业务不支持");
Long delegatedDays = tenantInfo.getDelegatedDays();
if (energyBusiType.equals("4")) {
Preconditions.checkState(delegatedDays == null, "笔数不限时套餐天数必须为无");
}
TenantInfo tenantInfoExample = new TenantInfo();
tenantInfoExample.setReceiverAddress(tenantInfo.getReceiverAddress());
List<TenantInfo> tenantInfoList = tenantInfoMapper.selectTenantInfoList(tenantInfoExample);
boolean exists = false;
if (CollectionUtil.isEmpty(tenantInfoList)) {
exists = !tenantInfoList.stream().anyMatch(tenantInfo1 -> {
if (CollectionUtil.isNotEmpty(tenantInfoList)) {
exists = tenantInfoList.stream().anyMatch(tenantInfo1 -> {
return tenantInfo1.getStatus().equals(DictUtils.getDictValue("sys_tenant_status", "生效中"));
});
}
Preconditions.checkState( !exists, "该接收能量地址已存在,请勿重复添加");
Preconditions.checkState(!exists, "该接收能量地址已有一笔正在生效中的业务,请勿重复添加");
Long price = tenantInfo.getPrice();
Long transferCount = tenantInfo.getTransferCount();
@ -107,6 +116,8 @@ public class TenantInfoServiceImpl implements ITenantInfoService {
String status = DictUtils.getDictValue("sys_tenant_status", "生效中");
tenantInfo.setStatus(status);
tenantInfo.setTotalCountUsed(0L);
tenantInfo.setLcd(new Date());
tenantInfo.setLcu(loginName);
@ -165,6 +176,10 @@ public class TenantInfoServiceImpl implements ITenantInfoService {
for (String id : idArray) {
TenantInfo tenantInfo = tenantInfoMapper.selectTenantInfoByIdTenantInfo(Long.valueOf(id));
Long totalCountUsed = tenantInfo.getTotalCountUsed();
Preconditions.checkState(totalCountUsed == 0, "该接收能量地址已在任务中,请勿重复发起");
String status = DictUtils.getDictValue("sys_tenant_status", "生效中");
Preconditions.checkState(status.equals(tenantInfo.getStatus()), "该租户不是生效中状态,不能发起委托任务");
@ -216,20 +231,27 @@ public class TenantInfoServiceImpl implements ITenantInfoService {
trxExchange.setFromAddress(tenantInfo.getReceiverAddress());
trxExchange.setAccountAddress(accountAddress);
trxExchange.setTransferNumber(tenantInfo.getTransferCount());
// trxExchange.setTransferNumber(tenantInfo.getTransferCount());
trxExchange.setTransferNumber(2L);
trxExchange.setPrice(tenantInfo.getPrice());
trxExchange.setMonitorAddress(monitorAddress);
long between = DateUtil.between(DateUtil.date(), DateUtil.endOfDay(DateUtil.date()), DateUnit.HOUR);
trxExchange.setLockNum(between + 1);
// long between = DateUtil.between(DateUtil.date(), DateUtil.endOfDay(DateUtil.date()), DateUnit.HOUR);
trxExchange.setLockNum(24L);
trxExchange.setEnergyBusiType(tenantInfo.getEnergyBusiType());
trxExchange.setResourceCode(Common.ResourceCode.ENERGY.name());
trxExchange.setCalcRule(tenantInfo.getCalcRule());
userName = userName == null ? ShiroUtils.getLoginName() : userName;
trxExchangeInfoService.delegate(trxExchange, true, userName);
tenantInfo.setDelegatedDays(tenantInfo.getDelegatedDays() + 1);
tenantInfo.setTotalCountUsed(0L);
tenantInfo.setLcd(new Date());
tenantInfoMapper.updateTenantInfo(tenantInfo);
}

View File

@ -133,19 +133,23 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
userName = userName == null ? ShiroUtils.getLoginName() : userName;
String calcRule = "energy_used";
String sysEnergyBusiType = DictUtils.getDictValue("sys_energy_busi_type", "闪兑套餐");
if (isTenant) {
sysEnergyBusiType = DictUtils.getDictValue("sys_energy_busi_type", "天数套餐");
// sysEnergyBusiType = DictUtils.getDictValue("sys_energy_busi_type", "天数套餐");
sysEnergyBusiType = trxExchange.getEnergyBusiType();
calcRule = trxExchange.getCalcRule();
} else if (lockPeriod > 1 && lockPeriod <= 24 ) {
sysEnergyBusiType = DictUtils.getDictValue("sys_energy_busi_type", "笔数套餐");
sysEnergyBusiType = DictUtils.getDictValue("sys_energy_busi_type", "笔数限时套餐");
}
// if (UserConstants.YES.equals(systronApiSwitch)) {
String accountAddress = trxExchange.getAccountAddress();
String decryptPrivateKey = accountAddressInfoService.getDecryptPrivateKey(accountAddress);
String tronApiKey = DictUtils.getDictValue("sys_tron_api_key", "synp@outlook");
// String tronApiKey = DictUtils.getDictValue("sys_tron_api_key", "synp@outlook");
String apiKey = DictUtils.getRandomDictValue("sys_tron_api_key");
ApiWrapper apiWrapper = ApiWrapper.ofMainnet(decryptPrivateKey, tronApiKey);
ApiWrapper apiWrapper = ApiWrapper.ofMainnet(decryptPrivateKey, apiKey);
trx2EneryTransferHandler.calcBalanceAndDelegate(null,
apiWrapper,
@ -159,7 +163,7 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
null,
null,
userName,
trxExchange.getResourceCode());
trxExchange.getResourceCode(), calcRule);
return 1;
}

View File

@ -95,11 +95,12 @@ public class UsdtExchangeInfoServiceImpl implements IUsdtExchangeInfoService {
}
String decryptPrivateKey = accountAddressInfoService.getDecryptPrivateKey(accountAddress);
String tronApiKey = DictUtils.getDictValue("sys_tron_api_key", "synp@outlook");
// String tronApiKey = DictUtils.getDictValue("sys_tron_api_key", "synp@outlook");
String apiKey = DictUtils.getRandomDictValue("sys_tron_api_key");
String fromAddress = usdtExchangeInfo.getFromAddress();
usdt2TrxTransferHandler.
doTransferUsdtAndStore(oneUsdtToTrxPair, tronApiKey, decryptPrivateKey, accountAddress, fromAddress, trxValue, null, null, usdtAmount);
doTransferUsdtAndStore(oneUsdtToTrxPair, apiKey, decryptPrivateKey, accountAddress, fromAddress, trxValue, null, null, usdtAmount);
return 1;
}

View File

@ -8,6 +8,7 @@
<result property="idTenantInfo" column="id_tenant_info" />
<result property="receiverAddress" column="receiver_address" />
<result property="monitorAddress" column="monitor_address" />
<result property="energyBusiType" column="energy_busi_type" />
<result property="price" column="price" />
<result property="transferCount" column="transfer_count" />
<result property="exchangeUnit" column="exchange_unit" />
@ -18,6 +19,8 @@
<result property="userId" column="user_id" />
<result property="status" column="status" />
<result property="delegatedDays" column="delegated_days" />
<result property="totalCountUsed" column="total_count_used" />
<result property="calcRule" column="calc_rule" />
<result property="fcd" column="fcd" />
<result property="fcu" column="fcu" />
<result property="lcd" column="lcd" />
@ -25,7 +28,7 @@
</resultMap>
<sql id="selectTenantInfoVo">
select id_tenant_info, receiver_address, monitor_address, price, transfer_count, exchange_unit, tx_id, exchange_amount, is_paid, period, t.status, delegated_days, fcd, fcu, lcd, lcu from tenant_info t
select id_tenant_info, receiver_address, monitor_address, energy_busi_type,price, transfer_count, exchange_unit, tx_id, exchange_amount, is_paid, period, t.user_id, t.status, delegated_days, total_count_used, calc_rule, fcd, fcu, lcd, lcu from tenant_info t
</sql>
<select id="selectTenantInfoList" parameterType="TenantInfo" resultMap="TenantInfoResult">
@ -34,14 +37,17 @@
<where> 1 = 1
<if test="receiverAddress != null and receiverAddress != ''"> and receiver_address = #{receiverAddress}</if>
<if test="monitorAddress != null and monitorAddress != ''"> and monitor_address = #{monitorAddress}</if>
<if test="energyBusiType != null and energyBusiType != ''"> and energy_busi_type = #{energyBusiType}</if>
<if test="price != null "> and price = #{price}</if>
<if test="transferCount != null "> and transfer_count = #{transferCount}</if>
<if test="exchangeUnit != null and exchangeUnit != ''"> and exchange_unit = #{exchangeUnit}</if>
<if test="txId != null and txId != ''"> and tx_id = #{txId}</if>
<if test="exchangeAmount != null "> and exchange_amount = #{exchangeAmount}</if>
<if test="isPaid != null and isPaid != ''"> and is_paid = #{isPaid}</if>
<if test="status != null and status != ''" >and t.status = #{status}</if>
<if test="period != null "> and period = #{period}</if>
<if test="fcd != null "> and fcd = #{fcd}</if>
<if test="calcRule != null and calcRule != ''"> and calc_rule = #{calcRule}</if>
<if test="params.beginFcd != null and params.beginFcd != '' and params.endFcd != null and params.endFcd != ''"> and fcd between #{params.beginFcd} and #{params.endFcd}</if>
<if test="fcu != null and fcu != ''"> and fcu = #{fcu}</if>
<if test="lcd != null "> and lcd = #{lcd}</if>
<if test="lcu != null and lcu != ''"> and lcu = #{lcu}</if>
@ -55,11 +61,13 @@
where id_tenant_info = #{idTenantInfo}
</select>
<insert id="insertTenantInfo" parameterType="TenantInfo" useGeneratedKeys="true" keyProperty="idTenantInfo">
insert into tenant_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="receiverAddress != null and receiverAddress != ''">receiver_address,</if>
<if test="monitorAddress != null">monitor_address,</if>
<if test="energyBusiType != null">energy_busi_type,</if>
<if test="price != null">price,</if>
<if test="transferCount != null">transfer_count,</if>
<if test="exchangeUnit != null">exchange_unit,</if>
@ -70,6 +78,8 @@
<if test="userId != null">user_id,</if>
<if test="status != null">status,</if>
<if test="delegatedDays != null">delegated_days,</if>
<if test="totalCountUsed != null">total_count_used,</if>
<if test="calcRule != null">calc_rule,</if>
<if test="fcd != null">fcd,</if>
<if test="fcu != null">fcu,</if>
<if test="lcd != null">lcd,</if>
@ -78,6 +88,7 @@
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="receiverAddress != null and receiverAddress != ''">#{receiverAddress},</if>
<if test="monitorAddress != null">#{monitorAddress},</if>
<if test="energyBusiType != null">#{energyBusiType},</if>
<if test="price != null">#{price},</if>
<if test="transferCount != null">#{transferCount},</if>
<if test="exchangeUnit != null">#{exchangeUnit},</if>
@ -88,6 +99,8 @@
<if test="userId != null">#{userId},</if>
<if test="status != null">#{status},</if>
<if test="delegatedDays != null">#{delegatedDays},</if>
<if test="totalCountUsed != null">#{totalCountUsed},</if>
<if test="calcRule != null">#{calcRule},</if>
<if test="fcd != null">#{fcd},</if>
<if test="fcu != null">#{fcu},</if>
<if test="lcd != null">#{lcd},</if>
@ -100,6 +113,7 @@
<trim prefix="SET" suffixOverrides=",">
<if test="receiverAddress != null and receiverAddress != ''">receiver_address = #{receiverAddress},</if>
<if test="monitorAddress != null">monitor_address = #{monitorAddress},</if>
<if test="energyBusiType != null">energy_busi_type = #{energyBusiType},</if>
<if test="price != null">price = #{price},</if>
<if test="transferCount != null">transfer_count = #{transferCount},</if>
<if test="exchangeUnit != null">exchange_unit = #{exchangeUnit},</if>
@ -110,6 +124,8 @@
<if test="userId != null">user_id = #{userId},</if>
<if test="status != null">status = #{status},</if>
<if test="delegatedDays != null">delegated_days = #{delegatedDays},</if>
<if test="totalCountUsed != null">total_count_used = #{totalCountUsed},</if>
<if test="calcRule != null">calc_rule = #{calcRule},</if>
<if test="fcd != null">fcd = #{fcd},</if>
<if test="fcu != null">fcu = #{fcu},</if>
<if test="lcd != null">lcd = #{lcd},</if>

View File

@ -21,6 +21,7 @@
<result column="delegateTxId" property="delegateTxId"/>
<result column="lockPeriod" property="lockPeriod"/>
<result column="delegateStatus" property="delegateStatus"/>
<result column="calcRule" property="calcRule"/>
<result column="unDelegateTxId" property="unDelegateTxId"/>
<result column="fcd" property="fcd"/>
<result column="fcu" property="fcu"/>
@ -43,6 +44,7 @@
<result property="delegateTxId" column="delegate_tx_id" />
<result property="lockPeriod" column="lock_period" />
<result property="delegateStatus" column="delegate_status" />
<result property="calcRule" column="calc_rule" />
<result property="unDelegateTxId" column="un_delegate_tx_id" />
<result property="fcd" column="fcd" />
<result property="fcu" column="fcu" />
@ -51,7 +53,7 @@
</resultMap>
<sql id="selectTrxExchangeInfoVo">
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
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, calc_rule, un_delegate_tx_id, fcd, fcu, lcd, lcu from trx_exchange_info
</sql>
<select id="selectTrxExchangeInfoList" parameterType="TrxExchangeInfo" resultMap="TrxExchangeInfoResult">
@ -71,6 +73,7 @@
<if test="delegateTxId != null and delegateTxId != ''"> and delegate_tx_id = #{delegateTxId}</if>
<if test="lockPeriod != null "> and lock_period = #{lockPeriod}</if>
<if test="delegateStatus != null and delegateStatus != ''"> and delegate_status = #{delegateStatus}</if>
<if test="calcRule != null and calcRule != ''"> and calc_rule = #{calcRule}</if>
<if test="unDelegateTxId != null and unDelegateTxId != ''"> and un_delegate_tx_id = #{unDelegateTxId}</if>
<if test="params.beginFcd != null and params.beginFcd != '' and params.endFcd != null and params.endFcd != ''"> and fcd between #{params.beginFcd} and #{params.endFcd}</if>
<if test="fcu != null and fcu != ''"> and fcu = #{fcu}</if>
@ -101,6 +104,7 @@
<if test="delegateTxId != null">delegate_tx_id,</if>
<if test="lockPeriod != null">lock_period,</if>
<if test="delegateStatus != null">delegate_status,</if>
<if test="calcRule != null">calc_rule,</if>
<if test="unDelegateTxId != null">un_delegate_tx_id,</if>
<if test="fcd != null">fcd,</if>
<if test="fcu != null">fcu,</if>
@ -122,6 +126,7 @@
<if test="delegateTxId != null">#{delegateTxId},</if>
<if test="lockPeriod != null">#{lockPeriod},</if>
<if test="delegateStatus != null">#{delegateStatus},</if>
<if test="calcRule != null">#{calcRule},</if>
<if test="unDelegateTxId != null">#{unDelegateTxId},</if>
<if test="fcd != null">#{fcd},</if>
<if test="fcu != null">#{fcu},</if>
@ -147,6 +152,7 @@
<if test="delegateTxId != null">delegate_tx_id = #{delegateTxId},</if>
<if test="lockPeriod != null">lock_period = #{lockPeriod},</if>
<if test="delegateStatus != null">delegate_status = #{delegateStatus},</if>
<if test="calcRule != null">calc_rule = #{calcRule},</if>
<if test="unDelegateTxId != null">un_delegate_tx_id = #{unDelegateTxId},</if>
<if test="fcd != null">fcd = #{fcd},</if>
<if test="fcu != null">fcu = #{fcu},</if>
@ -179,6 +185,7 @@
<result column="resource_code" property="resourceCode"/>
<result column="lock_period" property="lockPeriod"/>
<result column="delegate_status" property="delegateStatus"/>
<result column="calc_rule" property="calcRule"/>
<result column="delegate_tx_id" property="delegateTxId"/>
<result column="un_delegate_tx_id" property="unDelegateTxId"/>
<result column="fcd" property="fcd"/>
@ -199,6 +206,7 @@
t.resource_code,
t.lock_period,
t.delegate_status,
t.calc_rule,
t.delegate_tx_id,
t.un_delegate_tx_id,
t.fcd,
@ -240,6 +248,7 @@
t.delegate_tx_id delegateTxId,
t.lock_period lockPeriod,
t.delegate_status delegateStatus,
t.calc_rule calcRule,
t.un_delegate_tx_id unDelegateTxId,
t.fcd,
t.fcu,