Pārlūkot izejas kodu

添加营销模块用户关系列表

Yangzw 1 gadu atpakaļ
vecāks
revīzija
0eee5ad07b

+ 0 - 9
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/duser/DuserController.java

@@ -73,15 +73,6 @@ public class DuserController {
         return success(BeanUtils.toBean(duser, DuserRespVO.class));
     }
 
-    @GetMapping("/getDescendants")
-    @Operation(summary = "通过推荐人获得直推人")
-    @Parameter(name = "userId", description = "编号", required = true, example = "1024")
-    @Parameter(name = "depth", description = "层次", required = true, example = "1")
-    @PreAuthorize("@ss.hasPermission('distri:duser:query')")
-    public CommonResult<List<MemberUserRespVO>> getDescendants(@RequestParam("userId") Long userId, Long depth) {
-        List<MemberUserDO> descendants = duserService.getDescendants(userId, depth);
-        return success(BeanUtils.toBean(descendants, MemberUserRespVO.class));
-    }
 
     @GetMapping("/page")
     @Operation(summary = "获得推荐用户分页")

+ 0 - 3
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/duser/vo/DuserRespVO.java

@@ -62,7 +62,4 @@ public class DuserRespVO {
     @Schema(description = "后代总数")
     private Long childrenCount;
 
-    @Schema(description = "用户头像")
-    private String avatar;
-
 }

+ 10 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/sharepath/SharePathController.java

@@ -1,6 +1,8 @@
 package cn.newfeifan.mall.module.distri.controller.admin.sharepath;
 
 import cn.newfeifan.mall.module.distri.dal.dataobject.duser.DuserDO;
+import cn.newfeifan.mall.module.member.controller.admin.user.vo.MemberUserRespVO;
+import cn.newfeifan.mall.module.member.dal.dataobject.user.MemberUserDO;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -88,6 +90,14 @@ public class SharePathController {
         return success(BeanUtils.toBean(sharePath, SharePathRespVO.class));
     }
 
+    @GetMapping("/getDescendants")
+    @Operation(summary = "通过推荐人获得直推人")
+    @PreAuthorize("@ss.hasPermission('distri:duser:query')")
+    public CommonResult<PageResult<SharePathRespVO>> getDescendants(@Valid SharePathPageReqVO pageReqVO) {
+        PageResult<SharePathRespVO> descendants = sharePathService.getDescendants(pageReqVO);
+        return success(descendants);
+    }
+
     @GetMapping("/page")
     @Operation(summary = "获得分销用户关系分页")
     @PreAuthorize("@ss.hasPermission('distri:share-path:query')")

+ 3 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/sharepath/vo/SharePathRespVO.java

@@ -61,4 +61,7 @@ public class SharePathRespVO {
     @Schema(description = "直推人昵称", example = "张三")
     @ExcelProperty("直推人昵称")
     private String descNickName;
+
+    @Schema(description = "用户头像")
+    private String avatar;
 }

+ 11 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/sharepath/SharePathMapper.java

@@ -33,6 +33,17 @@ public interface SharePathMapper extends BaseMapperX<SharePathDO> {
                 .likeIfPresent(SharePathDO::getDescNickName, reqVO.getDescNickName())
                 .orderByDesc(SharePathDO::getId));
     }
+    default PageResult<SharePathDO> selectDescendantsPage(SharePathPageReqVO reqVO) {
+        LambdaQueryWrapperX<SharePathDO> queryWrapper = new LambdaQueryWrapperX<SharePathDO>()
+                .eqIfPresent(SharePathDO::getAncestor, reqVO.getAncestor());
+        if(reqVO.getDepth() != null){
+            queryWrapper.eq(SharePathDO::getDepth, 1);
+            queryWrapper.orderByAsc(SharePathDO::getSort);
+        }else {
+            queryWrapper.ne(SharePathDO::getDepth, 1);
+        }
+        return selectPage(reqVO, queryWrapper);
+    }
 
     void addNode(@Param("parentId") Long parentId,
                  @Param("parentName") String parentName,

+ 1 - 1
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/duser/DuserService.java

@@ -82,5 +82,5 @@ public interface DuserService {
      */
     DuserInfoVO getDuserInfo(Long userId);
 
-    List<MemberUserDO> getDescendants(Long userId, Long depth);
+    DuserDO getDuserByUserId(Long userId);
 }

+ 7 - 19
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/duser/DuserServiceImpl.java

@@ -158,6 +158,13 @@ public class DuserServiceImpl implements DuserService {
 
     }
 
+    @Override
+    public DuserDO getDuserByUserId(Long userId) {
+        return duserMapper.selectOne(new LambdaQueryWrapper<DuserDO>()
+                .eq(DuserDO::getUserId,userId)
+        );
+    }
+
     private void checkAndCreat(Long userId) {
         DuserDO duserDO = duserMapper.selectOne(new LambdaQueryWrapperX<DuserDO>().eqIfPresent(DuserDO::getUserId, userId));
         MemberUserDO user = memberUserService.getUser(userId);
@@ -206,23 +213,4 @@ public class DuserServiceImpl implements DuserService {
             ));
         }
     }
-
-    @Override
-    public List<MemberUserDO> getDescendants(Long userId, Long depth) {
-        LambdaQueryWrapperX<SharePathDO> wrapper = new LambdaQueryWrapperX<SharePathDO>()
-                .eq(SharePathDO::getAncestor, userId);
-        if(depth != null){
-            wrapper.eq(SharePathDO::getDepth, 1);
-        }else {
-            wrapper.ne(SharePathDO::getDepth, 1);
-        }
-        List<SharePathDO> sharePathDOS = sharePathMapper.selectList(wrapper);
-        List<Long> userIds = sharePathDOS.stream().map(SharePathDO::getDescendant).collect(Collectors.toList());
-
-
-        return memberUserMapper.selectList(new LambdaQueryWrapper<MemberUserDO>()
-                .in(MemberUserDO::getId, userIds)
-        );
-    }
-
 }

+ 3 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/sharepath/SharePathService.java

@@ -3,6 +3,8 @@ package cn.newfeifan.mall.module.distri.service.sharepath;
 import java.util.*;
 import javax.validation.*;
 
+import cn.newfeifan.mall.module.distri.controller.admin.duser.vo.DuserPageReqVO;
+import cn.newfeifan.mall.module.distri.controller.admin.duser.vo.DuserRespVO;
 import cn.newfeifan.mall.module.distri.controller.admin.sharepath.vo.*;
 import cn.newfeifan.mall.module.distri.dal.dataobject.duser.DuserDO;
 import cn.newfeifan.mall.module.distri.dal.dataobject.ordercalc.OrderCalcDO;
@@ -100,4 +102,5 @@ public interface SharePathService {
 
     List<Long> sonsId(Long userId);
 
+    PageResult<SharePathRespVO> getDescendants(SharePathPageReqVO pageReqVO);
 }

+ 23 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/sharepath/SharePathServiceImpl.java

@@ -1,12 +1,15 @@
 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.DuserPageReqVO;
+import cn.newfeifan.mall.module.distri.controller.admin.duser.vo.DuserRespVO;
 import cn.newfeifan.mall.module.distri.dal.dataobject.duser.DuserDO;
 import cn.newfeifan.mall.module.distri.dal.dataobject.ordercalc.OrderCalcDO;
 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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
@@ -269,6 +272,26 @@ 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){
+            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());
+        });
+        return result;
+    }
+
+
 
 
 }