getLoginPromote(); $repository = new TestingResourceRepository(); $query = $repository->getTestingRolesQuery($params, $loginPromote); [$roles, $pagination, $count] = $this->paginate($query); $records = $repository->makeTestingRoleRecords($roles); $gameRepository = new GameRepository(); $this->assign('games', $gameRepository->getChoiceGames()); $this->assign('servers', $gameRepository->getServersByGameId($gameId)); $this->assign('count', $count); $this->assign('pagination', $pagination); $this->assign('records', $records); $this->display(); } public function testingUsers() { $params = I('get.'); $loginPromote = $this->getLoginPromote(); $repository = new TestingResourceRepository(); $query = $repository->getTestingUsersQuery($params, $loginPromote); [$testingUsers, $pagination, $count] = $this->paginate($query); $records = $repository->makeTestingUserRecords($testingUsers); $this->assign('count', $count); $this->assign('records', $records); $this->assign('pagination', $pagination); $this->display(); } public function addTestingUsers() { $loginPromote = $this->getLoginPromote(); $accountsStr = trim(I('accounts', ''), ','); if ($accountsStr == '') { return $this->ajaxReturn(['status' => 0, 'message' => '请输入测试资源账号']); } $accounts = explode(',', $accountsStr); $testingResourceService = new TestingResourceService(); $result = $testingResourceService->addTestingUsers($accounts, $loginPromote); return $this->ajaxReturn(['status' => 1, 'message' => '请求成功', 'data' => $result]); } public function batches() { $params = I('get.'); $gameId = $params['game_id'] ?? 0; $loginPromote = $this->getLoginPromote(); $repository = new TestingResourceRepository(); $query = $repository->getBatchesQuery($params, $loginPromote); list($batches, $pagination, $count) = $this->paginate($query); $records = $repository->makeBatchesRecords($batches); $gameRepository = new GameRepository(); $this->assign('verifyStatusList', TestingResourceRepository::$verifyStatusList); $this->assign('provideStatusList', TestingResourceRepository::$provideStatusList); $this->assign('servers', $gameRepository->getServersByGameId($gameId)); $this->assign('games', $gameRepository->getChoiceGames()); $this->assign('count', $count); $this->assign('pagination', $pagination); $this->assign('records', $records); $this->display(); } public function orders() { $id = I('id', 0); $batch = M('testing_resource_batch', 'tab_')->where(['id' => $id])->find(); $role = M('user_play_info', 'tab_') ->field(['id', 'game_name', 'server_name', 'role_name', 'game_role_id', 'user_account']) ->where(['game_id' => $batch['game_id'], 'role_id' => $batch['role_id']]) ->find(); $applyPromote = M('promote', 'tab_')->field(['id', 'account'])->where(['id' => $batch['apply_promote_id']])->find(); $promote = M('promote', 'tab_')->field(['id', 'account'])->where(['id' => $role['apply_promote_id']])->find(); $query = M('testing_resource_order', 'tab_')->where(['batch_id' => $id])->order('id desc'); list($orders, $pagination, $count) = $this->paginate($query); $repository = new TestingResourceRepository(); foreach ($orders as $order) { $records[] = [ 'id' => $order['id'], 'create_time' => $batch['create_time'] == 0 ? '--' : date('Y-m-d H:i:s', $batch['create_time']), 'game_name' => $role['game_name'], 'user_account' => $role['user_account'], 'server_name' => $role['server_name'], 'role_name' => $role['role_name'], 'apply_promote_account' => $applyPromote ? $applyPromote['account'] : '', 'promote_account' => $promote['account'], 'ref_name' => $order['ref_name'], 'ref_amount' => $order['ref_amount'], 'num' => $order['num'], 'amount' => $order['num'] * $order['ref_amount'], 'remark' => $order['remark'], 'provide_status' => $order['provide_status'], 'provide_status_text' => $repository->getProvideStatusText($order['provide_status']), ]; } $this->assign('count', $count); $this->assign('pagination', $pagination); $this->assign('records', $records); $this->display(); } public function apply() { $id = I('id', 0); $role = null; if ($id != 0) { $role = M('user_play_info', 'tab_') ->field(['id', 'role_id', 'user_id', 'game_id', 'server_id', 'user_account', 'role_name', 'testing_other_quota']) ->where(['id' => $id]) ->find(); } $hasItf = 0; $servers = []; $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(); $binding = M('testing_binding', 'tab_')->where(['game_id' => $role['game_id'], 'role_id' => $role['role_id']])->find(); if ($binding) { $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']]) ->find(); if ($bindingRole) { $bindingRole['binding_time'] = $binding['create_time']; } } $repository = new TestingResourceRepository(); $gameSetting = $repository->getGameSettingByGameId($role['game_id']); $hasItf = $gameSetting ? $gameSetting['has_itf'] : 0; } $testingResourceService = new TestingResourceService(); $quota = $testingResourceService->getRemainQuota($role, $bindingRole); $this->assign('hasItf', $hasItf); $games = M('game', 'tab_')->field(['id' , 'game_name'])->select(); $this->assign('games', $games); $this->assign('servers', $servers); $this->assign('bindingRole', $bindingRole); $this->assign('role', $role); $this->assign('quota', $quota); $this->display(); } public function doApply() { $params = I('post.'); $loginPromote = $this->getLoginPromote(); try { $testingResourceService = new TestingResourceService(); $testingResourceService->apply($params, $loginPromote); return $this->ajaxReturn(['status' => 1, 'message' => '申请成功,等待审核。']); } catch (\Exception $e) { return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]); } } public function bindRole() { $params = I('post.'); $loginPromote = $this->getLoginPromote(); try { $testingResourceService = new TestingResourceService(); $testingResourceService->bindRole($params, $loginPromote); return $this->ajaxReturn(['status' => 1, 'message' => '绑定成功']); } catch (\Exception $e) { return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]); } } public function getServers() { $gameId = I('game_id', 0); $gameRepository = new GameRepository(); $servers = $gameRepository->getServersByGameId($gameId); return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['servers' => $servers]]); } public function getResourceTypes() { $gameId = I('game_id', 0); $testingResourceService = new TestingResourceService(); $resourceTypes = $testingResourceService->getResourceTypes($gameId); return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]); } public function getResources() { $typeId = I('type_id', 0); $testingResourceService = new TestingResourceService(); $resources = $testingResourceService->getResources($typeId); return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resources' => $resources]]); } 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]]); } }