| | |
| | | package com.ruoyi.account; |
| | | package com.ruoyi.order.account; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.account.RuoYiAccountApplication; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.service.AppUserService; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = RuoYiAccountApplication.class) |
| | | public class RuoYiAccountApplicationTests { |
| | | |
| | | @Autowired |
| | | private AppUserService appUserService; |
| | | |
| | | @Test |
| | | public void contextLoads() { |
| | | List<AppUser> appUserList = appUserService.list(new LambdaQueryWrapper<AppUser>() |
| | | .ne(AppUser::getStatus, 3)); |
| | | 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); |
| | | } |
| | | |
| | | 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) { |
| | | 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(); |
| | | List<Long> userIdList = children.stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | getUserAncestorList(userIdList, children); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |