1
This commit is contained in:
parent
1cf277742b
commit
ae9893d4f7
@ -12,9 +12,11 @@ class TempToolsController extends BaseController {
|
||||
public function getBattleData()
|
||||
{
|
||||
$targetId = getReqVal('target_id', '');
|
||||
$time = getReqVal('time', '');
|
||||
$conn = myself()->_getMysql($targetId);
|
||||
$data = array();
|
||||
$survivalTime = 0;
|
||||
$sameTimes = 0;
|
||||
{
|
||||
$rows = SqlHelper::ormSelect(
|
||||
$conn,
|
||||
@ -32,10 +34,22 @@ class TempToolsController extends BaseController {
|
||||
}
|
||||
}
|
||||
usort($data, function ($a, $b) {
|
||||
return $a['start_time'] < $b['start_time'];
|
||||
return $a['start_time'] < $b['start_time'] ? -1 : 1;
|
||||
});
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
myself()->_rspData(array(
|
||||
'battle_times' => count($data),
|
||||
'same_times' => $sameTimes,
|
||||
'survival_time' => $survivalTime,
|
||||
'data' => $data
|
||||
));
|
||||
|
Loading…
x
Reference in New Issue
Block a user