Browse Source

获取群主列表

houxiaohua 2 months ago
parent
commit
ce315172ca
1 changed files with 40 additions and 1 deletions
  1. 40 1
      app/Service/ChatGroup/ChatGroupService.php

+ 40 - 1
app/Service/ChatGroup/ChatGroupService.php

@@ -262,7 +262,46 @@ class ChatGroupService
262 262
      * */
263 263
     public static function ownerListOfCompany($userName, $sysGroupId)
264 264
     {
265
-        return [];
265
+        try {
266
+            # 获取公司账号下绑定的企微
267
+            $corpIds = AdminManageCorp::where('sys_user_id', $sysGroupId)->where('is_delete', 0)->pluck('corpid');
268
+            $accountList = AuthorizeCorp::select('corpid', 'corp_name')->where('enable', 1)
269
+                ->whereIn('id', $corpIds)->get();
270
+
271
+            if(empty($accountList)) return [];
272
+
273
+            $corpidList = $accountList->pluck('corpid');
274
+            $ownerList = ChatGroup::select('corpid', 'owner')->whereIn('corpid', $corpidList)->where('status', 1)->get();
275
+
276
+            $data = [];
277
+            foreach ($accountList as $account) {
278
+                $corpid = $account->corpid;
279
+                $corpName = $account->corp_name;
280
+
281
+                # 整理数据
282
+                $userIdList = $ownerList->where('corpid', $corpid)->pluck('owner');
283
+                $userList = DjUser::select(['user_id', 'name', 'avatar', 'status', 'is_active'])
284
+                    ->where('corpid', $corpid)->where('enable', 1)->where('status', 1)
285
+                    ->whereIn('user_id', $userIdList)
286
+                    ->get();
287
+
288
+                $data[] = [
289
+                    'corpid' => $corpid,
290
+                    'corp_name' => $corpName,
291
+                    'user_list' => $userList
292
+                ];
293
+            }
294
+        } catch (\Exception $e) {
295
+            Log::logError('获取账号下各企微的群主列表出现异常', [
296
+                'line' => $e->getLine(),
297
+                'msg' => $e->getTraceAsString()
298
+            ], 'ownerListOfCompany');
299
+
300
+            return [];
301
+        }
302
+
303
+
304
+        return $data;
266 305
     }
267 306
 
268 307
     public static function ownerIndex($corpid, $userName)