From b44a5118cfff3dfe51c01450dcce8eaa0e8f63f1 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Wed, 21 Oct 2020 09:57:08 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/TestingResourceController.class.php | 3 +++ .../Base/Service/TestingResourceService.class.php | 11 +++++++++-- .../Controller/TestingResourceController.class.php | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Controller/TestingResourceController.class.php b/Application/Admin/Controller/TestingResourceController.class.php index b2f28a187..881cc1934 100644 --- a/Application/Admin/Controller/TestingResourceController.class.php +++ b/Application/Admin/Controller/TestingResourceController.class.php @@ -290,6 +290,9 @@ class TestingResourceController extends ThinkController ->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(); diff --git a/Application/Base/Service/TestingResourceService.class.php b/Application/Base/Service/TestingResourceService.class.php index bb9aea68a..54124fc71 100644 --- a/Application/Base/Service/TestingResourceService.class.php +++ b/Application/Base/Service/TestingResourceService.class.php @@ -178,8 +178,14 @@ class TestingResourceService $totalQuota = $role['testing_other_quota'] + ($gameSetting['base_quota'] ?? 0); if (!is_null($bindRole)) { + $bindTime = $bindRole['binding_time'] ?? 0; $spendQuota += M('spend', 'tab_') - ->where(['game_id' => $role['game_id'], 'game_player_id' => $bindRole['role_id'], 'pay_status' => 1]) + ->where([ + 'game_id' => $role['game_id'], + 'game_player_id' => $bindRole['role_id'], + 'pay_status' => 1, + 'egt' => strtotime(date('Y-m-d 00:00:00', $bindTime)) + ]) ->group('game_id,game_player_id') ->sum('pay_amount'); $totalQuota += round($gameSetting['rate'] / 100 * $spendQuota, 2); @@ -421,6 +427,7 @@ class TestingResourceService if (is_null($bindingRole)) { throw new \Exception('绑定玩家角色不存在'); } + $bindingRole['binding_time'] = $binding['create_time']; $bindPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $bindingRole['promote_id']])->find(); if (is_null($bindPromote) || ($promote && !$promoteService->isSubOrSelf($bindPromote, $promote))) { throw new \Exception('绑定角色所属推广员异常'); @@ -461,7 +468,7 @@ class TestingResourceService } } - $remainQuota = $this->getRemainQuota($role, $bindingRole); + $remainQuota = $this->getRemainQuota($role, $bindingRole, $gameSetting); if ($amount > $remainQuota) { throw new \Exception('额度不足'); } diff --git a/Application/Home/Controller/TestingResourceController.class.php b/Application/Home/Controller/TestingResourceController.class.php index 83fa00dcb..37ca7a3fa 100644 --- a/Application/Home/Controller/TestingResourceController.class.php +++ b/Application/Home/Controller/TestingResourceController.class.php @@ -143,6 +143,9 @@ class TestingResourceController extends BaseController ->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(); From dd71ccdf83360613df42fb2a2f5cc745c5ca0e07 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Tue, 10 Nov 2020 21:06:46 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/ConsoleController.class.php | 15 - .../Controller/GameApiController.class.php | 9 +- .../TestingResourceController.class.php | 71 +++- .../Admin/View/TestingResource/users.html | 338 ++++++++++++++++++ .../TestingResourceRepository.class.php | 102 +++++- .../Service/PromoteGradeService.class.php | 1 - .../Service/TestingResourceService.class.php | 173 +++++---- Application/Base/Tool/GameResource.class.php | 63 ++++ .../Tool/GameResource/JtxcClient.class.php | 156 ++++++++ .../Tool/GameResource/LsxxClient.class.php | 135 +++++++ .../YzchzbClient.class.php} | 62 +++- .../TestingResourceController.class.php | 24 +- Data/update.sql | 9 +- 13 files changed, 1044 insertions(+), 114 deletions(-) create mode 100644 Application/Admin/View/TestingResource/users.html create mode 100644 Application/Base/Tool/GameResource.class.php create mode 100644 Application/Base/Tool/GameResource/JtxcClient.class.php create mode 100644 Application/Base/Tool/GameResource/LsxxClient.class.php rename Application/Base/Tool/{GameCatClient.class.php => GameResource/YzchzbClient.class.php} (59%) diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index c720d5d4b..c432bc5d5 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -133,21 +133,6 @@ class ConsoleController extends Think { echo M('game', 'tab_')->where('id>2')->field(['id', 'game_name'])->where('sdk_version=1')->select(false); } - public function testGameCat() - { - $key = '123456'; - $params = [ - - ]; - ksort($params); - $paramsStr = http_build_query($params) . '&key=' . $key; - $sign = md5($paramsStr); - - $client = new AggregateClient(); - $result = $client->api('game-data', ['unique_codes' => ['w123'], 'started_at' => '2019-06-27', 'ended_at' => '2020-07-27']); - var_dump($result); - } - public function initMarketAdmin() { $marketService = new MarketService(); diff --git a/Application/Admin/Controller/GameApiController.class.php b/Application/Admin/Controller/GameApiController.class.php index e52bd0396..4968842e9 100644 --- a/Application/Admin/Controller/GameApiController.class.php +++ b/Application/Admin/Controller/GameApiController.class.php @@ -10,7 +10,7 @@ use Base\Tool\TaskClient; use Base\Service\TestingResourceService; use GuzzleHttp\Client; use think\Db; -use Base\Tool\GameCatClient; +use Base\Tool\GameResource; class GameApiController extends Think { @@ -24,7 +24,7 @@ class GameApiController extends Think { $service = new TestingResourceService(); $gameIds = $service->getHasItfGameIds(); - $map = ['verify_status' => 0]; + $map = ['verify_status' => 0, 'auto_verify' => 1]; if (count($gameIds) > 0) { $map['game_id'] = ['in', $gameIds]; } @@ -52,6 +52,7 @@ class GameApiController extends Think { public function send() { + $game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => 232])->find(); $role = [ 'role_id' => '6819493', 'user_account' => 'qh11102', @@ -63,8 +64,8 @@ class GameApiController extends Think { 'remark' => '测试', 'order_no' => date('YmdHis') . rand(1000, 9999) . '_1', ]; - $service = new TestingResourceService(); - $result = $service->provideFromGameCat($order, $role); + $gameResource = new GameResource($game); + $result = $gameResource->getResources(); var_dump($result); } } diff --git a/Application/Admin/Controller/TestingResourceController.class.php b/Application/Admin/Controller/TestingResourceController.class.php index 881cc1934..176df005f 100644 --- a/Application/Admin/Controller/TestingResourceController.class.php +++ b/Application/Admin/Controller/TestingResourceController.class.php @@ -18,11 +18,11 @@ class TestingResourceController extends ThinkController $gameId = $params['game_id'] ?? 0; $repository = new TestingResourceRepository(); - $query = $repository->getTestingUsersQuery($params); + $query = $repository->getTestingRolesQuery($params); [$roles, $page, $count] = $this->paginate($query); - $records = $repository->makeTestingUserRecords($roles); + $records = $repository->makeTestingRoleRecords($roles); $gameRepository = new GameRepository(); @@ -34,6 +34,24 @@ class TestingResourceController extends ThinkController $this->display(); } + public function users() + { + $params = I('get.'); + + $repository = new TestingResourceRepository(); + $query = $repository->getTestingUsersQuery($params); + + [$testingUsers, $page, $count] = $this->paginate($query); + + $records = $repository->makeTestingUserRecords($testingUsers); + + $this->assign('statusList', TestingResourceRepository::$userStatusList); + $this->assign('count', $count); + $this->assign('records', $records); + $this->assign('_page', $page); + $this->display(); + } + public function getServers() { $gameId = I('game_id', 0); @@ -534,4 +552,53 @@ class TestingResourceController extends ThinkController 'provide_status_text' => '发放状态' ]); } + + public function deleteTestingUser() + { + $userId = I('user_id', 0); + try { + $testingResourceService = new TestingResourceService(); + $testingResourceService->deleteTestingUser($userId); + return $this->ajaxReturn(['status' => 1, 'message' => '删除成功']); + } catch (\Throwable $e) { + return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]); + } + } + + public function verifyTestingUsers() + { + $userIds = I('user_ids', 0); + $verifyStatus = I('verify_status', 1); + try { + $testingResourceService = new TestingResourceService(); + $testingResourceService->verifyTestingUser($userIds, $verifyStatus); + return $this->ajaxReturn(['status' => 1, 'message' => '审核成功']); + } catch (\Throwable $e) { + return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]); + } + } + + public function unfreezeTestingUser() + { + $userId = I('user_id', 0); + try { + $testingResourceService = new TestingResourceService(); + $testingResourceService->unfreezeTestingUser($userId); + return $this->ajaxReturn(['status' => 1, 'message' => '解禁成功']); + } catch (\Throwable $e) { + return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]); + } + } + + public function freezeTestingUser() + { + $userId = I('user_id', 0); + try { + $testingResourceService = new TestingResourceService(); + $testingResourceService->freezeTestingUser($userId); + return $this->ajaxReturn(['status' => 1, 'message' => '禁用成功']); + } catch (\Throwable $e) { + return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]); + } + } } \ No newline at end of file diff --git a/Application/Admin/View/TestingResource/users.html b/Application/Admin/View/TestingResource/users.html new file mode 100644 index 000000000..a6d1b8c34 --- /dev/null +++ b/Application/Admin/View/TestingResource/users.html @@ -0,0 +1,338 @@ + + + + + + + + + + + + + + + + + + + + 测试账号 + + + + + + + 新增测试账号 + + + + + + + 搜索: + + + + + + + 请选择状态 + $value):?> + =$value?> + + + + + + - + + + + + + + 搜索 + + + + + + + + + + + + 测试账号 + 账号状态 + 推广员 + 添加时间 + 操作 + + + + + + + aOh! 暂时还没有内容! + + + + {$record.user_account} + {$record.status_text} + {$record.promote_account} + {$record.create_time} + + + 解禁 + + 禁用 + + + + + + + + + + + + 导出 + + {$_page|default=''} + + + + + + + + + 已添加添加至常用设置 + + + + + + 用户账号 + + + + + + + 确定 + + + + + + + + + + + + \ No newline at end of file diff --git a/Application/Base/Repository/TestingResourceRepository.class.php b/Application/Base/Repository/TestingResourceRepository.class.php index ec7be34f2..21d81347a 100644 --- a/Application/Base/Repository/TestingResourceRepository.class.php +++ b/Application/Base/Repository/TestingResourceRepository.class.php @@ -19,6 +19,18 @@ class TestingResourceRepository '2' => '审核拒绝', ]; + public static $userVerifyStatusList = [ + '0' => '待审核', + '1' => '审核通过', + '2' => '审核拒绝', + ]; + + public static $userStatusList = [ + '1' => '正常', + '2' => '警告', + '3' => '禁用', + ]; + public function getProvideStatusText($provideStatus) { return self::$provideStatusList[$provideStatus] ?? '未知'; @@ -208,7 +220,10 @@ class TestingResourceRepository $bindings = []; $bindingRoles = []; $applyRecords = []; + $testingUsers = []; if (count($roles) > 0) { + $testingUsers = M('testing_user', 'tab_')->where(['user_id' => ['in', $userIds]])->select(); + $testingUsers = index_by_column('user_id', $testingUsers); $users = M('user', 'tab_')->field(['id', 'phone', 'lock_status'])->where(['id' => ['in', $userIds]])->select(); $users = index_by_column('id', $users); $bindingRows = M('testing_binding', 'tab_')->where(['_string' => implode(' or ', $bindingOrWhere)])->select(); @@ -301,13 +316,15 @@ class TestingResourceRepository 'verifyRecords' => $verifyRecords, 'todayProvideRecords' => $todayProvideRecords, 'gameSettings' => $gameSettings, + 'testingUsers' => $testingUsers, ]; } - public function makeTestingUserRecords($roles) + public function makeTestingRoleRecords($roles) { $result = $this->statByRoles($roles); $users = $result['users']; + $testingUsers = $result['testingUsers']; $spendItems = $result['spendItems']; $gameSettings = $result['gameSettings']; $bindings = $result['bindings']; @@ -324,6 +341,7 @@ class TestingResourceRepository $records = []; foreach ($roles as $role) { $user = $users[$role['user_id']] ?? null; + $testingUser = $testingUsers[$role['user_id']] ?? null; $binding = $bindings[$role['game_role_id']] ?? null; $bindingRole = null; if ($binding) { @@ -339,6 +357,17 @@ class TestingResourceRepository $spendQuota = $bindingRole && isset($spendItems[$bindingRole['game_role_id']]) ? $spendItems[$bindingRole['game_role_id']] : 0; $quota = $gameSetting ? round($spendQuota * $gameSetting['rate'] / 100, 2) : 0; + $statusText = '正常'; + if (is_null($user) || is_null($testingUser)) { + $statusText = '错误'; + } elseif ($user['lock_status'] != 1) { + $statusText = '锁定'; + } elseif ($testingUser['status'] == 2) { + $statusText = '警告'; + } elseif ($testingUser['status'] == 3) { + $statusText = '禁用'; + } + $records[] = [ 'id' => $role['id'], 'game_name' => $role['game_name'], @@ -358,14 +387,14 @@ class TestingResourceRepository 'provide_amount' => $provideRecords[$role['game_role_id']] ?? 0, 'today_amount' => $todayProvideRecords[$role['game_role_id']] ?? 0, 'apply_amount' => $applyRecords[$role['game_role_id']] ?? 0, - 'status' => $user && $user['lock_status'] == 1 ? '正常' : '锁定', + 'status' => $statusText, 'create_time' => date('Y-m-d H:i:s', $role['create_time']) ]; } return $records; } - public function getTestingUsersQuery($params, array $promote = null) + public function getTestingRolesQuery($params, array $promote = null) { $createTimeStart = $params['create_time_start'] ?? ''; $createTimeEnd = $params['create_time_end'] ?? ''; @@ -406,6 +435,7 @@ class TestingResourceRepository $strCondition .= ' and create_time <=' . strtotime($createTimeEnd . ' 23:59:59'); } + $subConditions['verify_status'] = 1; $subSql = M('testing_user', 'tab_')->field(['user_id'])->where($subConditions)->select(false); $strCondition .= ' and user_id in (' . $subSql . ')'; @@ -429,4 +459,70 @@ class TestingResourceRepository $conditions['_string'] = $strCondition; return M('user_play_info', 'tab_')->where($conditions)->order('create_time desc'); } + + public function getTestingUsersQuery($params, array $promote = null) + { + $createTimeStart = $params['create_time_start'] ?? ''; + $createTimeEnd = $params['create_time_end'] ?? ''; + $status = $params['status'] ?? 0; + $verifyStatus = $params['verify_status'] ?? -1; + $account = $params['account'] ?? ''; + + $conditions = []; + $strCondition = '1=1'; + + /* $promoteService = new PromoteService(); + if ($promote) { + $subSql = M('user', 'tab_')->field('id')->where('promote_id in (' . $promoteService->subInSql($promote) . ')')->select(false); + $strCondition .= ' and user_id in (' . $subSql . ')'; + } */ + + if ($account) { + $conditions['user_account'] = ['like', '%' . $account . '%']; + } + if ($verifyStatus != -1) { + $conditions['verify_status'] = $verifyStatus; + } + if ($status != 0) { + $conditions['status'] = $status; + } + if ($createTimeStart) { + $strCondition .= ' and create_time >=' . strtotime($createTimeStart . ' 00:00:00'); + } + if ($createTimeEnd) { + $strCondition .= ' and create_time <=' . strtotime($createTimeEnd . ' 23:59:59'); + } + + $conditions['_string'] = $strCondition; + return M('testing_user', 'tab_')->where($conditions); + } + + public function makeTestingUserRecords($testingUsers) + { + $ids = array_column($testingUsers, 'user_id'); + if (count($ids) == 0) { + return []; + } + $users = M('user', 'tab_')->field(['id', 'login_time', 'promote_account'])->where(['id' => ['in', $ids]])->select(); + $users = index_by_column('id', $users); + + $records = []; + foreach ($testingUsers as $testingUser) { + $user = $users[$testingUser['user_id']] ?? null; + + $records[] = [ + 'user_id' => $testingUser['user_id'], + 'user_account' => $testingUser['user_account'], + 'status_text' => self::$userStatusList[$testingUser['status']] ?? '未知', + 'verify_status_text' => self::$userVerifyStatusList[$testingUser['verify_status']] ?? '未知', + 'verify_status' => $testingUser['verify_status'], + 'status' => $testingUser['status'], + 'verify_time' => $testingUser['verify_time'] == 0 ? '' : date('Y-m-d H:i:s', $testingUser['verify_time']), + 'create_time' => date('Y-m-d H:i:s', $testingUser['create_time']), + 'promote_account' => $user ? $user['promote_account'] : '--', + 'login_time' => $user ? date('Y-m-d H:i:s', $user['login_time']) : '--', + ]; + } + return $records; + } } \ No newline at end of file diff --git a/Application/Base/Service/PromoteGradeService.class.php b/Application/Base/Service/PromoteGradeService.class.php index f15d088d6..8e644d771 100644 --- a/Application/Base/Service/PromoteGradeService.class.php +++ b/Application/Base/Service/PromoteGradeService.class.php @@ -2,7 +2,6 @@ namespace Base\Service; use Base\Facade\Request; -use Base\Tool\GameCatClient; class PromoteGradeService { diff --git a/Application/Base/Service/TestingResourceService.class.php b/Application/Base/Service/TestingResourceService.class.php index 54124fc71..a4aa29bf7 100644 --- a/Application/Base/Service/TestingResourceService.class.php +++ b/Application/Base/Service/TestingResourceService.class.php @@ -2,7 +2,7 @@ namespace Base\Service; use Base\Facade\Request; -use Base\Tool\GameCatClient; +use Base\Tool\GameResource; use Base\Repository\TestingResourceRepository; use Think\Model; @@ -104,9 +104,10 @@ class TestingResourceService foreach ($orders as $order) { $orderData = []; if ($gameSetting['has_itf'] == 1) { - $result = $this->provideFromGameCat($order, $role); + $gameResource = new GameResource($game); + $result = $gameResource->apply($order, $role); $orderData = [ - 'result' => json_encode(['code' => $result['code'], 'message' => $result['message']]), + 'result' => json_encode($result), ]; if (!$result['status']) { $hasError = true; @@ -138,34 +139,6 @@ class TestingResourceService ->save($batchData); } - public function provideFromGameCat($order, $role) - { - $gameCatClient = new GameCatClient(); - $result = $gameCatClient->api('provide', [ - 'roleId' => $role['role_id'], - 'amount' => intval($order['ref_amount']), - 'supportItem' => $order['ref_id'], - 'supportType' => '0', - 'channelUid' => $role['user_account'], - 'applyRemark' => $order['remark'] == '' ? '测试资源申请' : $order['remark'], - 'applyId' => $order['order_no'], - 'device_type' => $role['sdk_version'] == 1 ? 'andriod' : 'ios', - ]); - if ($result['state'] == 1 && $result['data']) { - return [ - 'status' => true, - 'message' => $result['msg'], - 'code' => 1, - ]; - } else { - return [ - 'status' => false, - 'msg' => $result['msg'], - 'code' => $result['state'], - ]; - } - } - public function getRemainQuota($role, $bindRole = null, $gameSetting = null) { if (is_null($gameSetting)) { @@ -201,6 +174,15 @@ class TestingResourceService public function addTestingUsers($accounts, $promote = null) { + // 测试账号是否自动审核 + $isAutoVerify = true; + $verifyStatus = 0; + $verifyTime = 0; + if ($isAutoVerify) { + $verifyStatus = 1; + $verifyTime = time(); + } + $accounts = array_unique($accounts); $existAccounts = M('testing_user', 'tab_')->where(['user_account' => ['in', $accounts]])->getField('user_account', true); $existAccounts = $existAccounts ?? []; @@ -227,6 +209,8 @@ class TestingResourceService 'user_id' => $user['id'], 'user_account' => $user['account'], 'status' => 1, + 'verify_status' => $verifyStatus, + 'verify_time' => $verifyTime, 'create_time' => time(), 'update_time' => time(), ]; @@ -290,6 +274,14 @@ class TestingResourceService throw new \Exception('测试账号不存在'); } + if ($testingUser['verify_status'] != 1) { + throw new \Exception('测试账号未审核通过'); + } + + if (!in_array($testingUser['status'], [1, 2])) { + throw new \Exception('测试账号已禁用'); + } + $promoteService = new PromoteService(); $testPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $testingRole['promote_id']])->find(); if (is_null($testPromote) || ($promote && !$promoteService->isSubOrSelf($testPromote, $promote))) { @@ -359,12 +351,8 @@ class TestingResourceService throw new \Exception('权限不足'); } - $resources = []; - if ($gameId == 229) { - $resources = $this->getGameCatResources('android'); - } elseif ($gameId == 230) { - $resources = $this->getGameCatResources('ios'); - } + $game = M('game', 'tab_')->where(['id' => $gameId])->find(); + $resources = $this->getResources($game); $gameSetting = $this->repository->getGameSettingByGameId($gameId); if (is_null($gameSetting)) { @@ -384,7 +372,13 @@ class TestingResourceService if (is_null($testingUser)) { throw new \Exception('测试账号不存在'); } + if ($testingUser['verify_status'] != 1) { + throw new \Exception('测试账号未审核通过'); + } + if (!in_array($testingUser['status'], [1, 2])) { + throw new \Exception('测试账号已禁用'); + } $server = M('server', 'tab_')->field(['id', 'server_name', 'server_id'])->where(['id' => $serverId])->find(); if (is_null($server)) { throw new \Exception('区服不存在'); @@ -473,6 +467,7 @@ class TestingResourceService throw new \Exception('额度不足'); } + $olderBatch = M('testing_resource_batch', 'tab_')->field(['id'])->where(['user_id' => $testingUser['user_id'], 'game_id' => $gameId])->find(); $batchNo = date('YmdHis') . substr(md5($roleId . strval(microtime(true)) . rand(0, 9999)), 8, 16); try { @@ -489,6 +484,7 @@ class TestingResourceService 'apply_amount' => $amount, 'provide_status' => 0, 'verify_status' => 0, + 'auto_verify' => $gameSetting['has_itf'] == 1 && $olderBatch ? 1 : 0, 'create_time' => time(), 'update_time' => time(), ]; @@ -515,52 +511,16 @@ class TestingResourceService } } - public function getResourceTypes($gameId) + public function getResourceTypes($game) { - $resourceTypes = []; - - /** - * @todo 目前固定游戏猫 - */ - if ($gameId == 229) { - $resourceTypes[] = ['id' => 1, 'name' => '通用']; - } elseif ($gameId == 230) { - $resourceTypes[] = ['id' => 2, 'name' => '通用']; - } - return $resourceTypes; + $gameResource = new GameResource($game); + return $gameResource->getResourceTypes(); } - public function getResources($typeId) + public function getResources($game, $typeId) { - $resources = []; - - /** - * @todo 目前固定游戏猫资源类型ID - */ - if ($typeId == 2) { - $resources = $this->getGameCatResources('ios'); - } elseif ($typeId == 1) { - $resources = $this->getGameCatResources('andriod'); - } - return $resources; - } - - private function getGameCatResources($deviceType) - { - $resources = []; - $gameCatClient = new GameCatClient(); - $result = $gameCatClient->api('get-pay-type', ['device_type' => $deviceType]); - if ($result['state'] == 1) { - $items = $result['data']; - foreach ($items as $item) { - $resources[$item['supportItem']] = [ - 'ref_id' => $item['supportItem'], - 'name' => $item['content'], - 'amount' => $item['amount'], - ]; - } - } - return $resources; + $gameResource = new GameResource($game); + return $gameResource->getResources($typeId); } public function getHasItfGameIds() @@ -582,4 +542,59 @@ class TestingResourceService return array_merge(array_column($baseGames, 'android_game_id'), array_column($baseGames, 'ios_game_id')); } } + + public function verifyTestingUser($userIds, $verifyStatus) + { + if (count($userIds) == 0) { + throw new \Exception('请选择要审核的测试账号'); + } + + if (!in_array($verifyStatus, [1, 2])) { + throw new \Exception('状态值异常'); + } + + $testingUsers = M('testing_user', 'tab_')->where(['verify_status' => 0, 'user_id' => ['in', $userIds]])->get(); + if (count($testingUsers) == 0) { + throw new \Exception('含有非待审核的测试账号'); + } + + M('testing_user', 'tab_')->where(['user_id' => ['in', $userIds]])->save([ + 'status' => $verifyStatus + ]); + } + + public function freezeTestingUser($userId) + { + $testingUser = M('testing_user', 'tab_')->where(['user_id' => $userId])->find(); + if (is_null($testingUser)) { + throw new \Exception('测试账号不存在'); + } + M('testing_user', 'tab_')->where(['user_id' => $userId])->save([ + 'status' => 3 + ]); + } + + public function unfreezeTestingUser($userId) + { + $testingUser = M('testing_user', 'tab_')->where(['user_id' => $userId])->find(); + if (is_null($testingUser)) { + throw new \Exception('测试账号不存在'); + } + M('testing_user', 'tab_')->where(['user_id' => $userId])->save([ + 'status' => 1 + ]); + } + + public function deleteTestingUser($userId) + { + $testingUser = M('testing_user', 'tab_')->where(['user_id' => $userId])->find(); + if (is_null($testingUser)) { + throw new \Exception('测试账号不存在'); + } + if ($testingUser['verify_status'] != 2) { + throw new \Exception('只有审核拒绝的测试账号才能删除'); + } + + M('testing_user', 'tab_')->where(['user_id' => $userId])->delete(); + } } \ No newline at end of file diff --git a/Application/Base/Tool/GameResource.class.php b/Application/Base/Tool/GameResource.class.php new file mode 100644 index 000000000..f408cba90 --- /dev/null +++ b/Application/Base/Tool/GameResource.class.php @@ -0,0 +1,63 @@ + JtxcClient::class, + 192 => JtxcClient::class, + 231 => LsxxClient::class, + 232 => LsxxClient::class, + 229 => YzchzbClient::class, + 230 => YzchzbClient::class, + ]; + + public function __construct($game) + { + $this->game = $game; + $this->client = $this->createClient(); + } + + private function createClient() + { + $clientClass = ''; + $gameId = intval($this->game['id']); + if (isset($this->clientMap[$gameId])) { + $clientClass = $this->clientMap[$gameId]; + } else { + throw new \Exception('游戏资源客户端未配置'); + } + return new $clientClass(); + } + + public function getResourceTypes() + { + $deviceType = $this->game['sdk_version'] == 1 ? 'andriod' : 'ios'; + return $this->client->getResourceTypes($deviceType); + } + + public function getResources($typeId = null) + { + $deviceType = $this->game['sdk_version'] == 1 ? 'andriod' : 'ios'; + return $this->client->getResources($typeId, $deviceType); + } + + public function apply($order, $role) + { + return $this->client->apply($order, $role); + } +} \ No newline at end of file diff --git a/Application/Base/Tool/GameResource/JtxcClient.class.php b/Application/Base/Tool/GameResource/JtxcClient.class.php new file mode 100644 index 000000000..1368fcbe4 --- /dev/null +++ b/Application/Base/Tool/GameResource/JtxcClient.class.php @@ -0,0 +1,156 @@ + ['uri' => '/api/game/sendGold/zhuimeng/jxlm/53334', 'method' => 'post'], + ]; + + public function __construct() + { + $this->client = new Client([ + 'base_uri' => 'http://chat.leniu.com', + 'timeout' => 10.0, + ]); + } + + public function api($api, array $params = []) + { + $api = $this->apis[$api] ?? null; + if (is_null($api)) { + throw new \Exception('接口不存在'); + } + $params[self::SIGN_NAME] = $this->sign($params); + try { + return $this->request($api, $params); + } catch (\Exception $e) { + $env = C('APP_ENV', null, 'prod'); + return ['code' => 1000, 'state' => 1000, 'message' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []]; + } + } + + public function request($api, $params) + { + if ($api['method'] == 'get') { + return $this->get($api['uri'], $params); + } else { + return $this->post($api['uri'], $params); + } + } + + protected function post($uri, array $params = []) + { + $response = $this->client->post($uri, [ + 'verify' => false, + 'form_params' => $params, + ]); + $result = (string)$response->getBody(); + return json_decode($result, true); + } + + protected function get($uri, array $params = []) + { + $response = $this->client->get($uri, [ + 'verify' => false, + 'query' => $params, + ]); + $result = (string)$response->getBody(); + return json_decode($result, true); + } + + protected function sign($params) + { + unset($params[self::SIGN_NAME]); + ksort($params); + $signRows = []; + foreach ($params as $key => $value) { + $signRows[] = $key . '=' . $value; + } + return md5(implode('&', $signRows) . self::KEY); + } + + public function apply($order, $role) + { + $result = $this->api('provide', [ + 'role_id' => $role['role_id'], + 'money' => intval($order['ref_amount']), + 'type' => 2, + // 'goods_id' => 0, + 'server_no' => $role['user_account'], + ]); + if ($result['state'] == 1 && $result['data']) { + return [ + 'status' => true, + 'message' => $result['msg'], + 'result' => $result + ]; + } else { + return [ + 'status' => false, + 'message' => $result['msg'], + 'result' => $result ?? [] + ]; + } + } + + public function getResourceTypes($deviceType) + { + if ($deviceType == 'andriod') { + return ['id' => 1, 'name' => '通用', 'device_type' => 'andriod']; + } elseif ($deviceType == 'ios') { + return ['id' => 2, 'name' => '通用', 'device_type' => 'ios']; + } + } + + public function getResources($typeId, $deviceType) + { + return [ + ['ref_id' => 1, 'name' => '60元宝', 'amount' => 6], + ['ref_id' => 2, 'name' => '300元宝', 'amount' => 30], + ['ref_id' => 3, 'name' => '980元宝', 'amount' => 98], + ['ref_id' => 4, 'name' => '1280元宝', 'amount' => 128], + ['ref_id' => 5, 'name' => '1980元宝', 'amount' => 198], + ['ref_id' => 6, 'name' => '3280元宝', 'amount' => 328], + ['ref_id' => 7, 'name' => '6480元宝', 'amount' => 648], + ['ref_id' => 8, 'name' => '10000元宝', 'amount' => 1000], + ['ref_id' => 9, 'name' => '20000元宝', 'amount' => 2000], + ['ref_id' => 10, 'name' => '30000元宝', 'amount' => 3000], + ['ref_id' => 11, 'name' => '50000元宝', 'amount' => 5000], + ['ref_id' => 12, 'name' => '100000元宝', 'amount' => 10000], + ['ref_id' => 13, 'name' => '200000元宝', 'amount' => 20000], + ['ref_id' => 14, 'name' => '680元宝', 'amount' => 68], + ]; + + /* return [ + ['ref_id' => 121209, 'name' => '6元充值卡', 'amount' => 6], + ['ref_id' => 121210, 'name' => '30元充值卡', 'amount' => 30], + ['ref_id' => 121211, 'name' => '98元充值卡', 'amount' => 98], + ['ref_id' => 121212, 'name' => '128元充值卡', 'amount' => 128], + ['ref_id' => 121213, 'name' => '198元充值卡', 'amount' => 198], + ['ref_id' => 121214, 'name' => '328元充值卡', 'amount' => 328], + ['ref_id' => 121215, 'name' => '648元充值卡', 'amount' => 648], + ['ref_id' => 121216, 'name' => '1000元充值卡', 'amount' => 1000], + ['ref_id' => 121217, 'name' => '2000元充值卡', 'amount' => 2000], + ['ref_id' => 121218, 'name' => '3000元充值卡', 'amount' => 3000], + ['ref_id' => 121219, 'name' => '5000元充值卡', 'amount' => 5000], + ['ref_id' => 121220, 'name' => '10000元充值卡', 'amount' => 10000], + ['ref_id' => 121221, 'name' => '20000元充值卡', 'amount' => 20000], + ['ref_id' => 121222, 'name' => '68元充值卡', 'amount' => 68], + ]; */ + } +} \ No newline at end of file diff --git a/Application/Base/Tool/GameResource/LsxxClient.class.php b/Application/Base/Tool/GameResource/LsxxClient.class.php new file mode 100644 index 000000000..73950cde1 --- /dev/null +++ b/Application/Base/Tool/GameResource/LsxxClient.class.php @@ -0,0 +1,135 @@ + ['uri' => '/wanmeng/prop.php', 'method' => 'get'], + 'provide' => ['uri' => '/wanmeng/prop.php?action=prop', 'method' => 'post'], + ]; + + public function __construct() + { + $this->client = new Client([ + 'base_uri' => 'http://47.114.91.166:1096', + 'timeout' => 10.0, + ]); + } + + public function api($api, array $params = []) + { + $api = $this->apis[$api] ?? null; + if (is_null($api)) { + throw new \Exception('接口不存在'); + } + $params[self::SIGN_NAME] = $this->sign($params); + try { + return $this->request($api, $params); + } catch (\Exception $e) { + $env = C('APP_ENV', null, 'prod'); + return ['code' => 1000, 'state' => 1000, 'message' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []]; + } + } + + public function request($api, $params) + { + if ($api['method'] == 'get') { + return $this->get($api['uri'], $params); + } else { + return $this->post($api['uri'], $params); + } + } + + protected function post($uri, array $params = []) + { + $response = $this->client->post($uri, [ + 'verify' => false, + 'form_params' => $params, + ]); + $result = (string)$response->getBody(); + return json_decode($result, true); + } + + protected function get($uri, array $params = []) + { + $response = $this->client->get($uri, [ + 'verify' => false, + 'query' => $params, + ]); + $result = (string)$response->getBody(); + return json_decode($result, true); + } + + protected function sign($params) + { + unset($params[self::SIGN_NAME]); + ksort($params); + $signRows = []; + foreach ($params as $key => $value) { + $signRows[] = $key . '=' . $value; + } + return md5(implode('&', $signRows) . self::KEY); + } + + public function apply($order, $role) + { + $result = $this->api('provide', [ + 'role_id' => $role['role_id'], + 'money' => intval($order['ref_amount']), + 'goods_id' => $order['ref_id'], + 'server_no' => $role['user_account'], + 'send_time' => time() + ]); + if ($result['status'] == 1) { + return [ + 'status' => true, + 'message' => $result['msg'], + 'result' => $result + ]; + } else { + return [ + 'status' => false, + 'message' => $result['msg'], + 'result' => $result ?? [] + ]; + } + } + + public function getResourceTypes($deviceType) + { + if ($deviceType == 'andriod') { + return ['id' => 1, 'name' => '通用', 'device_type' => 'andriod']; + } elseif ($deviceType == 'ios') { + return ['id' => 2, 'name' => '通用', 'device_type' => 'ios']; + } + } + + public function getResources($typeId, $deviceType) + { + $resources = []; + $result = $this->api('get-pay-type', ['action' => 'getItems']); + if ($result['status'] == 1) { + $items = $result['data']; + foreach ($items as $item) { + $resources[$item['id']] = [ + 'ref_id' => $item['id'], + 'name' => $item['name'], + 'amount' => $item['money'], + ]; + } + } + return $resources; + } +} \ No newline at end of file diff --git a/Application/Base/Tool/GameCatClient.class.php b/Application/Base/Tool/GameResource/YzchzbClient.class.php similarity index 59% rename from Application/Base/Tool/GameCatClient.class.php rename to Application/Base/Tool/GameResource/YzchzbClient.class.php index 594c1964c..36f6c86ea 100644 --- a/Application/Base/Tool/GameCatClient.class.php +++ b/Application/Base/Tool/GameResource/YzchzbClient.class.php @@ -1,14 +1,14 @@ $params, ]); $result = (string)$response->getBody(); - /* var_dump($uri); - var_dump($params); - var_dump($result); */ return json_decode($result, true); } @@ -105,4 +102,57 @@ class GameCatClient // var_dump(implode('&', $signRows)); return md5(implode('&', $signRows)); } + + public function apply($order, $role) + { + $result = $this->api('provide', [ + 'roleId' => $role['role_id'], + 'amount' => intval($order['ref_amount']), + 'supportItem' => $order['ref_id'], + 'supportType' => '0', + 'channelUid' => $role['user_account'], + 'applyRemark' => $order['remark'] == '' ? '测试资源申请' : $order['remark'], + 'applyId' => $order['order_no'], + 'device_type' => $role['sdk_version'] == 1 ? 'andriod' : 'ios', + ]); + if ($result['state'] == 1 && $result['data']) { + return [ + 'status' => true, + 'message' => $result['msg'], + 'result' => $result + ]; + } else { + return [ + 'status' => false, + 'message' => $result['msg'], + 'result' => $result ?? [] + ]; + } + } + + public function getResourceTypes($deviceType) + { + if ($deviceType == 'andriod') { + return ['id' => 1, 'name' => '通用', 'device_type' => 'andriod']; + } elseif ($deviceType == 'ios') { + return ['id' => 2, 'name' => '通用', 'device_type' => 'ios']; + } + } + + public function getResources($typeId, $deviceType) + { + $resources = []; + $result = $this->api('get-pay-type', ['device_type' => $deviceType]); + if ($result['state'] == 1) { + $items = $result['data']; + foreach ($items as $item) { + $resources[$item['supportItem']] = [ + 'ref_id' => $item['supportItem'], + 'name' => $item['content'], + 'amount' => $item['amount'], + ]; + } + } + return $resources; + } } \ No newline at end of file diff --git a/Application/Home/Controller/TestingResourceController.class.php b/Application/Home/Controller/TestingResourceController.class.php index 37ca7a3fa..d519c6a15 100644 --- a/Application/Home/Controller/TestingResourceController.class.php +++ b/Application/Home/Controller/TestingResourceController.class.php @@ -6,7 +6,6 @@ namespace Home\Controller; use Base\Model\PromoteModel; use Base\Service\PromoteService; use OSS\Core\OssException; -use Base\Tool\GameCatClient; use Think\Model; use Base\Service\TestingResourceService; use Base\Repository\TestingResourceRepository; @@ -21,10 +20,10 @@ class TestingResourceController extends BaseController $loginPromote = $this->getLoginPromote(); $repository = new TestingResourceRepository(); - $query = $repository->getTestingUsersQuery($params, $loginPromote); + $query = $repository->getTestingRolesQuery($params, $loginPromote); [$roles, $pagination, $count] = $this->paginate($query); - $records = $repository->makeTestingUserRecords($roles); + $records = $repository->makeTestingRoleRecords($roles); $gameRepository = new GameRepository(); @@ -36,6 +35,25 @@ class TestingResourceController extends BaseController $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(); diff --git a/Data/update.sql b/Data/update.sql index badd46a76..76b9e30db 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -2706,4 +2706,11 @@ CREATE TABLE `tab_testing_game_setting` ( ALTER TABLE `tab_promote_grade_setting` ADD COLUMN `base_game_id` int(11) not NULL DEFAULT 0 COMMENT '游戏ID' AFTER `name`, ADD COLUMN `month_begin` int(11) not NULL DEFAULT 0 COMMENT '规则截止月份' AFTER `base_game_id`, -ADD COLUMN `month_end` int(11) not NULL DEFAULT 0 COMMENT '规则开始月份' AFTER `month_begin`; \ No newline at end of file +ADD COLUMN `month_end` int(11) not NULL DEFAULT 0 COMMENT '规则开始月份' AFTER `month_begin`; + +ALTER TABLE `tab_testing_user` +ADD COLUMN `verify_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '审核状态' AFTER `status`; +ALTER TABLE `tab_testing_user` +ADD COLUMN `verify_time` int(11) NOT NULL DEFAULT 0 COMMENT '审核时间' AFTER `verify_status`; +ALTER TABLE `tab_testing_resource_batch` +ADD COLUMN `auto_verify` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否需要审核' AFTER `verify_status`; \ No newline at end of file From e1352fea1e7e71ccef2ab4bc62ea6ed713719138 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Wed, 11 Nov 2020 18:48:35 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/GameApiController.class.php | 42 +++++++++++++++++-- .../Service/TestingResourceService.class.php | 2 +- .../Tool/GameResource/JtxcClient.class.php | 27 ++++++------ .../Tool/GameResource/LsxxClient.class.php | 5 +-- 4 files changed, 55 insertions(+), 21 deletions(-) diff --git a/Application/Admin/Controller/GameApiController.class.php b/Application/Admin/Controller/GameApiController.class.php index 4968842e9..5980156ac 100644 --- a/Application/Admin/Controller/GameApiController.class.php +++ b/Application/Admin/Controller/GameApiController.class.php @@ -52,8 +52,22 @@ class GameApiController extends Think { public function send() { - $game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => 232])->find(); - $role = [ + // 229 + // 231 + $game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => 231])->find(); + // $gameResource1 = new GameResource($game); + /* $resources = $gameResource1->getResources(1); + return; */ + /* $successCount = 0; + for ($i = 0; $i < 10; $i ++) { + $resources = $gameResource1->getResources(1); + if (count($resources) > 0) { + $successCount ++; + } + } + var_dump($successCount); + return; */ + /* $role = [ 'role_id' => '6819493', 'user_account' => 'qh11102', 'sdk_version' => 1, @@ -63,9 +77,31 @@ class GameApiController extends Think { 'ref_id' => '8', 'remark' => '测试', 'order_no' => date('YmdHis') . rand(1000, 9999) . '_1', + ]; */ + $role = [ + 'role_id' => '9571794000008', + 'server_id' => '8', + 'sdk_version' => 1, + ]; + $order = [ + 'ref_id' => '9000', + 'remark' => '测试', + 'order_no' => date('YmdHis') . rand(1000, 9999) . '_1', + ]; + /* $role = [ + 'role_id' => '466500506', + 'server_id' => '49000152', + 'sdk_version' => 2, ]; + $order = [ + // 'ref_id' => '9000', + 'ref_amount' => 6, + 'order_no' => date('YmdHis') . rand(1000, 9999) . '_1', + ]; */ + $gameResource = new GameResource($game); - $result = $gameResource->getResources(); + // $result = $gameResource->getResources(); + $result = $gameResource->apply($order, $role); var_dump($result); } } diff --git a/Application/Base/Service/TestingResourceService.class.php b/Application/Base/Service/TestingResourceService.class.php index a4aa29bf7..2cde8bc1a 100644 --- a/Application/Base/Service/TestingResourceService.class.php +++ b/Application/Base/Service/TestingResourceService.class.php @@ -92,7 +92,7 @@ class TestingResourceService throw new \Exception('该游戏不支持发放测试资源'); } $role = M('user_play_info', 'tab_') - ->field(['id', 'role_id', 'user_id', 'promote_id', 'user_account', 'sdk_version']) + ->field(['id', 'role_id', 'user_id', 'promote_id', 'user_account', 'sdk_version', 'server_id']) ->where(['game_id' => $batch['game_id'], 'role_id' => $batch['role_id']]) ->find(); $orders = M('testing_resource_order', 'tab_') diff --git a/Application/Base/Tool/GameResource/JtxcClient.class.php b/Application/Base/Tool/GameResource/JtxcClient.class.php index 1368fcbe4..c02cdc089 100644 --- a/Application/Base/Tool/GameResource/JtxcClient.class.php +++ b/Application/Base/Tool/GameResource/JtxcClient.class.php @@ -17,8 +17,9 @@ class JtxcClient protected $client; + // http://chat.leniu.com/api/game/sendGold/zhuimeng/jxlm/57972 private $apis = [ - 'provide' => ['uri' => '/api/game/sendGold/zhuimeng/jxlm/53334', 'method' => 'post'], + 'provide' => ['uri' => '/api/game/sendGold/zhuimeng/jxlm/57972', 'method' => 'post'], ]; public function __construct() @@ -40,7 +41,7 @@ class JtxcClient return $this->request($api, $params); } catch (\Exception $e) { $env = C('APP_ENV', null, 'prod'); - return ['code' => 1000, 'state' => 1000, 'message' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []]; + return $e->getMessage(); } } @@ -59,8 +60,7 @@ class JtxcClient 'verify' => false, 'form_params' => $params, ]); - $result = (string)$response->getBody(); - return json_decode($result, true); + return (string)$response->getBody(); } protected function get($uri, array $params = []) @@ -69,10 +69,9 @@ class JtxcClient 'verify' => false, 'query' => $params, ]); - $result = (string)$response->getBody(); - return json_decode($result, true); + return (string)$response->getBody(); } - + protected function sign($params) { unset($params[self::SIGN_NAME]); @@ -88,22 +87,22 @@ class JtxcClient { $result = $this->api('provide', [ 'role_id' => $role['role_id'], - 'money' => intval($order['ref_amount']), + 'money' => intval($order['ref_amount']) * 10, 'type' => 2, // 'goods_id' => 0, - 'server_no' => $role['user_account'], + 'server_no' => $role['server_id'], ]); - if ($result['state'] == 1 && $result['data']) { + if ($result == 'SUCCESS') { return [ 'status' => true, - 'message' => $result['msg'], - 'result' => $result + 'message' => $result, + 'result' => ['result' => $result] ]; } else { return [ 'status' => false, - 'message' => $result['msg'], - 'result' => $result ?? [] + 'message' => $result, + 'result' => ['result' => $result] ]; } } diff --git a/Application/Base/Tool/GameResource/LsxxClient.class.php b/Application/Base/Tool/GameResource/LsxxClient.class.php index 73950cde1..ee4742559 100644 --- a/Application/Base/Tool/GameResource/LsxxClient.class.php +++ b/Application/Base/Tool/GameResource/LsxxClient.class.php @@ -39,7 +39,7 @@ class LsxxClient return $this->request($api, $params); } catch (\Exception $e) { $env = C('APP_ENV', null, 'prod'); - return ['code' => 1000, 'state' => 1000, 'message' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []]; + return ['status' => 0, 'msg' => '接口请求错误。' . ($env == 'prod' ? '' : $e->getMessage()) , 'data' => []]; } } @@ -87,9 +87,8 @@ class LsxxClient { $result = $this->api('provide', [ 'role_id' => $role['role_id'], - 'money' => intval($order['ref_amount']), 'goods_id' => $order['ref_id'], - 'server_no' => $role['user_account'], + 'server_no' => $role['server_id'], 'send_time' => time() ]); if ($result['status'] == 1) { From 47ca2f2b9e36c03ba7783747792fb23df2b70f3f Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Thu, 12 Nov 2020 10:18:34 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TestingResourceController.class.php | 24 +++++++---- .../Admin/View/TestingResource/apply.html | 2 +- .../Tool/GameResource/JtxcClient.class.php | 4 +- .../Tool/GameResource/LsxxClient.class.php | 4 +- .../TestingResourceController.class.php | 42 ++++++++----------- .../View/default/TestingResource/apply.html | 2 +- 6 files changed, 40 insertions(+), 38 deletions(-) diff --git a/Application/Admin/Controller/TestingResourceController.class.php b/Application/Admin/Controller/TestingResourceController.class.php index 176df005f..cef4675da 100644 --- a/Application/Admin/Controller/TestingResourceController.class.php +++ b/Application/Admin/Controller/TestingResourceController.class.php @@ -295,7 +295,6 @@ class TestingResourceController extends ThinkController ->find(); } - $hasItf = 0; $servers = []; @@ -464,17 +463,28 @@ class TestingResourceController extends ThinkController public function getResourceTypes() { $gameId = I('game_id', 0); - $testingResourceService = new TestingResourceService(); - $resourceTypes = $testingResourceService->getResourceTypes($gameId); - return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]); + $game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => $gameId])->find(); + try { + $testingResourceService = new TestingResourceService(); + $resourceTypes = $testingResourceService->getResourceTypes($game); + return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]); + } catch (\Throwable $e) { + return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage(), 'data' => ['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]]); + $gameId = I('game_id', 0); + $game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => $gameId])->find(); + try { + $testingResourceService = new TestingResourceService(); + $resources = $testingResourceService->getResources($game, $typeId); + return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resources' => $resources]]); + } catch (\Throwable $e) { + return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage(), 'data' => ['resources' => []]]); + } } public function exportOrders() diff --git a/Application/Admin/View/TestingResource/apply.html b/Application/Admin/View/TestingResource/apply.html index 1a7211ef0..fcf471233 100644 --- a/Application/Admin/View/TestingResource/apply.html +++ b/Application/Admin/View/TestingResource/apply.html @@ -365,7 +365,7 @@ body { $.ajax({ url: "{:U('getResources')}", type: "post", - data: { type_id: typeId }, + data: { game_id: globalGameId, type_id: typeId }, dataType: 'json', success: function(result){ if (result.status == 1) { diff --git a/Application/Base/Tool/GameResource/JtxcClient.class.php b/Application/Base/Tool/GameResource/JtxcClient.class.php index c02cdc089..628bc97cd 100644 --- a/Application/Base/Tool/GameResource/JtxcClient.class.php +++ b/Application/Base/Tool/GameResource/JtxcClient.class.php @@ -110,9 +110,9 @@ class JtxcClient public function getResourceTypes($deviceType) { if ($deviceType == 'andriod') { - return ['id' => 1, 'name' => '通用', 'device_type' => 'andriod']; + return [['id' => 1, 'name' => '通用', 'device_type' => 'andriod']]; } elseif ($deviceType == 'ios') { - return ['id' => 2, 'name' => '通用', 'device_type' => 'ios']; + return [['id' => 2, 'name' => '通用', 'device_type' => 'ios']]; } } diff --git a/Application/Base/Tool/GameResource/LsxxClient.class.php b/Application/Base/Tool/GameResource/LsxxClient.class.php index ee4742559..733ee7595 100644 --- a/Application/Base/Tool/GameResource/LsxxClient.class.php +++ b/Application/Base/Tool/GameResource/LsxxClient.class.php @@ -109,9 +109,9 @@ class LsxxClient public function getResourceTypes($deviceType) { if ($deviceType == 'andriod') { - return ['id' => 1, 'name' => '通用', 'device_type' => 'andriod']; + return [['id' => 1, 'name' => '通用', 'device_type' => 'andriod']]; } elseif ($deviceType == 'ios') { - return ['id' => 2, 'name' => '通用', 'device_type' => 'ios']; + return [['id' => 2, 'name' => '通用', 'device_type' => 'ios']]; } } diff --git a/Application/Home/Controller/TestingResourceController.class.php b/Application/Home/Controller/TestingResourceController.class.php index d519c6a15..9f08d400b 100644 --- a/Application/Home/Controller/TestingResourceController.class.php +++ b/Application/Home/Controller/TestingResourceController.class.php @@ -34,25 +34,6 @@ class TestingResourceController extends BaseController $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() { @@ -223,17 +204,28 @@ class TestingResourceController extends BaseController public function getResourceTypes() { $gameId = I('game_id', 0); - $testingResourceService = new TestingResourceService(); - $resourceTypes = $testingResourceService->getResourceTypes($gameId); - return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]); + $game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => $gameId])->find(); + try { + $testingResourceService = new TestingResourceService(); + $resourceTypes = $testingResourceService->getResourceTypes($game); + return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]); + } catch (\Throwable $e) { + return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage(), 'data' => ['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]]); + $gameId = I('game_id', 0); + $game = M('game', 'tab_')->field(['id', 'sdk_version'])->where(['id' => $gameId])->find(); + try { + $testingResourceService = new TestingResourceService(); + $resources = $testingResourceService->getResources($game, $typeId); + return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resources' => $resources]]); + } catch (\Throwable $e) { + return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage(), 'data' => ['resources' => []]]); + } } public function getUserRoles() diff --git a/Application/Home/View/default/TestingResource/apply.html b/Application/Home/View/default/TestingResource/apply.html index 56e488239..4cf0b1050 100644 --- a/Application/Home/View/default/TestingResource/apply.html +++ b/Application/Home/View/default/TestingResource/apply.html @@ -318,7 +318,7 @@ $.ajax({ url: "{:U('getResources')}", type: "post", - data: { type_id: typeId }, + data: { game_id: globalGameId, type_id: typeId }, dataType: 'json', success: function(result){ if (result.status == 1) {