mirror of https://gitee.com/y_project/RuoYi.git
第一次提交,优化部分trx兑换服用逻辑
parent
974cf43b43
commit
3704b2183e
|
@ -13,15 +13,15 @@
|
|||
<input name="receiverAddress" class="form-control" type="text" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<!-- <div class="form-group" >
|
||||
<label class="col-sm-3 control-label">监控入账地址:</label>
|
||||
<div class="col-sm-8">
|
||||
<!-- <input name="accountAddress" class="form-control" type="text">-->
|
||||
<!– <input name="accountAddress" class="form-control" type="text">–>
|
||||
<select id="monitorAddress" name="monitorAddress" class="form-control " >
|
||||
<option th:each="monitorAddressInfo:${monitorAddressInfoList}" th:value="${monitorAddressInfo.monitorAddress}" th:text="${monitorAddressInfo.monitorAddress}" ></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">单价:</label>
|
||||
<div class="col-sm-8">
|
||||
|
|
|
@ -14,15 +14,15 @@
|
|||
<input name="receiverAddress" th:field="*{receiverAddress}" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<!-- <div class="form-group">
|
||||
<label class="col-sm-3 control-label">监控入账地址:</label>
|
||||
<div class="col-sm-8">
|
||||
<!-- <input name="accountAddress" th:field="*{accountAddress}" class="form-control" type="text">-->
|
||||
<!– <input name="accountAddress" th:field="*{accountAddress}" class="form-control" type="text">–>
|
||||
<select id="monitorAddress" name="monitorAddress" class="form-control " >
|
||||
<option th:each="monitorAddressInfo:${monitorAddressInfoList}" th:value="${monitorAddressInfo.monitorAddress}" th:text="${monitorAddressInfo.monitorAddress}" th:field="*{monitorAddress}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">单价:</label>
|
||||
<div class="col-sm-8">
|
||||
|
|
|
@ -84,10 +84,10 @@
|
|||
field: 'receiverAddress',
|
||||
title: '接收能量地址'
|
||||
},
|
||||
{
|
||||
/* {
|
||||
field: 'monitorAddress',
|
||||
title: '监控入账地址'
|
||||
},
|
||||
},*/
|
||||
{
|
||||
field: 'price',
|
||||
title: '单价'
|
||||
|
@ -132,7 +132,7 @@
|
|||
field: 'fcd',
|
||||
title: '创建时间'
|
||||
},
|
||||
{
|
||||
/* {
|
||||
field: 'fcu',
|
||||
title: '创建用户'
|
||||
},
|
||||
|
@ -143,7 +143,7 @@
|
|||
{
|
||||
field: 'lcu',
|
||||
title: '更新用户'
|
||||
},
|
||||
},*/
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
|
@ -151,7 +151,7 @@
|
|||
var actions = [];
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.idTenantInfo + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.idTenantInfo + '\')"><i class="fa fa-remove"></i>删除</a> ');
|
||||
actions.push('<a class="btn btn-warning btn-xs' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.activeData(\'' + row.idTenantInfo + '\')"><i class="fa fa-remove"></i>发起</a>');
|
||||
actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.activeData(\'' + row.idTenantInfo + '\')"><i class="fa fa-edit"></i>发起</a>');
|
||||
return actions.join('');
|
||||
}
|
||||
}]
|
||||
|
|
|
@ -19,18 +19,18 @@
|
|||
|
||||
<form id="form" action="#" class="wizard-big">
|
||||
<select class="form-control dual_select" multiple>
|
||||
<option value="1">feeen1</option>
|
||||
<option value="2">feeen2</option>
|
||||
<option value="3">feeen3</option>
|
||||
<option selected value="4">feeen4</option>
|
||||
<option selected value="5">feeen5</option>
|
||||
<option value="6">feeen6</option>
|
||||
<option value="7">feeen7</option>
|
||||
<option value="8">feeen8</option>
|
||||
<option value="9">feeen9</option>
|
||||
<option value="10">feeen10</option>
|
||||
<option value="11">feeen11</option>
|
||||
<option value="12">feeen12</option>
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
<option selected value="4">4</option>
|
||||
<option selected value="5">5</option>
|
||||
<option value="6">6</option>
|
||||
<option value="7">7</option>
|
||||
<option value="8">8</option>
|
||||
<option value="9">9</option>
|
||||
<option value="10">10</option>
|
||||
<option value="11">11</option>
|
||||
<option value="12">12</option>
|
||||
</select>
|
||||
</form>
|
||||
<hr>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</div>
|
||||
<div class="ibox-content no-padding">
|
||||
<div class="summernote">
|
||||
<h2>feeen后台管理系统</h2>
|
||||
<h2>后台管理系统</h2>
|
||||
<p>ruoyi是一个完全响应式,基于Bootstrap3.3.7最新版本开发的扁平化主题,她采用了主流的左右两栏式布局,使用了Html5+CSS3等现代技术,她提供了诸多的强大的可以重新组合的UI组件,并集成了最新的jQuery版本(v2.1.1),当然,也集成了很多功能强大,用途广泛的就jQuery插件,她可以用于所有的Web应用程序,如<b>网站管理后台</b>,<b>网站会员中心</b>,<b>CMS</b>,<b>CRM</b>,<b>OA</b>等等,当然,您也可以对她进行深度定制,以做出更强系统。</p>
|
||||
<p>
|
||||
<b>当前版本:</b>v4.7.8
|
||||
|
@ -53,7 +53,7 @@
|
|||
<div class="ibox-content" id="eg">
|
||||
|
||||
<div class="click2edit wrapper">
|
||||
<h3>你好,feeen </h3>
|
||||
<h3>你好, </h3>
|
||||
<p>H+是一个完全响应式,基于Bootstrap3.3.7最新版本开发的扁平化主题,她采用了主流的左右两栏式布局,使用了Html5+CSS3等现代技术,她提供了诸多的强大的可以重新组合的UI组件,并集成了最新的jQuery版本(v2.1.1),当然,也集成了很多功能强大,用途广泛的就jQuery插件,她可以用于所有的Web应用程序,如<b>网站管理后台</b>,<b>网站会员中心</b>,<b>CMS</b>,<b>CRM</b>,<b>OA</b>等等,当然,您也可以对她进行深度定制,以做出更强系统。</p>
|
||||
<p>
|
||||
<b>当前版本:</b>v4.7.8
|
||||
|
|
|
@ -259,7 +259,7 @@
|
|||
|
||||
$("#button-open-16").click(function(){
|
||||
var json = {
|
||||
"title": "feeen相册", //相册标题
|
||||
"title": "相册", //相册标题
|
||||
"id": 123, //相册id
|
||||
"start": 0, //初始显示的图片序号,默认0
|
||||
"data": [ //相册包含的图片,数组格式
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="renderer" content="webkit">
|
||||
<title>feeen系统首页</title>
|
||||
<title>系统首页</title>
|
||||
<!-- 避免IE使用兼容模式 -->
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<link th:href="@{favicon.ico}" rel="shortcut icon"/>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="renderer" content="webkit">
|
||||
<title>feeen系统首页</title>
|
||||
<title>系统首页</title>
|
||||
<!-- 避免IE使用兼容模式 -->
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<link th:href="@{favicon.ico}" rel="shortcut icon"/>
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
<title>登录feeen系统</title>
|
||||
<meta name="description" content="feeen后台管理框架">
|
||||
<title>登录系统</title>
|
||||
<meta name="description" content="后台管理框架">
|
||||
<link href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
|
||||
<link href="../static/css/font-awesome.min.css" th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
|
||||
<link href="../static/css/style.min.css" th:href="@{/css/style.min.css}" rel="stylesheet"/>
|
||||
|
@ -26,10 +26,10 @@
|
|||
<div class="col-sm-7">
|
||||
<div class="signin-info">
|
||||
<!-- <div class="logopanel m-b">
|
||||
<h1><img alt="[ feeen ]" src="../static/ruoyi.png" th:src="@{/ruoyi.png}"></h1>
|
||||
<h1><img alt="[ ]" src="../static/ruoyi.png" th:src="@{/ruoyi.png}"></h1>
|
||||
</div>
|
||||
<div class="m-b"></div>-->
|
||||
<!-- <h4>欢迎使用 <strong>feeen 后台管理系统</strong></h4>
|
||||
<!-- <h4>欢迎使用 <strong> 后台管理系统</strong></h4>
|
||||
<ul class="m-b">
|
||||
<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> SpringBoot</li>
|
||||
<li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Mybatis</li>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<!--360浏览器优先以webkit内核解析-->
|
||||
<title>feeen介绍</title>
|
||||
<title>介绍</title>
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
|
||||
<link href="../static/css/font-awesome.min.css" th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
<title>注册feeen系统</title>
|
||||
<meta name="description" content="feeen后台管理框架">
|
||||
<title>注册系统</title>
|
||||
<meta name="description" content="后台管理框架">
|
||||
<link href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
|
||||
<link href="../static/css/font-awesome.min.css" th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
|
||||
<link href="../static/css/style.min.css" th:href="@{/css/style.min.css}" rel="stylesheet"/>
|
||||
|
@ -23,10 +23,10 @@
|
|||
<div class="col-sm-7">
|
||||
<div class="signin-info">
|
||||
<!-- <div class="logopanel m-b">-->
|
||||
<!-- <h1><img alt="[ feeen ]" src="../static/ruoyi.png" th:src="@{/ruoyi.png}"></h1>-->
|
||||
<!-- <h1><img alt="[ ]" src="../static/ruoyi.png" th:src="@{/ruoyi.png}"></h1>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="m-b"></div>-->
|
||||
<!-- <h4>欢迎使用 <strong>feeen 后台管理系统</strong></h4>-->
|
||||
<!-- <h4>欢迎使用 <strong> 后台管理系统</strong></h4>-->
|
||||
<!-- <ul class="m-b">-->
|
||||
<!-- <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> SpringBoot</li>-->
|
||||
<!-- <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Mybatis</li>-->
|
||||
|
|
|
@ -2,12 +2,15 @@ package com.ruoyi.system.service.impl;
|
|||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.entity.MonitorAddressInfo;
|
||||
import com.ruoyi.common.core.domain.entity.TenantInfo;
|
||||
import com.ruoyi.common.core.domain.entity.TrxExchangeInfo;
|
||||
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.mapper.MonitorAddressInfoMapper;
|
||||
|
@ -70,6 +73,13 @@ public class TenantInfoServiceImpl implements ITenantInfoService
|
|||
@Override
|
||||
public int insertTenantInfo(TenantInfo tenantInfo)
|
||||
{
|
||||
|
||||
TenantInfo tenantInfoExample = new TenantInfo();
|
||||
tenantInfoExample.setReceiverAddress(tenantInfo.getReceiverAddress());
|
||||
List<TenantInfo> tenantInfoList = tenantInfoMapper.selectTenantInfoList(tenantInfoExample);
|
||||
|
||||
Preconditions.checkState(CollectionUtil.isEmpty(tenantInfoList), "该接收能量地址已存在,请勿重复添加");
|
||||
|
||||
Long price = tenantInfo.getPrice();
|
||||
Long transferCount = tenantInfo.getTransferCount();
|
||||
|
||||
|
@ -78,7 +88,7 @@ public class TenantInfoServiceImpl implements ITenantInfoService
|
|||
tenantInfo.setIsPaid(UserConstants.NO);
|
||||
Long period = tenantInfo.getPeriod();
|
||||
|
||||
DateTime dateTime = DateUtil.offsetDay(DateUtil.date(), period.intValue());
|
||||
DateTime dateTime = DateUtil.offsetDay(DateUtil.date(), period.intValue() -1);
|
||||
|
||||
tenantInfo.setFinishTransferTime( DateUtil.endOfDay(dateTime));
|
||||
|
||||
|
@ -150,6 +160,19 @@ public class TenantInfoServiceImpl implements ITenantInfoService
|
|||
for (String id : idArray) {
|
||||
TenantInfo tenantInfo = tenantInfoMapper.selectTenantInfoByIdTenantInfo(Long.valueOf(id));
|
||||
|
||||
String dictValue = DictUtils.getDictValue("sys_delegate_status", "已委托");
|
||||
String busiType = DictUtils.getDictValue("sys_busi_type", "天数套餐");
|
||||
TrxExchangeInfo trxExchangeInfo = TrxExchangeInfo.builder().fromAddress(tenantInfo.getReceiverAddress())
|
||||
.delegateStatus(dictValue)
|
||||
.busiType(busiType)
|
||||
.build();
|
||||
|
||||
List<TrxExchangeInfo> trxExchangeInfos = trxExchangeInfoService.selectTrxExchangeInfoList(trxExchangeInfo);
|
||||
|
||||
|
||||
Preconditions.checkState(CollectionUtil.isEmpty(trxExchangeInfos), "该接收能量地址已在任务中,请勿重复发起");
|
||||
|
||||
|
||||
Date finishTransferTime = tenantInfo.getFinishTransferTime();
|
||||
int compare = DateUtil.compare(new Date(), finishTransferTime);
|
||||
|
||||
|
@ -168,11 +191,19 @@ public class TenantInfoServiceImpl implements ITenantInfoService
|
|||
trxExchange.setFromAddress(tenantInfo.getReceiverAddress());
|
||||
trxExchange.setAccountAddress(monitorAddressInfo.getAccountAddress());
|
||||
trxExchange.setTransferNumber(tenantInfo.getTransferCount());
|
||||
trxExchange.setLockNum(24L);
|
||||
|
||||
long between = DateUtil.between(DateUtil.date(), DateUtil.endOfDay(DateUtil.date()), DateUnit.HOUR);
|
||||
trxExchange.setLockNum(between + 1);
|
||||
|
||||
trxExchangeInfoService.delegate(trxExchange, true);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* public static void main(String[] args) {
|
||||
System.out.println(DateUtil.date());
|
||||
System.out.println( DateUtil.endOfDay(DateUtil.date()));
|
||||
System.out.println( DateUtil.between(DateUtil.date(),DateUtil.endOfDay(DateUtil.date()), DateUnit.HOUR));
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.ruoyi.common.core.domain.entity.TrxExchangeInfo;
|
|||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.utils.DictUtils;
|
||||
import com.ruoyi.common.utils.ShiroUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.encrpt.Dt;
|
||||
import com.ruoyi.common.utils.http.RestTemplateUtils;
|
||||
import com.ruoyi.system.domain.MonitorAddressAccount;
|
||||
|
@ -148,7 +149,7 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int delegate(TrxExchange trxExchange,Boolean isTenant) throws Exception {
|
||||
public int delegate(TrxExchange trxExchange, Boolean isTenant) throws Exception {
|
||||
//转账笔数
|
||||
Long transferNumber = trxExchange.getTransferNumber();
|
||||
//实际锁定周期
|
||||
|
@ -161,6 +162,12 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
|
|||
|
||||
TrxExchangeInfo trxExchangeInfo = null;
|
||||
String userName = ShiroUtils.getLoginName();
|
||||
String busiType = DictUtils.getDictValue("sys_busi_type", "闪兑套餐");
|
||||
if (isTenant) {
|
||||
busiType = DictUtils.getDictValue("sys_busi_type", "天数套餐");
|
||||
} else if (lockPeriod > 1200 && lockPeriod <= 24 * 1200) {
|
||||
busiType = DictUtils.getDictValue("sys_busi_type", "笔数套餐");
|
||||
}
|
||||
if (UserConstants.YES.equals(systronApiSwitch)) {
|
||||
String accountAddress = trxExchange.getAccountAddress();
|
||||
String decryptPrivateKey = accountAddressInfoService.getDecryptPrivateKey(accountAddress);
|
||||
|
@ -168,21 +175,26 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
|
|||
String tronApiKey = DictUtils.getDictValue("sys_tron_api_key", "synp@outlook");
|
||||
|
||||
ApiWrapper apiWrapper = ApiWrapper.ofMainnet(decryptPrivateKey, tronApiKey);
|
||||
Response.AccountResourceMessage accountResource = apiWrapper.getAccountResource(accountAddress);
|
||||
|
||||
calcBalanceAndDelegate(null,
|
||||
apiWrapper,
|
||||
accountAddress,
|
||||
transferNumber,
|
||||
fromAddress,
|
||||
lockPeriod,
|
||||
null,
|
||||
null,
|
||||
busiType,
|
||||
null,
|
||||
userName);
|
||||
/* Response.AccountResourceMessage accountResource = apiWrapper.getAccountResource(accountAddress);
|
||||
|
||||
//总用于质押换取能量的trx上限
|
||||
long balance = getBalance(accountResource, transferNumber);
|
||||
|
||||
String delegateResourceTxid = getDelegateResourceTxid(apiWrapper, accountAddress, balance, fromAddress, lockPeriod);
|
||||
|
||||
String busiType = DictUtils.getDictValue("sys_busi_type", "闪兑套餐");
|
||||
|
||||
if (isTenant){
|
||||
busiType = DictUtils.getDictValue("sys_busi_type", "天数套餐");
|
||||
}else if (lockPeriod > 1200 && lockPeriod <= 24*1200){
|
||||
busiType = DictUtils.getDictValue("sys_busi_type", "笔数套餐");
|
||||
}
|
||||
trxExchangeInfo = TrxExchangeInfo.builder()
|
||||
.delegateAmountTrx(balance)
|
||||
.tranferCount(transferNumber)
|
||||
|
@ -194,15 +206,15 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
|
|||
.delegateStatus(dictValue)
|
||||
.fcu(userName)
|
||||
.lcu(userName)
|
||||
.build();
|
||||
.build();*/
|
||||
|
||||
}else{
|
||||
String busiType = DictUtils.getDictValue("sys_busi_type", "闪兑套餐");
|
||||
if (isTenant){
|
||||
busiType = DictUtils.getDictValue("sys_busi_type", "天数套餐");
|
||||
}else if (lockPeriod > 1200 && lockPeriod <= 24*1200){
|
||||
busiType = DictUtils.getDictValue("sys_busi_type", "笔数套餐");
|
||||
}
|
||||
} else {
|
||||
// String busiType = DictUtils.getDictValue("sys_busi_type", "闪兑套餐");
|
||||
// if (isTenant) {
|
||||
// busiType = DictUtils.getDictValue("sys_busi_type", "天数套餐");
|
||||
// } else if (lockPeriod > 1200 && lockPeriod <= 24 * 1200) {
|
||||
// busiType = DictUtils.getDictValue("sys_busi_type", "笔数套餐");
|
||||
// }
|
||||
trxExchangeInfo = TrxExchangeInfo.builder()
|
||||
.delegateAmountTrx(0L)
|
||||
.tranferCount(transferNumber)
|
||||
|
@ -295,6 +307,7 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
|
|||
.lcu("system").build();
|
||||
|
||||
errorLogMapper.insertErrorLog(errorLog);
|
||||
throw new RuntimeException("doDelegateResource业务处理异常", e);
|
||||
} finally {
|
||||
if (lock.isLocked()) {
|
||||
if (lock.isHeldByCurrentThread()) {
|
||||
|
@ -384,19 +397,19 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
|
|||
String ownerAddress = value.getOwner_address();
|
||||
String toAddress = value.getTo_address();
|
||||
|
||||
//查询是否是按天支付的租户
|
||||
TenantInfo tenantInfoExample = new TenantInfo();
|
||||
tenantInfoExample.setReceiverAddress(ownerAddress);
|
||||
tenantInfoExample.setMonitorAddress(monitorAddressAccount.getMonitorAddress());
|
||||
tenantInfoExample.setFinishTransferTime(new Date());
|
||||
tenantInfoExample.setIsPaid(UserConstants.NO);
|
||||
List<TenantInfo> tenantInfoList = tenantInfoMapper.selectTenantInfoList(tenantInfoExample);
|
||||
|
||||
long lockPeriod = 1200L;
|
||||
long transferCount = 0L;
|
||||
Integer price = null;
|
||||
String busiType = DictUtils.getDictValue("sys_busi_type", "闪兑套餐");
|
||||
|
||||
//查询是否是按天支付的租户
|
||||
TenantInfo tenantInfoExample = new TenantInfo();
|
||||
tenantInfoExample.setReceiverAddress(ownerAddress);
|
||||
// tenantInfoExample.setMonitorAddress(monitorAddressAccount.getMonitorAddress());
|
||||
tenantInfoExample.setFinishTransferTime(new Date());
|
||||
tenantInfoExample.setIsPaid(UserConstants.NO);
|
||||
List<TenantInfo> tenantInfoList = tenantInfoMapper.selectTenantInfoList(tenantInfoExample);
|
||||
|
||||
if (tenantInfoList.size() > 0) {
|
||||
TenantInfo tenantInfo = tenantInfoList.get(0);
|
||||
Long exchangeAmount = tenantInfo.getExchangeAmount();
|
||||
|
@ -419,7 +432,7 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
|
|||
tenantInfoMapper.updateTenantInfo(tenantInfo);
|
||||
//取包天的套餐锁定时间和交易笔数
|
||||
lockPeriod = 1200L * 24;
|
||||
busiType = DictUtils.getDictValue("sys_busi_type", "天数套餐");
|
||||
busiType = DictUtils.getDictValue("sys_busi_type", "天数套餐");
|
||||
transferCount = tenantInfo.getTransferCount();
|
||||
price = tenantInfo.getPrice().intValue();
|
||||
|
||||
|
@ -437,13 +450,42 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
|
|||
String accountAddress = monitorAddressAccount.getAccountAddress();
|
||||
String encryptPrivateKey = monitorAddressAccount.getEncryptPrivateKey();
|
||||
String encryptKey = monitorAddressAccount.getEncryptKey();
|
||||
String apiKey = monitorAddressAccount.getApiKey();
|
||||
|
||||
String decryptPrivateKey = Dt.decrypt(encryptPrivateKey, encryptKey);
|
||||
ApiWrapper apiWrapper = ApiWrapper.ofMainnet(decryptPrivateKey, apiKey);
|
||||
|
||||
// apiWrapper = ApiWrapper.ofShasta(encryptPrivateKey);
|
||||
calcBalanceAndDelegate(txID, apiWrapper, accountAddress, transferCount, ownerAddress, lockPeriod, toAddress, price, busiType, amount, "system");
|
||||
//持久化之后放redis
|
||||
redisTemplate.opsForValue().set("transfer_trx_" + txID, txID, 1, TimeUnit.DAYS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param txID 转账交易订单号
|
||||
* @param apiWrapper apiWrapper
|
||||
* @param accountAddress 出账地址
|
||||
* @param transferCount 转账笔数
|
||||
* @param ownerAddress 转入地址
|
||||
* @param lockPeriod 锁定周期
|
||||
* @param toAddress 监听地址
|
||||
* @param price 单价
|
||||
* @param busiType 业务类型
|
||||
* @param amount 转入金额
|
||||
* @param currentUser 当前处理人
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
private void calcBalanceAndDelegate(String txID,
|
||||
ApiWrapper apiWrapper,
|
||||
String accountAddress,
|
||||
long transferCount,
|
||||
String ownerAddress,
|
||||
long lockPeriod,
|
||||
String toAddress,
|
||||
Integer price,
|
||||
String busiType,
|
||||
Long amount,
|
||||
String currentUser) throws Exception {
|
||||
|
||||
String tronApiKey = DictUtils.getDictValue("sys_tron_api_key", "synp@outlook");
|
||||
ApiWrapper apiWrapper = ApiWrapper.ofMainnet(decryptPrivateKey, tronApiKey);
|
||||
|
||||
Response.AccountResourceMessage accountResource = apiWrapper.getAccountResource(accountAddress);
|
||||
|
||||
|
@ -468,16 +510,11 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
|
|||
.lockPeriod(lockPeriod)
|
||||
.delegateStatus("0")
|
||||
.fcd(new Date())
|
||||
.fcu("system")
|
||||
.fcu(currentUser)
|
||||
.lcd(new Date())
|
||||
.fcu("system")
|
||||
.fcu(currentUser)
|
||||
.build();
|
||||
|
||||
trxExchangeInfoMapper.insertTrxExchangeInfo(trxExchangeInfo);
|
||||
|
||||
//持久化之后放redis
|
||||
redisTemplate.opsForValue().set("transfer_trx_" + txID, txID, 1, TimeUnit.DAYS);
|
||||
|
||||
}
|
||||
|
||||
private static long getBalance(Response.AccountResourceMessage accountResource, long energyNum) {
|
||||
|
@ -531,10 +568,16 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
|
|||
//回收能量
|
||||
doUndelegateEnergy(trxExchangeInfo, apiWrapper);
|
||||
|
||||
String busiType = DictUtils.getDictValue("sys_busi_type", "天数套餐");
|
||||
String trxExchangeInfoBusiType = trxExchangeInfo.getBusiType();
|
||||
if (!busiType.equals(trxExchangeInfoBusiType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//查询是否是按天支付的租户,是的话需要回收完再次赠送
|
||||
TenantInfo tenantInfoExample = new TenantInfo();
|
||||
tenantInfoExample.setReceiverAddress(trxExchangeInfo.getFromAddress());
|
||||
tenantInfoExample.setMonitorAddress(trxExchangeInfo.getToAddress());
|
||||
// tenantInfoExample.setMonitorAddress(trxExchangeInfo.getToAddress());
|
||||
tenantInfoExample.setFinishTransferTime(new Date());
|
||||
List<TenantInfo> tenantInfoList = tenantInfoMapper.selectTenantInfoList(tenantInfoExample);
|
||||
|
||||
|
@ -542,7 +585,7 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
|
|||
Response.AccountResourceMessage accountResource = apiWrapper.getAccountResource(accountAddress);
|
||||
TenantInfo tenantInfo = tenantInfoList.get(0);
|
||||
|
||||
if (UserConstants.NO.equals(tenantInfo.getIsPaid())){
|
||||
if (UserConstants.NO.equals(tenantInfo.getIsPaid())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -554,12 +597,32 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
|
|||
return;
|
||||
}
|
||||
|
||||
Long transferCount = tenantInfo.getTransferCount();
|
||||
long balance = getBalance(accountResource, transferCount);
|
||||
String receiverAddress = tenantInfo.getReceiverAddress();
|
||||
/* lock_period: 锁定周期,以区块时间(3s)为单位,表示锁定多少个区块的时间,当lock为true时,该字段有效。如果代理锁定期为1天,则lock_period为:28800*/
|
||||
String monitorAddress = tenantInfo.getMonitorAddress();
|
||||
String toAddress = trxExchangeInfo.getToAddress();
|
||||
if (StringUtils.isNotEmpty(toAddress) && !toAddress.equals(monitorAddress)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String receiverAddress = tenantInfo.getReceiverAddress();
|
||||
Long transferCount = tenantInfo.getTransferCount();
|
||||
long newLockPeriod = 24 * 1200L;
|
||||
|
||||
calcBalanceAndDelegate(null,
|
||||
apiWrapper,
|
||||
accountAddress,
|
||||
transferCount,
|
||||
receiverAddress,
|
||||
newLockPeriod,
|
||||
monitorAddress,
|
||||
tenantInfo.getPrice() == null ? null : tenantInfo.getPrice().intValue(),
|
||||
busiType,
|
||||
null,
|
||||
"system");
|
||||
/* long balance = getBalance(accountResource, transferCount);
|
||||
|
||||
*//* lock_period: 锁定周期,以区块时间(3s)为单位,表示锁定多少个区块的时间,当lock为true时,该字段有效。如果代理锁定期为1天,则lock_period为:28800*//*
|
||||
|
||||
|
||||
String delegateResourceTxid = getDelegateResourceTxid(apiWrapper, accountAddress, balance, receiverAddress, newLockPeriod);
|
||||
|
||||
TrxExchangeInfo trxExchangeInfoNew = TrxExchangeInfo.builder()
|
||||
|
@ -581,7 +644,7 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
|
|||
.fcu("system")
|
||||
.build();
|
||||
|
||||
trxExchangeInfoMapper.insertTrxExchangeInfo(trxExchangeInfoNew);
|
||||
trxExchangeInfoMapper.insertTrxExchangeInfo(trxExchangeInfoNew);*/
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -607,6 +670,7 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 回收业务逻辑
|
||||
*
|
||||
|
@ -634,4 +698,5 @@ public class TrxExchangeInfoServiceImpl implements ITrxExchangeInfoService {
|
|||
trxExchangeInfo.setLcu("system");
|
||||
trxExchangeInfoMapper.updateTrxExchangeInfo(trxExchangeInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue