From 485a607820cbbff2369ab164ef09ea74291f39eb Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 15 Jan 2024 17:32:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/Model/TaskStages.php | 2 +- application/project/controller/Project.php | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/application/common/Model/TaskStages.php b/application/common/Model/TaskStages.php index f45f035..33cce1a 100755 --- a/application/common/Model/TaskStages.php +++ b/application/common/Model/TaskStages.php @@ -136,7 +136,7 @@ class TaskStages extends CommonModel if ($endTime > $createTime) { $timeDifference = abs($endTime - $createTime); // 计算天数 - $days = $timeDifference / 86400; + $days = bcdiv($timeDifference,86400,2); $task['timeout']=$days.'天'; } diff --git a/application/project/controller/Project.php b/application/project/controller/Project.php index 79abb61..7de04f3 100755 --- a/application/project/controller/Project.php +++ b/application/project/controller/Project.php @@ -588,23 +588,26 @@ class Project extends BasicApi } $data=[]; foreach($select as $k=>$v){ - $find=Db::name('positioning')->where(['member_code'=>$v['member_code']])->whereDay('date')->order('date desc')->field('positioning,date,end_date')->find(); + $find=Db::name('positioning')->where(['member_code'=>$v['member_code']])->whereTime('date','today')->order('date desc')->field('positioning,date,end_date')->find(); $data[$k]=[ 'name'=>$v['name'], 'avatar'=>$v['avatar'], 'member_code'=>$v['member_code'], 'positioning'=>$find['positioning']??'', 'date'=>$find['date']??'', - 'end_date'=>'', + 'end_date'=>$find['end_date']??'', ]; - if($v['end_date']){ - $endTime = strtotime($v['end']); - $createTime = strtotime($v['end_date']); + if($find &&$find['end_date']){ + $createTime = strtotime($find['date']); + $endTime = strtotime($find['end_date']); if ($endTime > $createTime) { $timeDifference = abs($endTime - $createTime); - // 计算天数 - $days = $timeDifference / 60; - $data[$k]['end_date']=$days.'分钟'; + $days = bcdiv($timeDifference,60,2); + if($days>1){ + $data[$k]['stop_time']=$days.'分钟'; + }else{ + $data[$k]['stop_time']=$days.'秒'; + } } }