|
|
@@ -64,4 +64,78 @@ class GameGroupLogic extends BaseLogic
|
|
|
|
|
|
return (new GameLogic())->gameMainTree($pfCame);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取游戏根据部门ID, 返回根据分组后的游戏列表
|
|
|
+ */
|
|
|
+ public function getGameListOptionsByDeptId($where): array
|
|
|
+ {
|
|
|
+ $deptId = $where['dept_id'];
|
|
|
+ // 1. 根据部门ID获取游戏列表
|
|
|
+ $deptGameList = Db::connect('db_system')
|
|
|
+ ->table('sa_system_dept')
|
|
|
+ ->field('game_list')
|
|
|
+ ->where('id', $deptId)
|
|
|
+ ->select()->toArray();
|
|
|
+ $deptGameList = $deptGameList[0]['game_list'];
|
|
|
+
|
|
|
+
|
|
|
+ // 2. 所有游戏信息列表
|
|
|
+ $pfGameList = Db::connect('db_center')
|
|
|
+ ->table('pf_game')
|
|
|
+ ->field('id,name')
|
|
|
+ ->select()->toArray();
|
|
|
+ $pfGameList = array_column($pfGameList, null, 'id');
|
|
|
+
|
|
|
+ // 3. 分组列表
|
|
|
+ $groupList = Db::connect('db_center')
|
|
|
+ ->table('game_group')
|
|
|
+ ->select()->toArray();
|
|
|
+
|
|
|
+ if(!empty($deptGameList)){
|
|
|
+ // 返回分组所有游戏
|
|
|
+ if($deptGameList == '*'){
|
|
|
+ foreach($groupList as &$group){
|
|
|
+ $group['id'] = 'group_'.$group['id'];
|
|
|
+ $gameList = explode(',', $group['game_list']);
|
|
|
+ foreach($gameList as $gameId){
|
|
|
+ $group['children'][] = [
|
|
|
+ 'id' => $pfGameList[$gameId]['id'],
|
|
|
+ 'name' => '['.$pfGameList[$gameId]['id'].']'.$pfGameList[$gameId]['name']
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $gameList = $groupList;
|
|
|
+ }else{
|
|
|
+ // 根据权限 4,5,7
|
|
|
+ // $deptGameList = 4,5,7
|
|
|
+ // $group['game_list'] 取交集
|
|
|
+ $deptGameList = explode(',', $deptGameList);
|
|
|
+ foreach($groupList as &$group){
|
|
|
+ $group['id'] = 'group_'.$group['id'];
|
|
|
+ $gameList = explode(',', $group['game_list']);
|
|
|
+ $group['game_list'] = array_intersect($deptGameList, $gameList);
|
|
|
+ foreach($group['game_list'] as $gameId){
|
|
|
+ $group['children'][] = [
|
|
|
+ 'id' => $pfGameList[$gameId]['id'],
|
|
|
+ 'name' => '['.$pfGameList[$gameId]['id'].']'.$pfGameList[$gameId]['name']
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ $groupList = array_filter($groupList, function($group){
|
|
|
+ return !empty($group['game_list']);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ $gameList = $groupList;
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $gameList = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ return $gameList;
|
|
|
+ }
|
|
|
}
|