|  | @@ -1,6 +1,7 @@
 | 
	
		
			
				|  |  |  package cn.newfeifan.mall.module.distri.service.sharepath;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
 | 
	
		
			
				|  |  | +import cn.newfeifan.mall.module.distri.controller.admin.duser.vo.DuserSaveReqVO;
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.distri.dal.dataobject.duser.DuserDO;
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.distri.dal.dataobject.ordercalc.OrderCalcDO;
 | 
	
	
		
			
				|  | @@ -19,8 +20,8 @@ import cn.newfeifan.mall.module.member.controller.admin.user.vo.MemberUserUpdate
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.member.convert.user.MemberUserConvert;
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.member.dal.dataobject.user.MemberUserDO;
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.member.service.user.MemberUserService;
 | 
	
		
			
				|  |  | -import com.alibaba.druid.util.StringUtils;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
	
		
			
				|  |  | +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 | 
	
		
			
				|  |  |  import org.springframework.context.annotation.Lazy;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -66,6 +67,7 @@ public class SharePathServiceImpl implements SharePathService {
 | 
	
		
			
				|  |  |      @Resource
 | 
	
		
			
				|  |  |      private MemberUserService memberUserService;
 | 
	
		
			
				|  |  |      @Resource
 | 
	
		
			
				|  |  | +    @Lazy
 | 
	
		
			
				|  |  |      private OrderCalcService orderCalcService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Resource
 | 
	
	
		
			
				|  | @@ -87,36 +89,36 @@ public class SharePathServiceImpl implements SharePathService {
 | 
	
		
			
				|  |  |      public void createSharePathByUserId(SharePathSaveReqVO createReqVO, Boolean isNew) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 如果直推人为空, 则直接结束
 | 
	
		
			
				|  |  | -        if (createReqVO.getDescendant() == null) {
 | 
	
		
			
				|  |  | +        if (createReqVO.getUserId() == null) {
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 判断当前直推人是否有父亲
 | 
	
		
			
				|  |  | -        Boolean has = hasParent(createReqVO.getDescendant());
 | 
	
		
			
				|  |  | +        Boolean has = hasParent(createReqVO.getUserId());
 | 
	
		
			
				|  |  |          if (has) {
 | 
	
		
			
				|  |  |              throw exception(HAS_PARENT);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if (createReqVO.getAncestor() == null) {
 | 
	
		
			
				|  |  | -            createReqVO.setAncestor(BOOS_ID);
 | 
	
		
			
				|  |  | +        if (createReqVO.getReferrerId() == null) {
 | 
	
		
			
				|  |  | +            createReqVO.setReferrerId(BOOS_ID);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        MemberUserDO ancestor = memberUserService.getUser(createReqVO.getAncestor());
 | 
	
		
			
				|  |  | -        MemberUserDO descendant = memberUserService.getUser(createReqVO.getDescendant());
 | 
	
		
			
				|  |  | +        MemberUserDO ancestor = memberUserService.getUser(createReqVO.getReferrerId());
 | 
	
		
			
				|  |  | +        MemberUserDO descendant = memberUserService.getUser(createReqVO.getUserId());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 创建直推人以及推荐人的关系
 | 
	
		
			
				|  |  |          // 需要判断当前推荐人跟直推人是否已经存在于用户表(duser)了
 | 
	
		
			
				|  |  |          duserService.hasUserAndCreat(createReqVO);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 存储他们之间的关系
 | 
	
		
			
				|  |  | -        if (!Objects.equals(createReqVO.getDescendant(), PT_ID)) {
 | 
	
		
			
				|  |  | +        if (!Objects.equals(createReqVO.getUserId(), PT_ID)) {
 | 
	
		
			
				|  |  |              sharePathMapper.addNode(
 | 
	
		
			
				|  |  | -                    createReqVO.getAncestor(),
 | 
	
		
			
				|  |  | +                    createReqVO.getReferrerId(),
 | 
	
		
			
				|  |  |                      ancestor.getUsername(),
 | 
	
		
			
				|  |  | -                    ancestor.getNickname(),
 | 
	
		
			
				|  |  | +                    null,
 | 
	
		
			
				|  |  |                      ancestor.getMobile(),
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                    createReqVO.getDescendant(),
 | 
	
		
			
				|  |  | +                    createReqVO.getUserId(),
 | 
	
		
			
				|  |  |                      descendant.getUsername(),
 | 
	
		
			
				|  |  | -                    descendant.getNickname(),
 | 
	
		
			
				|  |  | +                    null,
 | 
	
		
			
				|  |  |                      descendant.getMobile());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -124,8 +126,8 @@ public class SharePathServiceImpl implements SharePathService {
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          OrderPercentageDO orderPercentageDO = orderPercentageMapper.selectList().get(0);
 | 
	
		
			
				|  |  | -        duserService.updateDuserSocial(createReqVO.getAncestor(), Long.valueOf(orderPercentageDO.getRegisterAncestorSocialStatus()), SocialStatusEnum.REGISTER_ANCESTOR_SOCIAL.getStatus());
 | 
	
		
			
				|  |  | -        socialStatusChangeLogService.createSocialStatusChangeLog(createReqVO.getAncestor(), Long.valueOf(orderPercentageDO.getRegisterAncestorSocialStatus()), createReqVO.getAncestor(), SocialStatusEnum.REGISTER_ANCESTOR_SOCIAL);
 | 
	
		
			
				|  |  | +        duserService.updateDuserSocial(createReqVO.getReferrerId(), Long.valueOf(orderPercentageDO.getRegisterAncestorSocialStatus()), SocialStatusEnum.REGISTER_ANCESTOR_SOCIAL.getStatus());
 | 
	
		
			
				|  |  | +        socialStatusChangeLogService.createSocialStatusChangeLog(createReqVO.getReferrerId(), Long.valueOf(orderPercentageDO.getRegisterAncestorSocialStatus()), createReqVO.getReferrerId(), SocialStatusEnum.REGISTER_ANCESTOR_SOCIAL);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -139,8 +141,8 @@ public class SharePathServiceImpl implements SharePathService {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              // 如果是没有父亲, 将其推荐人设置为平台
 | 
	
		
			
				|  |  |              SharePathSaveReqVO build = SharePathSaveReqVO.builder()
 | 
	
		
			
				|  |  | -                    .ancestor(BOOS_ID)
 | 
	
		
			
				|  |  | -                    .descendant(userId)
 | 
	
		
			
				|  |  | +                    .referrerId(BOOS_ID)
 | 
	
		
			
				|  |  | +                    .userId(userId)
 | 
	
		
			
				|  |  |                      .build();
 | 
	
		
			
				|  |  |              createSharePathByUserId(build, true);
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -148,8 +150,7 @@ public class SharePathServiceImpl implements SharePathService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private Boolean hasParent(Long descendant) {
 | 
	
		
			
				|  |  |          List<SharePathDO> sharePathDO = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>()
 | 
	
		
			
				|  |  | -                .eqIfPresent(SharePathDO::getDescendant, descendant)
 | 
	
		
			
				|  |  | -                .eqIfPresent(SharePathDO::getDepth, 1));
 | 
	
		
			
				|  |  | +                .eqIfPresent(SharePathDO::getUserId, descendant));
 | 
	
		
			
				|  |  |          return !sharePathDO.isEmpty();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -193,43 +194,20 @@ public class SharePathServiceImpl implements SharePathService {
 | 
	
		
			
				|  |  |          if (userId == null) {
 | 
	
		
			
				|  |  |              userId = PT_ID;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        DuserDO sharePathDO = duserService.getDuserByUser(userId);
 | 
	
		
			
				|  |  | -        // 查询层级范围
 | 
	
		
			
				|  |  | -        List<SharePathDO> sharePathDOS = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>().eq(SharePathDO::getAncestor, userId)
 | 
	
		
			
				|  |  | -                .between(SharePathDO::getDepth, 1, maxDepth));
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        List<TreeNode> deep = sharePathDO2TreeNode(sharePathDOS);
 | 
	
		
			
				|  |  | -        if (maxDepth > 1) {
 | 
	
		
			
				|  |  | -            List<Long> descs = sharePathDOS.stream().filter(k -> k.getDepth() > 1).map(SharePathDO::getDescendant).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -            // 获取大于1层级的数据
 | 
	
		
			
				|  |  | -            if (!descs.isEmpty()) {
 | 
	
		
			
				|  |  | -                List<SharePathDO> descList = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>().ne(SharePathDO::getAncestor, 1).in(SharePathDO::getDescendant, descs));
 | 
	
		
			
				|  |  | -                List<TreeNode> treeNodes1 = sharePathDO2TreeNode(descList);
 | 
	
		
			
				|  |  | -//                deep = deep.stream().filter(k -> k.getDeep() == 1).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -                deep.addAll(treeNodes1);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        // 只需要深度等于1的数据
 | 
	
		
			
				|  |  | -        deep = deep.stream().filter(k -> k.getDeep() == 1).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        // 整合结构
 | 
	
		
			
				|  |  | -        List<TreeNode> treeNodes = listWithTree(deep, userId);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        return TreeNode.builder()
 | 
	
		
			
				|  |  | -                .phone(sharePathDO.getMobile())
 | 
	
		
			
				|  |  | -                .name(sharePathDO.getName())
 | 
	
		
			
				|  |  | -                .nickname(sharePathDO.getNickName())
 | 
	
		
			
				|  |  | -                .children(treeNodes).build();
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    @Override
 | 
	
		
			
				|  |  | -    public TreeNode getTreeByNameOrMobile(SharePathTreeReqVO sharePathTreeReqVO) {
 | 
	
		
			
				|  |  | -        //拿到当前用户ID
 | 
	
		
			
				|  |  | -        Long userId = getUserIdByNameOrMobile(sharePathTreeReqVO.getNickName(), sharePathTreeReqVO.getMobile());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //拿到推荐人ID
 | 
	
		
			
				|  |  | -        Long ancestor = sharePathMapper.selectAncestorByDescendant(userId);
 | 
	
		
			
				|  |  | -        return getTree(ancestor, sharePathTreeReqVO.getMaxDepth());
 | 
	
		
			
				|  |  | +        // 查询出第一层用户
 | 
	
		
			
				|  |  | +        List<SharePathDO> sharePathDOS = sharePathMapper.selectListByUserId(userId, maxDepth);
 | 
	
		
			
				|  |  | +        final Long userid = userId;
 | 
	
		
			
				|  |  | +        SharePathDO sharePathDO = sharePathDOS.stream()
 | 
	
		
			
				|  |  | +                .filter(k -> k.getUserId().equals(userid))
 | 
	
		
			
				|  |  | +                .findFirst().get();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 转换后的对象
 | 
	
		
			
				|  |  | +        List<TreeNode> treeNodes = sharePathDO2TreeNode(sharePathDOS);
 | 
	
		
			
				|  |  | +        treeNodes = listWithTree(treeNodes, userId);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        TreeNode bean = BeanUtils.toBean(sharePathDO, TreeNode.class);
 | 
	
		
			
				|  |  | +        bean.setChildren(treeNodes);
 | 
	
		
			
				|  |  | +        return bean;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
	
		
			
				|  | @@ -238,24 +216,29 @@ public class SharePathServiceImpl implements SharePathService {
 | 
	
		
			
				|  |  |          MemberUserRespVO memberUserRespVO = MemberUserConvert.INSTANCE.convert03(user);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          SharePathDO sharePathDO = sharePathMapper.selectOne(new LambdaQueryWrapper<SharePathDO>()
 | 
	
		
			
				|  |  | -                .eq(SharePathDO::getDescendant, userId)
 | 
	
		
			
				|  |  | -                .eq(SharePathDO::getDepth, 1)
 | 
	
		
			
				|  |  | +                .eq(SharePathDO::getUserId, userId)
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  |          if (sharePathDO != null) {
 | 
	
		
			
				|  |  | -            memberUserRespVO.setAncNickName(sharePathDO.getAncNickName());
 | 
	
		
			
				|  |  | -            memberUserRespVO.setRecommenderdId(sharePathDO.getAncestor());
 | 
	
		
			
				|  |  | +            SharePathDO referrer = sharePathMapper.selectOne(new LambdaQueryWrapper<SharePathDO>()
 | 
	
		
			
				|  |  | +                    .eq(SharePathDO::getUserId, sharePathDO.getReferrerId())
 | 
	
		
			
				|  |  | +            );
 | 
	
		
			
				|  |  | +            if (referrer != null) {
 | 
	
		
			
				|  |  | +                memberUserRespVO.setAncNickName(referrer.getUserName());
 | 
	
		
			
				|  |  | +                memberUserRespVO.setRecommenderdId(referrer.getUserId());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          DuserDO duser = duserService.getDuserByUser(memberUserRespVO.getId());
 | 
	
		
			
				|  |  |          //没有这个用户直接就返回
 | 
	
		
			
				|  |  |          if (duser == null) return memberUserRespVO;
 | 
	
		
			
				|  |  | +        memberUserRespVO.setCategoryId(duser.getCategoryId());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          IntegralDO integral = integralService.getIntegralByUserId(userId);
 | 
	
		
			
				|  |  |          if (integral != null) {
 | 
	
		
			
				|  |  | -            memberUserRespVO.setCurrentQuota(integral.getCurrentQuota());
 | 
	
		
			
				|  |  | -            OrderPercentageDO orderPercentageDO = orderPercentageService.queryStatus();
 | 
	
		
			
				|  |  | -            memberUserRespVO.setHighQuotaTotal(integral.getHighQuotaTotal() + new BigDecimal(orderPercentageDO.getBaseMaxQuota()).longValue());
 | 
	
		
			
				|  |  | -            memberUserRespVO.setConsumptionPoints(integral.getConsumptionPoints());
 | 
	
		
			
				|  |  | +            memberUserRespVO.setRedCurrentQuota(integral.getRedCurrentQuota());
 | 
	
		
			
				|  |  | +            memberUserRespVO.setYellowCurrentQuota(integral.getYellowCurrentQuota());
 | 
	
		
			
				|  |  | +            memberUserRespVO.setGreenCurrentQuota(integral.getGreenCurrentQuota());
 | 
	
		
			
				|  |  | +            memberUserRespVO.setHighQuotaTotal(integral.getHighQuotaTotal());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          SocialStatusDO socialStatus = socialStatusService.getSocialStatus(duser.getSocialStatusId());
 | 
	
	
		
			
				|  | @@ -272,77 +255,151 @@ public class SharePathServiceImpl implements SharePathService {
 | 
	
		
			
				|  |  |          // 判断当前用户是否更新推荐人
 | 
	
		
			
				|  |  |          Long ancestor = sharePathMapper.selectAncestorByDescendant(updateReqVO.getId());
 | 
	
		
			
				|  |  |          if (!Objects.equals(updateReqVO.getRecommenderdId(), ancestor)) {
 | 
	
		
			
				|  |  | -            // 如果用户为游客,将清除游客标识
 | 
	
		
			
				|  |  | -            updateReqVO.setVisitor(false);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            // 如果有更新的话,要清除原来的关系树
 | 
	
		
			
				|  |  | -            List<SharePathDO> sharePathDOS = sharePathMapper.selectList(new LambdaQueryWrapper<SharePathDO>()
 | 
	
		
			
				|  |  | -                    .eq(SharePathDO::getAncestor, updateReqVO.getId()));
 | 
	
		
			
				|  |  | -            List<SharePathDO> sharePathDOS1;
 | 
	
		
			
				|  |  | -            List<SharePathDO> children = null;
 | 
	
		
			
				|  |  | -            if (!sharePathDOS.isEmpty()) {
 | 
	
		
			
				|  |  | -                sharePathDOS1 = sharePathMapper.selectList(new LambdaQueryWrapper<SharePathDO>()
 | 
	
		
			
				|  |  | -                        .in(SharePathDO::getDescendant, sharePathDOS.stream().map(SharePathDO::getDescendant).collect(Collectors.toList())));
 | 
	
		
			
				|  |  | -                children = sharePathMapper.selectList(new LambdaQueryWrapper<SharePathDO>()
 | 
	
		
			
				|  |  | -                        .in(SharePathDO::getDescendant, sharePathDOS.stream().map(SharePathDO::getDescendant).collect(Collectors.toList()))
 | 
	
		
			
				|  |  | -                        .eq(SharePathDO::getDepth, 1));
 | 
	
		
			
				|  |  | -                // 逻辑删除旧的关系树
 | 
	
		
			
				|  |  | -                sharePathMapper.deleteBatchIds(sharePathDOS1.stream().map(SharePathDO::getId).collect(Collectors.toList()));
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            sharePathMapper.delete(new LambdaQueryWrapper<SharePathDO>()
 | 
	
		
			
				|  |  | -                    .eq(SharePathDO::getDescendant, updateReqVO.getId()));
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            // 添加新的关系树
 | 
	
		
			
				|  |  | -            createSharePathByUserId(SharePathSaveReqVO.builder().ancestor(updateReqVO.getRecommenderdId()).descendant(updateReqVO.getId()).build(), false);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            if (children != null && !children.isEmpty()) for (SharePathDO child : children) {
 | 
	
		
			
				|  |  | -                createSharePathByUserId(SharePathSaveReqVO.builder().ancestor(child.getAncestor()).descendant(child.getDescendant()).build(), false);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +            updateUserSharePath(updateReqVO.getId(), updateReqVO.getRecommenderdId());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        DuserDO duser = duserService.getDuserByUser(updateReqVO.getId());
 | 
	
		
			
				|  |  | +        if (!Objects.equals(duser.getCategoryId(), updateReqVO.getCategoryId())) {
 | 
	
		
			
				|  |  | +            duser.setCategoryId(updateReqVO.getCategoryId());
 | 
	
		
			
				|  |  | +            duserService.updateDuser(BeanUtils.toBean(duser, DuserSaveReqVO.class));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 更新
 | 
	
		
			
				|  |  |          memberUserService.updateUser(updateReqVO);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private void createSharePath(List<TreeNode> children) {
 | 
	
		
			
				|  |  | -        for (TreeNode child : children) {
 | 
	
		
			
				|  |  | -            createSharePathByUserId(SharePathSaveReqVO.builder().ancestor(child.getParentId()).descendant(child.getUserId()).build(), false);
 | 
	
		
			
				|  |  | -            if (child.getChildren() != null) {
 | 
	
		
			
				|  |  | -                createSharePath(child.getChildren());
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public PageResult<SharePathRespVO> getAreaChildren(SharePathPageReqVO pageReqVO) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        PageResult<SharePathDO> sharePathDOPageResult = new PageResult<>();
 | 
	
		
			
				|  |  | +        List<SharePathDO> sharePathDOS = sharePathMapper.selectListPage(pageReqVO.getAreaId(), pageReqVO.getPageSize(), (pageReqVO.getPageNo() - 1) * pageReqVO.getPageSize());
 | 
	
		
			
				|  |  | +        List<SharePathDO> totals = sharePathMapper.selectListByUserId(pageReqVO.getAreaId(), 99999);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        sharePathDOPageResult.setList(sharePathDOS);
 | 
	
		
			
				|  |  | +        sharePathDOPageResult.setTotal(totals == null ? 0L : totals.size());
 | 
	
		
			
				|  |  | +        PageResult<SharePathRespVO> result = BeanUtils.toBean(sharePathDOPageResult, SharePathRespVO.class);
 | 
	
		
			
				|  |  | +        List<SharePathRespVO> list = result.getList();
 | 
	
		
			
				|  |  | +        list.forEach(sharePath -> sharePath.setAvatar(memberUserService.getUser(sharePath.getUserId()).getAvatar()));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return result;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private Long getUserIdByNameOrMobile(String name, String mobile) {
 | 
	
		
			
				|  |  | -        if (!StringUtils.isEmpty(name)) {
 | 
	
		
			
				|  |  | -            List<DuserDO> duserDOS = duserService.getDuserByName(name);
 | 
	
		
			
				|  |  | -            if (duserDOS.isEmpty()) {
 | 
	
		
			
				|  |  | -                throw exception(DUSER_NAME_NOT_EXISTS);
 | 
	
		
			
				|  |  | -            } else if (duserDOS.size() > 1) {
 | 
	
		
			
				|  |  | -                throw exception(DUSER_NAME_IS_NOT_ONLY_ONE);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public List<SharePathDO> selectList() {
 | 
	
		
			
				|  |  | +        // 不算平台的
 | 
	
		
			
				|  |  | +        return sharePathMapper.selectList(new LambdaQueryWrapper<SharePathDO>().ne(SharePathDO::getUserId, 1L));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            return duserDOS.get(0).getUserId();
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public Integer getReferrerNumber(Long userId) {
 | 
	
		
			
				|  |  | +        return sharePathMapper.selectCount(new LambdaQueryWrapper<SharePathDO>().eq(SharePathDO::getReferrerId, userId)).intValue();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public List<Long> getUserIds(Long userId, Integer maxDepth) {
 | 
	
		
			
				|  |  | +        List<SharePathDO> sharePathDOS = sharePathMapper.selectListByUserId(userId, maxDepth);
 | 
	
		
			
				|  |  | +        List<Long> collect = sharePathDOS.stream().map(SharePathDO::getUserId).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        collect.remove(0);
 | 
	
		
			
				|  |  | +        return collect;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 更新用户关系网
 | 
	
		
			
				|  |  | +     * @param userId 用户id
 | 
	
		
			
				|  |  | +     * @param referrerId 推荐人id
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private void updateUserSharePath(Long userId, Long referrerId) {
 | 
	
		
			
				|  |  | +        // 获取当前用户的关系网
 | 
	
		
			
				|  |  | +        SharePathDO user = sharePathMapper.selectOne(new LambdaQueryWrapper<SharePathDO>()
 | 
	
		
			
				|  |  | +                .eq(SharePathDO::getUserId, userId));
 | 
	
		
			
				|  |  | +        // 获取上级的关系网
 | 
	
		
			
				|  |  | +        SharePathDO parent = sharePathMapper.selectOne(new LambdaQueryWrapper<SharePathDO>()
 | 
	
		
			
				|  |  | +                .eq(SharePathDO::getUserId, user.getParentId()));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 去除上级用户的分区值
 | 
	
		
			
				|  |  | +        if (parent.getLeftChildId() != null && parent.getLeftChildId().equals(user.getUserId())) {
 | 
	
		
			
				|  |  | +            parent.setLeftChildId(null);
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  | -            DuserDO duserDO = duserService.getDuserByMobile(mobile);
 | 
	
		
			
				|  |  | -            if (duserDO == null) {
 | 
	
		
			
				|  |  | -                throw exception(DUSER_MOBILE_NOT_EXISTS);
 | 
	
		
			
				|  |  | +            parent.setRightChildId(null);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        LambdaUpdateWrapper<SharePathDO> wrapper = new LambdaUpdateWrapper<SharePathDO>().eq(SharePathDO::getUserId, parent.getUserId());
 | 
	
		
			
				|  |  | +        if (parent.getLeftChildId() == null) {
 | 
	
		
			
				|  |  | +            wrapper.set(SharePathDO::getLeftChildId, null);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (parent.getRightChildId() == null) {
 | 
	
		
			
				|  |  | +            wrapper.set(SharePathDO::getRightChildId, null);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        sharePathMapper.update(parent, wrapper);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 获取推荐人的关系网
 | 
	
		
			
				|  |  | +        SharePathDO referrer = sharePathMapper.selectOne(new LambdaQueryWrapper<SharePathDO>()
 | 
	
		
			
				|  |  | +                .eq(SharePathDO::getUserId, referrerId));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 记录原来的层级
 | 
	
		
			
				|  |  | +        Integer depth = user.getDepth();
 | 
	
		
			
				|  |  | +        user.setReferrerId(referrerId);
 | 
	
		
			
				|  |  | +        user.setDepth(referrer.getDepth() + 1);
 | 
	
		
			
				|  |  | +        user.setParentId(referrerId);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (referrer.getLeftChildId() == null) {
 | 
	
		
			
				|  |  | +            referrer.setLeftChildId(userId);
 | 
	
		
			
				|  |  | +            sharePathMapper.update(referrer, new LambdaQueryWrapperX<SharePathDO>().eq(SharePathDO::getUserId, referrer.getUserId()));
 | 
	
		
			
				|  |  | +        } else if (referrer.getRightChildId() == null) {    // 判断右区是否有空位
 | 
	
		
			
				|  |  | +            referrer.setRightChildId(userId);
 | 
	
		
			
				|  |  | +            sharePathMapper.update(referrer, new LambdaQueryWrapperX<SharePathDO>().eq(SharePathDO::getUserId, referrer.getUserId()));
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            // 左区列表
 | 
	
		
			
				|  |  | +            List<SharePathDO> leftArea = sharePathMapper.selectListByUserId(referrer.getLeftChildId(), 99999);
 | 
	
		
			
				|  |  | +            // 右区列表
 | 
	
		
			
				|  |  | +            List<SharePathDO> rightArea = sharePathMapper.selectListByUserId(referrer.getRightChildId(), 99999);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            // 判断左右两区的节点数
 | 
	
		
			
				|  |  | +            List<SharePathDO> list = leftArea.size() <= rightArea.size() ? leftArea : rightArea;
 | 
	
		
			
				|  |  | +            for (SharePathDO sharePathDO : list) {
 | 
	
		
			
				|  |  | +                if (sharePathDO.getLeftChildId() == null) {
 | 
	
		
			
				|  |  | +                    user.setDepth(sharePathDO.getDepth() + 1);
 | 
	
		
			
				|  |  | +                    user.setParentId(sharePathDO.getUserId());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    sharePathDO.setLeftChildId(userId);
 | 
	
		
			
				|  |  | +                    sharePathMapper.update(sharePathDO, new LambdaQueryWrapperX<SharePathDO>().eq(SharePathDO::getUserId, sharePathDO.getUserId()));
 | 
	
		
			
				|  |  | +                    break;
 | 
	
		
			
				|  |  | +                } else if (sharePathDO.getRightChildId() == null) {
 | 
	
		
			
				|  |  | +                    user.setDepth(sharePathDO.getDepth() + 1);
 | 
	
		
			
				|  |  | +                    user.setParentId(sharePathDO.getUserId());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    sharePathDO.setRightChildId(userId);
 | 
	
		
			
				|  |  | +                    sharePathMapper.update(sharePathDO, new LambdaQueryWrapperX<SharePathDO>().eq(SharePathDO::getUserId, sharePathDO.getUserId()));
 | 
	
		
			
				|  |  | +                    break;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            return duserDO.getUserId();
 | 
	
		
			
				|  |  | +            sharePathMapper.updateById(user);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        // 用户的关系网
 | 
	
		
			
				|  |  | +        List<SharePathDO> userArea = sharePathMapper.selectListByUserId(userId, 99999);
 | 
	
		
			
				|  |  | +        depth -= user.getDepth();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 遍历修改层级
 | 
	
		
			
				|  |  | +        for (SharePathDO sharePathDO : userArea) {
 | 
	
		
			
				|  |  | +            if (sharePathDO.getUserId().equals(userId)) {
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            sharePathDO.setDepth(sharePathDO.getDepth() - depth);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        sharePathMapper.updateBatch(userArea);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public List<TreeNode> sharePathDO2TreeNode(List<SharePathDO> sharePathDOS) {
 | 
	
		
			
				|  |  |          return sharePathDOS.stream().map(k -> TreeNode.builder()
 | 
	
		
			
				|  |  | -                .phone(k.getDescPhone())
 | 
	
		
			
				|  |  | -                .name(k.getDescName())
 | 
	
		
			
				|  |  | -                .deep(k.getDepth())
 | 
	
		
			
				|  |  | -                .parentId(k.getAncestor())
 | 
	
		
			
				|  |  | -                .userId(k.getDescendant())
 | 
	
		
			
				|  |  | -                .sort(k.getSort())
 | 
	
		
			
				|  |  | -                .nickname(k.getDescNickName()).build()).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +                .phone(k.getPhone())
 | 
	
		
			
				|  |  | +                .userName(k.getUserName())
 | 
	
		
			
				|  |  | +                .depth(k.getDepth())
 | 
	
		
			
				|  |  | +                .parentId(k.getParentId())
 | 
	
		
			
				|  |  | +                .userId(k.getUserId())
 | 
	
		
			
				|  |  | +                .referrerId(k.getReferrerId())
 | 
	
		
			
				|  |  | +                .leftChildId(k.getLeftChildId())
 | 
	
		
			
				|  |  | +                .rightChildId(k.getRightChildId()).build()).collect(Collectors.toList());
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -372,21 +429,13 @@ public class SharePathServiceImpl implements SharePathService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public SharePathDO getSharePathByDescendant(Long userId) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        List<SharePathDO> sharePathDOS = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>().eqIfPresent(SharePathDO::getDescendant, userId)
 | 
	
		
			
				|  |  | -                .eqIfPresent(SharePathDO::getDepth, 1));
 | 
	
		
			
				|  |  | -        if (sharePathDOS.isEmpty()) {
 | 
	
		
			
				|  |  | -            return null;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        return sharePathDOS.get(0);
 | 
	
		
			
				|  |  | +        return sharePathMapper.selectOne(new LambdaQueryWrapperX<SharePathDO>().eq(SharePathDO::getUserId, userId));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public List<OrderCalcDO> selectSons(Long userId, List<Long> userIds) {
 | 
	
		
			
				|  |  | -        List<SharePathDO> sharePathDOS = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>()
 | 
	
		
			
				|  |  | -                .eq(SharePathDO::getAncestor, userId));
 | 
	
		
			
				|  |  | -        List<Long> allDescendants = sharePathDOS.stream().map(SharePathDO::getDescendant).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -//        List<Long> allDescendants = sharePathMapper.findAllDescendants(userId);
 | 
	
		
			
				|  |  | +    public List<OrderCalcDO> selectArea(Long userId, List<Long> userIds) {
 | 
	
		
			
				|  |  | +        List<SharePathDO> sharePathDOS = sharePathMapper.selectListByUserId(userId, 99999);
 | 
	
		
			
				|  |  | +        List<Long> allDescendants = sharePathDOS.stream().map(SharePathDO::getUserId).collect(Collectors.toList());
 | 
	
		
			
				|  |  |          if (allDescendants.isEmpty()) {
 | 
	
		
			
				|  |  |              return Collections.emptyList();
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -411,88 +460,15 @@ public class SharePathServiceImpl implements SharePathService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    @Override
 | 
	
		
			
				|  |  | -    public List<OrderCalcDO> selectBrothers(Long userId, List<Long> userIds, MemberUserDO user) {
 | 
	
		
			
				|  |  | -        List<Long> sortedSiblings = new ArrayList<>();
 | 
	
		
			
				|  |  | -        // 先查询出他的父亲
 | 
	
		
			
				|  |  | -        List<SharePathDO> sharePathDO = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>().eq(SharePathDO::getDepth, 1).eq(SharePathDO::getDescendant, userId));
 | 
	
		
			
				|  |  | -        if (sharePathDO.isEmpty()) {
 | 
	
		
			
				|  |  | -            sortedSiblings = sharePathMapper.findLessSortedSiblings(userId);
 | 
	
		
			
				|  |  | -        } else {
 | 
	
		
			
				|  |  | -            // 再根据父亲查询他的所有儿子
 | 
	
		
			
				|  |  | -//            List<SharePathDO> sharePathDOS = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>()
 | 
	
		
			
				|  |  | -//                    .eq(SharePathDO::getDepth, 1)
 | 
	
		
			
				|  |  | -//                    .eq(SharePathDO::getAncestor, sharePathDO.get(0).getAncestor()));
 | 
	
		
			
				|  |  | -            // 后续加了游客身份所以,查询的时候要隔离游客的兄弟分区和用户的兄弟分区
 | 
	
		
			
				|  |  | -            List<SharePathDO> sharePathDOS = sharePathMapper.selectListByVisitor(sharePathDO.get(0).getAncestor(), user.getVisitor());
 | 
	
		
			
				|  |  | -            //最后再进行排序
 | 
	
		
			
				|  |  | -            sortedSiblings = filterByDescendant(sharePathDOS, userId);
 | 
	
		
			
				|  |  | -            // 查询兄弟的所有儿子
 | 
	
		
			
				|  |  | -            sortedSiblings.addAll(findSons(sortedSiblings));
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        if (sortedSiblings.isEmpty()) {
 | 
	
		
			
				|  |  | -            return Collections.emptyList();
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        // 查询出两个list的并集
 | 
	
		
			
				|  |  | -        List<Long> unionList = unionList(userIds, sortedSiblings);
 | 
	
		
			
				|  |  | -        if (unionList.isEmpty()) {
 | 
	
		
			
				|  |  | -            return Collections.emptyList();
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        // 获取这个分区的所有订单的合赢奖
 | 
	
		
			
				|  |  | -        return calcQuota(unionList);
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    private List<Long> findSons(List<Long> sortedSiblings) {
 | 
	
		
			
				|  |  | -        List<Long> longs = new ArrayList<>();
 | 
	
		
			
				|  |  | -        for (Long sortedSibling : sortedSiblings) {
 | 
	
		
			
				|  |  | -            List<SharePathDO> sharePathDOS = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>()
 | 
	
		
			
				|  |  | -                    .eq(SharePathDO::getAncestor, sortedSibling));
 | 
	
		
			
				|  |  | -            if (sharePathDOS.isEmpty()) {
 | 
	
		
			
				|  |  | -                continue;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            List<Long> collect = sharePathDOS.stream().map(SharePathDO::getDescendant).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -            longs.addAll(collect);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        return longs.stream().distinct().collect(Collectors.toList());
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    public List<Long> filterByDescendant(List<SharePathDO> sharePaths, Long descendantId) {
 | 
	
		
			
				|  |  | -        // 首先,找到特定 descendantId 的 sort 值
 | 
	
		
			
				|  |  | -        SharePathDO reference = sharePaths.stream()
 | 
	
		
			
				|  |  | -                .filter(sharePath -> sharePath.getDescendant().equals(descendantId))
 | 
	
		
			
				|  |  | -                .findFirst()
 | 
	
		
			
				|  |  | -                .orElse(null);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        if (reference == null) {
 | 
	
		
			
				|  |  | -            throw new IllegalArgumentException("Descendant with ID " + descendantId + " not found");
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        // 过滤出所有 sort 值大于找到的 sort 值的记录
 | 
	
		
			
				|  |  | -        return sharePaths.stream()
 | 
	
		
			
				|  |  | -                .filter(sharePath ->
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            if (reference.getSort() != null && sharePath.getSort() != null) {
 | 
	
		
			
				|  |  | -                                return sharePath.getSort() > reference.getSort();
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                            return false;
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                )
 | 
	
		
			
				|  |  | -                .map(SharePathDO::getDescendant)
 | 
	
		
			
				|  |  | -                .collect(Collectors.toList());
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public Long queryParentBySonUserId(Long userId) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        List<SharePathDO> sharePathDO = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>()
 | 
	
		
			
				|  |  | -                .eqIfPresent(SharePathDO::getDescendant, userId).eqIfPresent(SharePathDO::getDepth, 1));
 | 
	
		
			
				|  |  | -        if (sharePathDO.isEmpty()) {
 | 
	
		
			
				|  |  | +        SharePathDO sharePathDO = sharePathMapper.selectOne(new LambdaQueryWrapperX<SharePathDO>()
 | 
	
		
			
				|  |  | +                .eqIfPresent(SharePathDO::getUserId, userId));
 | 
	
		
			
				|  |  | +        if (sharePathDO == null) {
 | 
	
		
			
				|  |  |              return 1L;
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  | -            return sharePathDO.get(0).getAncestor();
 | 
	
		
			
				|  |  | +            return sharePathDO.getParentId();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -502,9 +478,9 @@ public class SharePathServiceImpl implements SharePathService {
 | 
	
		
			
				|  |  |      public List<DuserDO> selectSon(Long userId) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 查询当前用户的所有后代
 | 
	
		
			
				|  |  | -        List<SharePathDO> sharePathDOS = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>().eqIfPresent(SharePathDO::getAncestor, userId));
 | 
	
		
			
				|  |  | +        List<SharePathDO> sharePathDOS = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>().eqIfPresent(SharePathDO::getReferrerId, userId));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        List<Long> duserId = sharePathDOS.stream().map(SharePathDO::getDescendant).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        List<Long> duserId = sharePathDOS.stream().map(SharePathDO::getUserId).collect(Collectors.toList());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if (duserId.isEmpty()) {
 | 
	
		
			
				|  |  |              return Collections.emptyList();
 | 
	
	
		
			
				|  | @@ -516,8 +492,8 @@ public class SharePathServiceImpl implements SharePathService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public List<Long> sonsId(Long userId) {
 | 
	
		
			
				|  |  | -        List<SharePathDO> sharePathDOS = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>().eq(SharePathDO::getAncestor, userId));
 | 
	
		
			
				|  |  | -        return sharePathDOS.stream().map(SharePathDO::getDescendant).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        List<SharePathDO> sharePathDOS = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>().eq(SharePathDO::getReferrerId, userId));
 | 
	
		
			
				|  |  | +        return sharePathDOS.stream().map(SharePathDO::getUserId).collect(Collectors.toList());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -533,18 +509,11 @@ public class SharePathServiceImpl implements SharePathService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public PageResult<SharePathRespVO> getDescendants(SharePathPageReqVO pageReqVO) {
 | 
	
		
			
				|  |  | -        LambdaQueryWrapperX<SharePathDO> wrapper = new LambdaQueryWrapperX<SharePathDO>()
 | 
	
		
			
				|  |  | -                .eq(SharePathDO::getAncestor, pageReqVO.getAncestor());
 | 
	
		
			
				|  |  | -        if (pageReqVO.getDepth() != null) {
 | 
	
		
			
				|  |  | -            wrapper.eq(SharePathDO::getDepth, 1);
 | 
	
		
			
				|  |  | -        } else {
 | 
	
		
			
				|  |  | -            wrapper.ne(SharePathDO::getDepth, 1);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          PageResult<SharePathDO> sharePathDOPageResult = sharePathMapper.selectDescendantsPage(pageReqVO);
 | 
	
		
			
				|  |  |          PageResult<SharePathRespVO> result = BeanUtils.toBean(sharePathDOPageResult, SharePathRespVO.class);
 | 
	
		
			
				|  |  |          List<SharePathRespVO> list = result.getList();
 | 
	
		
			
				|  |  | -        list.forEach(sharePath -> sharePath.setAvatar(memberUserService.getUser(sharePath.getDescendant()).getAvatar()));
 | 
	
		
			
				|  |  | +        list.forEach(sharePath -> sharePath.setAvatar(memberUserService.getUser(sharePath.getUserId()).getAvatar()));
 | 
	
		
			
				|  |  |          return result;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 |