Kaynağa Gözat

会员用户看课记录

wangxy 1 hafta önce
ebeveyn
işleme
c88d9eab3e

+ 16 - 0
fs-company-app/src/main/java/com/fs/app/controller/FsUserController.java

@@ -20,8 +20,10 @@ import com.fs.course.domain.FsUserCompanyUser;
 import com.fs.course.param.CourseAnalysisParam;
 import com.fs.course.param.newfs.FsUserCourseBeMemberImageParam;
 import com.fs.course.param.newfs.FsUserCourseBeMemberParam;
+import com.fs.course.service.IFsCourseWatchLogService;
 import com.fs.course.service.IFsUserCompanyUserService;
 import com.fs.course.service.IFsUserCourseService;
+import com.fs.course.vo.AppUserWatchLogVO;
 import com.fs.course.vo.newfs.FsCourseAnalysisVO;
 import com.fs.his.domain.FsUser;
 import com.fs.his.service.IFsUserProjectTagService;
@@ -84,6 +86,9 @@ public class FsUserController extends AppBaseController {
     @Autowired
     private IFsUserProjectTagService userProjectTagService;
 
+    @Autowired
+    private IFsCourseWatchLogService courseWatchLogService;
+
 
     @Login
     @PostMapping("/pageList")
@@ -391,4 +396,15 @@ public class FsUserController extends AppBaseController {
         System.out.println(s);
     }
 
+    @ApiOperation("获取用户看课记录列表")
+    @GetMapping("/getWatchLogList")
+    public R getWatchLogList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+                             @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,@RequestParam Long userId,@RequestParam Long projectId
+            ,@RequestParam(required = false) String dateTag,@RequestParam Long companyUserId ) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<AppUserWatchLogVO> list = courseWatchLogService.selectAppUserWatchLogList(userId,projectId,dateTag,companyUserId);
+        PageInfo<AppUserWatchLogVO> pageInfo = new PageInfo<>(list);
+        return R.ok().put("data", pageInfo);
+    }
+
 }

+ 3 - 2
fs-service/src/main/java/com/fs/course/mapper/FsCourseWatchLogMapper.java

@@ -621,7 +621,7 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
             "INNER JOIN ( " +
             "    SELECT user_id, video_id, MAX(log_id) AS log_id " +
             "    FROM fs_course_watch_log " +
-            "    WHERE user_id IS NOT NULL AND user_id > 0 " +
+            "    WHERE user_id IS NOT NULL  AND  user_id=4051515674 " +
             "      AND watch_type = 1 " +
             "      AND send_type = 1 " +
             "      AND create_time >= CURDATE() " +
@@ -631,6 +631,7 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
             "WHERE l.log_type <> 2 " +
             "  AND l.watch_type = 1 " +
             "  AND l.send_type = 1 " +
+            "and l.user_id=4051515674" +
             "  AND NOT EXISTS ( " +
             "      SELECT 1 FROM fs_course_watch_log f " +
             "      WHERE f.user_id = l.user_id " +
@@ -953,7 +954,7 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
     /**
      * APP用户看课记录列表
      */
-    List<AppUserWatchLogVO> selectAppUserWatchLogList(@Param("userId") Long userId);
+    List<AppUserWatchLogVO> selectAppUserWatchLogList(@Param("userId") Long userId,@Param("projectId") Long projectId,@Param("dateTag") String dateTag,@Param("companyUserId") Long companyUserId);
 
     /**
      * 查询用户当日未完课的课程列表

+ 1 - 1
fs-service/src/main/java/com/fs/course/service/IFsCourseWatchLogService.java

@@ -211,7 +211,7 @@ public interface IFsCourseWatchLogService extends IService<FsCourseWatchLog> {
     /**
      * APP用户看课记录列表
      */
-    List<AppUserWatchLogVO> selectAppUserWatchLogList(Long userId);
+    List<AppUserWatchLogVO> selectAppUserWatchLogList(Long userId,Long projectId,String dateTag,Long companyUserId);
 
     /**
      * 查询用户当日未完课的课程列表

+ 74 - 13
fs-service/src/main/java/com/fs/course/service/impl/FsCourseWatchLogServiceImpl.java

@@ -20,6 +20,7 @@ import com.fs.company.cache.ICompanyUserCacheService;
 import com.fs.company.domain.Company;
 import com.fs.company.domain.CompanyUser;
 import com.fs.company.mapper.CompanyMapper;
+import com.fs.company.mapper.CompanyUserMapper;
 import com.fs.course.config.CourseConfig;
 import com.fs.course.constant.CourseConstant;
 import com.fs.course.domain.*;
@@ -165,6 +166,9 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
     @Autowired
     private FsUserCourseStudyLogMapper fsUserCourseStudyLogMapper;
 
+    @Autowired
+    private CompanyUserMapper companyUserMapper;
+
     /**
      * 查询短链课程看课记录
      *
@@ -1409,12 +1413,23 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
         List<AppCourseReportVO> answerList = fsCourseWatchLogMapper.selectAppAnswerStatistics(param);
         List<AppCourseReportVO> redpackList = fsCourseWatchLogMapper.selectAppRedPacketStatistics(param);
 
+        // 获取公司红包开关状态
+        Map<Long, Integer> companyRedPacketStatus = new HashMap<>();
+        for (Long companyId : companyIds) {
+            Company company = companyCacheService.selectCompanyById(companyId);
+            companyRedPacketStatus.put(companyId, company != null ? company.getOpenRedPacket() : null);
+        }
+
         // 5. 转换为 Map 便于查找
         Map<Long, AppCourseReportVO> watchStatsMap = watchStatsList.stream()
                 .collect(Collectors.toMap(AppCourseReportVO::getCompanyId, Function.identity()));
         Map<Long, AppCourseReportVO> answerStatsMap = answerList.stream()
                 .collect(Collectors.toMap(AppCourseReportVO::getCompanyId, Function.identity(), (e, r) -> e));
         Map<Long, AppCourseReportVO> redPacketStatsMap = redpackList.stream()
+                .filter(stats -> {
+                    Integer status = companyRedPacketStatus.get(stats.getCompanyId());
+                    return status != null && status == 1;
+                })
                 .collect(Collectors.toMap(AppCourseReportVO::getCompanyId, Function.identity(), (e, r) -> e));
 
         // 6. 一次性组装所有数据,减少遍历次数
@@ -1605,18 +1620,39 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
     private Map<String, FsCourseReportVO> getRedPacketStatistics(FsCourseWatchLogStatisticsListParam query) {
         List<FsCourseReportVO> redPacketStatistics = fsCourseWatchLogMapper.selectRedPacketStatistics(query);
         Map<String, FsCourseReportVO> redPacketMap = new HashMap<>();
+        
+        Set<Long> companyIds = redPacketStatistics.stream()
+                .map(FsCourseReportVO::getCompanyId)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toSet());
+        Map<Long, Integer> companyRedPacketStatus = new HashMap<>();
+        for (Long companyId : companyIds) {
+            Company company = companyCacheService.selectCompanyById(companyId);
+            companyRedPacketStatus.put(companyId, company != null ? company.getOpenRedPacket() : null);
+        }
+        
         if ("company".equals(query.getDimension())) {
-            redPacketMap = redPacketStatistics.stream().collect(Collectors.toMap(
-                    stats -> String.valueOf(stats.getCompanyId()),
-                    Function.identity(),
-                    (existing, replacement) -> existing // 当出现重复键时,保留第一个值
-            ));
+            redPacketMap = redPacketStatistics.stream()
+                    .filter(stats -> {
+                        Integer status = companyRedPacketStatus.get(stats.getCompanyId());
+                        return status != null && status == 1;
+                    })
+                    .collect(Collectors.toMap(
+                            stats -> String.valueOf(stats.getCompanyId()),
+                            Function.identity(),
+                            (existing, replacement) -> existing
+                    ));
         } else if ("camp".equals(query.getDimension())) {
-            redPacketMap = redPacketStatistics.stream().collect(Collectors.toMap(
-                    stats -> stats.getPeriodId() + "_" + stats.getCompanyId(),
-                    Function.identity(),
-                    (existing, replacement) -> existing // 当出现重复键时,保留第一个值
-            ));
+            redPacketMap = redPacketStatistics.stream()
+                    .filter(stats -> {
+                        Integer status = companyRedPacketStatus.get(stats.getCompanyId());
+                        return status != null && status == 1;
+                    })
+                    .collect(Collectors.toMap(
+                            stats -> stats.getPeriodId() + "_" + stats.getCompanyId(),
+                            Function.identity(),
+                            (existing, replacement) -> existing
+                    ));
         }
 
         return redPacketMap;
@@ -2642,13 +2678,38 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
     }
 
     @Override
-    public List<AppUserWatchLogVO> selectAppUserWatchLogList(Long userId) {
-        return fsCourseWatchLogMapper.selectAppUserWatchLogList(userId);
+    public List<AppUserWatchLogVO> selectAppUserWatchLogList(Long userId,Long projectId,String dateTag,Long companyUserId) {
+        return fsCourseWatchLogMapper.selectAppUserWatchLogList(userId,projectId,dateTag,companyUserId);
     }
 
     @Override
     public List<TodayUnfinishedCourseVO> selectTodayUnfinishedCourseList(Long userId) {
-        return fsCourseWatchLogMapper.selectTodayUnfinishedCourseList(userId);
+        String json = configService.selectConfigByKey("course.config");
+        CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
+        List<TodayUnfinishedCourseVO> todayUnfinishedCourseVOS = fsCourseWatchLogMapper.selectTodayUnfinishedCourseList(userId);
+        todayUnfinishedCourseVOS.forEach(f -> {
+            String domainName = getDomainName(f.getCompanyUserId(), config);
+            FsCourseRealLink courseRealLink = new FsCourseRealLink();
+            courseRealLink.setCompanyUserId(f.getCompanyUserId());
+            courseRealLink.setCourseId(f.getCourseId());
+            courseRealLink.setVideoId(f.getVideoId());
+            courseRealLink.setPeriodId(f.getPeriodId());
+            courseRealLink.setId(f.getPeriodDaysId());
+            courseRealLink.setCompanyId(f.getCompanyId());
+            courseRealLink.setProjectId(f.getProjectId());
+            courseRealLink.setFsUserId(userId);
+            String sortLink = domainName + "/courseH5/pages_course/videovip?course=" + JSON.toJSONString(courseRealLink);
+            f.setUrl(sortLink);
+        });
+        return  todayUnfinishedCourseVOS;
+    }
+
+    private String getDomainName(Long companyUserId, CourseConfig config){
+        String domainName = companyUserMapper.selectDomainByUserId(companyUserId);
+        if (com.fs.common.utils.StringUtils.isEmpty(domainName)){
+            domainName = config.getRealLinkDomainName();
+        }
+        return domainName;
     }
 
 }

+ 2 - 0
fs-service/src/main/java/com/fs/course/vo/AppUserWatchLogVO.java

@@ -34,4 +34,6 @@ public class AppUserWatchLogVO implements Serializable {
     private Date finishTime;
 
     private Integer watchType;
+
+    private  String imgUrl;
 }

+ 24 - 0
fs-service/src/main/java/com/fs/his/service/IFraudUsersService.java

@@ -0,0 +1,24 @@
+package com.fs.his.service;
+
+import com.fs.his.domain.FraudUsers;
+
+import java.util.List;
+import java.util.Map;
+
+public interface IFraudUsersService {
+    FraudUsers selectFraudUsersById(Long id);
+
+    List<FraudUsers> selectFraudUsersList(FraudUsers fraudUsers);
+
+    Map<String, Object> insertFraudUsers(FraudUsers fraudUsers);
+
+    Map<String, Object> updateFraudUsers(FraudUsers fraudUsers);
+
+    int deleteFraudUsersByIds(Long[] ids);
+
+    int deleteFraudUsersById(Long id);
+
+    Map<String, Object> syncFraudUsers();
+
+    boolean isFraudUser(String phone, String address);
+}

+ 25 - 2
fs-service/src/main/resources/mapper/course/FsCourseWatchLogMapper.xml

@@ -2418,6 +2418,7 @@ FROM
             l.log_id AS logId,
             l.course_id AS courseId,
             c.course_name AS courseName,
+            c.img_url as imgUrl,
             l.video_id AS videoId,
             v.title AS videoName,
             l.log_type AS logType,
@@ -2429,7 +2430,23 @@ FROM
         FROM fs_course_watch_log l
         LEFT JOIN fs_user_course c ON l.course_id = c.course_id
         LEFT JOIN fs_user_course_video v ON l.video_id = v.video_id
-        WHERE l.user_id = #{userId} and watch_type=1 and send_type=1
+        WHERE l.user_id = #{userId} and l.project=#{projectId} and l.company_user_id=#{companyUserId} and l.watch_type=1 and l.send_type=1
+        <if test="dateTag != null and dateTag !='' ">
+            <choose>
+                <when test = "dateTag == '今天'">
+                    and to_days(l.create_time) = to_days(now())
+                </when>
+                <when test = "dateTag == '昨天'">
+                    and l.create_time &gt;= CURDATE() - INTERVAL 1 DAY AND l.create_time &lt; CURDATE()
+                </when>
+                <when test = "dateTag == '前天'">
+                    and l.create_time &gt;= CURDATE() - INTERVAL 2 DAY AND l.create_time &lt; CURDATE() - INTERVAL 1 DAY
+                </when>
+                <when test = "dateTag == '近七天'">
+                    and l.create_time &gt;= CURDATE() - INTERVAL 7 DAY
+                </when>
+            </choose>
+        </if>
         ORDER BY l.create_time DESC
     </select>
 
@@ -2438,7 +2455,10 @@ FROM
         SELECT
             l.log_id AS logId,
             l.course_id AS courseId,
+            l.company_user_id  as companyUserId,
+            l.company_id as companyId,
             c.course_name AS courseName,
+            c.img_url as imgUrl,
             l.video_id AS videoId,
             v.title AS videoName,
             l.log_type AS logType,
@@ -2447,13 +2467,15 @@ FROM
             l.create_time AS createTime,
             l.watch_type AS watchType,
             l.period_id AS periodId,
+            l.project as projectId,
             p.period_name AS periodName,
             pd.start_date_time AS startDateTime,
+            pd.id as periodDaysId,
             pd.end_date_time AS endDateTime
         FROM fs_course_watch_log l
         LEFT JOIN fs_user_course c ON l.course_id = c.course_id
         LEFT JOIN fs_user_course_video v ON l.video_id = v.video_id
-        LEFT JOIN fs_user_course_period_days pd ON l.video_id = pd.video_id AND l.period_id = pd.period_id
+        LEFT JOIN fs_user_course_period_days pd ON l.video_id = pd.video_id AND l.period_id = pd.period_id and pd.del_flag=0
         LEFT JOIN fs_user_course_period p ON l.period_id = p.period_id
         WHERE l.user_id = #{userId}
         AND l.watch_type = 1
@@ -2467,6 +2489,7 @@ FROM
             AND f.video_id = l.video_id
             AND f.log_type = 2
         )
+        GROUP BY l.course_id
         ORDER BY l.create_time DESC
     </select>
 </mapper>

+ 1 - 13
fs-user-app/src/main/java/com/fs/app/controller/UserController.java

@@ -97,8 +97,6 @@ public class UserController extends  AppBaseController {
     @Autowired
     private IUserBehaviorService userBehaviorService;
 
-    @Autowired
-    private IFsCourseWatchLogService courseWatchLogService;
 
     @Login
     @ApiOperation("获取用户信息")
@@ -465,15 +463,5 @@ public class UserController extends  AppBaseController {
         return AjaxResult.success();
     }
 
-    @Login
-    @ApiOperation("获取用户看课记录列表")
-    @GetMapping("/getWatchLogList")
-    public R getWatchLogList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
-                             @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
-        Long userId = Long.parseLong(getUserId());
-        PageHelper.startPage(pageNum, pageSize);
-        List<AppUserWatchLogVO> list = courseWatchLogService.selectAppUserWatchLogList(userId);
-        PageInfo<AppUserWatchLogVO> pageInfo = new PageInfo<>(list);
-        return R.ok().put("data", pageInfo);
-    }
+
 }