diff --git a/Application/Admin/Controller/GameApiController.class.php b/Application/Admin/Controller/GameApiController.class.php index 47fd29d50..d8b43e514 100644 --- a/Application/Admin/Controller/GameApiController.class.php +++ b/Application/Admin/Controller/GameApiController.class.php @@ -22,6 +22,6 @@ class GameApiController extends Think { public function getGameCatPayTypes() { $gameCatClient = new GameCatClient(); $result = $gameCatClient->api('get-pay-type'); - + var_dump($result); } } diff --git a/Application/Base/Tool/GameCatClient.class.php b/Application/Base/Tool/GameCatClient.class.php index 8204dbb3f..0b23bac3d 100644 --- a/Application/Base/Tool/GameCatClient.class.php +++ b/Application/Base/Tool/GameCatClient.class.php @@ -10,15 +10,24 @@ use GuzzleHttp\Exception\RequestException; */ class GameCatClient { - const SIGN_NAME = 'Sign'; + const SIGN_NAME = 'sign'; const SUCCESS = '0000'; protected $client; private $apis = [ - 'get-pay-type' => ['uri' => '/api/pay/GetPayType', 'method' => 'get'], - 'internal-pay' => ['uri' => '/api/pay/InternalPayOrder/yushi', 'method' => 'post'], - 'check-role' => ['uri' => '/api/pay/CheckActorID', 'method' => 'get'] + 'get-pay-type' => ['uri' => '/game/support/items/v1', 'method' => 'post'], + 'internal-pay' => ['uri' => '/game/support/provide/v1', 'method' => 'post'], + ]; + + private $appIds = [ + 'andriod' => 1746, + 'ios' => 1747, + ]; + + private $channelIds = [ + 'andriod' => 11595, + 'ios' => 11596, ]; public function __construct() @@ -35,6 +44,13 @@ class GameCatClient if (is_null($api)) { throw new \Exception('接口不存在'); } + $deviceType = 'andriod'; + if (isset($params['device_type'])) { + $deviceType = $params['device_type']; + unset($params['device_type']); + } + $params['appId'] = $this->appIds[$deviceType] ?? $this->appIds['andriod']; + $params['channelId'] = $this->channelIds[$deviceType] ?? $this->channelIds['andriod']; $params[self::SIGN_NAME] = $this->sign($params); try { diff --git a/Application/Home/Controller/TestingResourceController.class.php b/Application/Home/Controller/TestingResourceController.class.php index 06dc7680e..3f4b050d5 100644 --- a/Application/Home/Controller/TestingResourceController.class.php +++ b/Application/Home/Controller/TestingResourceController.class.php @@ -24,9 +24,7 @@ class TestingResourceController extends BaseController $loginPromote = $this->getLoginPromote(); $conditions = []; - $subConditions = [ - 'promote_id' => $loginPromote['id'], - ]; + $subConditions = []; if ($createTimeStart) { $subConditions['create_time'] = ['egt', strtotime($createTimeStart . ' 00:00:00')]; @@ -38,6 +36,9 @@ class TestingResourceController extends BaseController $subSql = M('testing_user', 'tab_')->field(['user_id'])->where($subConditions)->select(false); $strCondition = 'user_id in (' . $subSql . ')'; + $promoteService = new PromoteService(); + $strCondition .= ' and promote_id in (' . $promoteService->subInSql($loginPromote) . ')'; + if ($account) { $user = M('user', 'tab_')->field(['id'])->where('account like ' . $account . '%')->find(); if ($user) { @@ -74,17 +75,23 @@ class TestingResourceController extends BaseController $bindings = index_by_column('role_id', $bindings); $bindingRoleIds = array_column($bindings, 'bind_role_id'); if (count($bindings) > 0) { - $bindingRoles = M('user_play_info', 'tab_')->field(['id', 'role_name'])->where(['id' => ['in', $bindingRoleIds]])->select(); + $bindingRoles = M('user_play_info', 'tab_')->field(['id', 'role_id', 'role_name', 'user_account'])->where(['id' => ['in', $bindingRoleIds]])->select(); $bindingRoles = index_by_column('id', $bindingRoles); } } + if (count($bindingRoles) > 0) { + M('spend', 'tab_')->where(); + } + + $records = []; foreach ($roles as $role) { $user = $users[$role['user_id']] ?? null; $binding = $bindings[$role['id']] ?? null; $bindingRole = $binding && $bindingRoles[$binding['bind_role_id']] ? $bindingRoles[$binding['bind_role_id']] : null; $records[] = [ + 'id' => $role['id'], 'game_name' => $role['game_name'], 'server_name' => $role['server_name'], 'server_id' => $role['server_id'], @@ -94,7 +101,7 @@ class TestingResourceController extends BaseController 'role_name' => $role['role_name'], 'bind_user_account' => $bindingRole ? $bindingRole['user_account'] : '', 'bind_role_name' => $bindingRole ? $bindingRole['role_name'] : '', - 'base_quota' => $binding ? $binding['base_quota'] : 1200, + 'base_quota' => $binding ? $binding['base_quota'] : 0, 'other_quota' => $binding ? $binding['other_quota'] : 0, 'quota' => 0, 'verify_amount' => 0, @@ -128,7 +135,11 @@ class TestingResourceController extends BaseController $errorCount = 0; $successCount = 0; if (count($newAccounts)) { - $users = M('user', 'tab_')->field(['id', 'account'])->where(['account' => ['in', $newAccounts]])->select(); + + $promoteService = new PromoteService(); + $strCondition = 'promote_id in (' . $promoteService->subInSql($loginPromote) . ')'; + + $users = M('user', 'tab_')->field(['id', 'account'])->where(['account' => ['in', $newAccounts], '_string' => $strCondition])->select(); $errorAccounts = array_diff($newAccounts, array_column($users, 'account')); $errorCount = count($errorAccounts); foreach ($users as $user) { @@ -139,7 +150,6 @@ class TestingResourceController extends BaseController 'user_id' => $user['id'], 'user_account' => $user['account'], 'status' => 1, - 'promote_id' => $loginPromote['id'], 'create_time' => time(), 'update_time' => time(), ]; @@ -191,6 +201,48 @@ class TestingResourceController extends BaseController $query = M('testing_resource_batch', 'tab_')->where($conditions)->order('create_time desc')->select(); list($batches, $pagination, $count) = $this->paginate($query); + $records = []; + foreach ($batches as $batch) { + $records[] = [ + 'id' => $batch['id'], + 'batch_no' => $batch['batch_no'], + 'create_time' => date('Y-m-d H:i:s', $batch['create_time']), + 'game_name' => $batch['game_id'], + 'server_name' => $batch['server_id'], + 'role_name' => $batch['role_id'], + 'user_account' => $batch['user_id'], + 'user_phone' => $batch['batch_no'], + 'creator_account' => $batch['batch_no'], + 'history_provide_amount' => 0.00, + 'apply_amount' => $batch['apply_amount'], + 'provide_amount' => $batch['provide_amount'], + 'remark' => $batch['remark'], + 'verify_status_text' => $batch['verify_status'], + 'verify_time' => date('Y-m-d H:i:s', $batch['verify_time']), + 'status_text' => $batch['status'], + 'provide_status_text' => $batch['provide_status'], + 'provide_time' => date('Y-m-d H:i:s', $batch['provide_time']), + 'content' => $content, + ]; + } + + $this->assign('count', $count); + $this->assign('pagination', $pagination); + $this->assign('records', $records); + $this->display(); + } + + public function orders() + { + $batchId = I('batch_id', 0); + + $query = M('testing_resource_order', 'tab_')->where(['batch_id' => $batchId])->order('create_time desc')->select(); + list($orders, $pagination, $count) = $this->paginate($query); + + /** + * @todo + */ + $this->assign('count', $count); $this->assign('pagination', $pagination); $this->assign('records', $records); @@ -199,16 +251,31 @@ class TestingResourceController extends BaseController public function apply() { - $records = []; - $pagination = ''; + $roleId = I('role_id', 0); + + $role = null; + if ($roleId > 0) { + $role = M('user_play_info', 'tab_')->field(['id', 'role_id', 'user_id', 'game_id', 'server_id', 'user_account', 'role_name'])->where(['id' => $roleId])->find(); + } + + $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(['role_id' => $roleId])->find(); + if ($binding) { + $bindingRole = M('user_play_info', 'tab_')->field(['id', 'role_id', 'user_id', 'game_id', 'server_id', 'user_account', 'role_name'])->where(['id' => $binding['bind_role_id']])->find(); + } + } /** * @todo 目前固定游戏猫 */ $games = M('game', 'tab_')->field(['id' , 'game_name'])->where(['id' => ['in', [229, 230]]])->select(); $this->assign('games', $games); - $this->assign('records', $records); - $this->assign('pagination', $pagination); + $this->assign('servers', $servers); + $this->assign('bindingRole', $bindingRole); + $this->assign('role', $role); $this->display(); } @@ -311,56 +378,56 @@ class TestingResourceController extends BaseController public function bindRole() { - $testingUserId = I('testing_user_id', 0); $testingRoleId = I('testing_role_id', 0); - $bindUserId = I('bind_user_id', 0); $bindRoleId = I('bind_role_id', 0); - $bindUser = M('user', 'tab_')->field(['id', 'account'])->where(['id' => $bindUserId])->find(); - if (is_null($bindUser)) { - return $this->ajaxReturn(['status' => 0, 'message' => '用户不存在']); - } - - $testingUser = M('testing_user', 'tab_')->where(['user_id' => $testingUserId])->find(); - if (is_null($testingUser)) { - return $this->ajaxReturn(['status' => 0, 'message' => '测试账号不存在']); - } - $testingRole = M('user_play_info', 'tab_') - ->field(['id', 'role_id']) + ->field(['id', 'role_id', 'user_id']) ->where(['id' => $testingRoleId]) ->find(); if (is_null($testingRole)) { return $this->ajaxReturn(['status' => 0, 'message' => '测试账号角色不存在']); } + + $testingUser = M('testing_user', 'tab_')->where(['user_id' => $testingRole['user_id']])->find(); + if (is_null($testingUser)) { + return $this->ajaxReturn(['status' => 0, 'message' => '测试账号不存在']); + } + $bindRole = M('user_play_info', 'tab_') - ->field(['id', 'role_id']) + ->field(['id', 'role_id', 'user_id']) ->where(['id' => $bindRoleId]) ->find(); if (is_null($bindRole)) { return $this->ajaxReturn(['status' => 0, 'message' => '玩家角色不存在']); } - - $existBind = M('testing_user', 'tab_')->field(['id'])->where(['bind_user_id' => $bindUser['id']])->find(); + $bindIsTesting = M('testing_user', 'tab_')->where(['user_id' => $bindRole['user_id']])->find(); + if ($bindIsTesting) { + return $this->ajaxReturn(['status' => 0, 'message' => '该玩家账号为测试账号,无法绑定']); + } + + $existBind = M('testing_binding', 'tab_')->field(['id'])->where(['bind_role_id' => $bindRoleId])->find(); if ($existBind) { - return $this->ajaxReturn(['status' => 0, 'message' => '该玩家账号已被绑定']); + return $this->ajaxReturn(['status' => 0, 'message' => '该玩家角色已被绑定']); + } + + $testExistBind = M('testing_binding', 'tab_')->field(['id'])->where(['role_id' => $testingRoleId])->find(); + if ($testExistBind) { + return $this->ajaxReturn(['status' => 0, 'message' => '该测试账号角色已绑定有角色']); } - M('testing_user', 'tab_')->where(['user_id' => $testingUserId])->save([ + M('testing_binding', 'tab_')->add([ + 'user_id' => $testingRole['user_id'], 'role_id' => $testingRole['id'], - 'bind_user_id' => $bindUser['id'], - 'bind_user_account' => $bindUser['account'], - 'bind_role_id' => $bindRoleId, + 'bind_user_id' => $bindRole['user_id'], + 'bind_role_id' => $bindRole['id'], + 'create_time' => time(), + 'update_time' => time() ]); return $this->ajaxReturn(['status' => 1, 'message' => '绑定成功']); } - public function getRolesByUser() - { - - } - public function getServers() { $gameId = I('game_id', 0); @@ -382,8 +449,10 @@ class TestingResourceController extends BaseController /** * @todo 目前固定游戏猫 */ - if (in_array($gameId, [229, 230])) { + if ($gameId == 229) { $resourceTypes[] = ['id' => 1, 'name' => '通用']; + } elseif ($gameId == 230) { + $resourceTypes[] = ['id' => 2, 'name' => '通用']; } return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resourceTypes' => $resourceTypes]]); } @@ -397,8 +466,10 @@ class TestingResourceController extends BaseController /** * @todo 目前固定游戏猫资源类型ID */ - if ($typeId == 1) { - $resources = $this->getGameCatResources(); + if ($typeId == 2) { + $resources = $this->getGameCatResources('ios'); + } elseif ($typeId == 1) { + $resources = $this->getGameCatResources('andriod'); } return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['resources' => $resources]]); @@ -413,25 +484,29 @@ class TestingResourceController extends BaseController if (is_null($server)) { 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_name']) ->where(['user_account' => $userAccount, 'game_id' => $gameId, 'server_id' => $server['server_id']]) ->select(); - return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['roles' => $roles]]); + return $this->ajaxReturn(['status' => 1, 'message' => '获取成功', 'data' => ['roles' => $roles, 'is_testing_account' => $isTestingAccount]]); } - private function getGameCatResources() + private function getGameCatResources($deviceType) { $resources = []; $gameCatClient = new GameCatClient(); - $result = $gameCatClient->api('get-pay-type'); - if ($result['code'] == 1) { - $payTypeList = $result['paytypelist']; - foreach ($payTypeList as $item) { - $resources[$item['PayType']] = [ - 'ref_id' => $item['PayType'], - 'name' => $item['Text'], - 'amount' => $item['Amount'], + $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'], ]; } } diff --git a/Application/Home/View/default/TestingResource/apply.html b/Application/Home/View/default/TestingResource/apply.html index e0f176b39..9c09f1b07 100644 --- a/Application/Home/View/default/TestingResource/apply.html +++ b/Application/Home/View/default/TestingResource/apply.html @@ -88,30 +88,44 @@
- disabled> - +
- disabled> + + +
- + disabled>
- disabled> + + +
- + +
当前可用额度:1364 待审核额度:0
+ + +
@@ -169,20 +183,20 @@
- +
-
@@ -191,7 +205,10 @@ + + + + + + + \ No newline at end of file diff --git a/Application/Home/View/default/TestingResource/index.html b/Application/Home/View/default/TestingResource/index.html index 986f073dd..2cfa29770 100644 --- a/Application/Home/View/default/TestingResource/index.html +++ b/Application/Home/View/default/TestingResource/index.html @@ -212,7 +212,7 @@ @@ -292,13 +292,20 @@ $('#apply').click(function () { var title = '添加测试资源申请' - var url = "{:U('TestingResource/apply')}" + var url = "{:U('TestingResource/apply', '', '')}" + + var id = $('input[name=role_id]:checked').val() + console.log(id) + id = id == undefined ? 0 : id; + if (id > 0) { + url += '/role_id/' + id + } layer.open({ title: title, type: 2, content: [url , 'no'], - area: ['1000px', '550px'], + area: ['1000px', '600px'], zIndex: 250, scrollbar: false, }) diff --git a/Application/Home/View/default/TestingResource/orders.html b/Application/Home/View/default/TestingResource/orders.html index e69de29bb..9432b427f 100644 --- a/Application/Home/View/default/TestingResource/orders.html +++ b/Application/Home/View/default/TestingResource/orders.html @@ -0,0 +1,143 @@ + + + + + + + + + \ No newline at end of file diff --git a/Data/update.sql b/Data/update.sql index 782acec80..e3e73fa6d 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -2454,7 +2454,7 @@ CREATE TABLE `tab_testing_resource_order` ( `order_no` varchar(30) NOT NULL COMMENT '订单号', `ref_id` varchar(30) NOT NULL COMMENT '测试资源ID(第三方)', `ref_name` varchar(150) NOT NULL COMMENT '测试资源名称(第三方)', - `num` int(11) NOT NULL DEFAULT 0 COMMENT '申请数量' + `num` int(11) NOT NULL DEFAULT 0 COMMENT '申请数量', `amount` decimal(12, 2) not null default '0.00' comment '申请金额', `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '审核备注', PRIMARY KEY (`id`) @@ -2467,9 +2467,12 @@ CREATE TABLE `tab_testing_resource_batch` ( `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户ID', `server_id` int(11) NOT NULL DEFAULT '0' COMMENT '区服ID', `role_id` int(11) NOT NULL DEFAULT '0' COMMENT '角色ID', - `amount` decimal(12, 2) not null default '0.00' comment '申请金额', - `status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 待发放 1 已经发放 2 拒绝 3 异常', - `promote_id` int(11) not null default 0 COMMENT '推广员ID', + `role_id` int(11) NOT NULL DEFAULT '0' COMMENT '角色ID', + `apply_amount` decimal(12, 2) not null default '0.00' comment '申请金额', + `provide_amount` decimal(12, 2) not null default '0.00' comment '申请金额', + `provide_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 待发放 1 已经发放 2 拒绝 3 异常', + `provide_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '审核时间', + `apply_promote_id` int(11) NOT NULL DEFAULT '0' COMMENT '申请推广员ID', `verify_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0 未审核 1 审核通过 1 未审核通过', `verify_remark` varchar(255) NOT NULL DEFAULT '' COMMENT '审核备注', `verify_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '审核时间',