From de3cd7b5444f5d9059491e9bd62387f31bf66fc5 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Fri, 29 Jul 2022 09:55:12 +0800
Subject: [PATCH] fix
---
src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java | 107 +++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 94 insertions(+), 13 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java
index c7bf6c8..69f033a 100644
--- a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java
@@ -24,17 +24,24 @@
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.*;
/**
- * @author
+ * @author
* @date 2022-03-24
**/
@Slf4j
@@ -99,7 +106,7 @@
Object makePoolObj = redisUtils.get(AppContants.REDIS_KEY_MAKE_POOL_CNT);
BigDecimal balance;
if (makePoolObj == null) {
- balance = ChainService.getInstance(ChainEnum.BSC_TFC_MAKE.name()).balanceOf(ChainEnum.BSC_TFC_MAKE.getAddress());
+ balance = ChainService.getInstance(ChainEnum.BSC_TFC.name()).balanceOf(ChainEnum.BSC_TFC.getAddress());
redisUtils.set(AppContants.REDIS_KEY_MAKE_POOL_CNT, balance);
} else {
balance = (BigDecimal) makePoolObj;
@@ -150,7 +157,8 @@
system.setUsdtTotal(usdtTotal);
system.setUsdtRemain(usdtRemain);
- system.setFeeRatio(BigDecimal.TEN);
+ system.setFeeRatio(new BigDecimal("7"));
+ system.setBuyFeeRatio(new BigDecimal("3"));
return system;
}
@@ -168,7 +176,8 @@
parents = new ArrayList<>();
} else {
List<String> inviteIds = StrUtil.split(member.getRefererId(), ',');
- parents = dappMemberDao.selectParentsList(inviteIds, 6);;
+ parents = dappMemberDao.selectParentsList(inviteIds, 6);
+ ;
}
DataDictionaryCustom miniHoldCoin = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.DIC_TYPE_SYSTEM_SETTING, AppContants.DIC_VALUE_MINI_HOLD_COIN_LIMIT);
@@ -258,6 +267,66 @@
// 发送转账消息
chainProducer.sendOnlineTransfer(JSONObject.toJSONString(map));
}
+
+ @Override
+ public void tradeNftProfitDistribute(Long id) {
+ DappFundFlowEntity fundFlow = dappFundFlowDao.selectById(id);
+ String batchNo = RandomUtil.randomString(16) + id.toString();
+
+ ContractChainService instance = ChainService.getInstance(ChainEnum.BSC_TFC.name());
+ BigDecimal preNFTAmount;
+ BigDecimal distribAmount = fundFlow.getFee();
+ if (fundFlow.getType() == 1) {
+ preNFTAmount = distribAmount.divide(new BigDecimal("5000"), 2, RoundingMode.HALF_UP);
+
+ } else if (fundFlow.getType() == 2) {
+ BigDecimal destroyAmount = fundFlow.getFee().multiply(new BigDecimal("2").divide(new BigDecimal("7"), instance.decimals(), RoundingMode.HALF_UP));
+ // 销毁
+ OnlineTransferUtil.addTransfer(AppContants.DESTROY_ADDRESS, destroyAmount, fundFlow.getType(), 3, ChainEnum.BSC_TFC_SOURCE.name(), AppContants.SYMBOL_COIN, batchNo);
+ distribAmount = fundFlow.getFee().subtract(destroyAmount);
+
+ preNFTAmount = distribAmount.divide(new BigDecimal("5000"), 2, RoundingMode.HALF_UP);
+
+ } else {
+ return;
+ }
+
+ List<DappMemberEntity> allMembers = dappMemberDao.selectList(null);
+ if (CollUtil.isEmpty(allMembers)) {
+ return;
+ }
+
+ BigDecimal total = BigDecimal.ZERO;
+ for (DappMemberEntity member : allMembers) {
+ BigDecimal balance = instance.balanceOf(member.getAddress());
+ BigDecimal memberProfit = balance.multiply(preNFTAmount);
+
+ // 返利
+ OnlineTransferUtil.addTransfer(member.getAddress(), memberProfit, fundFlow.getType(), 1, ChainEnum.BSC_TFC_SOURCE.name(), AppContants.SYMBOL_COIN, batchNo);
+
+ DappFundFlowEntity distribFlow = new DappFundFlowEntity(member.getId(), memberProfit, 4, 2, BigDecimal.ZERO);
+ dappFundFlowDao.insert(distribFlow);
+
+ total = total.add(memberProfit);
+ }
+
+ BigDecimal remain = distribAmount.subtract(total);
+ // 剩余的
+ OnlineTransferUtil.addTransfer(ChainEnum.BSC_TFC_TECH.getAddress(), remain, fundFlow.getType(), 3, ChainEnum.BSC_TFC_SOURCE.name(), AppContants.SYMBOL_COIN, batchNo);
+ }
+
+// public static void main(String[] args) throws IOException {
+// Document parse = Jsoup.parse(new URL("https://bscscan.com/token/generic-tokenholders2?a=0x03c7d3f141c5f03971604958170e253362e13be6"), 10000000);
+//
+// Elements tbodys = parse.getElementsByTag("tbody");
+//
+// Element tbody = tbodys.get(0);
+//
+// Elements elements = tbody.getElementsMatchingOwnText("^0x.*$");
+//
+// String text = elements.get(0).text();
+// System.out.println(1111);
+// }
@Override
public void mining() {
@@ -384,8 +453,7 @@
@Override
public void userBuyReward(Long id) {
// 系统未启动不参与
- String hasStart = redisUtils.getString(AppContants.SYSTEM_START_FLAG);
- if (!"start".equals(hasStart)) {
+ if (!systemHasStart()) {
return;
}
@@ -394,6 +462,10 @@
DappMemberEntity member = dappMemberDao.selectById(fundFlow.getMemberId());
DappMemberEntity referer = dappMemberDao.selectMemberInfoByInviteId(member.getRefererId());
if (referer == null || "admin".equals(referer.getAccountType())) {
+ return;
+ }
+
+ if (!hasProfit(referer.getAddress())) {
return;
}
@@ -452,7 +524,7 @@
Object o = redisUtils.get(AppContants.REDIS_KEY_TRANSFER_POOL_VOL);
if (o == null) {
- RedisTransferPoolVo transferPool= new RedisTransferPoolVo();
+ RedisTransferPoolVo transferPool = new RedisTransferPoolVo();
BigDecimal total = basicVol.multiply(volProp.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP));
transferPool.setTodayVol(total);
transferPool.setTodayProp(volProp);
@@ -562,12 +634,7 @@
return;
}
- BigDecimal balance = ChainService.getInstance(ChainEnum.BSC_TFC.name()).balanceOf(member.getAddress());
- BigDecimal usdtBalance = balance.multiply(newestPrice());
-
- DataDictionaryCustom data = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.DIC_TYPE_SYSTEM_SETTING, AppContants.DIC_VALUE_MINI_HOLD_COIN_LIMIT);
- BigDecimal miniLimit = new BigDecimal(data.getValue());
- if (usdtBalance.compareTo(miniLimit) < 0) {
+ if (!hasProfit(parent.getAddress())) {
return;
}
@@ -627,4 +694,18 @@
return new BigDecimal("0.05");
}
}
+
+ @Override
+ public boolean hasProfit(String address) {
+ BigDecimal balance = ChainService.getInstance(ChainEnum.BSC_TFC.name()).balanceOf(address);
+ BigDecimal usdtBalance = balance.multiply(newestPrice());
+
+ DataDictionaryCustom data = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.DIC_TYPE_SYSTEM_SETTING, AppContants.DIC_VALUE_MINI_HOLD_COIN_LIMIT);
+ BigDecimal miniLimit = new BigDecimal(data.getValue());
+ if (usdtBalance.compareTo(miniLimit) < 0) {
+ return false;
+ }
+
+ return true;
+ }
}
--
Gitblit v1.9.1