From 688ebe68f7e1b618541715c68c61d69e08346e0a Mon Sep 17 00:00:00 2001 From: none Date: Tue, 6 Dec 2022 13:47:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fixed:=20=E5=BD=95=E6=92=AD=E8=AF=BE?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E7=9C=8B=E5=AE=8C=E7=9A=84event=20emit=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/Member/Services/UserService.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Services/Member/Services/UserService.php b/app/Services/Member/Services/UserService.php index 36127f9c5..31d281e19 100644 --- a/app/Services/Member/Services/UserService.php +++ b/app/Services/Member/Services/UserService.php @@ -512,11 +512,16 @@ public function recordUserVideoWatch(int $userId, int $courseId, int $videoId, i ->where('video_id', $videoId) ->first(); + $isEmitWatchedEvent = false; + if ($record) { if ($record->watched_at === null && $record->watch_seconds <= $duration) { // 如果有记录[没看完 && 当前时间超过已记录的时间] $data = ['watch_seconds' => $duration]; - $isWatched && $data['watched_at'] = Carbon::now(); + if ($isWatched) { + $data['watched_at'] = Carbon::now(); + $isEmitWatchedEvent = true; + } $record->fill($data)->save(); } } else { @@ -527,10 +532,10 @@ public function recordUserVideoWatch(int $userId, int $courseId, int $videoId, i 'watch_seconds' => $duration, 'watched_at' => $isWatched ? Carbon::now() : null, ]); + $isEmitWatchedEvent = $isWatched; } - // 视频看完event - $isWatched && event(new UserVideoWatchedEvent($userId, $videoId)); + $isEmitWatchedEvent && event(new UserVideoWatchedEvent($userId, $videoId)); } /** From 8b7a1fd58a56fe071c01fb4c953e4cb9ff958e79 Mon Sep 17 00:00:00 2001 From: none Date: Tue, 6 Dec 2022 13:48:21 +0800 Subject: [PATCH 2/2] update ver --- app/Meedu/MeEdu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Meedu/MeEdu.php b/app/Meedu/MeEdu.php index 0fbe2cbb2..12f5d2547 100644 --- a/app/Meedu/MeEdu.php +++ b/app/Meedu/MeEdu.php @@ -10,5 +10,5 @@ class MeEdu { - const VERSION = 'v4.8'; + const VERSION = 'v4.8.1'; }