347 lines
11 KiB
PHP
347 lines
11 KiB
PHP
<?php
|
|
|
|
use phpcommon\SqlHelper;
|
|
|
|
class TempToolsController extends BaseController {
|
|
|
|
public function _handlePre()
|
|
{
|
|
parent::_handlePre();
|
|
}
|
|
|
|
public function getBattleData()
|
|
{
|
|
$targetId = getReqVal('target_id', '');
|
|
$time = getReqVal('time', '');
|
|
$conn = myself()->_getMysql($targetId);
|
|
$data = array();
|
|
$survivalTime = 0;
|
|
$sameTimes = 0;
|
|
$sessionChgTimes = 0;
|
|
{
|
|
$rows = SqlHelper::ormSelect(
|
|
$conn,
|
|
't_battle_record',
|
|
array(
|
|
'account_id' => $targetId
|
|
)
|
|
);
|
|
foreach ($rows as $row) {
|
|
$reqObj = json_decode($row['request'], true);
|
|
$reqObj['start_time'] = $reqObj['game_time'] -
|
|
$reqObj['alive_time']/1000;
|
|
$survivalTime += $reqObj['alive_time']/1000;
|
|
array_push($data, $reqObj);
|
|
}
|
|
}
|
|
usort($data, function ($a, $b) {
|
|
return $a['start_time'] < $b['start_time'] ? -1 : 1;
|
|
});
|
|
$lastSessionId = '';
|
|
{
|
|
for ($i = 0; $i < count($data); ++$i){
|
|
if ($i + 1 >= count($data)) {
|
|
break;
|
|
}
|
|
if ($data[$i]['start_time'] + $time > $data[$i + 1]['start_time']) {
|
|
++$i;
|
|
++$sameTimes;
|
|
}
|
|
if ($lastSessionId) {
|
|
if ($lastSessionId != $data[$i]['session_id']) {
|
|
++$sessionChgTimes;
|
|
$lastSessionId = $data[$i]['session_id'];
|
|
}
|
|
} else {
|
|
$lastSessionId = $data[$i]['session_id'];
|
|
}
|
|
}
|
|
}
|
|
myself()->_rspData(array(
|
|
'battle_times' => count($data),
|
|
'same_times' => $sameTimes,
|
|
'session_chg_times' => $sessionChgTimes,
|
|
'survival_time' => $survivalTime,
|
|
'data' => $data
|
|
));
|
|
}
|
|
|
|
public function exportRankActivity()
|
|
{
|
|
$type = getReqVal('type', '');
|
|
$count = getReqVal('count', '');
|
|
$cond = getReqVal('cond', 0);
|
|
$accounts = array();
|
|
$conn = myself()->_getMysql('');
|
|
{
|
|
$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' => $type,
|
|
':channel' => 6516,
|
|
':value' => $cond
|
|
)
|
|
);
|
|
$ranked = 1;
|
|
foreach ($rows as $row) {
|
|
array_push($accounts, array(
|
|
'account_id' => $row['account_id'],
|
|
'name' => '',
|
|
'ranked' => $ranked,
|
|
'score' => $row['value'],
|
|
'modifytime' => $row['modifytime']
|
|
));
|
|
++$ranked;
|
|
}
|
|
}
|
|
{
|
|
foreach ($accounts as &$account) {
|
|
$row = SqlHelper::ormSelectone(
|
|
$conn,
|
|
't_user',
|
|
array(
|
|
'account_id' => $account['account_id']
|
|
)
|
|
);
|
|
$account['name'] = $row['name'];
|
|
}
|
|
}
|
|
{
|
|
foreach ($accounts as &$account) {
|
|
$row = $conn->execQueryOne(
|
|
'SELECT MAX(hero_lv) AS max_hero_lv FROM t_hero WHERE account_id=:account_id',
|
|
array(
|
|
':account_id' => $account['account_id'],
|
|
)
|
|
);
|
|
$account['max_hero_lv'] = $row['max_hero_lv'];
|
|
}
|
|
}
|
|
{
|
|
foreach ($accounts as &$account) {
|
|
$row = $conn->execQueryOne(
|
|
'SELECT MAX(quality) AS max_hero_quality FROM t_hero WHERE account_id=:account_id',
|
|
array(
|
|
':account_id' => $account['account_id'],
|
|
)
|
|
);
|
|
$account['max_hero_quality'] = $row['max_hero_quality'];
|
|
}
|
|
}
|
|
echo 'account_id,name,rank,score,max_hero_lv,max_hero_quality,flag, time' . "\n";
|
|
foreach ($accounts as $account) {
|
|
$flag = 0;
|
|
if ($type == 3) {
|
|
$flag = $account['max_hero_lv'] != $account['score'] ? 1 : 0;
|
|
}
|
|
if ($type == 4) {
|
|
$flag = $account['max_hero_quality'] != $account['score'] ? 1 : 0;
|
|
}
|
|
echo
|
|
phpcommon\extractOpenId($account['account_id']) . ','
|
|
. $account['name'] . ','
|
|
. $account['ranked'] . ','
|
|
. $account['score'] . ','
|
|
. $account['max_hero_lv'] . ','
|
|
. $account['max_hero_quality'] . ','
|
|
. $flag . ','
|
|
. phpcommon\timestamp_to_datetime($account['modifytime'])
|
|
. "\n";
|
|
}
|
|
}
|
|
|
|
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";
|
|
}
|
|
}
|
|
|
|
public function exportData()
|
|
{
|
|
$type = getReqVal('type', '');
|
|
if ($type == 1) {
|
|
$this->exportData1();
|
|
} else if($type == 2) {
|
|
$this->exportData2();
|
|
} else if($type == 3) {
|
|
$this->exportData3();
|
|
} else if($type == 4) {
|
|
$this->exportData4();
|
|
}
|
|
}
|
|
|
|
public function exportData1()
|
|
{
|
|
$type = getReqVal('type', '');
|
|
$accounts = array();
|
|
$conn = myself()->_getMysql('');
|
|
{
|
|
$rows = $conn->execQuery(
|
|
'SELECT * FROM t_battle',
|
|
array(
|
|
)
|
|
);
|
|
echo 'account_id,first_battle_utc_time' . "\n";
|
|
foreach ($rows as $row) {
|
|
$channel = phpcommon\extractChannel($row['account_id']);
|
|
if ($channel == 6516) {
|
|
echo phpcommon\extractOpenId($row['account_id'])
|
|
. ',' . phpcommon\timestamp_to_datetime($row['createtime']) . "\n";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function exportData2()
|
|
{
|
|
$type = getReqVal('type', '');
|
|
$accounts = array();
|
|
$conn = myself()->_getMysql('');
|
|
{
|
|
$rows = $conn->execQuery(
|
|
'SELECT * FROM t_user',
|
|
array(
|
|
)
|
|
);
|
|
echo 'account_id' . "\n";
|
|
foreach ($rows as $row) {
|
|
$channel = phpcommon\extractChannel($row['account_id']);
|
|
if ($channel == 6516) {
|
|
echo $row['account_id'] . "\n";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function exportData3()
|
|
{
|
|
$type = getReqVal('type', '');
|
|
$accounts = array();
|
|
$conn = myself()->_getMysql('');
|
|
{
|
|
$rows = $conn->execQuery(
|
|
'SELECT * FROM t_dyndata WHERE x=:x AND y=:y',
|
|
array(
|
|
':x' => TN_ACTIVE,
|
|
':y' => 0,
|
|
)
|
|
);
|
|
echo 'account_id' . ",name,active>=10,active>=30,active>=50,active_value\n";
|
|
foreach ($rows as $row) {
|
|
$channel = phpcommon\extractChannel($row['account_id']);
|
|
if ($channel == 6516) {
|
|
$userDb = SqlHelper::ormSelectone(
|
|
$conn,
|
|
't_user',
|
|
array(
|
|
'account_id' => $row['account_id']
|
|
)
|
|
);
|
|
echo
|
|
$row['account_id'] . ','
|
|
. ($userDb ? $userDb['name'] : '') . ','
|
|
. ($row['val'] >= 10 && $row['val'] < 30 ? 1 :0) . ','
|
|
. ($row['val'] >= 30 && $row['val'] < 50 ? 1 :0) . ','
|
|
. ($row['val'] >= 50 ? 1 :0) . ','
|
|
. $row['val'] . ','
|
|
. "\n";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function exportData4()
|
|
{
|
|
$conn = myself()->_getMysql('');
|
|
$rows = $conn->execQuery(
|
|
'SELECT account_id, name FROM t_user',
|
|
array(
|
|
|
|
)
|
|
);
|
|
$data = array();
|
|
foreach ($rows as $row) {
|
|
$channel = phpcommon\extractChannel($row['account_id']);
|
|
if ($channel == BC_CHANNEL) {
|
|
$row2 = $conn->execQueryOne(
|
|
'SELECT count(*) AS battle_times FROM t_battle_record WHERE account_id=:account_id',
|
|
array(
|
|
':account_id' => $row['account_id']
|
|
)
|
|
);
|
|
$data[$row['account_id']] = array(
|
|
'account_id' => $row['account_id'],
|
|
'name' => $row['name'],
|
|
'battle_times' => $row2 ? $row2['battle_times'] : 0
|
|
);
|
|
}
|
|
}
|
|
echo 'account_id' . ",name,game_times\n";
|
|
foreach ($data as $item) {
|
|
echo
|
|
$item['account_id'] . ','
|
|
. $item['name'] . ','
|
|
. $item['battle_times']
|
|
. "\n";
|
|
}
|
|
}
|
|
|
|
}
|