|
|
@@ -1284,6 +1284,61 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public R getGjInternetTraffic(FsUserCourseVideoFinishUParam param) {
|
|
|
+ try {
|
|
|
+ if (param.getBufferRate() == null) {
|
|
|
+ logger.error("【缓冲值空】参数: {}", param);
|
|
|
+ return R.error("缓冲值空");
|
|
|
+ }
|
|
|
+ FsCourseTrafficLog trafficLog = new FsCourseTrafficLog();
|
|
|
+ trafficLog.setCreateTime(new Date());
|
|
|
+ BeanUtils.copyProperties(param, trafficLog);
|
|
|
+
|
|
|
+ FsUserCourseVideo video = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(param.getVideoId());
|
|
|
+ if (video == null) {
|
|
|
+ return R.error("视频不存在");
|
|
|
+ }
|
|
|
+ Company company = companyMapper.selectCompanyById(param.getCompanyId());
|
|
|
+ if (company == null) {
|
|
|
+ return R.error("公司不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 实际流量传输消耗是大于文件的,添加倍数计算流量消耗 配置 course.data.usage.multiple
|
|
|
+ BigDecimal multiple = new BigDecimal("1"); // 默认一倍
|
|
|
+ String config=configService.selectConfigByKey("course.data.usage.multiple");
|
|
|
+ if(StringUtils.isNotEmpty(config)){
|
|
|
+ multiple=new BigDecimal(config);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算流量
|
|
|
+ BigDecimal result = param.getBufferRate().divide(new BigDecimal("100"), 4, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal longAsBigDecimal = BigDecimal.valueOf(video.getFileSize());
|
|
|
+ long roundedResult = result.multiply(longAsBigDecimal).multiply(multiple).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())) {
|
|
|
+ // 插入或更新
|
|
|
+ fsCourseTrafficLogMapper.insertOrUpdateTrafficLog(trafficLog);
|
|
|
+ asyncDeductTraffic(company, trafficLog);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ // 打印参数param和异常信息
|
|
|
+ logger.error("【插入或更新流量失败】参数: {}, 错误信息:{}", param, e.getMessage(), e);
|
|
|
+ return R.error();
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public void asyncDeductTraffic(Company company, FsCourseTrafficLog trafficLog) {
|
|
|
try {
|
|
|
//根据uuid查询
|
|
|
@@ -2916,6 +2971,41 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
|
|
|
return ResponseResult.ok(vo);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseResult<FsUserCourseVideoLinkDetailsVO> getCourseGjVideoDetails(FsUserCourseVideoLinkParam param) {
|
|
|
+
|
|
|
+ String json = configService.selectConfigByKey("course.config");
|
|
|
+ CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
+
|
|
|
+ // 1、获取视频详情、问题详情
|
|
|
+ ResponseResult<FsUserCourseVideoDetailsVO> videoDetails = this.getVideoDetails(param.getVideoId());
|
|
|
+ FsUserCourseVideoDetailsVO courseVideoDetails = videoDetails.getData() != null ? videoDetails.getData() : null;
|
|
|
+
|
|
|
+ //课程logo
|
|
|
+ if (param.getPeriodId() != null) {
|
|
|
+ FsUserCoursePeriod fsUserCoursePeriod = fsUserCoursePeriodMapper.selectFsUserCoursePeriodById(param.getPeriodId());
|
|
|
+ if (fsUserCoursePeriod != null) {
|
|
|
+ config.setCourseLogo(fsUserCoursePeriod.getCourseLogo());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ long duration = 0L;
|
|
|
+ long tipsTime = 0L;
|
|
|
+ long tipsTime2 = 0L;
|
|
|
+ int isFinish = 0;
|
|
|
+ FsUserCourseVideoLinkDetailsVO vo = new FsUserCourseVideoLinkDetailsVO();
|
|
|
+ vo.setCourseVideoDetails(courseVideoDetails);
|
|
|
+ vo.setCourseConfig(config);
|
|
|
+ vo.setIsFinish(isFinish);
|
|
|
+ vo.setPlayDuration(duration);
|
|
|
+ vo.setTipsTime(tipsTime);
|
|
|
+ vo.setTipsTime2(tipsTime2);
|
|
|
+ vo.setIsFinish(isFinish);
|
|
|
+ vo.setPlayDuration(duration);
|
|
|
+ return ResponseResult.ok(vo);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @Description: 是否看课中断
|
|
|
* @Param:
|