This commit is contained in:
aozhiwei 2022-06-01 11:59:04 +08:00
parent 85917b3687
commit aa3075703a

View File

@ -43,7 +43,7 @@ class TempToolsController extends BaseController {
if ($i + 1 >= count($data)) {
break;
}
if ($data[$i]['start_time'] + $time < $data[$i + 1]['start_time']) {
if ($data[$i]['start_time'] + $time > $data[$i + 1]['start_time']) {
++$i;
++$sameTimes;
}
@ -66,4 +66,64 @@ class TempToolsController extends BaseController {
));
}
public function getRiskAccounts()
{
$accounts = array();
$conn = myself()->_getMysql('');
{
$count = 1000;
$rows = $conn->execQuery(
'SELECT * FROM t_rank_activity ' .
'WHERE type=:type AND channel=:channel AND value>=:value ' .
'ORDER BY value DESC, modifytime ASC ' .
"LIMIT ${count}",
array(
':type' => 1,
':channel' => 6516,
':value' => 600
)
);
$ranked = 1;
foreach ($rows as $row) {
array_push($accounts, array(
'account_id' => $row['account_id'],
'ranked' => $ranked
));
++$ranked;
}
}
$riskAccountHash = array();
foreach ($accounts as $account) {
$rows = SqlHelper::ormSelect(
$conn,
't_battle_record',
array(
'account_id' => $account['account_id']
)
);
$sessionChgTimes = 0;
$lastSessionId = '';
foreach ($rows as $row) {
$reqObj = json_decode($row['request'], true);
if ($lastSessionId) {
if ($lastSessionId != $reqObj['session_id']) {
++$sessionChgTimes;
$lastSessionId = $reqObj['session_id'];
}
} else {
$lastSessionId = $reqObj['session_id'];
}
}
$account['session_changed_times'] = $sessionChgTimes;
array_push($riskAccountHash, $account);
}
usort($riskAccountHash, function ($a, $b) {
return $a['session_changed_times'] < $b['session_changed_times'] ? -1 : 1;
});
echo 'account_id,rank,session_changed_times' . "\n";
foreach ($riskAccountHash as $account) {
echo $account['account_id'] . ',' . $account['ranked'] . ',' . $account['session_changed_times'] . "\n";
}
}
}