From 96e7913ae4246e394c1e5daca05de7bc03032f17 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Tue, 14 Feb 2023 10:47:34 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=B6=E9=97=B4=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/ProjectTask.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/Models/ProjectTask.php b/app/Models/ProjectTask.php index 202eb6378..baba314d0 100644 --- a/app/Models/ProjectTask.php +++ b/app/Models/ProjectTask.php @@ -764,10 +764,11 @@ class ProjectTask extends AbstractModel }); } $newStringAt = $this->start_at ? ($this->start_at->toDateTimeString() . '~' . $this->end_at->toDateTimeString()) : ''; - $this->addLog("修改{任务}时间" . ($desc ? "(备注:{$desc})" : ""), [ + $newDesc = $desc ? "(备注:{$desc})" : ""; + $this->addLog("修改{任务}时间" . $newDesc, [ 'change' => [$oldStringAt, $newStringAt] ]); - $this->taskPush(null, 3); + $this->taskPush(null, 3, $newDesc); } // 以下仅顶级任务可修改 if ($this->parent_id === 0) { @@ -1435,12 +1436,13 @@ class ProjectTask extends AbstractModel * 任务提醒 * @param $userids * @param int $type 0-新任务、1-即将超时、2-已超时、3-修改时间 + * @param string $suffix 描述后缀 * @return void */ - public function taskPush($userids, int $type) + public function taskPush($userids, int $type, string $suffix = "") { if ($userids === null) { - $userids = $this->taskUser->where('owner', 1)->pluck('userid')->toArray(); + $userids = $this->taskUser->pluck('userid')->toArray(); } if (empty($userids)) { return; @@ -1471,8 +1473,7 @@ class ProjectTask extends AbstractModel 'userid' => $user->userid, 'task_id' => $this->id, ]; - $pushLog = ProjectTaskPushLog::where($data)->exists(); - if ($pushLog) { + if (in_array($type, [1, 2]) && ProjectTaskPushLog::where($data)->exists()) { continue; } // @@ -1481,7 +1482,7 @@ class ProjectTask extends AbstractModel if ($dialog) { ProjectTaskPushLog::createInstance($data)->save(); WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', [ - 'text' => str_replace("您的任务", $replace, $text) + 'text' => str_replace("您的任务", $replace, $text) . $suffix ], $botUser->userid); } }