yjwang пре 3 недеља
родитељ
комит
ada825fc05

+ 3 - 0
fs-company/src/main/java/com/fs/company/controller/course/FsCourseWatchLogController.java

@@ -406,6 +406,7 @@ public class FsCourseWatchLogController extends BaseController
         }
         }
         FsCourseSummaryDetailQueryParam param = new FsCourseSummaryDetailQueryParam();
         FsCourseSummaryDetailQueryParam param = new FsCourseSummaryDetailQueryParam();
         param.setCompanyId(loginUser.getCompany().getCompanyId());
         param.setCompanyId(loginUser.getCompany().getCompanyId());
+        param.setCompanyUserId(loginUser.getCompany().getUserId());
         param.setVideoId(videoId);
         param.setVideoId(videoId);
         param.setPeriodId(periodId);
         param.setPeriodId(periodId);
         return R.ok().put("data", fsCourseWatchLogService.getCourseStatisticsDetail(param));
         return R.ok().put("data", fsCourseWatchLogService.getCourseStatisticsDetail(param));
@@ -440,6 +441,7 @@ public class FsCourseWatchLogController extends BaseController
         param.setPeriodId(periodId);
         param.setPeriodId(periodId);
         param.setPageNum(pageNum);
         param.setPageNum(pageNum);
         param.setPageSize(pageSize);
         param.setPageSize(pageSize);
+        param.setCompanyUserId(loginUser.getCompany().getUserId());
         param.setCompanyId(loginUser.getCompany().getCompanyId());
         param.setCompanyId(loginUser.getCompany().getCompanyId());
         PageHelper.startPage(pageNum, pageSize);
         PageHelper.startPage(pageNum, pageSize);
         return R.ok().put("data", new PageInfo<>(fsCourseWatchLogService.getCourseStatisticsUserDetailList(param)));
         return R.ok().put("data", new PageInfo<>(fsCourseWatchLogService.getCourseStatisticsUserDetailList(param)));
@@ -465,6 +467,7 @@ public class FsCourseWatchLogController extends BaseController
         param.setVideoId(videoId);
         param.setVideoId(videoId);
         param.setPeriodId(periodId);
         param.setPeriodId(periodId);
         param.setCompanyId(loginUser.getCompany().getCompanyId());
         param.setCompanyId(loginUser.getCompany().getCompanyId());
+        param.setCompanyUserId(loginUser.getCompany().getUserId());
         List<com.fs.course.vo.CourseStatisticsUserDetailVO> list = fsCourseWatchLogService.getCourseStatisticsUserDetailExportList(param);
         List<com.fs.course.vo.CourseStatisticsUserDetailVO> list = fsCourseWatchLogService.getCourseStatisticsUserDetailExportList(param);
         ExcelUtil<com.fs.course.vo.CourseStatisticsUserDetailVO> util = new ExcelUtil<>(com.fs.course.vo.CourseStatisticsUserDetailVO.class);
         ExcelUtil<com.fs.course.vo.CourseStatisticsUserDetailVO> util = new ExcelUtil<>(com.fs.course.vo.CourseStatisticsUserDetailVO.class);
         return util.exportExcel(list, "用户看课数据");
         return util.exportExcel(list, "用户看课数据");

+ 3 - 1
fs-service/src/main/java/com/fs/course/mapper/FsCourseAnswerLogsMapper.java

@@ -171,8 +171,10 @@ public interface FsCourseAnswerLogsMapper
             "SELECT COUNT(DISTINCT user_id) FROM fs_course_answer_logs " +
             "SELECT COUNT(DISTINCT user_id) FROM fs_course_answer_logs " +
             "WHERE video_id = #{videoId} AND period_id = #{periodId} " +
             "WHERE video_id = #{videoId} AND period_id = #{periodId} " +
             "<if test='companyId != null'>AND company_id = #{companyId}</if>" +
             "<if test='companyId != null'>AND company_id = #{companyId}</if>" +
+            "<if test='companyUserId != null'>AND company_user_id = #{companyUserId}</if>" +
             "</script>")
             "</script>")
     Long countDistinctUsersByVideoAndPeriod(@Param("videoId") Long videoId,
     Long countDistinctUsersByVideoAndPeriod(@Param("videoId") Long videoId,
                                             @Param("periodId") Long periodId,
                                             @Param("periodId") Long periodId,
-                                            @Param("companyId") Long companyId);
+                                            @Param("companyId") Long companyId,
+                                            @Param("companyUserId") Long companyUserId);
 }
 }

+ 3 - 1
fs-service/src/main/java/com/fs/course/mapper/FsCourseRedPacketLogMapper.java

@@ -193,10 +193,12 @@ public interface FsCourseRedPacketLogMapper
             "SELECT COUNT(DISTINCT user_id) FROM fs_course_red_packet_log " +
             "SELECT COUNT(DISTINCT user_id) FROM fs_course_red_packet_log " +
             "WHERE video_id = #{videoId} AND period_id = #{periodId} " +
             "WHERE video_id = #{videoId} AND period_id = #{periodId} " +
             "<if test='companyId != null'>AND company_id = #{companyId}</if>" +
             "<if test='companyId != null'>AND company_id = #{companyId}</if>" +
+            "<if test='companyUserId != null'>AND company_user_id = #{companyUserId}</if>" +
             "</script>")
             "</script>")
     Long countDistinctUsersByVideoAndPeriod(@Param("videoId") Long videoId,
     Long countDistinctUsersByVideoAndPeriod(@Param("videoId") Long videoId,
                                             @Param("periodId") Long periodId,
                                             @Param("periodId") Long periodId,
-                                            @Param("companyId") Long companyId);
+                                            @Param("companyId") Long companyId,
+                                            @Param("companyUserId") Long companyUserId);
 
 
     @Select("SELECT * FROM fs_course_red_packet_log \n" +
     @Select("SELECT * FROM fs_course_red_packet_log \n" +
             "WHERE create_time <= DATE_SUB(NOW(), INTERVAL 10 MINUTE)  -- 10 分钟前或更早\n" +
             "WHERE create_time <= DATE_SUB(NOW(), INTERVAL 10 MINUTE)  -- 10 分钟前或更早\n" +

+ 8 - 4
fs-service/src/main/java/com/fs/course/mapper/FsCourseWatchLogMapper.java

@@ -778,10 +778,12 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
             "SELECT COUNT(DISTINCT user_id) FROM fs_course_watch_log " +
             "SELECT COUNT(DISTINCT user_id) FROM fs_course_watch_log " +
             "WHERE video_id = #{videoId} AND period_id = #{periodId} " +
             "WHERE video_id = #{videoId} AND period_id = #{periodId} " +
             "<if test='companyId != null'>AND company_id = #{companyId}</if>" +
             "<if test='companyId != null'>AND company_id = #{companyId}</if>" +
+            "<if test='companyUserId != null'>AND company_user_id = #{companyUserId}</if>" +
             "</script>")
             "</script>")
     Long countDistinctWatchUsers(@Param("videoId") Long videoId,
     Long countDistinctWatchUsers(@Param("videoId") Long videoId,
                                  @Param("periodId") Long periodId,
                                  @Param("periodId") Long periodId,
-                                 @Param("companyId") Long companyId);
+                                 @Param("companyId") Long companyId,
+                                 @Param("companyUserId") Long companyUserId);
 
 
     /**
     /**
      * 统计累计完课人数(duration >= 1200秒,即20分钟,对userId去重)
      * 统计累计完课人数(duration >= 1200秒,即20分钟,对userId去重)
@@ -793,10 +795,12 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
             "SELECT COUNT(DISTINCT user_id) FROM fs_course_watch_log " +
             "SELECT COUNT(DISTINCT user_id) FROM fs_course_watch_log " +
             "WHERE video_id = #{videoId} AND period_id = #{periodId} AND duration >= 1200 " +
             "WHERE video_id = #{videoId} AND period_id = #{periodId} AND duration >= 1200 " +
             "<if test='companyId != null'>AND company_id = #{companyId}</if>" +
             "<if test='companyId != null'>AND company_id = #{companyId}</if>" +
+            "<if test='companyUserId != null'>AND company_user_id = #{companyUserId}</if>" +
             "</script>")
             "</script>")
     Long countDistinctCompleteUsers(@Param("videoId") Long videoId,
     Long countDistinctCompleteUsers(@Param("videoId") Long videoId,
                                     @Param("periodId") Long periodId,
                                     @Param("periodId") Long periodId,
-                                    @Param("companyId") Long companyId);
+                                    @Param("companyId") Long companyId,
+                                    @Param("companyUserId") Long companyUserId);
 
 
     /**
     /**
      * 首次点播数据统计:观看人数、>=20分钟人数、>=30分钟人数
      * 首次点播数据统计:观看人数、>=20分钟人数、>=30分钟人数
@@ -808,7 +812,7 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
      * @return Map: firstWatchCount, firstWatch20MinCount, firstWatch30MinCount
      * @return Map: firstWatchCount, firstWatch20MinCount, firstWatch30MinCount
      */
      */
     Map<String, Object> selectFirstPlaybackStats(@Param("videoId") Long videoId,
     Map<String, Object> selectFirstPlaybackStats(@Param("videoId") Long videoId,
-                                                 @Param("periodId") Long periodId, @Param("companyId") Long companyId);
+                                                 @Param("periodId") Long periodId, @Param("companyId") Long companyId, @Param("companyUserId") Long companyUserId);
 
 
     /**
     /**
      * 第2-n次观看数据统计:view_start不在首次点播窗口内的观看记录
      * 第2-n次观看数据统计:view_start不在首次点播窗口内的观看记录
@@ -834,5 +838,5 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
     List<com.fs.course.vo.CourseStatisticsUserDetailVO> selectCourseStatisticsUserDetailExportList(
     List<com.fs.course.vo.CourseStatisticsUserDetailVO> selectCourseStatisticsUserDetailExportList(
             @Param("param") com.fs.course.param.CourseStatisticsUserDetailParam param);
             @Param("param") com.fs.course.param.CourseStatisticsUserDetailParam param);
 
 
-    FSActualCompletionVO selectActualCompletionList(@Param("periodId") Long periodId, @Param("videoId") Long videoId, @Param("companyId") Long companyId);
+    FSActualCompletionVO selectActualCompletionList(@Param("periodId") Long periodId, @Param("videoId") Long videoId, @Param("companyId") Long companyId,@Param("companyUserId") Long companyUserId);
 }
 }

+ 3 - 0
fs-service/src/main/java/com/fs/course/param/CourseStatisticsUserDetailParam.java

@@ -24,4 +24,7 @@ public class CourseStatisticsUserDetailParam implements Serializable {
 
 
     // 公司ID
     // 公司ID
     private Long companyId;
     private Long companyId;
+
+    // 公司ID
+    private Long companyUserId;
 }
 }

+ 1 - 0
fs-service/src/main/java/com/fs/course/param/FsCourseSummaryDetailQueryParam.java

@@ -12,4 +12,5 @@ public class FsCourseSummaryDetailQueryParam implements Serializable {
     private Long videoId;
     private Long videoId;
     private Long periodId;
     private Long periodId;
     private Long companyId;
     private Long companyId;
+    private Long companyUserId;
 }
 }

+ 8 - 6
fs-service/src/main/java/com/fs/course/service/impl/FsCourseWatchLogServiceImpl.java

@@ -1764,6 +1764,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
         Long videoId = param.getVideoId();
         Long videoId = param.getVideoId();
         Long periodId = param.getPeriodId();
         Long periodId = param.getPeriodId();
         Long companyId = param.getCompanyId() != null ? param.getCompanyId() : null;
         Long companyId = param.getCompanyId() != null ? param.getCompanyId() : null;
+        Long companyUserId = param.getCompanyUserId() != null ? param.getCompanyUserId() : null;
 
 
         // 总体数据
         // 总体数据
         
         
@@ -1775,11 +1776,11 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
 
 
 
 
         // 2. 统计累计观看人数(对userId去重)
         // 2. 统计累计观看人数(对userId去重)
-        Long totalWatchCount = fsCourseWatchLogMapper.countDistinctWatchUsers(videoId, periodId,companyId);
+        Long totalWatchCount = fsCourseWatchLogMapper.countDistinctWatchUsers(videoId, periodId,companyId,companyUserId);
         vo.setTotalWatchCount(totalWatchCount != null ? totalWatchCount : 0L);
         vo.setTotalWatchCount(totalWatchCount != null ? totalWatchCount : 0L);
         
         
         // 3. 统计累计完课人数(duration >= 1200秒,即20分钟,对userId去重)
         // 3. 统计累计完课人数(duration >= 1200秒,即20分钟,对userId去重)
-        Long totalCompleteCount = fsCourseWatchLogMapper.countDistinctCompleteUsers(videoId, periodId,companyId);
+        Long totalCompleteCount = fsCourseWatchLogMapper.countDistinctCompleteUsers(videoId, periodId,companyId,companyUserId);
         vo.setTotalCompleteCount(totalCompleteCount != null ? totalCompleteCount : 0L);
         vo.setTotalCompleteCount(totalCompleteCount != null ? totalCompleteCount : 0L);
         
         
         // 4. 计算到课完课率 = 累计完课人数 / 累计观看人数
         // 4. 计算到课完课率 = 累计完课人数 / 累计观看人数
@@ -1793,7 +1794,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
 
 
         // 首次点播数据:营期开始时间+视频时长内的观看记录,view_start=update_time-duration 或 finish_time-duration(SQL内联计算窗口)
         // 首次点播数据:营期开始时间+视频时长内的观看记录,view_start=update_time-duration 或 finish_time-duration(SQL内联计算窗口)
         if (periodId != null && videoId != null) {
         if (periodId != null && videoId != null) {
-            Map<String, Object> firstStats = fsCourseWatchLogMapper.selectFirstPlaybackStats(videoId, periodId,companyId);
+            Map<String, Object> firstStats = fsCourseWatchLogMapper.selectFirstPlaybackStats(videoId, periodId,companyId,companyUserId);
             if (firstStats != null && !firstStats.isEmpty()) {
             if (firstStats != null && !firstStats.isEmpty()) {
                 Long firstWatch = getLongFromMap(firstStats, "firstWatchCount");
                 Long firstWatch = getLongFromMap(firstStats, "firstWatchCount");
                 Long first20 = getLongFromMap(firstStats, "firstWatch20MinCount");
                 Long first20 = getLongFromMap(firstStats, "firstWatch20MinCount");
@@ -1831,7 +1832,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
 
 
         //实际看课数据
         //实际看课数据
         if (periodId != null && videoId != null) {
         if (periodId != null && videoId != null) {
-            vo.setFsActualCompletionVO(fsCourseWatchLogMapper.selectActualCompletionList(periodId,videoId,companyId));
+            vo.setFsActualCompletionVO(fsCourseWatchLogMapper.selectActualCompletionList(periodId,videoId,companyId,companyUserId));
         }
         }
 
 
         // 订单数据:fs_store_order_scrm order_type=3,videoId+periodId 匹配,paid=1
         // 订单数据:fs_store_order_scrm order_type=3,videoId+periodId 匹配,paid=1
@@ -1841,6 +1842,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
             orderQuery.setVideoId(videoId.intValue());
             orderQuery.setVideoId(videoId.intValue());
             orderQuery.setPeriodId(periodId.intValue());
             orderQuery.setPeriodId(periodId.intValue());
             orderQuery.setCompanyId(companyId);
             orderQuery.setCompanyId(companyId);
+            orderQuery.setCompanyUserId(companyUserId);
             orderQuery.setPaid(1);
             orderQuery.setPaid(1);
             List<FsStoreOrderScrm> orders = fsStoreOrderScrmMapper.selectFsStoreOrderList(orderQuery);
             List<FsStoreOrderScrm> orders = fsStoreOrderScrmMapper.selectFsStoreOrderList(orderQuery);
             List<FsStoreOrderScrm> paidOrders = orders != null ? orders.stream()
             List<FsStoreOrderScrm> paidOrders = orders != null ? orders.stream()
@@ -1871,10 +1873,10 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
                 vo.setCompleteRValue(gmv.divide(BigDecimal.valueOf(vo.getTotalCompleteCount()), 2, RoundingMode.HALF_UP));
                 vo.setCompleteRValue(gmv.divide(BigDecimal.valueOf(vo.getTotalCompleteCount()), 2, RoundingMode.HALF_UP));
             }
             }
 
 
-            Long answerCount = fsCourseAnswerLogsMapper.countDistinctUsersByVideoAndPeriod(videoId, periodId,companyId);
+            Long answerCount = fsCourseAnswerLogsMapper.countDistinctUsersByVideoAndPeriod(videoId, periodId,companyId,companyUserId);
             vo.setAnswerUserCount(answerCount != null ? answerCount : 0L);
             vo.setAnswerUserCount(answerCount != null ? answerCount : 0L);
 
 
-            Long redCount = fsCourseRedPacketLogMapper.countDistinctUsersByVideoAndPeriod(videoId, periodId,companyId);
+            Long redCount = fsCourseRedPacketLogMapper.countDistinctUsersByVideoAndPeriod(videoId, periodId,companyId,companyUserId);
             vo.setRedPacketUserCount(redCount != null ? redCount : 0L);
             vo.setRedPacketUserCount(redCount != null ? redCount : 0L);
 
 
             // 单品销量统计:从订单明细汇总
             // 单品销量统计:从订单明细汇总

+ 2 - 1
fs-service/src/main/java/com/fs/crm/service/ICrmCustomerAnalyzeService.java

@@ -2,6 +2,7 @@ package com.fs.crm.service;
 
 
 import java.util.List;
 import java.util.List;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fs.crm.domain.CrmCustomerAnalyze;
 import com.fs.crm.domain.CrmCustomerAnalyze;
 import com.fs.crm.param.PolishingScriptParam;
 import com.fs.crm.param.PolishingScriptParam;
 
 
@@ -76,5 +77,5 @@ public interface ICrmCustomerAnalyzeService extends IService<CrmCustomerAnalyze>
 
 
     List<CrmCustomerAnalyze> selectCrmCustomerAnalyzeListAll(CrmCustomerAnalyze crmCustomerAnalyze);
     List<CrmCustomerAnalyze> selectCrmCustomerAnalyzeListAll(CrmCustomerAnalyze crmCustomerAnalyze);
 
 
-    String aiIntentionDegree(String content , Long chatId);
+    String aiIntentionDegree(String content , Long chatId) throws JsonProcessingException;
 }
 }

+ 12 - 0
fs-service/src/main/resources/mapper/course/FsCourseWatchLogMapper.xml

@@ -1409,6 +1409,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           AND l.user_id IS NOT NULL
           AND l.user_id IS NOT NULL
         <if test="companyId != null">
         <if test="companyId != null">
             AND l.company_id = #{companyId}
             AND l.company_id = #{companyId}
+        </if>
+        <if test="companyUserId != null">
+            AND l.company_user_id = #{companyUserId}
         </if>
         </if>
           AND (
           AND (
               (COALESCE(DATE_SUB(l.finish_time, INTERVAL COALESCE(l.duration, 0) SECOND), DATE_SUB(l.update_time, INTERVAL COALESCE(l.duration, 0) SECOND), l.create_time) &gt;= fcpd.start_date_time)
               (COALESCE(DATE_SUB(l.finish_time, INTERVAL COALESCE(l.duration, 0) SECOND), DATE_SUB(l.update_time, INTERVAL COALESCE(l.duration, 0) SECOND), l.create_time) &gt;= fcpd.start_date_time)
@@ -1468,6 +1471,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="param.companyId != null">
             <if test="param.companyId != null">
                 AND l.company_id = #{param.companyId}
                 AND l.company_id = #{param.companyId}
             </if>
             </if>
+        <if test="param.companyUserId != null">
+            AND l.company_user_id = #{param.companyUserId}
+        </if>
             GROUP BY l.user_id
             GROUP BY l.user_id
         ) ua
         ) ua
         LEFT JOIN fs_user u ON u.user_id = ua.user_id
         LEFT JOIN fs_user u ON u.user_id = ua.user_id
@@ -1520,6 +1526,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             WHERE l.video_id = #{param.videoId} AND l.period_id = #{param.periodId} AND l.user_id IS NOT NULL
             WHERE l.video_id = #{param.videoId} AND l.period_id = #{param.periodId} AND l.user_id IS NOT NULL
         <if test="param.companyId != null">
         <if test="param.companyId != null">
             AND l.company_id = #{param.companyId}
             AND l.company_id = #{param.companyId}
+        </if>
+        <if test="param.companyUserId != null">
+            AND l.company_user_id = #{param.companyUserId}
         </if>
         </if>
             GROUP BY l.user_id
             GROUP BY l.user_id
         ) ua
         ) ua
@@ -1570,6 +1579,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyId != null">
             <if test="companyId != null">
                 AND wl.company_id = #{companyId}
                 AND wl.company_id = #{companyId}
             </if>
             </if>
+            <if test="companyUserId != null">
+                AND wl.company_user_id = #{companyUserId}
+            </if>
         </where>
         </where>
         GROUP BY
         GROUP BY
         pd.period_id
         pd.period_id