From 8acc98732aba58ad5c710f92d72e6fa5bf888d11 Mon Sep 17 00:00:00 2001
From: luofl <1442745593@qq.com>
Date: 星期一, 24 二月 2025 01:08:06 +0800
Subject: [PATCH] 修改物流信息导入模板

---
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java |   80 +++++++++++++++++++++++++++++++--------
 1 files changed, 63 insertions(+), 17 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 7f61832..05a8184 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
@@ -276,14 +276,30 @@
         Long userId = tokenService.getLoginUserApplet().getUserid();
         //获取绑定门店
         AppUser user = appUserService.getById(userId);
-        if (user.getShopId() != null) {
-            R<Shop> storeById = storeClient.getStoreById(user.getShopId());
-            if (storeById.getData() != null) {
-                user.setShopName(storeById.getData().getName());
-                user.setShopCover(storeById.getData().getHomePicture());
-                user.setShopAddress(storeById.getData().getAddress());
+
+
+        //当前用户的推荐人信息(指导老师)
+        List<AppUser> allSuperiors = getAllSuperiors(userId);
+        //当前绑定门店的店铺信息
+        for (AppUser allSuperior : allSuperiors) {
+            List<Shop> shopList = shopClient.getShopByUserId(allSuperior.getId()).getData();
+            if (!CollectionUtils.isEmpty(shopList)){
+                user.setShopName(shopList.get(0).getName());
+                user.setShopCover(shopList.get(0).getHomePicture());
+                user.setShopAddress(shopList.get(0).getAddress());
+                break;
             }
         }
+
+        //指导老师
+        allSuperiors.stream()
+                .filter(superiors -> superiors.getVipId() != null && superiors.getVipId() > 3)
+                .findFirst()
+                .ifPresent(superiors -> {
+                    user.setTeacher(superiors.getName());
+                });
+
+
 
         //获取绑定上级
         if (user.getInviteUserId() != null) {
@@ -456,19 +472,29 @@
             appUserService.updateById(user);
         }
         
-        //当前用户的推荐人信息
-        if (user.getInviteUserId() != null) {
-            AppUser inviteUser = appUserService.getById(user.getInviteUserId());
-            user.setInviteUserName(inviteUser.getName());
-        }
-        //当前绑定门店的店铺信息
-        if (user.getShopId() != null) {
-            R<Shop> storeById = shopClient.getShopById(user.getShopId());
-            if (storeById.getData() != null) {
-                Shop shop = storeById.getData();
-                user.setShopName(shop.getName());
+        //指导老师
+        List<AppUser> allSuperiors = getAllSuperiors(userId);
+        allSuperiors.stream()
+                .filter(superiors -> superiors.getVipId() != null && superiors.getVipId() > 3)
+                .findFirst()
+                .ifPresent(superiors -> {
+                    user.setTeacher(superiors.getName());
+                });
+        //当前绑定门店的店铺信息(服务商)
+        for (AppUser allSuperior : allSuperiors) {
+            List<Shop> shopList = shopClient.getShopByUserId(allSuperior.getId()).getData();
+            if (!CollectionUtils.isEmpty(shopList)){
+                user.setShopName(shopList.get(0).getName());
+                break;
             }
         }
+//        if (user.getShopId() != null) {
+//            R<Shop> storeById = shopClient.getShopById(user.getShopId());
+//            if (storeById.getData() != null) {
+//                Shop shop = storeById.getData();
+//                user.setShopName(shop.getName());
+//            }
+//        }
         ArrayList<Long> userIds = new ArrayList<>();
         userIds.add(userId);
         // 获取当前用户的所有下级
@@ -517,6 +543,25 @@
         }
         return R.ok(user);
     }
+
+
+    public List<AppUser> getAllSuperiors(Long userId) {
+        List<AppUser> allSuperiors = new ArrayList<>();
+
+        // 获取当前用户的直接上级
+        AppUser currentUser = appUserService.getById(userId);
+        if (currentUser != null && currentUser.getInviteUserId() != null) {
+            AppUser superior = appUserService.getById(currentUser.getInviteUserId());
+            if (superior != null) {
+                allSuperiors.add(superior); // 添加直接上级
+                allSuperiors.addAll(getAllSuperiors(superior.getId())); // 递归添加上级的上级
+            }
+        }
+
+        return allSuperiors;
+    }
+
+
     
     // 递归获取指定用户的所有下级
     public List<AppUser> getAllSubordinates(Long userId) {
@@ -1280,5 +1325,6 @@
                 .set(AppUser::getUserType,1));
         return R.ok();
     }
+
 }
 

--
Gitblit v1.7.1