Merge branch 'feature/testing_resource_admin' of wmtx/platform into release

测试资源优化
master
廖金灵 4 years ago committed by Gogs
commit f1a3be41cc

@ -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);
}
}

@ -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'];
}

@ -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');

Loading…
Cancel
Save