From 15bfd012429367bf9b8f03bdc8bb101ae0bdfe4d Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 21 三月 2025 15:26:39 +0800 Subject: [PATCH] 修改统计bug --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java | 109 +++++++++++++++++++++++++++++++----------------------- 1 files changed, 62 insertions(+), 47 deletions(-) diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java index e99289b..5d9b385 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java @@ -323,7 +323,11 @@ //获取绑定上级 if (user.getInviteUserId() != null) { AppUser byId = appUserService.getById(user.getInviteUserId()); - user.setTopUser(byId); + if(null != byId){ + user.setTopUser(byId); + }else{ + user.setTopUser(new AppUser()); + } }else { AppUser topUser = new AppUser(); user.setTopUser(topUser); @@ -371,7 +375,6 @@ .eq(AppUser::getDelFlag, 0) .ne(AppUser::getStatus, 3) .count(); - vip1Count1 += count1; Long count2 = appUserService.lambdaQuery() .eq(AppUser::getVipId, 2) @@ -379,42 +382,36 @@ .eq(AppUser::getDelFlag, 0) .ne(AppUser::getStatus, 3) .count(); - vip1Count2 += count2; Long count3 = appUserService.lambdaQuery() .eq(AppUser::getVipId, 3) .eq(AppUser::getInviteUserId, appUser.getId()) .eq(AppUser::getDelFlag, 0) .ne(AppUser::getStatus, 3) .count(); - vip1Count3 += count3; Long count4 = appUserService.lambdaQuery() .eq(AppUser::getVipId, 4) .eq(AppUser::getInviteUserId, appUser.getId()) .eq(AppUser::getDelFlag, 0) .ne(AppUser::getStatus, 3) .count(); - vip1Count4 += count4; Long count5 = appUserService.lambdaQuery() .eq(AppUser::getVipId, 5) .eq(AppUser::getInviteUserId, appUser.getId()) .eq(AppUser::getDelFlag, 0) .ne(AppUser::getStatus, 3) .count(); - vip1Count5 += count5; Long count6 = appUserService.lambdaQuery() .eq(AppUser::getVipId, 6) .eq(AppUser::getInviteUserId, appUser.getId()) .eq(AppUser::getDelFlag, 0) .ne(AppUser::getStatus, 3) .count(); - vip1Count6 += count6; Long count7 = appUserService.lambdaQuery() .eq(AppUser::getVipId, 7) .eq(AppUser::getInviteUserId, appUser.getId()) .eq(AppUser::getDelFlag, 0) .ne(AppUser::getStatus, 3) .count(); - vip1Count7 += count7; appUser.setCount1(count1); appUser.setCount2(count2); appUser.setCount3(count3); @@ -423,6 +420,7 @@ appUser.setCount6(count6); appUser.setCount7(count7); } + user.setBottomUsers(list); user.setCount1(vip1Count1); user.setCount2(vip1Count2); @@ -512,42 +510,23 @@ ArrayList<Long> userIds = new ArrayList<>(); userIds.add(userId); // 获取当前用户的所有下级 - 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<AppUser> allSubordinates = appUserService.list(new LambdaQueryWrapper<AppUser>() + .eq(AppUser::getInviteUserId, user.getId()).eq(AppUser::getDelFlag, 0) + .ne(AppUser::getStatus, 3)); + Long count1 = allSubordinates.stream().filter(s->s.getVipId() == 1).count(); + user.setCount1(count1); + Long count2 = allSubordinates.stream().filter(s->s.getVipId() == 2).count(); + user.setCount2(count2); + Long count3 = allSubordinates.stream().filter(s->s.getVipId() == 3).count(); + user.setCount3(count3); + Long count4 = allSubordinates.stream().filter(s->s.getVipId() == 4).count(); + user.setCount4(count4); + Long count5 = allSubordinates.stream().filter(s->s.getVipId() == 5).count(); + user.setCount5(count5); + Long count6 = allSubordinates.stream().filter(s->s.getVipId() == 6).count(); + user.setCount6(count6); + Long count7 = allSubordinates.stream().filter(s->s.getVipId() == 7).count(); + user.setCount7(count7); List<UserSignRecord> list = userSignRecordService.lambdaQuery().eq(UserSignRecord::getSignDay, LocalDate.now()) .eq(UserSignRecord::getAppUserId,userId).list(); if (!list.isEmpty()) { @@ -733,6 +712,41 @@ shopId = sysUser.getObjectId(); userId = orderClient.getAppUserByShoppingShop(shopId).getData(); } + appUser.setExcludeStatus(3); + IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser, shopId, userId); + for (AppUser record : appuserPage.getRecords()) { + if (record.getInviteUserId() != null) { + AppUser byId1 = appUserService.getById(record.getInviteUserId()); + if (byId1!=null) { + record.setInviteUserName(byId1.getName()); + } + } + Shop shop1 = shopClient.getServiceProvider(record.getId()).getData(); + if(null != shop1){ + record.setShopName(shop1.getName()); + record.setShopId(shop1.getId()); + } + record.setTotalPoint(record.getUserTotalPoint()); + } + return R.ok(appuserPage); + } + + + /** + * 获取用户积分列表 + */ + @GetMapping("/getUserPotPage") + public R<IPage<AppUser>> getUserPotPage(@ApiParam("页码") @RequestParam Integer pageNum, + @ApiParam("每一页数据大小") Integer pageSize, + AppUser appUser) { + Long userid = tokenService.getLoginUser().getUserid(); + SysUser sysUser = sysUserClient.getSysUser(userid).getData(); + Integer shopId = null; + Set<Long> userId = null; + if(sysUser.getRoleType() == 2){ + shopId = sysUser.getObjectId(); + userId = orderClient.getAppUserByShoppingShop(shopId).getData(); + } IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser, shopId, userId); for (AppUser record : appuserPage.getRecords()) { if (record.getInviteUserId() != null) { @@ -747,10 +761,10 @@ record.setShopName(shopById.getData().getName()); } } + record.setTotalPoint(record.getUserTotalPoint()); } return R.ok(appuserPage); } - @GetMapping("/shop/getAppuserPage") @@ -939,9 +953,10 @@ Long userid = tokenService.getLoginUser().getUserid(); SysUser sysUser = sysUserClient.getSysUser(userid).getData(); AppUser byId = appUserService.getById(id); - Shop shop1 = shopClient.getServiceProvider(id).getData(); + Shop shop1 = shopClient.getServiceProvider(byId.getId()).getData(); if(null != shop1){ byId.setShopName(shop1.getName()); + byId.setShopId(shop1.getId()); } R<List<Shop>> shopByUserId = shopClient.getShopByUserId(id); if (shopByUserId.getData() != null) { @@ -1197,7 +1212,7 @@ .eq(BalanceChangeRecord::getVipId, i); if(sysUser.getRoleType() == 2){ Integer objectId = sysUser.getObjectId(); - List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getShopId, objectId).eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1)); + List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getShopId, objectId).eq(AppUser::getDelFlag, 0).ne(AppUser::getStatus, 1)); List<Long> appUserIds = list.stream().map(AppUser::getId).collect(Collectors.toList()); Set<Long> data = orderClient.getAppUserByShoppingShop(objectId).getData(); if(null != data){ -- Gitblit v1.7.1