Преглед на файлове

95:红德堂APP调试 同步isAddKf最新代码

Long преди 1 ден
родител
ревизия
738c83fd71

+ 5 - 0
fs-service/src/main/java/com/fs/course/mapper/FsUserCourseMapper.java

@@ -271,4 +271,9 @@ public interface FsUserCourseMapper
     List<FsCourseListBySidebarVO> getFsCourseListBySidebar(@Param("data") FsCourseListBySidebarParam param);
 
     List<FsUserCourseParticipationRecordVO> getParticipationRecordByMap(@Param("params") Map<String, Object> params);
+
+    /**
+     * 查询当天用户-项目看课记录条数
+     */
+    Integer selectTodayCourseWatchLogCountByUserIdAndProjectId(@Param("userId") Long userId, @Param("projectId") Long projectId);
 }

+ 11 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -1448,6 +1448,17 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             courseProject = fsUserCourse.getProject();
         }
 
+        // 项目校验
+        if (Objects.isNull(courseProject) || !courseProject.equals(param.getProjectId())) {
+            return ResponseResult.fail(504, "课程项目不匹配");
+        }
+
+        // 项目看课数限制
+        Integer logCount = fsUserCourseMapper.selectTodayCourseWatchLogCountByUserIdAndProjectId(param.getUserId(), param.getProjectId());
+        if (Objects.isNull(watchCourseVideo) && logCount > 0) {
+            return ResponseResult.fail(504, "超过项目看课数量限制");
+        }
+
         //添加判断:该用户是否已经存在此课程的看课记录,并且看课记录的销售id不是传入的销售id
         if(watchCourseVideo != null){
             if(!watchCourseVideo.getCompanyUserId().equals(param.getCompanyUserId())) {

+ 9 - 0
fs-service/src/main/resources/mapper/course/FsUserCourseMapper.xml

@@ -143,6 +143,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         group by fu.user_id, fucv.video_id, fu.nick_name, fu.username, fu.avatar, fu.phone, fu.create_time
     </select>
 
+    <select id="selectTodayCourseWatchLogCountByUserIdAndProjectId" resultType="java.lang.Integer">
+        select count(distinct cwl.video_id)
+        from fs_course_watch_log cwl
+        inner join fs_user_course_video ucv on ucv.video_id = cwl.video_id
+        inner join fs_user_course uc on uc.course_id = ucv.course_id
+        where cwl.user_id = #{userId} and uc.project = #{projectId}
+          and cwl.create_time between curdate() and date_add(curdate(), interval 1 day)
+    </select>
+
 
     <insert id="insertFsUserCourse" parameterType="FsUserCourse" useGeneratedKeys="true" keyProperty="courseId">
         insert into fs_user_course