|
@@ -2354,36 +2354,22 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
// FsCourseWatchLog watchCourseVideo = courseWatchLogMapper.getWatchCourseVideoByFsUser(param.getUserId(), param.getVideoId(), param.getCompanyUserId());
|
|
// FsCourseWatchLog watchCourseVideo = courseWatchLogMapper.getWatchCourseVideoByFsUser(param.getUserId(), param.getVideoId(), param.getCompanyUserId());
|
|
|
FsCourseWatchLog watchCourseVideo = courseWatchLogMapper.getCourseWatchLogByUser(param.getUserId(), param.getVideoId(), param.getPeriodId());
|
|
FsCourseWatchLog watchCourseVideo = courseWatchLogMapper.getCourseWatchLogByUser(param.getUserId(), param.getVideoId(), param.getPeriodId());
|
|
|
|
|
|
|
|
-// if (!isUserCoursePeriodValid(param)) {
|
|
|
|
|
-// return ResponseResult.fail(504, "请观看最新的课程项目");
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
// 检查是否为自由模式
|
|
// 检查是否为自由模式
|
|
|
FsUserCoursePeriod period = fsUserCoursePeriodMapper.selectFsUserCoursePeriodById(param.getPeriodId());
|
|
FsUserCoursePeriod period = fsUserCoursePeriodMapper.selectFsUserCoursePeriodById(param.getPeriodId());
|
|
|
boolean isFreeMode = period != null && period.getFreeMode() != null && period.getFreeMode() == 1;
|
|
boolean isFreeMode = period != null && period.getFreeMode() != null && period.getFreeMode() == 1;
|
|
|
|
|
|
|
|
- // 项目看课数限制(自由模式下跳过此限制)
|
|
|
|
|
- // 注意:此限制仅针对手动发课(send_type=1),企微自动发课(send_type=2)不受此限制
|
|
|
|
|
- // 逻辑:如果用户今天已经看过其他手动发课的课程,则不能再看新的手动发课课程
|
|
|
|
|
- if(!isFreeMode && !EXCLUDE_PROJECTS.contains(signProjectName) && !CloudHostUtils.hasCloudHostName("弘德堂")) {
|
|
|
|
|
- Integer logCount = fsUserCourseMapper.selectTodayCourseWatchLogCountByUserIdAndProjectId(param.getUserId(), courseProject);
|
|
|
|
|
- if (Objects.isNull(watchCourseVideo) && logCount > 0) {
|
|
|
|
|
- log.info("【手动发课限制】用户今日已观看{}门手动发课课程,超过限制,periodId={}, userId={}, videoId={}",
|
|
|
|
|
- logCount, param.getPeriodId(), param.getUserId(), param.getVideoId());
|
|
|
|
|
- return ResponseResult.fail(504, "超过项目看课数量限制");
|
|
|
|
|
- }
|
|
|
|
|
- } else if(isFreeMode) {
|
|
|
|
|
- log.info("【自由模式检查】✅ 自由模式,跳过项目看课数量限制检查,periodId={}", param.getPeriodId());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //添加判断:该用户是否已经存在此课程的看课记录,并且看课记录的销售id不是传入的销售id
|
|
|
|
|
|
|
+ // ========== 重要:所有限制检查必须在创建看课记录之前进行 ==========
|
|
|
|
|
+
|
|
|
|
|
+ // 1. 检查是否已经存在看课记录,如果存在则更新,如果不存在则进行后续限制检查
|
|
|
if(watchCourseVideo != null){
|
|
if(watchCourseVideo != null){
|
|
|
|
|
+ // 存在看课记录,检查销售是否匹配
|
|
|
if(!watchCourseVideo.getCompanyUserId().equals(param.getCompanyUserId())) {
|
|
if(!watchCourseVideo.getCompanyUserId().equals(param.getCompanyUserId())) {
|
|
|
//提示
|
|
//提示
|
|
|
log.error("数据库存在销售信息:{},分享得销售信息:{}",watchCourseVideo.getCompanyUserId(),param.getCompanyUserId());
|
|
log.error("数据库存在销售信息:{},分享得销售信息:{}",watchCourseVideo.getCompanyUserId(),param.getCompanyUserId());
|
|
|
return ResponseResult.fail(504, "已看过其他课程,不能重复观看");
|
|
return ResponseResult.fail(504, "已看过其他课程,不能重复观看");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 更新现有看课记录
|
|
|
FsCourseWatchLog updateLog = new FsCourseWatchLog();
|
|
FsCourseWatchLog updateLog = new FsCourseWatchLog();
|
|
|
updateLog.setLogId(watchCourseVideo.getLogId());
|
|
updateLog.setLogId(watchCourseVideo.getLogId());
|
|
|
updateLog.setPeriodId(param.getPeriodId());
|
|
updateLog.setPeriodId(param.getPeriodId());
|
|
@@ -2391,7 +2377,31 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
updateLog.setUpdateTime(new Date());
|
|
updateLog.setUpdateTime(new Date());
|
|
|
courseWatchLogMapper.updateFsCourseWatchLog(updateLog);
|
|
courseWatchLogMapper.updateFsCourseWatchLog(updateLog);
|
|
|
} else {
|
|
} else {
|
|
|
- // 创建新的看课记录(手动发课:send_type=1)
|
|
|
|
|
|
|
+ // ========== 看课记录不存在,先进行各项限制检查,通过后才能创建看课记录 ==========
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 项目看课数量限制检查(自由模式下跳过此限制)
|
|
|
|
|
+ // 注意:此限制仅针对手动发课(send_type=1),企微自动发课(send_type=2)不受此限制
|
|
|
|
|
+ // 逻辑:如果用户今天已经看过其他手动发课的课程,则不能再看新的手动发课课程
|
|
|
|
|
+ if(!isFreeMode && !EXCLUDE_PROJECTS.contains(signProjectName) && !CloudHostUtils.hasCloudHostName("弘德堂")) {
|
|
|
|
|
+ Integer logCount = fsUserCourseMapper.selectTodayCourseWatchLogCountByUserIdAndProjectId(param.getUserId(), courseProject);
|
|
|
|
|
+ if (logCount > 0) {
|
|
|
|
|
+ log.info("【手动发课限制】用户今日已观看{}门手动发课课程,超过限制,periodId={}, userId={}, videoId={}",
|
|
|
|
|
+ logCount, param.getPeriodId(), param.getUserId(), param.getVideoId());
|
|
|
|
|
+ return ResponseResult.fail(504, "超过项目看课数量限制");
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if(isFreeMode) {
|
|
|
|
|
+ log.info("【自由模式检查】✅ 自由模式,跳过项目看课数量限制检查,periodId={}", param.getPeriodId());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 观看时间限制检查(可选,目前被注释)
|
|
|
|
|
+// if (!isUserCoursePeriodValid(param)) {
|
|
|
|
|
+// return ResponseResult.fail(504, "不在观看时间范围内");
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ // ========== 所有检查通过,创建新的看课记录 ==========
|
|
|
|
|
+ log.info("【创建看课记录】所有检查通过,创建新的看课记录,userId={}, videoId={}, periodId={}",
|
|
|
|
|
+ param.getUserId(), param.getVideoId(), param.getPeriodId());
|
|
|
|
|
+
|
|
|
FsCourseWatchLog fsCourseWatchLog = new FsCourseWatchLog();
|
|
FsCourseWatchLog fsCourseWatchLog = new FsCourseWatchLog();
|
|
|
BeanUtils.copyProperties(param, fsCourseWatchLog);
|
|
BeanUtils.copyProperties(param, fsCourseWatchLog);
|
|
|
fsCourseWatchLog.setSendType(1); // 1=手动发课(个微/后台)
|
|
fsCourseWatchLog.setSendType(1); // 1=手动发课(个微/后台)
|