gameMainLogic = new GameMainLogic(); $this->gameLogic = new GameLogic(); $this->mediaListLogic = new MediaListLogic(); $this->agentListLogic = new AgentListLogic(); $this->systemUserLogic = new SystemUserLogic(); $this->gamePackageLogic = new GamePackageLogic(); $this->agentSiteLogic = new AgentSiteLogic(); $this->gameGroupLogic = new GameGroupLogic(); } // /** // * 按照权限获取游戏信息,通过游戏分组 // */ // public function getGameListOptions(Request $request): Response // { // $where = $request->get(); // $data = $this->gameGroupLogic->getGameListOptions($where); // return $this->success($data); // } /** * 获取主游戏options列表 * @return Response */ public function getMainGameOptions(Request $request): Response { $data = $this->gameMainLogic->getMainGameOptions(); return $this->success($data); } /** * 获取子游戏options列表(有权限) * @return Response */ public function getGameOptions(Request $request): Response { $where = $request->get(); $data = $this->gameLogic->getGameOptions($where); return $this->success($data); } /** * 获取子游戏options列表(无权限) * @return Response */ public function getGameOptionsNoAuth(Request $request): Response { $where = $request->get(); $data = $this->gameLogic->getGameOptionsNoAuth($where); return $this->success($data); } /** * 查询媒体列表Options */ public function getMediaOptions(Request $request): Response { $data = $this->mediaListLogic->getMediaOptions(); $data = $data->toArray(); return $this->success($data); } /** * 查询渠道列表Options */ public function getAgentOptions(Request $request): Response { $data = $this->agentListLogic->getAgentOptions(); return $this->success($data); } /** * 后台归属人列表Options */ public function getAuthOptions(Request $request): Response { // 根据用户id获取用户权限 $token = getCurrentInfo(); // 用户权限缓存 $userAuthCache = new UserInfoCache($token['id']); $user_info = $userAuthCache->getUserInfo(); $currentUserRoleList = $user_info['roleList']; $currentUserRoleList = array_column($currentUserRoleList, 'id'); // 管理员角色ID:1, 则不限制权限 if(in_array(1,$currentUserRoleList)){ $data = $this->systemUserLogic->field('id as value, username as label,dept_id')->select()->toArray(); $deptList = SystemDept::where('1=1')->select()->toArray(); }else{ // 看公司的广告数据权限 if($user_info['ad_permission'] == 1){ $data = $this->systemUserLogic->field('id as value, username as label,dept_id')->select()->toArray(); $deptList = SystemDept::where('1=1')->select()->toArray(); } if($user_info['ad_permission'] == 2){ // 看自己以及组员 // 1. 查看自己是哪个组 $deptId = $user_info['dept_id']; // 2. 查看组员 $data = $this->systemUserLogic->field('id as value, username as label,dept_id')->where('dept_id',$deptId)->select()->toArray(); $deptList = SystemDept::where('id',$deptId)->select()->toArray(); } if($user_info['ad_permission'] == 0){ // 仅看自己 $data = $this->systemUserLogic->field('id as value, username as label,dept_id')->where('id',$user_info['id'])->select()->toArray(); $deptList = SystemDept::where('id',$user_info['dept_id'])->select()->toArray(); } } $result = []; // 将部门列表转为以id为key的数组,便于查找 $deptMap = []; foreach ($deptList as $dept) { $dept['children'] = []; $dept['users'] = []; $deptMap[$dept['id']] = $dept; } // 将用户分配到对应部门的users中 foreach ($data as $user) { if (isset($deptMap[$user['dept_id']])) { $deptMap[$user['dept_id']]['users'][] = [ 'id' => $user['value'], 'name' => $user['label'], ]; } } // 构建部门树 $tree = []; foreach ($deptMap as $id => &$dept) { if ($dept['parent_id'] && isset($deptMap[$dept['parent_id']])) { $deptMap[$dept['parent_id']]['children'][] = &$dept; } else { $tree[] = &$dept; } } unset($dept); // 递归格式化输出 $result = $this->formatDeptTree($tree); return $this->success($result); } public function formatDeptTree($depts) { $result = []; foreach ($depts as $dept) { $item = [ 'id' => 'dept_id_'.$dept['id'], 'name' => $dept['name'], ]; // 先加用户 if (!empty($dept['users'])) { $item['children'] = $dept['users']; } // 再加子部门 if (!empty($dept['children'])) { $children = $this->formatDeptTree($dept['children']); if (!empty($item['children'])) { $item['children'] = array_merge($item['children'], $children); } else { $item['children'] = $children; } } $result[] = $item; } return $result; } /** * 设计归属人列表Options */ public function getDesignAuthOptions(Request $request): Response { $data = $this->systemUserLogic ->field('sa_system_user.id as "value", sa_system_user.username as label') ->leftJoin('sa_system_user_role', 'sa_system_user_role.user_id = sa_system_user.id') ->leftJoin('sa_system_role', 'sa_system_role.id = sa_system_user_role.role_id') ->whereOr('sa_system_role.code', 'designLeader') ->whereOr('sa_system_role.code', 'design') ->where('sa_system_role.status', 1); echo $data->buildSql(); $data = $data->select() ->toArray(); return $this->success($data); } /** * 获取母包列表Options */ public function getPackageOptions(Request $request): Response { $where = $request->get(); $data = $this->gamePackageLogic->getPackageOptions($where); return $this->success($data); } /** * 获取广告位options */ public function getAgentSiteOptions(Request $request): Response { $data = $this->agentSiteLogic->getAgentSiteOptions(); return $this->success($data); } /** * 获取充值渠道 */ public function getPayChannelOptions(Request $request): Response { $data = Db::connect('db_center')->table('pay_channel')->where('status',1)->select()->toArray(); return $this->success($data); } /** * 给游戏分组用的游戏列表 */ public function getGameListOptionsByGroup(Request $request): Response { $where = $request->more([ ['game_group_id', ''] ]); $data = $this->gameGroupLogic->getGameListOptionsByGroup($where); 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); } }