From ec2c41a6dfbcd99b90d8df2b71f364f7d4fae96c Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Thu, 15 Dec 2022 10:34:23 +0800
Subject: [PATCH] 20221213转币

---
 src/main/java/cc/mrbird/febs/dapp/service/impl/DappMemberServiceImpl.java |   72 +++++++++++++++++++++++++++++++----
 1 files changed, 63 insertions(+), 9 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappMemberServiceImpl.java b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappMemberServiceImpl.java
index 0a132eb..78eb160 100644
--- a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappMemberServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappMemberServiceImpl.java
@@ -19,9 +19,7 @@
 import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum;
 import cc.mrbird.febs.dapp.mapper.*;
 import cc.mrbird.febs.dapp.service.DappMemberService;
-import cc.mrbird.febs.dapp.vo.AdminSystemFeeVo;
-import cc.mrbird.febs.dapp.vo.ApiRunListInfoVo;
-import cc.mrbird.febs.dapp.vo.TeamListVo;
+import cc.mrbird.febs.dapp.vo.*;
 import cc.mrbird.febs.rabbit.producer.ChainProducer;
 import cc.mrbird.febs.system.entity.User;
 import cn.hutool.core.collection.CollUtil;
@@ -60,6 +58,7 @@
     private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
     private final DappSystemProfitDao dappSystemProfitDao;
     private final ChainProducer chainProducer;
+    private final DappFundFlowDao dappFundFlowDao;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -202,7 +201,23 @@
         if (currentUser.getDeptId() == null) {
             member.setCurrentUser(currentUser.getUserId());
         }
-        return dappMemberDao.selectInPage(member, page);
+        IPage<DappMemberEntity> dappMemberEntityIPage = dappMemberDao.selectInPage(member, page);
+        List<DappMemberEntity> records = dappMemberEntityIPage.getRecords();
+        if(CollUtil.isNotEmpty(records)){
+            for(DappMemberEntity memberEntity : records){
+                Long memberId = memberEntity.getId();
+
+                DappSystemProfit dappSystemProfit = dappSystemProfitDao.selectByMemberIdAndState(memberId,DappSystemProfit.STATE_IN);
+                memberEntity.setSystemProfitId(ObjectUtil.isEmpty(dappSystemProfit) ? 0L : dappSystemProfit.getId());
+                BigDecimal directProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,3,2);
+                memberEntity.setDirectProfit(directProfit);
+                BigDecimal levelProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,4,2);
+                memberEntity.setLevelProfit(levelProfit);
+                BigDecimal luckyProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,7,2);
+                memberEntity.setLuckyProfit(luckyProfit);
+            }
+        }
+        return dappMemberEntityIPage;
     }
 
     @Override
@@ -388,7 +403,7 @@
         String memberOutCount = redisUtils.getString(redisKey);
         DataDictionaryCustom queueCountSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.QUEUE_COUNT.getType(), DataDictionaryEnum.QUEUE_COUNT.getCode());
         String queueCount = queueCountSet.getValue();
-        if(StrUtil.isBlank(memberOutCount)){
+        if(StrUtil.isBlank(memberOutCount)|| !queueCount.equals(memberOutCount)){
             redisUtils.set(redisKey,queueCount,0L);
             memberOutCount = queueCount;
         }
@@ -406,17 +421,56 @@
         objectQueryWrapper.eq("state",DappSystemProfit.STATE_IN);
         //实际投资人数
         Integer selectCount = dappSystemProfitDao.selectCount(objectQueryWrapper);
-        BigDecimal runPercent = new BigDecimal(selectCount).divide(new BigDecimal(memberCount), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100));
-        apiRunListInfoVo.setRunPercent(runPercent);
+        int runPercentNum = memberCount - selectCount;
+        runPercentNum = runPercentNum > 0 ? runPercentNum : 1;
+        apiRunListInfoVo.setRunPercent(new BigDecimal(runPercentNum).multiply(new BigDecimal(0.4)).setScale(BigDecimal.ROUND_DOWN,1));
+//        BigDecimal runPercent = new BigDecimal(selectCount).divide(new BigDecimal(memberCount), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100));
+//        apiRunListInfoVo.setRunPercent(runPercent);
         //实际投资人数小于出局条件人数
         //符合则出局 实际投资人数等于出局条件人数
         DappSystemProfit dappSystemProfitIn = dappSystemProfitDao.selectSystemProfitInByState(DappSystemProfit.STATE_IN);
-        apiRunListInfoVo.setLuckyMemberNext(dappSystemProfitIn.getId());
+        apiRunListInfoVo.setLuckyMemberNext(ObjectUtil.isEmpty(dappSystemProfitIn) ? 0L : dappSystemProfitIn.getId());
         DappSystemProfit dappSystemProfitOut = dappSystemProfitDao.selectSystemProfitOutByState(DappSystemProfit.STATE_OUT);
-        apiRunListInfoVo.setLuckyMember(dappSystemProfitOut.getId());
+        apiRunListInfoVo.setLuckyMember(ObjectUtil.isEmpty(dappSystemProfitOut) ? 0L : dappSystemProfitOut.getId());
         return apiRunListInfoVo;
     }
 
+    @Override
+    public IPage<AdminDappSystemProfitVo> selectSystemProfitInPage(DappSystemProfit dappSystemProfit, QueryRequest request) {
+        Page<AdminDappSystemProfitVo> page = new Page<>(request.getPageNum(), request.getPageSize());
+        return dappSystemProfitDao.selectSystemProfitInPage(dappSystemProfit, page);
+    }
+
+    @Override
+    public IPage<AdminSystemProfitFlowListVo> getSystemProfitFlowList(DappSystemProfit dappSystemProfit, QueryRequest request) {
+        Page<AdminSystemProfitFlowListVo> page = new Page<>(request.getPageNum(), request.getPageSize());
+        return dappSystemProfitDao.selectSystemProfitFlowListInPage(dappSystemProfit, page);
+    }
+
+    @Override
+    public IPage<AdminTeamInfoVo> getTeamInfo(DappMemberEntity dappMemberEntity, QueryRequest request) {
+        Page<AdminTeamInfoVo> page = new Page<>(request.getPageNum(), request.getPageSize());
+        dappMemberEntity = this.baseMapper.selectById(dappMemberEntity.getId());
+        IPage<AdminTeamInfoVo> adminTeamInfoVoIPage = this.baseMapper.findTeamInfoListInPage(page, dappMemberEntity);
+        List<AdminTeamInfoVo> records = adminTeamInfoVoIPage.getRecords();
+        if(CollUtil.isNotEmpty(records)){
+            for(AdminTeamInfoVo adminTeamInfoVo : records){
+                Long memberId = adminTeamInfoVo.getId();
+                List<DappMemberEntity> direct = dappMemberDao.selectChildMemberDirectOrNot(adminTeamInfoVo.getInviteId(), 1, 1);
+                adminTeamInfoVo.setDirectCnt(direct.size());
+                DappSystemProfit dappSystemProfit = dappSystemProfitDao.selectByMemberIdAndState(memberId,DappSystemProfit.STATE_IN);
+                adminTeamInfoVo.setSystemProfitId(ObjectUtil.isEmpty(dappSystemProfit) ? 0L : dappSystemProfit.getId());
+                BigDecimal directProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,3,2);
+                adminTeamInfoVo.setDirectProfit(directProfit);
+                BigDecimal levelProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,4,2);
+                adminTeamInfoVo.setLevelProfit(levelProfit);
+                BigDecimal luckyProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,7,2);
+                adminTeamInfoVo.setLuckyProfit(luckyProfit);
+            }
+        }
+        return adminTeamInfoVoIPage;
+    }
+
     public TeamListVo buildTeamMatrix(Long memberId) {
         DappMemberEntity member = dappMemberDao.selectById(memberId);
         TeamListVo teamListVo = new TeamListVo();

--
Gitblit v1.9.1