123
This commit is contained in:
1 parent
8d2c4e0159
commit
05b5a3d3cc
43 files changed
+434
-4728
No files matched your search
@@ -20,7 +20,6 @@ import org.springframework.context.annotation.Bean;
|
||||
})
|
||||
public class RuoYiApplication {
|
||||
public static void main(String[] args) {// System.setProperty("spring.devtools.restart.enabled", "false");
|
||||
System.setProperty("hazelcast.config", "D:\\myprojects\\yuyue\\RuoYi-Vue\\luqj-cache\\src\\main\\resources\\hazelcast-default1.xml");
|
||||
SpringApplication.run(RuoYiApplication.class, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
package com.ruoyi.task;
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.*;
|
||||
import com.ruoyi.system.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.tron.trident.core.ApiWrapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@Component("AggregationTask")
|
||||
public class AggregationTask {
|
||||
@Autowired
|
||||
private IUsdtAggregationTaskService usdtAggregationTaskService;
|
||||
@Autowired
|
||||
private IUsdtAggregationTaskItemService usdtAggregationTaskItemService;
|
||||
@Autowired
|
||||
private ITronService tronService;
|
||||
@Autowired
|
||||
private IUsdtFundFlowService usdtFundFlowService;
|
||||
@Autowired
|
||||
private IWalletAddressService walletAddressService;
|
||||
@Autowired
|
||||
private IWeb3WalletService web3WalletService;
|
||||
|
||||
@Scheduled(cron = "0 */10 * * * ?")
|
||||
// @Scheduled(cron = "0/10 * * * * ?")
|
||||
public void execute() {
|
||||
// com.license.LicenseBootstrap.init();
|
||||
List<UsdtAggregationTaskPlus> taskPluses = this.usdtAggregationTaskService.getListByStatusAndLtExeTime(0, new Date());
|
||||
for (UsdtAggregationTaskPlus taskPlus : taskPluses) {
|
||||
Web3WalletPlus web3Wallet = this.web3WalletService.getById(taskPlus.getUserId());
|
||||
if (web3Wallet == null) {
|
||||
web3Wallet = new Web3WalletPlus();
|
||||
web3Wallet.setId(taskPlus.getUserId());
|
||||
web3Wallet.setPassword(UUID.randomUUID().toString());
|
||||
web3Wallet.setEthBalance(new BigDecimal(0));
|
||||
web3Wallet.setTrxBalance(new BigDecimal(0));
|
||||
web3Wallet.setUsdtBalance(new BigDecimal(0));
|
||||
web3Wallet.setCreatedAt(new Date());
|
||||
web3Wallet.setUpdatedAt(new Date());
|
||||
this.web3WalletService.save(web3Wallet);
|
||||
}
|
||||
List<UsdtAggregationTaskItemPlus> itemPluses = this.usdtAggregationTaskItemService.getListByStatusAndParentId(0, taskPlus.getId());
|
||||
int success = 0;
|
||||
for (UsdtAggregationTaskItemPlus itemPlus : itemPluses) {
|
||||
WalletAddressPlus walletAddressPlus = walletAddressService.getByTokenAndAppId(itemPlus.getTokenAddress(), itemPlus.getAppId());
|
||||
if (walletAddressPlus.getUpdatedAt().getTime() < itemPlus.getCreatedAt().getTime()) {
|
||||
itemPlus.setStatus(0);
|
||||
itemPlus.setRemark("等待钱包更新");
|
||||
usdtAggregationTaskItemService.updateById(itemPlus);
|
||||
continue;
|
||||
}
|
||||
ApiWrapper api = tronService.buildApiWrapper(walletAddressPlus.getTokenKey());
|
||||
try {
|
||||
if (walletAddressPlus.getEnergyNum() < tronService.defaultEstimateEnergy()) {
|
||||
itemPlus.setStatus(0);
|
||||
itemPlus.setRemark("能量不足,需要手续费");
|
||||
usdtAggregationTaskItemService.updateById(itemPlus);
|
||||
continue;
|
||||
}
|
||||
long bandwidth = tronService.defaultEstimateBandwidth();
|
||||
if (bandwidth > walletAddressPlus.getBandwidthNum()) {
|
||||
itemPlus.setStatus(0);
|
||||
itemPlus.setRemark("带宽不足需要手续费");
|
||||
usdtAggregationTaskItemService.updateById(itemPlus);
|
||||
continue;
|
||||
}
|
||||
if (bandwidth > walletAddressPlus.getBandwidthStakedNum()
|
||||
&& bandwidth > (walletAddressPlus.getBandwidthNum() - walletAddressPlus.getBandwidthStakedNum())) {
|
||||
itemPlus.setStatus(0);
|
||||
itemPlus.setRemark("代理|免费带宽不足需要手续费");
|
||||
usdtAggregationTaskItemService.updateById(itemPlus);
|
||||
continue;
|
||||
}
|
||||
if (walletAddressPlus.getWithdrawUsdtBalance().subtract(itemPlus.getOpeAmount()).doubleValue() < 0) {
|
||||
itemPlus.setStatus(2);
|
||||
itemPlus.setRemark("超额或者重复提现,请排查");
|
||||
usdtAggregationTaskItemService.updateById(itemPlus);
|
||||
continue;
|
||||
}
|
||||
String result = this.tronService.usdtTrans(api, itemPlus.getTokenAddress(), itemPlus.getDistTokenAddress(), itemPlus.getOpeAmount().toString());
|
||||
//验证是否成功 TODO
|
||||
if (StringUtils.isNotEmpty(result)) {
|
||||
itemPlus.setStatus(1);
|
||||
itemPlus.setRemark(result);
|
||||
walletAddressPlus.setWithdrawUsdtBalance(walletAddressPlus.getWithdrawUsdtBalance().subtract(itemPlus.getOpeAmount()));
|
||||
web3Wallet.setUsdtBalance(web3Wallet.getUsdtBalance().subtract(itemPlus.getOpeAmount()));
|
||||
|
||||
UsdtFundFlowPlus shFlow = new UsdtFundFlowPlus();
|
||||
shFlow.setAppId(itemPlus.getAppId());
|
||||
shFlow.setAmount(itemPlus.getOpeAmount());
|
||||
shFlow.setOrderId(itemPlus.getId());
|
||||
shFlow.setOpType(2);
|
||||
shFlow.setUserId(itemPlus.getUserId());
|
||||
shFlow.setToken(itemPlus.getTokenAddress());
|
||||
shFlow.setRemark("归集成功");
|
||||
shFlow.setCreatedAt(new Date());
|
||||
shFlow.setUpdatedAt(new Date());
|
||||
this.usdtFundFlowService.save(shFlow);
|
||||
|
||||
this.web3WalletService.updateById(web3Wallet);
|
||||
this.walletAddressService.updateById(walletAddressPlus);
|
||||
success++;
|
||||
} else {
|
||||
itemPlus.setStatus(0);
|
||||
itemPlus.setRemark("归集失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
itemPlus.setStatus(0);
|
||||
itemPlus.setRemark(e.getMessage());
|
||||
}
|
||||
itemPlus.setUpdatedAt(new Date());
|
||||
this.usdtAggregationTaskItemService.updateById(itemPlus);
|
||||
api.close();
|
||||
}
|
||||
if (success == itemPluses.size() && itemPluses.size() > 0) {
|
||||
taskPlus.setStatus(1);
|
||||
this.usdtAggregationTaskService.updateById(taskPlus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package com.ruoyi.task;
|
||||
|
||||
import com.ruoyi.system.domain.*;
|
||||
import com.ruoyi.system.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
@Component("splitAccountsTask")
|
||||
public class SplitAccountsTask {
|
||||
@Autowired
|
||||
private IUsdtOrdersService usdtOrdersService;
|
||||
@Autowired
|
||||
private IUsdtUserSettlementConfigurationService usdtUserSettlementConfigurationService;
|
||||
@Autowired
|
||||
private IUsdtFundFlowService usdtFundFlowService;
|
||||
@Autowired
|
||||
private IWalletAddressService walletAddressService;
|
||||
@Autowired
|
||||
private IWeb3WalletService web3WalletService;
|
||||
// @Scheduled(cron = "0/10 * * * * ?")
|
||||
@Scheduled(cron = "0 */10 * * * ?")
|
||||
public void execute() {
|
||||
// com.license.LicenseBootstrap.init();
|
||||
List<UsdtOrdersPlus> list = usdtOrdersService.getWillSettlement(1000);
|
||||
Map<Long, UsdtUserSettlementConfigurationPlus> configMap = new HashMap<Long, UsdtUserSettlementConfigurationPlus>();
|
||||
List<UsdtFundFlowPlus> fundFlows = new ArrayList<UsdtFundFlowPlus>();
|
||||
List<Long> ids = new ArrayList<>();
|
||||
Map<Long, Web3WalletPlus> web3WalletMap = new HashMap<>();
|
||||
for (UsdtOrdersPlus usdtOrdersPlus : list) {
|
||||
WalletAddressPlus walletAddressPlus = walletAddressService.getByTokenAndAppId(usdtOrdersPlus.getToken(),usdtOrdersPlus.getAppId()
|
||||
,WalletAddressPlus::getId,WalletAddressPlus::getWithdrawUsdtBalance);
|
||||
if(walletAddressPlus.getWithdrawUsdtBalance() == null){
|
||||
walletAddressPlus.setWithdrawUsdtBalance(new BigDecimal(0));
|
||||
}
|
||||
UsdtUserSettlementConfigurationPlus config = configMap.getOrDefault(usdtOrdersPlus.getUserId(), usdtUserSettlementConfigurationService.getByUserId(usdtOrdersPlus.getUserId()));
|
||||
BigDecimal yj = usdtOrdersPlus.getActualAmount().multiply(config.getCommissionRate());
|
||||
UsdtFundFlowPlus yjFlow = new UsdtFundFlowPlus();
|
||||
yjFlow.setAppId(usdtOrdersPlus.getAppId());
|
||||
yjFlow.setAmount(yj);
|
||||
yjFlow.setOrderId(usdtOrdersPlus.getId());
|
||||
yjFlow.setOpType(1);
|
||||
yjFlow.setUserId(usdtOrdersPlus.getUserId());
|
||||
yjFlow.setToken(usdtOrdersPlus.getToken());
|
||||
|
||||
Web3WalletPlus web3Wallet = web3WalletMap.get(usdtOrdersPlus.getUserId());
|
||||
if (web3Wallet == null) {
|
||||
web3Wallet = new Web3WalletPlus();
|
||||
web3Wallet.setId(usdtOrdersPlus.getUserId());
|
||||
web3Wallet.setPassword(UUID.randomUUID().toString());
|
||||
web3Wallet.setEthBalance(new BigDecimal(0));
|
||||
web3Wallet.setTrxBalance(new BigDecimal(0));
|
||||
web3Wallet.setUsdtBalance(new BigDecimal(0));
|
||||
web3Wallet.setCreatedAt(new Date());
|
||||
web3Wallet.setUpdatedAt(new Date());
|
||||
this.web3WalletService.save(web3Wallet);
|
||||
} else {
|
||||
web3Wallet.setUpdatedAt(new Date());
|
||||
}
|
||||
web3Wallet.setUsdtBalance(web3Wallet.getUsdtBalance().add(usdtOrdersPlus.getActualAmount().subtract(yj)));
|
||||
web3WalletMap.put(usdtOrdersPlus.getUserId(), web3Wallet);
|
||||
|
||||
UsdtFundFlowPlus shFlow = new UsdtFundFlowPlus();
|
||||
shFlow.setAppId(usdtOrdersPlus.getAppId());
|
||||
shFlow.setAmount(usdtOrdersPlus.getActualAmount().subtract(yj));
|
||||
shFlow.setOrderId(usdtOrdersPlus.getId());
|
||||
shFlow.setOpType(0);
|
||||
shFlow.setUserId(usdtOrdersPlus.getUserId());
|
||||
shFlow.setToken(usdtOrdersPlus.getToken());
|
||||
walletAddressPlus.setWithdrawUsdtBalance(walletAddressPlus.getWithdrawUsdtBalance().add(shFlow.getAmount()));
|
||||
fundFlows.add(yjFlow);
|
||||
fundFlows.add(shFlow);
|
||||
ids.add(usdtOrdersPlus.getId());
|
||||
this.walletAddressService.updateWithdrawUsdtBalanceById(walletAddressPlus.getId(),walletAddressPlus.getWithdrawUsdtBalance());
|
||||
}
|
||||
Iterator<Map.Entry<Long, Web3WalletPlus>> iterator = web3WalletMap.entrySet().iterator();
|
||||
List<Web3WalletPlus> updates = new ArrayList<>();
|
||||
while (iterator.hasNext()) {
|
||||
updates.add(iterator.next().getValue());
|
||||
}
|
||||
if (!updates.isEmpty()) {
|
||||
web3WalletService.updateBatchById(updates);
|
||||
}
|
||||
if (!fundFlows.isEmpty()) {
|
||||
usdtFundFlowService.saveBatch(fundFlows);
|
||||
}
|
||||
if (!ids.isEmpty()) {
|
||||
this.usdtOrdersService.updateSettlementStatusByIds(ids, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package com.ruoyi.task;
|
||||
|
||||
import com.ruoyi.system.domain.WalletAddressPlus;
|
||||
import com.ruoyi.system.domain.vo.EnergyAndBandwidthVo;
|
||||
import com.ruoyi.system.service.ITronService;
|
||||
import com.ruoyi.system.service.IWalletAddressService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.tron.trident.core.ApiWrapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@Slf4j
|
||||
@Component("WalletAddressTask")
|
||||
public class WalletAddressTask {
|
||||
@Autowired
|
||||
private ITronService tronService;
|
||||
@Autowired
|
||||
private IWalletAddressService walletAddressService;
|
||||
// @Scheduled(cron = "0/5 * * * * ?")
|
||||
@Scheduled(cron = "0 */10 * * * ?")
|
||||
public void execute() {
|
||||
// com.license.LicenseBootstrap.init();
|
||||
List<WalletAddressPlus> walletAddressPluses = walletAddressService.list();
|
||||
for (WalletAddressPlus walletAddressPlus : walletAddressPluses) {
|
||||
ApiWrapper api = tronService.buildApiWrapper(walletAddressPlus.getTokenKey());
|
||||
BigDecimal amout = tronService.getUsdtBalance(api,walletAddressPlus.getToken());
|
||||
walletAddressPlus.setUsdtBalance(amout);
|
||||
amout = tronService.getTRxBalance(api,walletAddressPlus.getToken());
|
||||
walletAddressPlus.setTrxBalance(amout);
|
||||
EnergyAndBandwidthVo energyAndBandwidthVo = tronService.energyAndBandwidth(walletAddressPlus.getToken());
|
||||
walletAddressPlus.setEnergyNum(energyAndBandwidthVo.getEnergy().longValue());
|
||||
walletAddressPlus.setBandwidthNum(energyAndBandwidthVo.getBandwidth().longValue());
|
||||
amout = tronService.votedBalance(api,walletAddressPlus.getToken());
|
||||
walletAddressPlus.setVotedNum(amout.longValue());
|
||||
amout = tronService.stakedTrxBalance(api,walletAddressPlus.getToken(),1);
|
||||
walletAddressPlus.setEnergyStakedTrxNum(amout.longValue());
|
||||
amout = tronService.stakedTrxBalance(api,walletAddressPlus.getToken(),0);
|
||||
walletAddressPlus.setBandwidthStakedTrxNum(amout.longValue());
|
||||
energyAndBandwidthVo = tronService.allDelegatedDnergyAndBandwidth(walletAddressPlus.getToken());
|
||||
walletAddressPlus.setAcquiredDelegatedBandwidthValue(energyAndBandwidthVo.getAcquiredBandwidth());
|
||||
walletAddressPlus.setAcquiredDelegatedEnergyValue(energyAndBandwidthVo.getAcquiredEnergy());
|
||||
walletAddressPlus.setDelegatedBandwidthValue(energyAndBandwidthVo.getDelegateBandwidth());
|
||||
walletAddressPlus.setDelegatedEnergyValue(energyAndBandwidthVo.getDelegateEnergy());
|
||||
walletAddressPlus.setBandwidthStakedNum(energyAndBandwidthVo.getBandwidthStakedNum());
|
||||
|
||||
amout = tronService.delegatedStakedTrxBalance(api,walletAddressPlus.getToken(),1);
|
||||
walletAddressPlus.setDelegatedEnergyTrxNum(amout.longValue());
|
||||
amout = tronService.delegatedStakedTrxBalance(api,walletAddressPlus.getToken(),0);
|
||||
walletAddressPlus.setDelegatedBandwidthTrxNum(amout.longValue());
|
||||
|
||||
amout = tronService.acquiredDelegatedStakedTrxBalance(api,walletAddressPlus.getToken(),1);
|
||||
walletAddressPlus.setAcquiredDelegatedEnergyTrxNum(amout.longValue());
|
||||
amout = tronService.acquiredDelegatedStakedTrxBalance(api,walletAddressPlus.getToken(),0);
|
||||
walletAddressPlus.setAcquiredDelegatedBandwidthTrxNum(amout.longValue());
|
||||
|
||||
amout = tronService.voteBalance(api,walletAddressPlus.getToken());
|
||||
walletAddressPlus.setVoteNum(amout.longValue()+walletAddressPlus.getDelegatedBandwidthTrxNum()+ walletAddressPlus.getDelegatedEnergyTrxNum());
|
||||
|
||||
walletAddressPlus.setStakedTrxNum(walletAddressPlus.getVoteNum());
|
||||
|
||||
if(walletAddressPlus.getStakedTrxNum() != energyAndBandwidthVo.getStakedTrxNum().longValue()){
|
||||
log.error("please check stakedTrxNum is true");
|
||||
walletAddressPlus.setStakedTrxNum(energyAndBandwidthVo.getStakedTrxNum());
|
||||
walletAddressPlus.setVoteNum(walletAddressPlus.getStakedTrxNum());
|
||||
}
|
||||
walletAddressPlus.setUpdatedAt(new Date());
|
||||
walletAddressService.updateById(walletAddressPlus);
|
||||
api.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package com.ruoyi.web.core.config;
|
||||
|
||||
|
||||
import org.apache.catalina.connector.Connector;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Create by IntelliJ IDEA
|
||||
*
|
||||
* @author chenlei
|
||||
* @dateTime 2019/5/23 18:09
|
||||
* @description TomcatConfig
|
||||
*/
|
||||
//@Configuration
|
||||
public class TomcatConfig {
|
||||
@Value("${server.http.port:8085}")
|
||||
private Integer httpPort;
|
||||
// @Bean
|
||||
// public ServletWebServerFactory webServerFactory() {
|
||||
// TomcatServletWebServerFactory fa = new TomcatServletWebServerFactory();
|
||||
// fa.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> connector.setProperty("relaxedQueryChars", "[]{}"));
|
||||
// return fa;
|
||||
// }
|
||||
|
||||
|
||||
// @Bean
|
||||
// public Connector connector(){
|
||||
// Connector connector=new Connector("org.apache.coyote.http11.Http11NioProtocol");
|
||||
// connector.setScheme("http");
|
||||
// connector.setPort(80);
|
||||
// connector.setSecure(false);
|
||||
// connector.setRedirectPort(443);
|
||||
// return connector;
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public TomcatServletWebServerFactory tomcatServletWebServerFactory(Connector connector){
|
||||
// TomcatServletWebServerFactory tomcat=new TomcatServletWebServerFactory(){
|
||||
// @Override
|
||||
// protected void postProcessContext(Context context) {
|
||||
// SecurityConstraint securityConstraint=new SecurityConstraint();
|
||||
// securityConstraint.setUserConstraint("CONFIDENTIAL");
|
||||
// SecurityCollection collection=new SecurityCollection();
|
||||
// collection.addPattern("/*");
|
||||
// securityConstraint.addCollection(collection);
|
||||
// context.addConstraint(securityConstraint);
|
||||
// }
|
||||
// };
|
||||
// connector.setProperty("relaxedQueryChars", "[]{}");
|
||||
// tomcat.addAdditionalTomcatConnectors(connector);
|
||||
// return tomcat;
|
||||
// }
|
||||
|
||||
/* --------------------请按照自己spring boot版本选择 start--------------------- */
|
||||
|
||||
// 这是spring boot 2.0.X版本的 添加这个,上一个就不用添加了
|
||||
@Bean
|
||||
public ServletWebServerFactory servletContainer() {
|
||||
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
|
||||
tomcat.addAdditionalTomcatConnectors(createStandardConnector()); // 添加http
|
||||
return tomcat;
|
||||
}
|
||||
|
||||
/* --------------------请按照自己spring boot版本选择 end--------------------- */
|
||||
|
||||
|
||||
// 配置http
|
||||
private Connector createStandardConnector() {
|
||||
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
|
||||
connector.setPort(httpPort);
|
||||
return connector;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user