diff --git a/Application/Admin/Controller/PromoteController.class.php b/Application/Admin/Controller/PromoteController.class.php index 58900f04d..76e2b3537 100644 --- a/Application/Admin/Controller/PromoteController.class.php +++ b/Application/Admin/Controller/PromoteController.class.php @@ -443,7 +443,7 @@ class PromoteController extends ThinkController $data['withdraw_show'] = $_POST['withdraw_show']; $data['withdraw_done'] = $_POST['withdraw_done']; $data['can_view_recharge'] = $_POST['can_view_recharge']; - + $data['ts_over_apply'] = $_POST['ts_over_apply'] ?? 0; if (empty($pwd)) { unset($data['password']); } diff --git a/Application/Admin/View/Promote/edit.html b/Application/Admin/View/Promote/edit.html index 1e32f3003..2a6ee9578 100644 --- a/Application/Admin/View/Promote/edit.html +++ b/Application/Admin/View/Promote/edit.html @@ -332,6 +332,22 @@ + 1):?> + + 测试资源申请权限: + + + + + + 开启后该推广员有权限操作整个公会的测试资源查看与申请 + + + 备注: diff --git a/Application/Base/Repository/TestingResourceRepository.class.php b/Application/Base/Repository/TestingResourceRepository.class.php index 8df219f71..54fb1a003 100644 --- a/Application/Base/Repository/TestingResourceRepository.class.php +++ b/Application/Base/Repository/TestingResourceRepository.class.php @@ -95,8 +95,9 @@ class TestingResourceRepository if (!is_null($promote)) { $promoteService = new PromoteService(); + $permissionPromote = $promoteService->getTSPermPromote($promote); $subSql = M('user', 'tab_') - ->where('id=tab_testing_resource_batch.user_id and promote_id in (' . $promoteService->subInSql($promote) . ')') + ->where('id=tab_testing_resource_batch.user_id and promote_id in (' . $promoteService->subInSql($permissionPromote) . ')') ->select(false); $conditions['_string'] .= ' and exists (' . $subSql . ')'; @@ -530,14 +531,15 @@ class TestingResourceRepository $strCondition = '1=1'; $promoteService = new PromoteService(); - if ($promote) { - $visibleGameIds = $promoteService->getVisibleGameIds($promote); + $permissionPromote = $promoteService->getTSPermPromote($promote); + if ($permissionPromote) { + $visibleGameIds = $promoteService->getVisibleGameIds($permissionPromote); if (count($visibleGameIds) > 0) { $strCondition .= ' and game_id in (' . implode(',', $visibleGameIds) . ')'; } else { $strCondition .= ' and 1=0'; } - $strCondition .= ' and promote_id in (' . $promoteService->subInSql($promote) . ')'; + $strCondition .= ' and promote_id in (' . $promoteService->subInSql($permissionPromote) . ')'; } $gameIds = $this->getHadSettingGameIds(); diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php index 8bd829d15..bb7413388 100644 --- a/Application/Base/Service/PromoteService.class.php +++ b/Application/Base/Service/PromoteService.class.php @@ -1337,4 +1337,18 @@ class PromoteService { $siteConfig['keywords'] = C('channel_index.seo_keyword'); return $siteConfig; } + + /** + * 获取推广员实际拥有的测试资源数据操作范围(测试资源跨部门操作权限) + */ + public function getTSPermPromote($promote) + { + if (empty($promote)) { + return null; + } + if ($promote['ts_over_apply'] == 1) { + return $this->getTopPromote($promote); + } + return $promote; + } } \ No newline at end of file diff --git a/Application/Base/Service/TestingResourceService.class.php b/Application/Base/Service/TestingResourceService.class.php index 3ff9220af..08ea5bdf7 100644 --- a/Application/Base/Service/TestingResourceService.class.php +++ b/Application/Base/Service/TestingResourceService.class.php @@ -205,7 +205,8 @@ class TestingResourceService $strCondition = '1=1'; if ($promote) { $promoteService = new PromoteService(); - $strCondition .= ' and promote_id in (' . $promoteService->subInSql($promote) . ')'; + $permissionPromote = $promoteService->getTSPermPromote($promote); + $strCondition .= ' and promote_id in (' . $promoteService->subInSql($permissionPromote) . ')'; } $users = M('user', 'tab_')->field(['id', 'account'])->where(['account' => ['in', $newAccounts], '_string' => $strCondition])->select(); @@ -293,8 +294,9 @@ class TestingResourceService } $promoteService = new PromoteService(); + $permissionPromote = $promoteService->getTSPermPromote($promote); $testPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $testingRole['promote_id']])->find(); - if (is_null($testPromote) || ($promote && !$promoteService->isSubOrSelf($testPromote, $promote))) { + if (is_null($testPromote) || ($permissionPromote && !$promoteService->isSubOrSelf($testPromote, $permissionPromote))) { throw new \Exception('测试角色所属推广员异常'); } @@ -307,7 +309,7 @@ class TestingResourceService } $bindPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $bindRole['promote_id']])->find(); - if (is_null($bindPromote) || ($promote && !$promoteService->isSubOrSelf($bindPromote, $promote))) { + if (is_null($bindPromote) || ($permissionPromote && !$promoteService->isSubOrSelf($bindPromote, $permissionPromote))) { throw new \Exception('玩家账号所属推广员异常'); } @@ -357,7 +359,9 @@ class TestingResourceService $userAccount = $params['user_account'] ?? ''; $records = $params['records'] ?? []; - if ($promote && $promote['level'] > 2) { + $promoteService = new PromoteService(); + $permissionPromote = $promoteService->getTSPermPromote($promote); + if ($permissionPromote && $permissionPromote['level'] > 2) { throw new \Exception('权限不足'); } @@ -394,8 +398,6 @@ class TestingResourceService throw new \Exception('区服不存在'); } - $promoteService = new PromoteService(); - $role = M('user_play_info', 'tab_') ->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]) @@ -418,7 +420,7 @@ class TestingResourceService } $testPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $role['promote_id']])->find(); - if (is_null($testPromote) || ($promote && !$promoteService->isSubOrSelf($testPromote, $promote))) { + if (is_null($testPromote) || ($permissionPromote && !$promoteService->isSubOrSelf($testPromote, $permissionPromote))) { throw new \Exception('测试角色所属推广员异常'); } @@ -433,7 +435,7 @@ class TestingResourceService } $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))) { + if (is_null($bindPromote) || ($permissionPromote && !$promoteService->isSubOrSelf($bindPromote, $permissionPromote))) { throw new \Exception('绑定角色所属推广员异常'); } /* if ($testPromote['id'] != $bindPromote['id']) { diff --git a/Application/Home/View/default/Public/promote_base.html b/Application/Home/View/default/Public/promote_base.html index 26d93ead7..b292b77dd 100644 --- a/Application/Home/View/default/Public/promote_base.html +++ b/Application/Home/View/default/Public/promote_base.html @@ -125,7 +125,7 @@ 操作日志 - +