| | |
| | | .eq(AppUser::getDelFlag, 0)); |
| | | ArrayList<Long> userIds = new ArrayList<>(); |
| | | userIds.add(userId); |
| | | getUserAncestorList(user,userIds, appUserList); |
| | | getUserAncestorList(user,userIds,new ArrayList<>(),appUserList); |
| | | // Long count1 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 1).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | // Long count2 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 2).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | // Long count3 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 3).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | |
| | | } |
| | | return R.ok(user); |
| | | } |
| | | public void getUserAncestorList(AppUser user,List<Long> userIds, List<AppUser> list) { |
| | | List<AppUser> children = list.stream().filter(u -> userIds.contains(u.getInviteUserId()) || userIds.contains(u.getTopInviteId())).collect(Collectors.toList()); |
| | | public void getUserAncestorList(AppUser user,List<Long> userIds, List<AppUser> children,List<AppUser> list) { |
| | | children = list.stream().filter(u -> userIds.contains(u.getInviteUserId()) || userIds.contains(u.getTopInviteId())).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(children)){ |
| | | user.setCount1((user.getCount1() == null ? 0L : user.getCount1()) + children.stream().filter(e->e.getVipId() == 1).count()); |
| | | user.setCount2((user.getCount2() == null ? 0L : user.getCount2()) + children.stream().filter(e->e.getVipId() == 2).count()); |
| | |
| | | user.setCount6((user.getCount6() == null ? 0L : user.getCount6()) + children.stream().filter(e->e.getVipId() == 6).count()); |
| | | user.setCount7((user.getCount7() == null ? 0L : user.getCount7()) + children.stream().filter(e->e.getVipId() == 7).count()); |
| | | List<Long> userIdList = children.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | getUserAncestorList(user,userIdList, children); |
| | | getUserAncestorList(user,userIdList, children,list); |
| | | } |
| | | } |
| | | |
| | |
| | | List<AppUser> appUserList = appUserService.list(new LambdaQueryWrapper<AppUser>() |
| | | .ne(AppUser::getStatus, 3) |
| | | .eq(AppUser::getDelFlag, 0)); |
| | | AppUser user = appUserService.getById(1879046499735789569L); |
| | | AppUser user = appUserService.getById(1879047378761244673L); |
| | | ArrayList<Long> userIds = new ArrayList<>(); |
| | | userIds.add(1879046499735789569L); |
| | | getUserAncestorList(user,userIds, appUserList); |
| | | userIds.add(1879047378761244673L); |
| | | getUserAncestorList(user,userIds, new ArrayList<>(),appUserList); |
| | | System.err.println(user.getCount1()); |
| | | System.err.println(user.getCount2()); |
| | | System.err.println(user.getCount3()); |
| | |
| | | System.err.println(user.getCount6()); |
| | | System.err.println(user.getCount7()); |
| | | } |
| | | public void getUserAncestorList(AppUser user,List<Long> userIds, List<AppUser> list) { |
| | | List<AppUser> children = list.stream().filter(u -> userIds.contains(u.getInviteUserId()) || userIds.contains(u.getTopInviteId())).collect(Collectors.toList()); |
| | | public void getUserAncestorList(AppUser user,List<Long> userIds, List<AppUser> children,List<AppUser> list) { |
| | | children = list.stream().filter(u -> userIds.contains(u.getInviteUserId()) || userIds.contains(u.getTopInviteId())).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(children)){ |
| | | user.setCount1((user.getCount1() == null ? 0L : user.getCount1()) + children.stream().filter(e->e.getVipId() == 1).count()); |
| | | user.setCount2((user.getCount2() == null ? 0L : user.getCount2()) + children.stream().filter(e->e.getVipId() == 2).count()); |
| | |
| | | user.setCount6((user.getCount6() == null ? 0L : user.getCount6()) + children.stream().filter(e->e.getVipId() == 6).count()); |
| | | user.setCount7((user.getCount7() == null ? 0L : user.getCount7()) + children.stream().filter(e->e.getVipId() == 7).count()); |
| | | List<Long> userIdList = children.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | getUserAncestorList(user,userIdList, children); |
| | | getUserAncestorList(user,userIdList, children,list); |
| | | } |
| | | } |
| | | |