소스 검색

feat:会员链接看课判断调整

caoliqin 3 주 전
부모
커밋
6f5fff1025
1개의 변경된 파일37개의 추가작업 그리고 31개의 파일을 삭제
  1. 37 31
      fs-service-system/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

+ 37 - 31
fs-service-system/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -941,39 +941,45 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
         if(fsUser.getCompanyUserId() == null) {
             return ResponseResult.fail(503, "暂时未绑定销售,请联系管理员");
         }
-        if(companyUser.getUserId().equals(fsUser.getCompanyUserId())){
-            //查询看课记录
-            FsCourseWatchLog log = new FsCourseWatchLog();
-            log.setUserId(param.getUserId());
-            log.setCompanyUserId(param.getCompanyUserId());
-            log.setVideoId(param.getVideoId());
-            List<FsCourseWatchLog> fsCourseWatchLogs = courseWatchLogMapper.selectFsCourseWatchLogList(log);
-
-            // 获取课程所属项目id
-            FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(param.getCourseId());
-            Long courseProject = null;
-            if(fsUserCourse != null){
-                courseProject = fsUserCourse.getProject();
-            }
-            //如果存在,则更新
-            if (fsCourseWatchLogs != null && !fsCourseWatchLogs.isEmpty()){
-                FsCourseWatchLog updateLog = new FsCourseWatchLog();
-                updateLog.setPeriodId(param.getPeriodId());
-                updateLog.setProject(courseProject);
-                updateLog.setUpdateTime(new Date());
-                courseWatchLogMapper.updateFsCourseWatchLog(updateLog);
-            } else {
-                //如果是会员,则需要添加看课记录
-                FsCourseWatchLog fsCourseWatchLog = new FsCourseWatchLog();
-                BeanUtils.copyProperties(param, fsCourseWatchLog);
-                fsCourseWatchLog.setSendType(1);
-                fsCourseWatchLog.setDuration(0L);
-                fsCourseWatchLog.setCreateTime(new Date());
-                fsCourseWatchLog.setLogType(1);
-                fsCourseWatchLog.setProject(courseProject);
-                courseWatchLogMapper.insertFsCourseWatchLog(fsCourseWatchLog);
+
+        //添加判断:该用户是否已经存在此课程的看课记录,并且看课记录的销售id不是传入的销售id
+        //查询看课记录
+        FsCourseWatchLog log = new FsCourseWatchLog();
+        log.setUserId(param.getUserId());
+        log.setCompanyUserId(param.getCompanyUserId());
+        log.setVideoId(param.getVideoId());
+        FsCourseWatchLog watchCourseVideo = courseWatchLogMapper.getWatchCourseVideoByFsUser(param.getUserId(), param.getVideoId(), param.getCompanyUserId());
+
+        // 获取课程所属项目id
+        FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(param.getCourseId());
+        Long courseProject = null;
+        if(fsUserCourse != null){
+            courseProject = fsUserCourse.getProject();
+        }
+        if(watchCourseVideo != null){
+            if(!watchCourseVideo.getCompanyUserId().equals(param.getCompanyUserId())) {
+                //提示
+                return ResponseResult.fail(504, "已看过其他销售分享的此课程,不能重复观看");
             }
+
+            FsCourseWatchLog updateLog = new FsCourseWatchLog();
+            updateLog.setPeriodId(param.getPeriodId());
+            updateLog.setProject(courseProject);
+            updateLog.setUpdateTime(new Date());
+            courseWatchLogMapper.updateFsCourseWatchLog(updateLog);
         } else {
+            FsCourseWatchLog fsCourseWatchLog = new FsCourseWatchLog();
+            BeanUtils.copyProperties(param, fsCourseWatchLog);
+            fsCourseWatchLog.setSendType(1);
+            fsCourseWatchLog.setDuration(0L);
+            fsCourseWatchLog.setCreateTime(new Date());
+            fsCourseWatchLog.setLogType(1);
+            fsCourseWatchLog.setProject(courseProject);
+            courseWatchLogMapper.insertFsCourseWatchLog(fsCourseWatchLog);
+        }
+
+        // 判断是否重粉
+        if(!companyUser.getUserId().equals(fsUser.getCompanyUserId())){
             FsUserCompanyUser fsUserCompanyUser = new FsUserCompanyUser();
             fsUserCompanyUser.setIsRepeatFans(1);
             fsUserCompanyUser.setUserId(param.getUserId());