Merge pull request '修改测试资源跨区bug' (#247) from hotfix/testing_resource_over_bug into master

Reviewed-on: http://8.136.139.249:3000/wmtx/platform/pulls/247
master
廖金灵 4 years ago
commit 260ef91ce8

@ -13,7 +13,7 @@ use Base\Service\GameService;
class TestingResourceController extends ThinkController class TestingResourceController extends ThinkController
{ {
public function index() public function roles()
{ {
$params = I('get.'); $params = I('get.');
$gameId = $params['game_id'] ?? 0; $gameId = $params['game_id'] ?? 0;
@ -458,6 +458,7 @@ class TestingResourceController extends ThinkController
->find(); ->find();
if ($bindingRole) { if ($bindingRole) {
$bindingRole['binding_time'] = $binding['create_time']; $bindingRole['binding_time'] = $binding['create_time'];
$bindingRole['share_game_ids'] = $gameIds;
} }
} }
@ -467,7 +468,6 @@ class TestingResourceController extends ThinkController
$hasItf = $gameSetting ? $gameSetting['has_itf'] : 0; $hasItf = $gameSetting ? $gameSetting['has_itf'] : 0;
} }
$testingResourceService = new TestingResourceService(); $testingResourceService = new TestingResourceService();
$quota = $testingResourceService->getRemainQuota($role, $bindingRole); $quota = $testingResourceService->getRemainQuota($role, $bindingRole);

@ -692,7 +692,7 @@ body {
success: function(result){ success: function(result){
if (result.status == 1) { if (result.status == 1) {
layer.msg(result.message, function(){ layer.msg(result.message, function(){
parent.window.location.href = "{:U('index')}" parent.window.location.href = "{:U('roles')}"
}) })
} else { } else {
layer.msg(result.message) layer.msg(result.message)

@ -66,7 +66,7 @@
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script> <script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js"></script> <script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js"></script>
<div class="cf main-place top_nav_list navtab_list"> <div class="cf main-place top_nav_list navtab_list">
<h3 class="page_title">测试账号</h3> <h3 class="page_title">测试账号角色</h3>
</div> </div>
<div class="cf top_nav_list"> <div class="cf top_nav_list">
<!-- 高级搜索 --> <!-- 高级搜索 -->
@ -127,7 +127,7 @@
</select> </select>
</div> </div>
<div class="input-list"> <div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('TestingResource/index')}">搜索</a> <a class="sch-btn" href="javascript:;" id="search" url="{:U('TestingResource/roles')}">搜索</a>
</div> </div>
</div> </div>
</div> </div>
@ -273,7 +273,7 @@
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
//导航高亮 //导航高亮
highlight_subnav("{:U('TestingResource/index')}"); highlight_subnav("{:U('TestingResource/roles')}");
$(function(){ $(function(){
// 全局变量声明 // 全局变量声明
var base_quota = 0; var base_quota = 0;

@ -411,10 +411,27 @@ 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();
foreach ($games as $game) {
if ($game['data_share'] == 1) {
$baseGame = $gameRepository->getBaseGameByGameId($game['id'], $baseGames);
$gameIds = $gameRepository->getGameIdsByBaseGame($baseGame);
$gameIdMap[$game['id']] = $gameIds;
foreach ($gameIds as $gameId) {
$revGameIdMap[$gameId] = $game['id'];
}
} else {
$gameIdMap[$game['id']] = [$game['id']];
$revGameIdMap[$game['id']] = $game['id'];
}
}
$spendOrWhere = []; $spendOrWhere = [];
foreach ($bindingRoles as $bindingRole) { foreach ($bindingRoles as $bindingRole) {
$spendOrWhere[] = '(game_player_id="' . $bindingRole['role_id'] . '" and game_id=' . $bindingRole['game_id'] . ')'; $gameIds = $gameIdMap[$bindingRole['game_id']];
$spendOrWhere[] = '(game_player_id="' . $bindingRole['role_id'] . '" and game_id in (' . implode(',', $gameIds) . '))';
} }
$spendCondition = [ $spendCondition = [
'pay_status' => 1, 'pay_status' => 1,
@ -423,7 +440,7 @@ class TestingResourceRepository
$subBindingCondition = [ $subBindingCondition = [
'_string' => '_string' =>
'tab_testing_binding.bind_role_id = tab_spend.game_player_id and ' . 'tab_testing_binding.bind_role_id = tab_spend.game_player_id and ' .
'tab_testing_binding.game_id = tab_spend.game_id and ' . 'tab_testing_binding.bind_user_id = tab_spend.user_id and ' .
'UNIX_TIMESTAMP(FROM_UNIXTIME(tab_testing_binding.create_time, "%Y-%m-%d 00:00:00")) <= tab_spend.pay_time' 'UNIX_TIMESTAMP(FROM_UNIXTIME(tab_testing_binding.create_time, "%Y-%m-%d 00:00:00")) <= tab_spend.pay_time'
]; ];
$spendRepository = new SpendRepository(); $spendRepository = new SpendRepository();
@ -440,7 +457,13 @@ class TestingResourceRepository
->group('game_id,game_player_id') ->group('game_id,game_player_id')
->select(); ->select();
foreach ($spendList as $item) { foreach ($spendList as $item) {
$spendItems[$this->getGameRoleId($item['game_id'], $item['game_player_id'])] = $item['amount']; $mainGameId = $revGameIdMap[$item['game_id']];
$itemKey = $this->getGameRoleId($mainGameId, $item['game_player_id']);
if (isset($spendItems[$itemKey])) {
$spendItems[$itemKey] += $item['amount'];
} else {
$spendItems[$itemKey] = $item['amount'];
}
} }
} }
$gameSettings = $this->getGameSettings(); $gameSettings = $this->getGameSettings();
@ -455,6 +478,7 @@ class TestingResourceRepository
'todayProvideRecords' => $todayProvideRecords, 'todayProvideRecords' => $todayProvideRecords,
'gameSettings' => $gameSettings, 'gameSettings' => $gameSettings,
'testingUsers' => $testingUsers, 'testingUsers' => $testingUsers,
'revGameIdMap' => $revGameIdMap
]; ];
} }
@ -467,15 +491,14 @@ 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();
$records = []; $records = [];
foreach ($roles as $role) { foreach ($roles as $role) {
$user = $users[$role['user_id']] ?? null; $user = $users[$role['user_id']] ?? null;
@ -484,7 +507,13 @@ 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;
$quota = 0;
if ($binding) { if ($binding) {
$gameIds = $gameRepository->getGameIdsByBaseGame($baseGame); $gameIds = $gameRepository->getGameIdsByBaseGame($baseGame);
foreach ($gameIds as $gameId) { foreach ($gameIds as $gameId) {
@ -494,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) {
$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; $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)) {

@ -158,9 +158,9 @@ class TestingResourceService
$totalQuota = $role['testing_other_quota'] + ($gameSetting['base_quota'] ?? 0); $totalQuota = $role['testing_other_quota'] + ($gameSetting['base_quota'] ?? 0);
if (!is_null($bindRole)) { if (!is_null($bindRole)) {
$bindTime = $bindRole['binding_time'] ?? 0; $bindTime = $bindRole['binding_time'] ?? 0;
$gameIds = $bindRole['share_game_ids'];
$spendMap = [ $spendMap = [
'game_id' => $role['game_id'], 'game_id' => ['in', $gameIds],
'game_player_id' => $bindRole['role_id'], 'game_player_id' => $bindRole['role_id'],
'pay_status' => 1, 'pay_status' => 1,
'pay_time' => ['egt', strtotime(date('Y-m-d 00:00:00', $bindTime))] 'pay_time' => ['egt', strtotime(date('Y-m-d 00:00:00', $bindTime))]
@ -457,6 +457,7 @@ class TestingResourceService
if (is_null($bindingRole)) { if (is_null($bindingRole)) {
throw new \Exception('绑定玩家角色不存在'); throw new \Exception('绑定玩家角色不存在');
} }
$bindingRole['share_game_ids'] = $gameIds;
$bindingRole['binding_time'] = $binding['create_time']; $bindingRole['binding_time'] = $binding['create_time'];
$bindPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $bindingRole['promote_id']])->find(); $bindPromote = M('promote', 'tab_')->field(['id', 'chain'])->where(['id' => $bindingRole['promote_id']])->find();
if (is_null($bindPromote) || ($permissionPromote && !$promoteService->isSubOrSelf($bindPromote, $permissionPromote))) { if (is_null($bindPromote) || ($permissionPromote && !$promoteService->isSubOrSelf($bindPromote, $permissionPromote))) {

@ -154,6 +154,7 @@ class TestingResourceController extends BaseController
->find(); ->find();
if ($bindingRole) { if ($bindingRole) {
$bindingRole['binding_time'] = $binding['create_time']; $bindingRole['binding_time'] = $binding['create_time'];
$bindingRole['share_game_ids'] = $gameIds;
} }
} }

Loading…
Cancel
Save