From afc95791d2a685d68d5eb92bc7dfe541593706cf Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Thu, 12 Nov 2020 12:07:16 +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 --- .../Controller/ConsoleController.class.php | 34 +++++++++++++++++++ .../TestingResourceRepository.class.php | 15 +++++++- .../Service/TestingResourceService.class.php | 2 +- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index c432bc5d5..85aaf0a88 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -600,4 +600,38 @@ class ConsoleController extends Think { // ARPU (当日充值金额/当日活跃用户数) // ARRPU (当日充值金额/当日充值用户数) } + + public function checkAndfreezeTestingUser() + { + $pageCount = 100; + $hasNext = true; + $lastId = 0; + do { + $testingUsers = M('testing_user', 'tab_') + ->where(['status' => ['in', [1, 2]], 'id' => ['gt', $lastId]]) + ->order('id asc') + ->limit($pageCount) + ->select(); + if (count($testingUser) < $pageCount) { + $hasNext = false; + } + $userIds = array_column($testingUsers, 'user_id'); + $users = M('user', 'tab_')->field(['id', 'login_time'])->where(['id' => ['in', $userIds]])->select(); + $users = index_by_column('id', $users); + $unloginLimitTime = 7 * 24 * 3600; + $unloginUserIds = []; + foreach ($testingUsers as $testingUser) { + $user = $users[$testingUser['user_id']] ?? null; + if ($user && (time() - $user['login_time']) > $unloginLimitTime) { + $unloginUserIds[] = $user['id']; + } + $lastId = $testingUser['id']; + } + if (count($unloginUserIds) > 0) { + M('testing_user', 'tab_')->where(['user_id' => ['in', $unloginUserIds]])->save([ + 'status' => 2 + ]); + } + } while($hasNext); + } } diff --git a/Application/Base/Repository/TestingResourceRepository.class.php b/Application/Base/Repository/TestingResourceRepository.class.php index f9315dc8f..0ee9bf1ca 100644 --- a/Application/Base/Repository/TestingResourceRepository.class.php +++ b/Application/Base/Repository/TestingResourceRepository.class.php @@ -300,7 +300,20 @@ class TestingResourceRepository 'pay_status' => 1, '_string' => '(' . implode(' or ', $spendOrWhere) . ')', ]; - $spendList = M('spend', 'tab_')->field('sum(pay_amount) amount, game_id, game_player_id')->where($spendCondition)->group('game_id,game_player_id')->select(); + $subBindingSql = M('testing_binding', 'tab_') + ->where([ + '_string' => + 'tab_testing_binding.role_id < tab_spend.game_player_id and ' . + 'tab_testing_binding.game_id < tab_spend.game_id and ' . + 'UNIX_TIMESTAMP(FROM_UNIXTIME(tab_testing_binding.create_time, "%Y-%m-%d 00:00:00")) < tab_spend.pay_time' + ]) + ->select(false); + $spendCondition['_string'] .= ' and exists(' . $subBindingSql . ')'; + $spendList = M('spend', 'tab_') + ->field('sum(pay_amount) amount, game_id, game_player_id') + ->where($spendCondition) + ->group('game_id,game_player_id') + ->select(); foreach ($spendList as $item) { $spendItems[$this->getGameRoleId($item['game_id'], $item['game_player_id'])] = $item['amount']; } diff --git a/Application/Base/Service/TestingResourceService.class.php b/Application/Base/Service/TestingResourceService.class.php index 9194c3500..73b20c737 100644 --- a/Application/Base/Service/TestingResourceService.class.php +++ b/Application/Base/Service/TestingResourceService.class.php @@ -157,7 +157,7 @@ class TestingResourceService 'game_id' => $role['game_id'], 'game_player_id' => $bindRole['role_id'], 'pay_status' => 1, - 'egt' => strtotime(date('Y-m-d 00:00:00', $bindTime)) + 'pay_time' => ['egt', strtotime(date('Y-m-d 00:00:00', $bindTime))] ]) ->group('game_id,game_player_id') ->sum('pay_amount');