Переглянути джерело

自然量游戏权限设置

ith5 5 місяців тому
батько
коміт
0fe16794cd

+ 13 - 0
app/v1/controller/CommonController.php

@@ -68,6 +68,8 @@ class CommonController extends BaseController
         return $this->success($data);
     }
 
+
+
     /**
      * 获取子游戏options列表(有权限)
      * @return Response
@@ -268,5 +270,16 @@ class CommonController extends BaseController
         return $this->success($data);
     }
 
+    /**
+     * 获取游戏根据部门ID, 返回根据分组后的游戏列表
+     */
+    public function getGameListOptionsByDeptId(Request $request): Response
+    {
+        $where = $request->more([
+            ['dept_id', '']
+        ]);
+        $data = $this->gameGroupLogic->getGameListOptionsByDeptId($where);
+        return $this->success($data);
+    }
 
 }

+ 74 - 0
app/v1/logic/center/GameGroupLogic.php

@@ -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;
+    }
 }

+ 1 - 0
app/v1/logic/dataReport/ChannelAnalysisLogic.php

@@ -33,6 +33,7 @@ class ChannelAnalysisLogic extends BaseLogic
         $group = 'agent_id,thour';
         $whereSql = $this->generateWhereSql($params);
 
+        echo $whereSql;
 
         // 根据日期,连表查询
         $tableNames = ToolLogic::getMonthlyTableNames('base_total_hour_', $where['reg_date'][0], $where['reg_date'][1]);

+ 6 - 2
plugin/saiadmin/app/controller/system/SystemUserController.php

@@ -61,7 +61,8 @@ class SystemUserController extends BaseController
             'sa_system_dept.name' => 'dept_name',
             'GROUP_CONCAT(sa_system_user_role.role_id)' => 'role_id',
             'GROUP_CONCAT(sa_system_role.name)' => 'role_name',
-            'sa_system_user.ad_permission' => 'ad_permission'
+            'sa_system_user.ad_permission' => 'ad_permission',
+            'sa_system_user.normal_game_list' => 'normal_game_list'
         ]);
         $query->leftJoin('sa_system_user_role', 'sa_system_user.id = sa_system_user_role.user_id');
         $query->leftJoin('sa_system_dept', 'sa_system_user.dept_id = sa_system_dept.id');
@@ -205,7 +206,10 @@ class SystemUserController extends BaseController
         if ($normal_game_list) {
             $data['normal_game_list'] = $normal_game_list;
         }
-        $data['ad_permission'] = $ad_permission;
+        if($ad_permission){
+            $data['ad_permission'] = $ad_permission;
+        }
+        
         $this->logic->authEdit($id, $data);
         $userInfoCache = new UserInfoCache($id);
         $userInfoCache->clearUserInfo();