From 24287c08578c4743d9c874ea3fda0e3a10169a6d Mon Sep 17 00:00:00 2001 From: kuaifan Date: Thu, 6 Jan 2022 16:51:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=BB=E4=BB=BB=E5=8A=A1=E8=A2=AB?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=88=96=E5=BD=92=E6=A1=A3=E6=97=B6=E5=AD=90?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=BA=94=E8=AF=A5=E4=B9=9F=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/ProjectTask.php | 12 +++-- ...2023_project_tasks_update_subtask_time.php | 2 +- ...t_tasks_update_subtask_archived_delete.php | 51 +++++++++++++++++++ 3 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 database/migrations/2022_01_06_164034_project_tasks_update_subtask_archived_delete.php diff --git a/app/Models/ProjectTask.php b/app/Models/ProjectTask.php index 710ad3a8e..1ffaf256e 100644 --- a/app/Models/ProjectTask.php +++ b/app/Models/ProjectTask.php @@ -799,6 +799,11 @@ class ProjectTask extends AbstractModel $this->addLog($logText, $userid); $this->pushMsg('archived'); } + self::whereParentId($this->id)->update([ + 'archived_at' => $this->archived_at, + 'archived_userid' => $this->archived_userid, + 'archived_follow' => $this->archived_follow, + ]); $this->save(); }); return true; @@ -814,12 +819,11 @@ class ProjectTask extends AbstractModel AbstractModel::transaction(function () { if ($this->dialog_id) { $dialog = WebSocketDialog::find($this->dialog_id); - if ($dialog) { - $dialog->deleteDialog(); - } + $dialog?->deleteDialog(); } - $this->delete(); + self::whereParentId($this->id)->delete(); $this->addLog("删除{任务}:" . $this->name); + $this->delete(); }); if ($pushMsg) { $this->pushMsg('delete'); diff --git a/database/migrations/2022_01_06_132023_project_tasks_update_subtask_time.php b/database/migrations/2022_01_06_132023_project_tasks_update_subtask_time.php index 618e66f32..66e99ede0 100644 --- a/database/migrations/2022_01_06_132023_project_tasks_update_subtask_time.php +++ b/database/migrations/2022_01_06_132023_project_tasks_update_subtask_time.php @@ -6,7 +6,7 @@ use Illuminate\Database\Migrations\Migration; class ProjectTasksUpdateSubtaskTime extends Migration { /** - * Run the migrations. + * 子任务同步主任务(任务时间) * * @return void */ diff --git a/database/migrations/2022_01_06_164034_project_tasks_update_subtask_archived_delete.php b/database/migrations/2022_01_06_164034_project_tasks_update_subtask_archived_delete.php new file mode 100644 index 000000000..7261f3841 --- /dev/null +++ b/database/migrations/2022_01_06_164034_project_tasks_update_subtask_archived_delete.php @@ -0,0 +1,51 @@ +whereNotNull('archived_at') + ->chunkById(100, function ($lists) { + /** @var ProjectTask $task */ + foreach ($lists as $task) { + ProjectTask::whereParentId($task->id)->update([ + 'archived_at' => $task->archived_at, + 'archived_userid' => $task->archived_userid, + 'archived_follow' => $task->archived_follow, + ]); + } + }); + + // 删除 + ProjectTask::onlyTrashed() + ->whereParentId(0) + ->chunkById(100, function ($lists) { + /** @var ProjectTask $task */ + foreach ($lists as $task) { + ProjectTask::whereParentId($task->id)->update([ + 'deleted_at' => $task->deleted_at, + ]); + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +}