From 4a347c0ab4b88fd792d24d30bed36b1fa769d3a2 Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Mon, 15 Jul 2024 14:14:04 +0800
Subject: [PATCH] 逻辑

---
 src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java |   46 +++++++++++++++++++++++++++++-----------------
 1 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
index 57f17fd..43e3584 100644
--- a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java
@@ -1,5 +1,6 @@
 package cc.mrbird.febs.dapp.service.impl;
 
+import cc.mrbird.febs.common.contants.AppContants;
 import cc.mrbird.febs.common.entity.FebsResponse;
 import cc.mrbird.febs.common.entity.QueryRequest;
 import cc.mrbird.febs.common.exception.FebsException;
@@ -95,7 +96,7 @@
         BigDecimal runPerk = dappFundFlowDao.selectSumRunPerkByMemberId(member.getId());
         walletInfo.setRunPerk(runPerk);
 
-
+//        List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectList(null);
         List<DappStorage> allAddressNums = dappStorageMapper.selectListGroupByMemberId();
         walletInfo.setAddressNum(CollUtil.isEmpty(allAddressNums) ? 0 : allAddressNums.size());
 
@@ -243,17 +244,22 @@
 
         DappMemberEntity memberEntity = dappMemberDao.selectById(member.getId());
         BigDecimal usdtBalance = memberEntity.getUsdtBalance();
-        if(BigDecimal.ZERO.compareTo(usdtBalance) >= 0){
-            throw new FebsException("额度不足");
-        }
+        if(1 != memberEntity.getNodeType()){
+            if(BigDecimal.ZERO.compareTo(usdtBalance) >= 0){
+                throw new FebsException("额度不足");
+            }
 
-        if(BigDecimal.ZERO.compareTo(withdrawDto.getAmount()) >= 0){
-            throw new FebsException("请输入正确的数量");
+            if(BigDecimal.ZERO.compareTo(withdrawDto.getAmount()) >= 0){
+                throw new FebsException("请输入正确的数量");
+            }
+            if(withdrawDto.getAmount().compareTo(usdtBalance) > 0){
+                throw new FebsException("额度不足");
+            }
+        }else{
+            if(BigDecimal.ZERO.compareTo(withdrawDto.getAmount()) >= 0){
+                throw new FebsException("请输入正确的数量");
+            }
         }
-        if(withdrawDto.getAmount().compareTo(usdtBalance) > 0){
-            throw new FebsException("额度不足");
-        }
-
 //        List<MemberCoinWithdrawEntity> memberCoinWithdrawEntities = memberCoinWithdrawDao.selectListByDate(member.getId(),new Date());
 //        if(CollUtil.isNotEmpty(memberCoinWithdrawEntities)){
 //            throw new FebsException("今日已提现");
@@ -272,9 +278,10 @@
         BigDecimal feeAmount = withdrawDto.getAmount().multiply(withdrawPercent).setScale(2, BigDecimal.ROUND_DOWN);
 
         updateWalletCoinWithLock(withdrawDto.getAmount(), member.getId(), 2);
-
-        memberEntity.setUsdtBalance(usdtBalance.subtract(withdrawDto.getAmount()).setScale(2,BigDecimal.ROUND_DOWN));
-        dappMemberDao.updateById(memberEntity);
+        if(1 != memberEntity.getNodeType()){
+            memberEntity.setUsdtBalance(usdtBalance.subtract(withdrawDto.getAmount()).setScale(2,BigDecimal.ROUND_DOWN));
+            dappMemberDao.updateById(memberEntity);
+        }
 
         DappFundFlowEntity fundFlow = new DappFundFlowEntity(
                 member.getId(),
@@ -695,10 +702,15 @@
                 DataDictionaryEnum.BUCAHNG_CHI.getType(),
                 DataDictionaryEnum.BUCAHNG_CHI.getCode()
         ).getValue());
-        apiIndexInfoVo.setJiedianChi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
-                DataDictionaryEnum.JIE_DIAN_CHI.getType(),
-                DataDictionaryEnum.JIE_DIAN_CHI.getCode()
-        ).getValue());
+        List<DappStorage> dappStorages = dappStorageMapper.selectList(null);
+        BigDecimal reduce = dappStorages.stream().map(DappStorage::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+        BigDecimal bigDecimal = reduce.multiply(new BigDecimal(AppContants.DAO_NODE_PERCENT)).setScale(2, BigDecimal.ROUND_DOWN);
+        apiIndexInfoVo.setJiedianChi(bigDecimal.toString());
+
+//        apiIndexInfoVo.setJiedianChi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+//                DataDictionaryEnum.JIE_DIAN_CHI.getType(),
+//                DataDictionaryEnum.JIE_DIAN_CHI.getCode()
+//        ).getValue());
         apiIndexInfoVo.setJijinghuiChi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                 DataDictionaryEnum.JI_JING_HUI_CHI.getType(),
                 DataDictionaryEnum.JI_JING_HUI_CHI.getCode()

--
Gitblit v1.9.1