From 340a543843920a39d6f7b49f6e39fef1c14c1c6a Mon Sep 17 00:00:00 2001
From: wzy <wzy19931122ai@163.com>
Date: Sat, 27 Aug 2022 14:02:53 +0800
Subject: [PATCH] fix

---
 src/main/java/cc/mrbird/febs/dapp/service/impl/DappSystemServiceImpl.java |   45 ++++++++++++++++++++++++++++++++++-----------
 1 files changed, 34 insertions(+), 11 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 b71a9db..a699fca 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
@@ -8,6 +8,7 @@
 import cc.mrbird.febs.dapp.chain.ContractChainService;
 import cc.mrbird.febs.dapp.dto.SystemDto;
 import cc.mrbird.febs.dapp.entity.*;
+import cc.mrbird.febs.dapp.enumerate.CardPeriod;
 import cc.mrbird.febs.dapp.mapper.*;
 import cc.mrbird.febs.dapp.service.DappSystemService;
 import cc.mrbird.febs.dapp.utils.OnlineTransferUtil;
@@ -74,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()));
-        result.put("cardCnt", 1000);
+        BigInteger nftCount = ChainService.getInstance(ChainEnum.BSC_NFT_SDC.name()).totalSupplyNFT();
+        int count = nftCount == null ? 0 : nftCount.intValue();
+        result.put("cardCnt", 1000 - count);
+        result.put("nftPrice", AppContants.NFT_ACTIVE_PRICE);
         return result;
     }
 
@@ -115,6 +119,15 @@
             }
             system.setBuyRemain(balance);
             system.setBuyTotal(balance);
+
+
+            Object maxDailyBuy = redisUtils.get(AppContants.REDIS_KEY_IDO_USDT_MAX_BUY_DAILY + member.getAddress());
+            if (maxDailyBuy == null) {
+                DateTime tomorrow = DateUtil.beginOfDay(DateUtil.tomorrow());
+                long time = DateUtil.between(new Date(), tomorrow, DateUnit.SECOND, true);
+
+                redisUtils.set(AppContants.REDIS_KEY_IDO_USDT_MAX_BUY_DAILY + member.getAddress(), new BigDecimal("1000"), time);
+            }
 
             return system;
         }
@@ -640,11 +653,17 @@
             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;
         }
 
-        DataDictionaryCustom boxRecommendCnt = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.DIC_TYPE_SYSTEM_SETTING, AppContants.DIC_VALUE_BOX_RECOMMEND_CNT);
+        BigInteger totalSupply = ChainService.getInstance(ChainEnum.BSC_NFT_SDC.name()).totalSupplyNFT();
         int box = 0;
         // 需要第一次购买,才在推荐中加1
         Object parentRecommend = redisUtils.hget(AppContants.IDO_MEMBER_RECOMMEND_CNT, parent.getAddress());
@@ -654,7 +673,7 @@
             int i = (int) parentRecommend;
 
             // 如果超过10个,则新增一个盲盒,并重置推荐人数
-            if (++i == new Integer(boxRecommendCnt.getValue())) {
+            if (++i == CardPeriod.ONE.recommendCnt(totalSupply.intValue())) {
                 box = 1;
                 redisUtils.hset(AppContants.IDO_MEMBER_RECOMMEND_CNT, parent.getAddress(), 0);
             } else {
@@ -662,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
@@ -714,4 +732,9 @@
 
         return true;
     }
+
+    @Override
+    public void sdmWithdrawFee(String data) {
+
+    }
 }

--
Gitblit v1.9.1