|
@@ -19,6 +19,7 @@ import com.fs.course.mapper.*;
|
|
import com.fs.course.param.*;
|
|
import com.fs.course.param.*;
|
|
import com.fs.course.param.newfs.FsUserCourseAddCompanyUserParam;
|
|
import com.fs.course.param.newfs.FsUserCourseAddCompanyUserParam;
|
|
import com.fs.course.param.newfs.FsUserCourseVideoLinkParam;
|
|
import com.fs.course.param.newfs.FsUserCourseVideoLinkParam;
|
|
|
|
+import com.fs.course.param.newfs.FsUserCourseVideoUParam;
|
|
import com.fs.course.param.newfs.UserCourseVideoPageParam;
|
|
import com.fs.course.param.newfs.UserCourseVideoPageParam;
|
|
import com.fs.course.service.IFsUserCourseVideoService;
|
|
import com.fs.course.service.IFsUserCourseVideoService;
|
|
import com.fs.course.vo.FsUserCourseVideoListUVO;
|
|
import com.fs.course.vo.FsUserCourseVideoListUVO;
|
|
@@ -910,7 +911,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
ResponseResult.ok(vo);
|
|
ResponseResult.ok(vo);
|
|
}
|
|
}
|
|
// 从Redis中获取用户目前的观看时长
|
|
// 从Redis中获取用户目前的观看时长
|
|
- //todo 需要在修改看课记录中设置此key
|
|
|
|
String redisKey = "h5wxuser:watch:duration:" + param.getFsUserId() + ":" + param.getVideoId();
|
|
String redisKey = "h5wxuser:watch:duration:" + param.getFsUserId() + ":" + param.getVideoId();
|
|
String durationCurrent = redisCache.getCacheObject(redisKey);
|
|
String durationCurrent = redisCache.getCacheObject(redisKey);
|
|
|
|
|
|
@@ -946,4 +946,40 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
|
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public R updateWatchDurationWx(FsUserCourseVideoUParam param) {
|
|
|
|
+ //临时短链不做记录
|
|
|
|
+ if (param.getLinkType() != null && param.getLinkType() == 1){
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 从Redis中获取观看时长
|
|
|
|
+ String redisKey = "h5wxuser:watch:duration:" + param.getUserId() + ":" + param.getVideoId();
|
|
|
|
+ try {
|
|
|
|
+ String durationStr = redisCache.getCacheObject(redisKey);
|
|
|
|
+ long duration = durationStr != null ? Long.parseLong(durationStr) : 0L;
|
|
|
|
+
|
|
|
|
+ // 更新Redis中的观看时长
|
|
|
|
+ if (param.getDuration() != null && param.getDuration() > duration) {
|
|
|
|
+ //24小时过期
|
|
|
|
+ redisCache.setCacheObject(redisKey, param.getDuration().toString(),2,TimeUnit.HOURS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //更新缓存中的心跳时间
|
|
|
|
+ updateHeartbeatWx(param);
|
|
|
|
+ return R.ok();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ logger.error("更新看课时长失败:{}", redisKey, e.getMessage());
|
|
|
|
+ return R.error("更新看课时长失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //会员-更新心跳时间
|
|
|
|
+ public void updateHeartbeatWx(FsUserCourseVideoUParam param) {
|
|
|
|
+ String redisKey = "h5wxuser:watch:heartbeat:" + param.getUserId() + ":" + param.getVideoId();
|
|
|
|
+ redisCache.setCacheObject(redisKey, LocalDateTime.now().toString());
|
|
|
|
+ // 设置 Redis 记录的过期时间(例如 5 分钟)
|
|
|
|
+ redisCache.expire(redisKey, 300, TimeUnit.SECONDS);
|
|
|
|
+ }
|
|
}
|
|
}
|