Pu Zhibing
2025-03-25 d3e9a09cb54017a8063e5bfe3ace5012f66f3130
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -576,8 +576,40 @@
    }
    /**
     * 获取门店作为服务商的所有用户
     * @param shopId
     * @return
     */
    public Set<Long> getShopServerUser(Integer shopId){
        Shop shop = shopClient.getShopById(shopId).getData();
        List<Shop> shopList = shopClient.getAllShop().getData();
        List<Long> appUserIds = shopList.stream().map(Shop::getAppUserId).collect(Collectors.toList());
        Long appUserId = shop.getAppUserId();
        //所有未开店的用户
        List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0)
                .ne(AppUser::getStatus, 3).notIn(AppUser::getId, appUserIds));
        Set<Long> ids = new HashSet<>();
        getShopServerUser(appUserId, list, ids);
        return ids;
    }
    public void getShopServerUser(Long appUserId, List<AppUser> appUserList, Set<Long> ids){
        List<AppUser> collect = appUserList.stream().filter(s->s.getInviteUserId().equals(appUserId)).collect(Collectors.toList());
        if(collect.size() == 0){
            return;
        }
        Set<Long> appUserSet = collect.stream().map(AppUser::getId).collect(Collectors.toSet());
        if(ids.containsAll(appUserSet)){
            return;
        }
        ids.addAll(appUserSet);
        for (AppUser appUser : collect) {
            getShopServerUser(appUser.getId(), appUserList, ids);
        }
    }
@@ -683,6 +715,9 @@
            Integer shopId = data.getObjectId();
            List<Order> orders = orderClient.getRedeemedOrdersByShop(shopId).getData();
            List<Long> userIds = orders.stream().map(Order::getAppUserId).collect(Collectors.toList());
            //门店作为服务商的用户
            Set<Long> shopServerUser = getShopServerUser(shopId);
            userIds.addAll(shopServerUser);
            queryWrapper.in(!CollectionUtils.isEmpty(userIds), "id", userIds)
                    .like(StringUtils.isNotEmpty( appUser.getName()),"name", appUser.getName());
        }
@@ -785,8 +820,10 @@
            for (Order datum : listR.getData()) {
                userIds.add(datum.getAppUserId());
            }
            Set<Long> shopServerUser = getShopServerUser(objectId);
            userIds.addAll(shopServerUser);
        }
        IPage<AppUser> appuserPage = appUserService.getAppuserPage1(pageCurr, pageSize, appUser, objectId, userIds);
        IPage<AppUser> appuserPage = appUserService.getAppuserPage1(pageCurr, pageSize, appUser, userIds);
        return R.ok(appuserPage);
    }
@@ -1179,12 +1216,15 @@
            shopId = data.getObjectId();
            if(null == userId){
                userIds = orderClient.getAppUserByShoppingShop(shopId).getData();
                Set<Long> shopServerUser = getShopServerUser(shopId);
                userIds.addAll(shopServerUser);
            }else{
                userIds = new HashSet<>();
                userIds.add(userId);
            }
        }
        UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(shopId, userIds);
        UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(null, userIds);
        return R.ok(userStatisticsDetail);
    }