Skip to content

Commit

Permalink
Merge pull request #222 from Qsnh/hotfix/1206
Browse files Browse the repository at this point in the history
Hotfix/1206
  • Loading branch information
Qsnh authored Dec 6, 2022
2 parents fdbd538 + 8b7a1fd commit 33430cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Meedu/MeEdu.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

class MeEdu
{
const VERSION = 'v4.8';
const VERSION = 'v4.8.1';
}
11 changes: 8 additions & 3 deletions app/Services/Member/Services/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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));
}

/**
Expand Down

0 comments on commit 33430cf

Please sign in to comment.