From 486ac7bd6986e02bfd9dd3aafcde7004cc185fa2 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Thu, 11 Jan 2024 20:30:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3chapter=5Fuser=E8=A1=A8?= =?UTF-8?q?=E4=B8=ADplan=5Fid=3D0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/Logic/Chapter/ChapterInfo.php | 1 + db/migrations/20240111185633.php | 32 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 db/migrations/20240111185633.php diff --git a/app/Services/Logic/Chapter/ChapterInfo.php b/app/Services/Logic/Chapter/ChapterInfo.php index b6cd75b5..3311e644 100644 --- a/app/Services/Logic/Chapter/ChapterInfo.php +++ b/app/Services/Logic/Chapter/ChapterInfo.php @@ -126,6 +126,7 @@ class ChapterInfo extends LogicService $chapterUser = new ChapterUserModel(); + $chapterUser->plan_id = $this->courseUser->plan_id; $chapterUser->course_id = $chapter->course_id; $chapterUser->chapter_id = $chapter->id; $chapterUser->user_id = $user->id; diff --git a/db/migrations/20240111185633.php b/db/migrations/20240111185633.php new file mode 100644 index 00000000..75e433d9 --- /dev/null +++ b/db/migrations/20240111185633.php @@ -0,0 +1,32 @@ +handleChapterUsers(); + } + + /** + * 纠正 chapter_user 表中 plan_id = 0 的数据 + * + * @return void + */ + protected function handleChapterUsers() + { + $sql = 'UPDATE kg_chapter_user AS a JOIN kg_course_user AS b + ON a.course_id = b.course_id AND a.user_id = b.user_id + SET a.plan_id = b.plan_id WHERE a.plan_id = 0'; + + $this->query($sql); + } + +}