| | |
| | | user.setShopName(shop.getName()); |
| | | } |
| | | } |
| | | List<AppUser> appUserList = appUserService.list(new LambdaQueryWrapper<AppUser>() |
| | | .ne(AppUser::getStatus, 3) |
| | | .eq(AppUser::getDelFlag, 0)); |
| | | ArrayList<Long> userIds = new ArrayList<>(); |
| | | userIds.add(userId); |
| | | 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(); |
| | | // Long count4 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 4).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | // Long count5 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 5).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | // Long count6 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 6).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | // Long count7 = appUserService.lambdaQuery().ne(AppUser::getStatus,3).eq(AppUser::getVipId, 7).eq(AppUser::getInviteUserId, userId).or().eq(AppUser::getTopInviteId,userId).count(); |
| | | // user.setCount1(count1); |
| | | // user.setCount2(count2); |
| | | // user.setCount3(count3); |
| | | // user.setCount4(count4); |
| | | // user.setCount5(count5); |
| | | // user.setCount6(count6); |
| | | // user.setCount7(count7); |
| | | |
| | | // 获取当前用户的所有下级 |
| | | List<AppUser> allSubordinates = getAllSubordinates(userId); |
| | | // 统计下级中每种会员类型的人数 |
| | | Map<Integer, Long> countMap = allSubordinates.stream() |
| | | .collect(Collectors.groupingBy(AppUser::getVipId, Collectors.counting())); |
| | | countMap.forEach((vipId, count) -> { |
| | | switch (vipId) { |
| | | case 1: |
| | | Long count1 = user.getCount1() == null ? 0 : user.getCount1(); |
| | | user.setCount1(count1 + count); |
| | | break; |
| | | case 2: |
| | | Long count2 = user.getCount2() == null ? 0 : user.getCount2(); |
| | | user.setCount2(count2 + count); |
| | | break; |
| | | case 3: |
| | | Long count3 = user.getCount3() == null ? 0 : user.getCount3(); |
| | | user.setCount3(count3 + count); |
| | | break; |
| | | case 4: |
| | | Long count4 = user.getCount4() == null ? 0 : user.getCount4(); |
| | | user.setCount4(count4 + count); |
| | | break; |
| | | case 5: |
| | | Long count5 = user.getCount5() == null ? 0 : user.getCount5(); |
| | | user.setCount5(count5 + count); |
| | | break; |
| | | case 6: |
| | | Long count6 = user.getCount6() == null ? 0 : user.getCount6(); |
| | | user.setCount6(count6 + count); |
| | | break; |
| | | case 7: |
| | | Long count7 = user.getCount7() == null ? 0 : user.getCount7(); |
| | | user.setCount7(count7 + count); |
| | | break; |
| | | } |
| | | }); |
| | | List<UserSignRecord> list = userSignRecordService.lambdaQuery().eq(UserSignRecord::getSignDay, LocalDate.now()) |
| | | .eq(UserSignRecord::getAppUserId,userId).list(); |
| | | if (!list.isEmpty()) { |
| | |
| | | return R.ok(user); |
| | | } |
| | | |
| | | // 递归获取指定用户的所有下级 |
| | | public List<AppUser> getAllSubordinates(Long userId) { |
| | | List<AppUser> allSubordinates = new ArrayList<>(); |
| | | |
| | | 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.setCount3((user.getCount3() == null ? 0L : user.getCount3()) + children.stream().filter(e->e.getVipId() == 3).count()); |
| | | user.setCount4((user.getCount4() == null ? 0L : user.getCount4()) + children.stream().filter(e->e.getVipId() == 4).count()); |
| | | user.setCount5((user.getCount5() == null ? 0L : user.getCount5()) + children.stream().filter(e->e.getVipId() == 5).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,list); |
| | | List<AppUser> directChildren = appUserService.list(new LambdaQueryWrapper<AppUser>() |
| | | .eq(AppUser::getInviteUserId, userId)); |
| | | |
| | | for (AppUser child : directChildren) { |
| | | allSubordinates.add(child); // 添加直接下级 |
| | | allSubordinates.addAll(getAllSubordinates(child.getId())); // 递归添加间接下级 |
| | | } |
| | | return allSubordinates; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("/index/change") |
| | | @ApiOperation(value = "修改个人资料", tags = {"小程序-个人中心首页"}) |
| | | public R<AppUser> indexchange(String avatar, String name) { |