From a0a74747c9e486b700cf866250fbb64cbc73bc14 Mon Sep 17 00:00:00 2001
From: wzy <wzy19931122ai@163.com>
Date: Sat, 27 Aug 2022 16:07:35 +0800
Subject: [PATCH] fix

---
 src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java |   47 +++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 39 insertions(+), 8 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 ffd30b0..ad2e486 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
@@ -75,7 +75,10 @@
         result.put("coinCnt", coinCnt);
         result.put("sourceTFC", ChainService.getInstance(ChainEnum.BSC_TFC.name()).balanceOf(ChainEnum.BSC_TFC_SOURCE.getAddress()));
         result.put("sourceUSDT", ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOf(ChainEnum.BSC_USDT_SOURCE.getAddress()));
+//        BigInteger nftCount = ChainService.getInstance(ChainEnum.BSC_NFT_SDC.name()).totalSupplyNFT();
+//        int count = nftCount == null ? 0 : nftCount.intValue();
         result.put("cardCnt", 1000);
+        result.put("nftPrice", AppContants.NFT_ACTIVE_PRICE);
         return result;
     }
 
@@ -650,6 +653,12 @@
             return;
         }
 
+        DataDictionaryCustom data = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.DIC_TYPE_SYSTEM_SETTING, AppContants.DIC_VALUE_MINI_HOLD_COIN_LIMIT);
+        BigDecimal miniLimit = new BigDecimal(data.getValue());
+        if (fundFlow.getTargetAmount().compareTo(miniLimit) < 0) {
+            return;
+        }
+
         if (!hasProfit(parent.getAddress())) {
             return;
         }
@@ -672,22 +681,21 @@
             }
         }
 
+        DappMemberBoxRecordEntity memberBoxRecordEntity = new DappMemberBoxRecordEntity();
+        memberBoxRecordEntity.setMemberId(parent.getId());
+        memberBoxRecordEntity.setAddress(parent.getAddress());
+        memberBoxRecordEntity.setFromMemberId(member.getId());
+        memberBoxRecordEntity.setFromAddress(member.getAddress());
+        this.dappMemberBoxRecordMapper.insert(memberBoxRecordEntity);
+
         if (box > 0) {
             DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(parent.getId());
             walletCoin.setBoxCnt(walletCoin.getBoxCnt() + box);
             dappWalletCoinDao.updateById(walletCoin);
 
-            DappMemberBoxRecordEntity memberBoxRecordEntity = new DappMemberBoxRecordEntity();
-            memberBoxRecordEntity.setMemberId(parent.getId());
-            memberBoxRecordEntity.setAddress(parent.getAddress());
-            memberBoxRecordEntity.setFromMemberId(member.getId());
-            memberBoxRecordEntity.setFromAddress(member.getAddress());
-            this.dappMemberBoxRecordMapper.insert(memberBoxRecordEntity);
-
             DappFundFlowEntity boxFundFlow = new DappFundFlowEntity(parent.getId(), new BigDecimal(box), 5, 2, BigDecimal.ZERO);
             dappFundFlowDao.insert(boxFundFlow);
         }
-
     }
 
     @Override
@@ -724,4 +732,27 @@
 
         return true;
     }
+
+    @Override
+    public void sdmWithdrawFee(String data) {
+
+    }
+
+    @Override
+    public void tfcNewPrice() {
+        BigDecimal newPrice;
+        if (!systemHasStart()) {
+            newPrice = new BigDecimal("0.05");
+        } else {
+            ContractChainService tfcInstance = ChainService.getInstance(ChainEnum.BSC_TFC.name());
+            // u剩余数量
+            BigDecimal sourceU = ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOf(ChainEnum.BSC_USDT_SOURCE.getAddress());
+            // 源池代币剩余数量
+            BigDecimal sourceCoin = tfcInstance.balanceOf(ChainEnum.BSC_USDT_SOURCE.getAddress());
+
+            newPrice = sourceU.divide(sourceCoin, tfcInstance.decimals(), RoundingMode.HALF_UP);
+        }
+
+        chainProducer.sendTfcNewPrice(newPrice.toPlainString());
+    }
 }

--
Gitblit v1.9.1