From 7c5476bfde20037a3252e78963e38a83aa4342e5 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期三, 15 一月 2025 15:03:19 +0800
Subject: [PATCH] 修改
---
ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/order/account/RuoYiAccountApplicationTests.java | 46 ++++++++++-------------
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java | 41 ++++++++------------
2 files changed, 37 insertions(+), 50 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 834ecc6..1a5c5d4 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
@@ -374,7 +374,7 @@
.eq(AppUser::getDelFlag, 0));
ArrayList<Long> userIds = new ArrayList<>();
userIds.add(userId);
- getUserAncestorList(userIds, appUserList);
+ getUserAncestorList(user,userIds, 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();
@@ -382,13 +382,13 @@
// 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);
+// user.setCount1(count1);
+// user.setCount2(count2);
+// user.setCount3(count3);
+// user.setCount4(count4);
+// user.setCount5(count5);
+// user.setCount6(count6);
+// user.setCount7(count7);
List<UserSignRecord> list = userSignRecordService.lambdaQuery().eq(UserSignRecord::getSignDay, LocalDate.now())
.eq(UserSignRecord::getAppUserId,userId).list();
@@ -399,25 +399,18 @@
}
return R.ok(user);
}
- private Long count1 = 0L;
- private Long count2 = 0L;
- private Long count3 = 0L;
- private Long count4 = 0L;
- private Long count5 = 0L;
- private Long count6 = 0L;
- private Long count7 = 0L;
- public void getUserAncestorList(List<Long> userIds, List<AppUser> list) {
+ 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());
if(!CollectionUtils.isEmpty(children)){
- count1 = count1 + children.stream().filter(e->e.getVipId() == 1).count();
- count2 = count2 + children.stream().filter(e->e.getVipId() == 2).count();
- count3 = count3 + children.stream().filter(e->e.getVipId() == 3).count();
- count4 = count4 + children.stream().filter(e->e.getVipId() == 4).count();
- count5 = count5 + children.stream().filter(e->e.getVipId() == 5).count();
- count6 = count6 + children.stream().filter(e->e.getVipId() == 6).count();
- count7 = count7 + children.stream().filter(e->e.getVipId() == 7).count();
+ 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(userIdList, children);
+ getUserAncestorList(user,userIdList, children);
}
}
diff --git a/ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/order/account/RuoYiAccountApplicationTests.java b/ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/order/account/RuoYiAccountApplicationTests.java
index acaa797..7f258a0 100644
--- a/ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/order/account/RuoYiAccountApplicationTests.java
+++ b/ruoyi-service/ruoyi-account/src/test/java/com/ruoyi/order/account/RuoYiAccountApplicationTests.java
@@ -22,38 +22,32 @@
@Test
public void contextLoads() {
List<AppUser> appUserList = appUserService.list(new LambdaQueryWrapper<AppUser>()
- .ne(AppUser::getStatus, 3));
+ .ne(AppUser::getStatus, 3)
+ .eq(AppUser::getDelFlag, 0));
+ AppUser user = appUserService.getById(1879046499735789569L);
ArrayList<Long> userIds = new ArrayList<>();
userIds.add(1879046499735789569L);
- getUserAncestorList(userIds, appUserList);
- System.err.println(count1);
- System.err.println(count2);
- System.err.println(count3);
- System.err.println(count4);
- System.err.println(count5);
- System.err.println(count6);
- System.err.println(count7);
+ getUserAncestorList(user,userIds, appUserList);
+ System.err.println(user.getCount1());
+ System.err.println(user.getCount2());
+ System.err.println(user.getCount3());
+ System.err.println(user.getCount4());
+ System.err.println(user.getCount5());
+ System.err.println(user.getCount6());
+ System.err.println(user.getCount7());
}
-
- private Long count1 = 0L;
- private Long count2 = 0L;
- private Long count3 = 0L;
- private Long count4 = 0L;
- private Long count5 = 0L;
- private Long count6 = 0L;
- private Long count7 = 0L;
- public void getUserAncestorList(List<Long> userIds, List<AppUser> list) {
+ 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());
if(!CollectionUtils.isEmpty(children)){
- count1 = count1 + children.stream().filter(e->e.getVipId() == 1).count();
- count2 = count2 + children.stream().filter(e->e.getVipId() == 2).count();
- count3 = count3 + children.stream().filter(e->e.getVipId() == 3).count();
- count4 = count4 + children.stream().filter(e->e.getVipId() == 4).count();
- count5 = count5 + children.stream().filter(e->e.getVipId() == 5).count();
- count6 = count6 + children.stream().filter(e->e.getVipId() == 6).count();
- count7 = count7 + children.stream().filter(e->e.getVipId() == 7).count();
+ 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(userIdList, children);
+ getUserAncestorList(user,userIdList, children);
}
}
--
Gitblit v1.7.1