From 855b8a7835bfffd7e81ef5fb2d9e6bad133136c9 Mon Sep 17 00:00:00 2001 From: KKSU <15274802129@163.com> Date: Sat, 06 Jul 2024 23:02:04 +0800 Subject: [PATCH] 逻辑 --- src/main/java/cc/mrbird/febs/dapp/service/impl/DappMemberServiceImpl.java | 83 ++++++++++++++++++++++++----------------- 1 files changed, 49 insertions(+), 34 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 10a189c..3e89f6a 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 @@ -403,34 +403,41 @@ teamUpVo.setDirectCntAva(0); teamUpVo.setDirectAchieve(BigDecimal.ZERO); }else{ - teamUpVo.setDirectCnt(CollUtil.isNotEmpty(directMembers) ? 0 : directMembers.size()); + teamUpVo.setDirectCnt(CollUtil.isEmpty(directMembers) ? 0 : directMembers.size()); List<DappMemberEntity> directCntAva = directMembers.stream().filter(dappMemberEntity -> dappMemberEntity.getActiveStatus() == 1).collect(Collectors.toList()); - teamUpVo.setDirectCntAva(CollUtil.isNotEmpty(directCntAva) ? 0 : directCntAva.size()); - - List<Long> collectDirect = directCntAva.stream().map(DappMemberEntity::getId).collect(Collectors.toList()); - QueryWrapper<DappStorage> storageQueryWrapper = new QueryWrapper<>(); - storageQueryWrapper.in("member_id",collectDirect); - storageQueryWrapper.eq("state",1); - List<DappStorage> dappStoragesDirect = dappStorageMapper.selectList(storageQueryWrapper); - BigDecimal directAchieve = dappStoragesDirect.stream() - .map(DappStorage::getAmount) // 映射amount到流中 - .reduce(BigDecimal.ZERO, BigDecimal::add); - teamUpVo.setDirectAchieve(directAchieve); + teamUpVo.setDirectCntAva(CollUtil.isEmpty(directCntAva) ? 0 : directCntAva.size()); + if(CollUtil.isNotEmpty(directCntAva)){ + List<Long> collectDirect = directCntAva.stream().map(DappMemberEntity::getId).collect(Collectors.toList()); + QueryWrapper<DappStorage> storageQueryWrapper = new QueryWrapper<>(); + storageQueryWrapper.in("member_id",collectDirect); +// storageQueryWrapper.eq("state",1); + List<DappStorage> dappStoragesDirect = dappStorageMapper.selectList(storageQueryWrapper); + BigDecimal directAchieve = dappStoragesDirect.stream() + .map(DappStorage::getAmount) // 映射amount到流中 + .reduce(BigDecimal.ZERO, BigDecimal::add); + teamUpVo.setDirectAchieve(directAchieve); + }else{ + teamUpVo.setDirectAchieve(BigDecimal.ZERO); + } List<DappMemberEntity> teamMembers = dappMemberDao.selectChildMemberDirectOrNot(memberEntity.getInviteId(), 2, null); - teamUpVo.setTeamCnt(CollUtil.isNotEmpty(teamMembers) ? 0 : teamMembers.size()); + teamUpVo.setTeamCnt(CollUtil.isEmpty(teamMembers) ? 0 : teamMembers.size()); List<DappMemberEntity> teamCntAva = teamMembers.stream().filter(dappMemberEntity -> dappMemberEntity.getActiveStatus() == 1).collect(Collectors.toList()); - teamUpVo.setTeamCntAva(CollUtil.isNotEmpty(teamCntAva) ? 0 : teamCntAva.size()); + teamUpVo.setTeamCntAva(CollUtil.isEmpty(teamCntAva) ? 0 : teamCntAva.size()); - List<Long> collectTeam = teamCntAva.stream().map(DappMemberEntity::getId).collect(Collectors.toList()); - QueryWrapper<DappStorage> collectTeamWrapper = new QueryWrapper<>(); - collectTeamWrapper.in("member_id",collectTeam); - collectTeamWrapper.eq("state",1); - List<DappStorage> dappStoragesTeam = dappStorageMapper.selectList(collectTeamWrapper); - BigDecimal teamAchieve = dappStoragesTeam.stream() - .map(DappStorage::getAmount) // 映射amount到流中 - .reduce(BigDecimal.ZERO, BigDecimal::add); - teamUpVo.setTeamAchieve(teamAchieve); + if(CollUtil.isNotEmpty(teamCntAva)){ + List<Long> collectTeam = teamCntAva.stream().map(DappMemberEntity::getId).collect(Collectors.toList()); + QueryWrapper<DappStorage> collectTeamWrapper = new QueryWrapper<>(); + collectTeamWrapper.in("member_id",collectTeam); +// collectTeamWrapper.eq("state",1); + List<DappStorage> dappStoragesTeam = dappStorageMapper.selectList(collectTeamWrapper); + BigDecimal teamAchieve = dappStoragesTeam.stream() + .map(DappStorage::getAmount) // 映射amount到流中 + .reduce(BigDecimal.ZERO, BigDecimal::add); + teamUpVo.setTeamAchieve(teamAchieve); + }else{ + teamUpVo.setTeamAchieve(BigDecimal.ZERO); + } } return teamUpVo; } @@ -442,31 +449,39 @@ DappMemberEntity memberEntity = dappMemberDao.selectById(memberId); List<DappMemberEntity> directMembers = dappMemberDao.selectChildMemberDirectOrNot(memberEntity.getInviteId(), 1, null); + directMembers.add(memberEntity); if(CollUtil.isNotEmpty(directMembers)){ for(DappMemberEntity directMember : directMembers){ TeamDownVo teamDownVo = new TeamDownVo(); + + + teamDownVo.setAddress(directMember.getAddress()); List<DappMemberEntity> teamMembers = dappMemberDao.selectChildMemberDirectOrNot(directMember.getInviteId(), 2, null); if(CollUtil.isEmpty(teamMembers)){ - teamDownVo.setAddress(directMember.getAddress()); teamDownVo.setActiveCnt(0); teamDownVo.setActiveAchieve(BigDecimal.ZERO); }else{ List<DappMemberEntity> teamCntAva = teamMembers.stream().filter(dappMemberEntity -> dappMemberEntity.getActiveStatus() == 1).collect(Collectors.toList()); List<Long> collectTeam = teamCntAva.stream().map(DappMemberEntity::getId).collect(Collectors.toList()); - QueryWrapper<DappStorage> collectTeamWrapper = new QueryWrapper<>(); - collectTeamWrapper.in("member_id",collectTeam); - collectTeamWrapper.eq("state",1); - List<DappStorage> dappStoragesTeam = dappStorageMapper.selectList(collectTeamWrapper); - BigDecimal teamAchieve = dappStoragesTeam.stream() - .map(DappStorage::getAmount) // 映射amount到流中 - .reduce(BigDecimal.ZERO, BigDecimal::add); - teamDownVo.setAddress(directMember.getAddress()); - teamDownVo.setActiveCnt(teamCntAva.size()); - teamDownVo.setActiveAchieve(teamAchieve); + if(CollUtil.isNotEmpty(collectTeam)){ + QueryWrapper<DappStorage> collectTeamWrapper = new QueryWrapper<>(); + collectTeamWrapper.in("member_id",collectTeam); +// collectTeamWrapper.eq("state",1); + List<DappStorage> dappStoragesTeam = dappStorageMapper.selectList(collectTeamWrapper); + BigDecimal teamAchieve = dappStoragesTeam.stream() + .map(DappStorage::getAmount) // 映射amount到流中 + .reduce(BigDecimal.ZERO, BigDecimal::add); + + teamDownVo.setActiveCnt(teamCntAva.size()); + teamDownVo.setActiveAchieve(teamAchieve); + }else{ + teamDownVo.setActiveCnt(0); + teamDownVo.setActiveAchieve(BigDecimal.ZERO); + } } objects.add(teamDownVo); -- Gitblit v1.9.1