From c7b90f54a66e2152c6712180e0a3c510a2275296 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Fri, 26 Mar 2021 19:30:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TestingResourceRepository.class.php | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Application/Base/Repository/TestingResourceRepository.class.php b/Application/Base/Repository/TestingResourceRepository.class.php index 2292640ff..7cb179e7e 100644 --- a/Application/Base/Repository/TestingResourceRepository.class.php +++ b/Application/Base/Repository/TestingResourceRepository.class.php @@ -411,10 +411,10 @@ class TestingResourceRepository } $spendItems = []; + $revGameIdMap = []; + $gameIdMap = []; if (count($bindingRoles) > 0) { $games = M('game', 'tab_')->field(['id', 'data_share'])->where(['id' => ['in', array_column($bindingRoles, 'game_id')]])->select(); - $revGameIdMap = []; - $gameIdMap = []; foreach ($games as $game) { if ($game['data_share'] == 1) { $baseGame = $gameRepository->getBaseGameByGameId($game['id'], $baseGames); @@ -428,7 +428,6 @@ class TestingResourceRepository $revGameIdMap[$game['id']] = $game['id']; } } - $spendOrWhere = []; foreach ($bindingRoles as $bindingRole) { $gameIds = $gameIdMap[$bindingRole['game_id']]; @@ -479,6 +478,7 @@ class TestingResourceRepository 'todayProvideRecords' => $todayProvideRecords, 'gameSettings' => $gameSettings, 'testingUsers' => $testingUsers, + 'revGameIdMap' => $revGameIdMap ]; } @@ -491,11 +491,11 @@ class TestingResourceRepository $gameSettings = $result['gameSettings']; $bindings = $result['bindings']; $bindingRoles = $result['bindingRoles']; + $revGameIdMap = $result['revGameIdMap']; $applyRecords = $result['applyRecords']; $provideRecords = $result['provideRecords']; $verifyRecords = $result['verifyRecords']; $todayProvideRecords = $result['todayProvideRecords']; - $gameSettings = index_by_column('base_game_id', $gameSettings); $gameRepository = new GameRepository(); $baseGames = $gameRepository->getBaseGames(); @@ -508,7 +508,12 @@ class TestingResourceRepository $bindingRole = null; $baseGame = $gameRepository->getBaseGameByGameId($role['game_id'], $baseGames); + $gameSetting = null; + if ($baseGame && isset($gameSettings[$baseGame['id']])) { + $gameSetting = $gameSettings[$baseGame['id']]; + } + $spendQuota = 0; if ($binding) { $gameIds = $gameRepository->getGameIdsByBaseGame($baseGame); foreach ($gameIds as $gameId) { @@ -518,14 +523,14 @@ class TestingResourceRepository break; } } - } - $gameSetting = null; - if ($baseGame && isset($gameSettings[$baseGame['id']])) { - $gameSetting = $gameSettings[$baseGame['id']]; - } - $spendQuota = $bindingRole && isset($spendItems[$bindingRole['game_role_id']]) ? $spendItems[$bindingRole['game_role_id']] : 0; - $quota = $gameSetting ? round($spendQuota * $gameSetting['rate'] / 100, 2) : 0; + if ($bindingRole) { + $mainGameId = $revGameIdMap[$binding['game_id']]; + $mainGameRoleId = $this->getGameRoleId($mainGameId, $binding['bind_role_id']); + $spendQuota = isset($spendItems[$mainGameRoleId]) ? $spendItems[$mainGameRoleId] : 0; + } + $quota = $gameSetting ? round($spendQuota * $gameSetting['rate'] / 100, 2) : 0; + } $statusText = '正常'; if (is_null($user) || is_null($testingUser)) {