diff --git a/Application/Admin/Controller/TestingResourceController.class.php b/Application/Admin/Controller/TestingResourceController.class.php index 882a80204..d260b9f07 100644 --- a/Application/Admin/Controller/TestingResourceController.class.php +++ b/Application/Admin/Controller/TestingResourceController.class.php @@ -9,6 +9,7 @@ use Base\Service\TestingResourceService; use Base\Service\PartnerService; use Base\Repository\TestingResourceRepository; use Base\Repository\GameRepository; +use Base\Service\GameService; class TestingResourceController extends ThinkController { @@ -439,11 +440,21 @@ class TestingResourceController extends ThinkController $bindingRole = null; if ($role) { $servers = M('server', 'tab_')->field('id,server_name,server_id')->where(['game_id' => $role['game_id']])->order('server_id asc')->select(); + $game = M('game', 'tab_')->where(['id' => $role['game_id']])->find(['id', 'data_share']); $binding = M('testing_binding', 'tab_')->where(['game_id' => $role['game_id'], 'role_id' => $role['role_id']])->find(); if ($binding) { + + $gameIds = [$role['game_id']]; + if ($game['data_share'] == 1) { + $gameRepository = new GameRepository(); + $baseGames = $gameRepository->getBaseGames(); + $baseGame = $gameRepository->getBaseGameByGameId($role['game_id'], $baseGames); + $gameIds = $gameRepository->getGameIdsByBaseGame($baseGame); + } + $bindingRole = M('user_play_info', 'tab_') ->field(['id', 'role_id', 'user_id', 'game_id', 'server_id', 'user_account', 'role_name']) - ->where(['game_id' => $binding['game_id'], 'role_id' => $binding['bind_role_id']]) + ->where(['game_id' => ['in', $gameIds], 'role_id' => $binding['bind_role_id']]) ->find(); if ($bindingRole) { $bindingRole['binding_time'] = $binding['create_time']; @@ -577,31 +588,6 @@ class TestingResourceController extends ThinkController return $this->ajaxReturn(['status' => 1, 'message' => '设置成功']); } - public function getUserRoles() - { - $gameId = I('game_id', 0); - $serverId = I('server_id', 0); - $userAccount = I('user_account', ''); - $server = M('server', 'tab_')->field(['id', 'server_name', 'server_id'])->where(['id' => $serverId])->find(); - if (is_null($server)) { - return $this->ajaxReturn(['status' => 0, 'message' => '区服不存在']); - } - - $user = M('user', 'tab_')->field(['id', 'promote_id'])->where(['account' => $userAccount])->find(); - if (is_null($user)) { - return $this->ajaxReturn(['status' => 0, 'message' => '账号不存在']); - } - - $testingUser = M('testing_user', 'tab_')->where(['user_account' => $userAccount])->find(); - $isTestingAccount = is_null($testingUser) ? false : true; - - $roles = M('user_play_info', 'tab_') - ->field(['id', 'role_id', 'role_name']) - ->where(['user_account' => $userAccount, 'game_id' => $gameId, 'server_id' => $server['server_id']]) - ->select(); - return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['roles' => $roles, 'is_testing_account' => $isTestingAccount]]); - } - public function getResourceTypes() { $gameId = I('game_id', 0); @@ -759,4 +745,33 @@ class TestingResourceController extends ThinkController return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]); } } + + public function getUserRoles() + { + $gameId = I('game_id', 0); + $roleId = I('role_id', 0); + + $game = M('game', 'tab_')->where(['id' => $gameId])->find(); + if (is_null($game)) { + return $this->ajaxReturn(['status' => 0, 'message' => '游戏不存在']); + } + + $gameIds = [$gameId]; + if ($game['data_share'] == 1) { + $gameRepository = new GameRepository(); + $baseGames = $gameRepository->getBaseGames(); + $baseGame = $gameRepository->getBaseGameByGameId($gameId, $baseGames); + if (is_null($baseGame)) { + return $this->ajaxReturn(['status' => 0, 'message' => '游戏不存在']); + } + $gameIds = $gameRepository->getGameIdsByBaseGame($baseGame); + } + + $roles = M('user_play_info', 'tab_') + ->field(['id', 'role_id', 'role_name']) + ->where(['role_id' => $roleId, 'game_id' => ['in', $gameIds]]) + ->select(); + + return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['roles' => $roles]]); + } } \ No newline at end of file diff --git a/Application/Admin/View/TestingResource/apply.html b/Application/Admin/View/TestingResource/apply.html index 153a22811..a46acb912 100644 --- a/Application/Admin/View/TestingResource/apply.html +++ b/Application/Admin/View/TestingResource/apply.html @@ -264,9 +264,9 @@ body {