diff --git a/Application/Admin/Controller/GameApiController.class.php b/Application/Admin/Controller/GameApiController.class.php index 0bb388ebd..bdb89b333 100644 --- a/Application/Admin/Controller/GameApiController.class.php +++ b/Application/Admin/Controller/GameApiController.class.php @@ -19,6 +19,14 @@ class GameApiController extends Think { C(api('Config/lists')); } + public function verify() + { + $batch = M('testing_resource_batch', 'tab_')->where(['id' => 3])->find(); + $service = new TestingResourceService(); + // $service->verify($batch); + $service->provide($batch); + } + public function provice() { $role = [ 'role_id' => '6810778', diff --git a/Application/Base/Service/TestingResourceService.class.php b/Application/Base/Service/TestingResourceService.class.php index d8cd58347..24bc4ce46 100644 --- a/Application/Base/Service/TestingResourceService.class.php +++ b/Application/Base/Service/TestingResourceService.class.php @@ -53,12 +53,16 @@ class TestingResourceService public function provide($batch) { + if ($batch['verify_status'] != 1) { + throw new \Exception('该申请未审核通过'); + } + if ($batch['provide_status'] != 0) { throw new \Exception('发放状态异常'); } $role = M('user_play_info', 'tab_') - ->field(['id', 'role_id', 'user_id', 'promote_id']) + ->field(['id', 'role_id', 'user_id', 'promote_id', 'user_account', 'sdk_version']) ->where(['game_id' => $batch['game_id'], 'role_id' => $batch['role_id']]) ->find(); $orders = M('testing_resource_order', 'tab_') @@ -75,9 +79,10 @@ class TestingResourceService if (!$result['status']) { $hasError = true; $orderData['provide_status'] = 2; + } else { + $orderData['provide_status'] = 1; } $provideAmount += round($order['ref_amount'] * $order['num'], 2); - $orderData['provide_status'] = 1; $orderData['provide_time'] = time(); M('testing_resource_order', 'tab_') ->where(['id' => $order['id']]) @@ -87,6 +92,8 @@ class TestingResourceService $batchData = []; if ($hasError) { $batchData['provide_status'] = 2; + } else { + $batchData['provide_status'] = 1; } $batchData['provide_time'] = time(); $batchData['provide_amount'] = $provideAmount; @@ -98,6 +105,22 @@ class TestingResourceService public function provideFromGameCat($order, $role) { + var_dump([ + 'roleId' => $role['role_id'], + 'amount' => $order['ref_amount'], + 'supportItem' => $order['ref_id'], + 'supportType' => '0', + 'channelUid' => $role['user_account'], + 'applyRemark' => $order['remark'], + 'applyId' => $order['order_no'], + 'device_type' => $role['sdk_version'] == 1 ? 'andriod' : 'ios', + ]); + return [ + 'status' => true, + 'message' => '发送成功', + 'code' => 1, + ]; + $gameCatClient = new GameCatClient(); $result = $gameCatClient->api('provide', [ 'roleId' => $role['role_id'], diff --git a/Application/Home/Controller/TestingResourceController.class.php b/Application/Home/Controller/TestingResourceController.class.php index ba98ac36b..07baaa1de 100644 --- a/Application/Home/Controller/TestingResourceController.class.php +++ b/Application/Home/Controller/TestingResourceController.class.php @@ -12,6 +12,10 @@ use Base\Service\TestingResourceService; class TestingResourceController extends BaseController { + private $gameBaseQuota = [ + 229 => 300, + 230 => 300, + ]; public function index() { @@ -180,8 +184,8 @@ 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'] : 0, - 'other_quota' => $binding ? $binding['other_quota'] : 0, + 'base_quota' => $this->gameBaseQuota[$role['game_id']] ?? 0, + 'other_quota' => $role['testing_other_quota'], 'quota' => $bindingRole && isset($spendItems[$bindingRole['game_role_id']]) ? $spendItems[$bindingRole['game_role_id']] : 0, 'verify_amount' => $verifyRecords[$role['game_role_id']] ?? 0, 'provide_amount' => $provideRecords[$role['game_role_id']] ?? 0, @@ -346,7 +350,7 @@ class TestingResourceController extends BaseController 'user_phone' => $user ? $user['phone'] : '', 'apply_promote_account' => $applyPromote ? $applyPromote['account'] : '', 'promote_account' => $promote['account'], - 'history_provide_amount' => 0.00, + // 'history_provide_amount' => 0.00, 'apply_amount' => $batch['apply_amount'], 'provide_amount' => $batch['provide_amount'], 'verify_status' => $batch['verify_status'], @@ -413,17 +417,20 @@ class TestingResourceController extends BaseController $this->display(); } - private function getRemainQuota($gameId, $bindRoleId, $testingRoleId) + private function getRemainQuota($role, $bindRole = null) { - $totalQuota = M('spend', 'tab_') - ->where(['game_id' => $gameId, 'game_player_id' => $bindRoleId]) - ->group('game_id,game_player_id') - ->sum('pay_amount'); + $totalQuota = $role['testing_other_quota'] + ($this->gameBaseQuota[$role['game_id']] ?? 0); + if (!is_null($bindRole)) { + $totalQuota += M('spend', 'tab_') + ->where(['game_id' => $role['game_id'], 'game_player_id' => $bindRole['role_id']]) + ->group('game_id,game_player_id') + ->sum('pay_amount'); + } $providedQuota = M('testing_resource_batch', 'tab_') - ->where(['provide_status' => [in, [1, 2]], 'game_id' => $gameId, 'role_id' => $testingRoleId]) + ->where(['provide_status' => [in, [1, 2]], 'game_id' => $role['game_id'], 'role_id' => $role['role_id']]) ->sum('provide_amount'); $providingQuota = M('testing_resource_batch', 'tab_') - ->where(['verify_status' => [in, [0, 1]], 'provide_status' => 0, 'game_id' => $gameId, 'role_id' => $testingRoleId]) + ->where(['verify_status' => [in, [0, 1]], 'provide_status' => 0, 'game_id' => $role['game_id'], 'role_id' => $role['role_id']]) ->sum('apply_amount'); return round(floatval($totalQuota) - floatval($providedQuota) - floatval($providingQuota), 2); } @@ -435,7 +442,7 @@ class TestingResourceController extends BaseController $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']) + ->field(['id', 'role_id', 'user_id', 'game_id', 'server_id', 'user_account', 'role_name', 'testing_other_quota']) ->where(['id' => $id]) ->find(); } @@ -461,7 +468,7 @@ class TestingResourceController extends BaseController $this->assign('servers', $servers); $this->assign('bindingRole', $bindingRole); $this->assign('role', $role); - $this->assign('quota', $this->getRemainQuota($bindingRole['game_id'], $bindingRole['role_id'], $role['role_id'])); + $this->assign('quota', $this->getRemainQuota($role, $bindingRole)); $this->display(); } @@ -487,9 +494,9 @@ class TestingResourceController extends BaseController } $binding = M('testing_binding', 'tab_')->where(['game_id' => $gameId, 'role_id' => $roleId])->find(); - if (is_null($binding)) { + /* if (is_null($binding)) { return $this->ajaxReturn(['status' => 0, 'message' => '该角色未绑定玩家角色']); - } + } */ $user = M('user', 'tab_')->field(['id', 'promote_id'])->where(['account' => $userAccount])->find(); if (is_null($user)) { @@ -508,31 +515,34 @@ class TestingResourceController extends BaseController $promoteService = new PromoteService(); $role = M('user_play_info', 'tab_') - ->field(['id', 'role_id', 'promote_id']) + ->field(['id', 'role_id', 'promote_id', 'game_id', 'testing_other_quota']) ->where(['user_id' => $user['id'], 'game_id' => $gameId, 'server_id' => $server['server_id'], 'role_id' => $roleId]) ->find(); if (is_null($role)) { return $this->ajaxReturn(['status' => 0, 'message' => '角色不存在']); } + $testPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $role['promote_id']])->find(); if (is_null($testPromote) || !$promoteService->isSubOrSelf($testPromote, $loginPromote)) { return $this->ajaxReturn(['status' => 0, 'message' => '测试角色所属推广员异常']); } - $bindingRole = M('user_play_info', 'tab_') - ->field(['id', 'role_id', 'user_id', 'promote_id', 'game_id']) - ->where(['game_id' => $gameId, 'role_id' => $binding['bind_role_id']]) - ->find(); - if (is_null($bindingRole)) { - return $this->ajaxReturn(['status' => 0, 'message' => '绑定玩家角色不存在']); - } - $bindPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $bindingRole['promote_id']])->find(); - if (is_null($bindPromote) || !$promoteService->isSubOrSelf($bindPromote, $loginPromote)) { - return $this->ajaxReturn(['status' => 0, 'message' => '绑定角色所属推广员异常']); - } - - if ($testPromote['id'] != $bindPromote['id']) { - return $this->ajaxReturn(['status' => 0, 'message' => '测试账号与玩家账号所属推广员不同']); + $bindingRole = null; + if ($binding) { + $bindingRole = M('user_play_info', 'tab_') + ->field(['id', 'role_id', 'user_id', 'promote_id', 'game_id']) + ->where(['game_id' => $gameId, 'role_id' => $binding['bind_role_id']]) + ->find(); + if (is_null($bindingRole)) { + return $this->ajaxReturn(['status' => 0, 'message' => '绑定玩家角色不存在']); + } + $bindPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $bindingRole['promote_id']])->find(); + if (is_null($bindPromote) || !$promoteService->isSubOrSelf($bindPromote, $loginPromote)) { + return $this->ajaxReturn(['status' => 0, 'message' => '绑定角色所属推广员异常']); + } + /* if ($testPromote['id'] != $bindPromote['id']) { + return $this->ajaxReturn(['status' => 0, 'message' => '测试账号与玩家账号所属推广员不同']); + } */ } $amount = 0; @@ -553,7 +563,7 @@ class TestingResourceController extends BaseController } } - $remainQuota = $this->getRemainQuota($bindingRole['game_id'], $bindingRole['role_id'], $role['role_id']); + $remainQuota = $this->getRemainQuota($role, $bindingRole); if ($amount > $remainQuota) { return $this->ajaxReturn(['status' => 0, 'message' => '额度不足']); } @@ -643,9 +653,9 @@ class TestingResourceController extends BaseController return $this->ajaxReturn(['status' => 0, 'message' => '玩家账号所属推广员异常']); } - if ($testPromote['id'] != $bindPromote['id']) { + /* if ($testPromote['id'] != $bindPromote['id']) { return $this->ajaxReturn(['status' => 0, 'message' => '玩家账号与测试账号非同一推广员']); - } + } */ $bindIsTesting = M('testing_user', 'tab_')->where(['user_id' => $bindRole['user_id']])->find(); if ($bindIsTesting) { diff --git a/Application/Home/View/default/Public/promote_base.html b/Application/Home/View/default/Public/promote_base.html index 1067b8c35..5bbbdbbe4 100644 --- a/Application/Home/View/default/Public/promote_base.html +++ b/Application/Home/View/default/Public/promote_base.html @@ -112,11 +112,13 @@ 操作日志 +