Bläddra i källkod

修改SOP课程模板bug

吴树波 1 månad sedan
förälder
incheckning
e1fa49f2eb

+ 1 - 1
fs-service-system/src/main/java/com/fs/course/service/impl/FsCourseWatchLogServiceImpl.java

@@ -890,7 +890,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
                 //判断是否完课
                 long percentage = (duration * 100 / videoDuration);
                 if (percentage >= config.getAnswerRate()) {
-                    watchLog.setLogType(2); // 设置状态为“已完成”
+                    watchLog.setLogType(2); // 设置状态为“已完成”checkFsUserWatchStatus
                     watchLog.setFinishTime(new Date());
                     String heartbeatKey ="h5wxuser:watch:heartbeat:" + userId+ ":" + videoId + ":" + companyUserId;
                     // 完课删除心跳记录

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

@@ -45,6 +45,7 @@ import com.fs.sop.mapper.QwSopLogsMapper;
 import com.fs.store.service.cache.IFsUserCourseCacheService;
 import com.fs.system.service.ISysConfigService;
 import com.github.binarywang.wxpay.bean.transfer.TransferBillsResult;
+import lombok.extern.slf4j.Slf4j;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
@@ -71,6 +72,7 @@ import java.util.stream.Collectors;
  * @author fs
  * @date 2024-05-17
  */
+@Slf4j
 @Service
 public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 {
@@ -308,6 +310,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 
         // 从Redis中获取观看时长
         String redisKey = "h5user:watch:duration:" + param.getQwUserId()+ ":" + param.getQwExternalId() + ":" + param.getVideoId();
+        log.info("看课redis-key:{}", redisKey);
         try {
             String durationStr = redisCache.getCacheObject(redisKey);
             Long duration = durationStr != null ? Long.parseLong(durationStr) : 0L;
@@ -1021,8 +1024,10 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 
         // 从Redis中获取观看时长
         String redisKey = "h5wxuser:watch:duration:" + param.getUserId() + ":" + param.getVideoId() + ":" + param.getCompanyUserId();
+        log.info("看课redis缓存key:{}", redisKey);
         try {
             String durationStr = redisCache.getCacheObject(redisKey);
+            log.info("看课记录:{}", durationStr);
             long duration = durationStr != null ? Long.parseLong(durationStr) : 0L;
 
             // 更新Redis中的观看时长

+ 39 - 48
fs-service-system/src/main/java/com/fs/sop/service/impl/QwSopTempServiceImpl.java

@@ -210,55 +210,46 @@ public class QwSopTempServiceImpl implements IQwSopTempService
             day.setName("第" + day.getDayNum() + "天");
             day.setSorts(day.getDayNum());
             day.setList(new ArrayList<>());
-            QwSopTempRules rules = new QwSopTempRules();
-            rules.setTempId(temp.getId());
-            rules.setName(day.getName());
-            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
-            rules.setTime(e.getViewStartTime().format(formatter));
-            rules.setContentType(2);
-            rules.setType(2);
-            rules.setCourseType(0);
-            rules.setCourseId(e.getCourseId());
-            rules.setVideoId(e.getVideoId());
-            rules.setSorts(0);
-            day.getList().add(rules);
-            QwSopTempContent content = new QwSopTempContent();
-            content.setTempId(temp.getId());
-            content.setContentType(3);
-            QwSopTempSetting2.Content.Setting setting = new QwSopTempSetting2.Content.Setting();
-            setting.setLinkTitle(fsUserCourse.getCourseName());
-            setting.setIsBindUrl(1);
-            setting.setLinkDescribe(e.getTitle());
-            setting.setLinkImageUrl(fsUserCourse.getImgUrl());
-            setting.setContentType("3");
-            content.setContent(JSON.toJSONString(setting));
-            content.setIsBindUrl(1);
-            rules.setList(Collections.singletonList(content));
-
-
-
-            if(temp.getTimeList() != null &&  !temp.getTimeList().isEmpty()){
-                AtomicInteger sorts = new AtomicInteger(1);
-                List<QwSopTempRules> rulesList = temp.getTimeList().stream().map(time -> {
-                    QwSopTempRules rulesSub = new QwSopTempRules();
-                    rulesSub.setTempId(temp.getId());
-                    rulesSub.setName(day.getName());
-                    rulesSub.setTime(time);
-                    rulesSub.setContentType(1);
-                    rulesSub.setType(1);
-                    rulesSub.setSorts(sorts.getAndIncrement());
-                    QwSopTempContent contentSbu = new QwSopTempContent();
-                    contentSbu.setTempId(temp.getId());
-                    contentSbu.setContentType(1);
-                    QwSopTempSetting2.Content.Setting settingSub = new QwSopTempSetting2.Content.Setting();
-                    settingSub.setContentType("1");
-                    settingSub.setValue("");
-                    contentSbu.setContent(JSON.toJSONString(settingSub));
-                    rulesSub.setList(Collections.singletonList(contentSbu));
-                    return rulesSub;
-                }).collect(Collectors.toList());
-                day.getList().addAll(rulesList);
+            if(temp.getTimeList() == null){
+                temp.setTimeList(new ArrayList<>());
             }
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
+            temp.getTimeList().add(0, e.getViewStartTime().format(formatter));
+            AtomicInteger sorts = new AtomicInteger(0);
+            List<QwSopTempRules> rulesList = temp.getTimeList().stream().map(time -> {
+                QwSopTempRules rules = new QwSopTempRules();
+                rules.setTempId(temp.getId());
+                rules.setName(day.getName());
+                rules.setTime(time);
+                rules.setContentType(2);
+                rules.setType(2);
+                rules.setCourseType(0);
+                rules.setCourseId(e.getCourseId());
+                rules.setVideoId(e.getVideoId());
+                rules.setSorts(sorts.getAndIncrement());
+                // 设置消息类型
+                if(rules.getSorts() == 0){
+                    rules.setCourseType(0);
+                }else if(rules.getSorts() == 1){
+                    rules.setCourseType(1);
+                }else{
+                    rules.setCourseType(4);
+                }
+                QwSopTempContent content = new QwSopTempContent();
+                content.setTempId(temp.getId());
+                content.setContentType(3);
+                QwSopTempSetting2.Content.Setting setting = new QwSopTempSetting2.Content.Setting();
+                setting.setLinkTitle(fsUserCourse.getCourseName());
+                setting.setIsBindUrl(1);
+                setting.setLinkDescribe(e.getTitle());
+                setting.setLinkImageUrl(fsUserCourse.getImgUrl());
+                setting.setContentType("3");
+                content.setContent(JSON.toJSONString(setting));
+                content.setIsBindUrl(1);
+                rules.setList(Collections.singletonList(content));
+                return rules;
+            }).collect(Collectors.toList());
+            day.getList().addAll(rulesList);
             return day;
         }).collect(Collectors.toList());
         qwSopTempDayService.addOrUpdateBatch(collect);

+ 5 - 0
fs-user-app/src/main/java/com/fs/app/controller/CourseH5Controller.java

@@ -64,6 +64,7 @@ public class CourseH5Controller extends  AppBaseController{
     @GetMapping("/getH5CourseVideoDetails")
     public R getCourseVideoDetails(FsUserCourseVideoFinishUParam param)
     {
+        param.setUserId(Long.parseLong(getUserId()));
         String json = configService.selectConfigByKey("course.config");
         CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
         FsUserCourseVideoH5DVO course = courseService.selectFsUserCourseVideoH5DVOByVideoId(param.getVideoId());
@@ -128,6 +129,7 @@ public class CourseH5Controller extends  AppBaseController{
     @PostMapping("/updateWatchDuration")
     public R updateWatchDuration(@RequestBody FsUserCourseVideoFinishUParam param)
     {
+        param.setUserId(Long.parseLong(getUserId()));
         return courseVideoService.updateWatchDuration(param);
     }
 
@@ -135,6 +137,7 @@ public class CourseH5Controller extends  AppBaseController{
     @ApiOperation("获取缓冲流量")
     @PostMapping("/getInternetTraffic")
     public R getInternetTraffic(@RequestBody FsUserCourseVideoFinishUParam param) {
+        param.setUserId(Long.parseLong(getUserId()));
         return courseVideoService.getInternetTraffic(param);
     }
 
@@ -142,6 +145,7 @@ public class CourseH5Controller extends  AppBaseController{
     @PostMapping("/courseAnswer")
     public R courseAnswer(@RequestBody FsCourseQuestionAnswerUParam param)
     {
+        param.setUserId(Long.parseLong(getUserId()));
         logger.info("zyp \n【答题】:{}",param.getQuestions());
         if (param.getDuration()==null){
             logger.info("zyp \n【未识别到时长】:{}",param.getUserId());
@@ -154,6 +158,7 @@ public class CourseH5Controller extends  AppBaseController{
     @RepeatSubmit
     public R sendReward(@RequestBody FsCourseSendRewardUParam param)
     {
+        param.setUserId(Long.parseLong(getUserId()));
         logger.info("zyp \n【发放奖励】:{}",param);
         return courseVideoService.sendReward(param);
     }

+ 1 - 1
fs-user-app/src/main/resources/application.yml

@@ -50,7 +50,7 @@ server:
 # 日志配置
 logging:
   level:
-    com.fs: info
+    com.fs: debug
     org.springframework: warn
 
 # Spring配置