From ae9893d4f746c3a396d3de5f585f13af75f14bc7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 1 Jun 2022 10:25:24 +0800 Subject: [PATCH] 1 --- webapp/controller/TempToolsController.class.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/webapp/controller/TempToolsController.class.php b/webapp/controller/TempToolsController.class.php index 064cab90..24f64bbf 100644 --- a/webapp/controller/TempToolsController.class.php +++ b/webapp/controller/TempToolsController.class.php @@ -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 ));