From aa3075703a95b7601ff4dffbd4d9331af049a0d4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 1 Jun 2022 11:59:04 +0800 Subject: [PATCH] 1 --- .../controller/TempToolsController.class.php | 62 ++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/webapp/controller/TempToolsController.class.php b/webapp/controller/TempToolsController.class.php index 471d0a7f..7c122f49 100644 --- a/webapp/controller/TempToolsController.class.php +++ b/webapp/controller/TempToolsController.class.php @@ -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"; + } + } + }