game2006api/webapp/controller/TempToolsController.class.php
aozhiwei 1cf277742b 1
2022-06-01 09:54:09 +08:00

45 lines
1.2 KiB
PHP

<?php
use phpcommon\SqlHelper;
class TempToolsController extends BaseController {
public function _handlePre()
{
parent::_handlePre();
}
public function getBattleData()
{
$targetId = getReqVal('target_id', '');
$conn = myself()->_getMysql($targetId);
$data = array();
$survivalTime = 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'];
});
myself()->_rspData(array(
'battle_times' => count($data),
'survival_time' => $survivalTime,
'data' => $data
));
}
}