|
@@ -7,6 +7,7 @@ import cn.newfeifan.mall.module.distri.service.duser.DuserService;
|
|
|
import cn.newfeifan.mall.module.distri.service.ordercalc.OrderCalcService;
|
|
|
import cn.newfeifan.mall.module.member.dal.dataobject.user.MemberUserDO;
|
|
|
import cn.newfeifan.mall.module.member.service.user.MemberUserService;
|
|
|
+import com.aliyuncs.utils.StringUtils;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -189,8 +190,31 @@ public class SharePathServiceImpl implements SharePathService {
|
|
|
|
|
|
@Override
|
|
|
public TreeNode getTreeByNameOrMobile(SharePathTreeReqVO sharePathTreeReqVO) {
|
|
|
-// duserService.getDuserByName(sharePathTreeReqVO.getName());
|
|
|
- return null;
|
|
|
+ //拿到当前用户ID
|
|
|
+ Long userId = getUserIdByNameOrMobile(sharePathTreeReqVO.getName(), sharePathTreeReqVO.getMobile());
|
|
|
+
|
|
|
+ //拿到推荐人ID
|
|
|
+ Long ancestor = sharePathMapper.selectAncestorByDescendant(userId);
|
|
|
+ return getTree(ancestor, sharePathTreeReqVO.getMaxDepth());
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ return duserDOS.get(0).getUserId();
|
|
|
+ }else{
|
|
|
+ DuserDO duserDO = duserService.getDuserByMobile(mobile);
|
|
|
+ if (duserDO == null) {
|
|
|
+ throw exception(DUSER_MOBILE_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ return duserDO.getUserId();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -325,13 +349,14 @@ public class SharePathServiceImpl implements SharePathService {
|
|
|
return Stream.concat(orderUserId.stream(), userId.stream()).distinct().collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public PageResult<SharePathRespVO> getDescendants(SharePathPageReqVO pageReqVO) {
|
|
|
LambdaQueryWrapperX<SharePathDO> wrapper = new LambdaQueryWrapperX<SharePathDO>()
|
|
|
.eq(SharePathDO::getAncestor, pageReqVO.getAncestor());
|
|
|
- if(pageReqVO.getDepth() != null){
|
|
|
+ if (pageReqVO.getDepth() != null) {
|
|
|
wrapper.eq(SharePathDO::getDepth, 1);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
wrapper.ne(SharePathDO::getDepth, 1);
|
|
|
}
|
|
|
|
|
@@ -345,6 +370,4 @@ public class SharePathServiceImpl implements SharePathService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|