|
|
@@ -1001,22 +1001,26 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
return R.error("公司不存在");
|
|
|
}
|
|
|
|
|
|
- // 计算流量
|
|
|
- BigDecimal result = param.getBufferRate().divide(new BigDecimal("100"), 4, RoundingMode.HALF_UP);
|
|
|
- BigDecimal longAsBigDecimal = BigDecimal.valueOf(video.getFileSize());
|
|
|
- long roundedResult = result.multiply(longAsBigDecimal).setScale(0, RoundingMode.HALF_UP).longValue();
|
|
|
- trafficLog.setInternetTraffic(roundedResult);
|
|
|
- // 获取课程所属项目id
|
|
|
- FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(param.getCourseId());
|
|
|
- if(fsUserCourse != null){
|
|
|
- trafficLog.setProject(fsUserCourse.getProject());
|
|
|
- }
|
|
|
+ //验证看课记录是否存在
|
|
|
+ FsCourseWatchLog log = courseWatchLogMapper.getWatchCourseVideoInfo(param.getUserId(), param.getVideoId(), param.getPeriodId());
|
|
|
+ if(log != null){
|
|
|
+ // 计算流量
|
|
|
+ BigDecimal result = param.getBufferRate().divide(new BigDecimal("100"), 4, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal longAsBigDecimal = BigDecimal.valueOf(video.getFileSize());
|
|
|
+ long roundedResult = result.multiply(longAsBigDecimal).multiply(new BigDecimal("1.4")).setScale(0, RoundingMode.HALF_UP).longValue();
|
|
|
+ trafficLog.setInternetTraffic(roundedResult);
|
|
|
+ // 获取课程所属项目id
|
|
|
+ FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(param.getCourseId());
|
|
|
+ if(fsUserCourse != null){
|
|
|
+ trafficLog.setProject(fsUserCourse.getProject());
|
|
|
+ }
|
|
|
|
|
|
- // 处理 UUID 为空的情况
|
|
|
- if (StringUtils.isNotEmpty(trafficLog.getUuId())) {
|
|
|
- // 插入或更新
|
|
|
- asyncDeductTraffic(company, trafficLog);
|
|
|
- fsCourseTrafficLogMapper.insertOrUpdateTrafficLog(trafficLog);
|
|
|
+ // 处理 UUID 为空的情况
|
|
|
+ if (StringUtils.isNotEmpty(trafficLog.getUuId())) {
|
|
|
+ // 插入或更新
|
|
|
+ asyncDeductTraffic(company, trafficLog);
|
|
|
+ fsCourseTrafficLogMapper.insertOrUpdateTrafficLog(trafficLog);
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -3647,5 +3651,22 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static boolean isWithin20Minutes(Date createTime) {
|
|
|
+ if (createTime == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 转换为LocalDateTime
|
|
|
+ LocalDateTime createLocalDateTime = createTime.toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
+ .toLocalDateTime();
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+
|
|
|
+ // 计算时间差
|
|
|
+ Duration duration = Duration.between(createLocalDateTime, now);
|
|
|
+ long minutesDifference = Math.abs(duration.toMinutes());
|
|
|
+
|
|
|
+ return minutesDifference <= 20;
|
|
|
+ }
|
|
|
}
|
|
|
|