master
ELF 4 years ago
parent 5c034c3c7b
commit c7b90f54a6

@ -411,10 +411,10 @@ class TestingResourceRepository
} }
$spendItems = []; $spendItems = [];
$revGameIdMap = [];
$gameIdMap = [];
if (count($bindingRoles) > 0) { if (count($bindingRoles) > 0) {
$games = M('game', 'tab_')->field(['id', 'data_share'])->where(['id' => ['in', array_column($bindingRoles, 'game_id')]])->select(); $games = M('game', 'tab_')->field(['id', 'data_share'])->where(['id' => ['in', array_column($bindingRoles, 'game_id')]])->select();
$revGameIdMap = [];
$gameIdMap = [];
foreach ($games as $game) { foreach ($games as $game) {
if ($game['data_share'] == 1) { if ($game['data_share'] == 1) {
$baseGame = $gameRepository->getBaseGameByGameId($game['id'], $baseGames); $baseGame = $gameRepository->getBaseGameByGameId($game['id'], $baseGames);
@ -428,7 +428,6 @@ class TestingResourceRepository
$revGameIdMap[$game['id']] = $game['id']; $revGameIdMap[$game['id']] = $game['id'];
} }
} }
$spendOrWhere = []; $spendOrWhere = [];
foreach ($bindingRoles as $bindingRole) { foreach ($bindingRoles as $bindingRole) {
$gameIds = $gameIdMap[$bindingRole['game_id']]; $gameIds = $gameIdMap[$bindingRole['game_id']];
@ -479,6 +478,7 @@ class TestingResourceRepository
'todayProvideRecords' => $todayProvideRecords, 'todayProvideRecords' => $todayProvideRecords,
'gameSettings' => $gameSettings, 'gameSettings' => $gameSettings,
'testingUsers' => $testingUsers, 'testingUsers' => $testingUsers,
'revGameIdMap' => $revGameIdMap
]; ];
} }
@ -491,11 +491,11 @@ class TestingResourceRepository
$gameSettings = $result['gameSettings']; $gameSettings = $result['gameSettings'];
$bindings = $result['bindings']; $bindings = $result['bindings'];
$bindingRoles = $result['bindingRoles']; $bindingRoles = $result['bindingRoles'];
$revGameIdMap = $result['revGameIdMap'];
$applyRecords = $result['applyRecords']; $applyRecords = $result['applyRecords'];
$provideRecords = $result['provideRecords']; $provideRecords = $result['provideRecords'];
$verifyRecords = $result['verifyRecords']; $verifyRecords = $result['verifyRecords'];
$todayProvideRecords = $result['todayProvideRecords']; $todayProvideRecords = $result['todayProvideRecords'];
$gameSettings = index_by_column('base_game_id', $gameSettings); $gameSettings = index_by_column('base_game_id', $gameSettings);
$gameRepository = new GameRepository(); $gameRepository = new GameRepository();
$baseGames = $gameRepository->getBaseGames(); $baseGames = $gameRepository->getBaseGames();
@ -508,7 +508,12 @@ class TestingResourceRepository
$bindingRole = null; $bindingRole = null;
$baseGame = $gameRepository->getBaseGameByGameId($role['game_id'], $baseGames); $baseGame = $gameRepository->getBaseGameByGameId($role['game_id'], $baseGames);
$gameSetting = null;
if ($baseGame && isset($gameSettings[$baseGame['id']])) {
$gameSetting = $gameSettings[$baseGame['id']];
}
$spendQuota = 0;
if ($binding) { if ($binding) {
$gameIds = $gameRepository->getGameIdsByBaseGame($baseGame); $gameIds = $gameRepository->getGameIdsByBaseGame($baseGame);
foreach ($gameIds as $gameId) { foreach ($gameIds as $gameId) {
@ -518,14 +523,14 @@ class TestingResourceRepository
break; 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; if ($bindingRole) {
$quota = $gameSetting ? round($spendQuota * $gameSetting['rate'] / 100, 2) : 0; $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 = '正常'; $statusText = '正常';
if (is_null($user) || is_null($testingUser)) { if (is_null($user) || is_null($testingUser)) {

Loading…
Cancel
Save