Sfoglia il codice sorgente

1.修复企微看课统计中的红包记录

jzp 1 mese fa
parent
commit
d84ebec16b

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

@@ -203,6 +203,5 @@ public interface FsCourseRedPacketLogMapper
 
     List<FsCourseRedPacketLog> selectFsCourseRedPacketLogListBySending(@Param("maps") Map<String, Object> map);
 
-    @MapKey("qwUserId")
-    Map<Long, FsCourseWatchLogStatisticsListVO> selectFsCourseRedPacketLogByQwUserIdList(@Param("param") FsCourseWatchLogStatisticsListParam param);
+    List<FsCourseWatchLogStatisticsListVO> selectFsCourseRedPacketLogByQwUserIdList(@Param("param") FsCourseWatchLogStatisticsListParam param);
 }

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

@@ -225,7 +225,7 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
             "</if> " +
             "from (" +
             "SELECT \n" +
-            "o.video_id,o.company_id,o.qw_user_id,DATE(o.create_time) create_time," +
+            "o.video_id,o.course_id,o.company_id,o.qw_user_id,DATE(o.create_time) create_time," +
             "<if test= 'sendType != 1 '> " +
             " qu.qw_user_name qw_user_name," +
             "</if>\n" +

+ 14 - 3
fs-service/src/main/java/com/fs/course/service/impl/FsCourseWatchLogServiceImpl.java

@@ -768,11 +768,22 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
     public List<FsCourseWatchLogStatisticsListVO> selectFsCourseWatchLogStatisticsListVO(FsCourseWatchLogStatisticsListParam param) {
         if (param.getUserIds() != null && !param.getUserIds().isEmpty())param.setUserIds(param.getUserIds());
         List<FsCourseWatchLogStatisticsListVO> statisticsListVOS = fsCourseWatchLogMapper.selectFsCourseWatchLogStatisticsListVO(param);
-        Map<Long,FsCourseWatchLogStatisticsListVO> redAmountMap = fsCourseRedPacketLogMapper.selectFsCourseRedPacketLogByQwUserIdList(param);
+        Map<String, FsCourseWatchLogStatisticsListVO> redAmountMap = new HashMap<>();
+        List<FsCourseWatchLogStatisticsListVO> redPacketLogs = fsCourseRedPacketLogMapper.selectFsCourseRedPacketLogByQwUserIdList(param);
+        for (FsCourseWatchLogStatisticsListVO log : redPacketLogs) {
+            // 空值校验
+            if (log.getQwUserId() != null && log.getVideoId() != null) {
+                String key = log.getQwUserId() + "_" + log.getVideoId() + "_" + log.getCreateTime();
+                redAmountMap.put(key, log);
+            }
+        }
         statisticsListVOS.forEach(vo ->{
-            FsCourseWatchLogStatisticsListVO statisticsListVO = redAmountMap.get(vo.getQwUserId());
+            FsCourseWatchLogStatisticsListVO statisticsListVO = redAmountMap.get(vo.getQwUserId() + "_" + vo.getVideoId() + "_" + vo.getCreateTime());
             if(statisticsListVO != null){
-                if(statisticsListVO.getQwUserId().equals(vo.getQwUserId()) && statisticsListVO.getCreateTime().equals(vo.getCreateTime())){
+                if(statisticsListVO.getCourseId().equals(vo.getCourseId()) &&
+                        statisticsListVO.getVideoId().equals(vo.getVideoId()) &&
+                        statisticsListVO.getQwUserId().equals(vo.getQwUserId()) &&
+                        statisticsListVO.getCreateTime().equals(vo.getCreateTime())){
                     vo.setRedAmount(statisticsListVO.getRedAmount());
                 }
             }

+ 17 - 5
fs-service/src/main/resources/mapper/course/FsCourseRedPacketLogMapper.xml

@@ -276,17 +276,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </choose>
 
     </select>
-    <select id="selectFsCourseRedPacketLogByQwUserIdList" resultType="com.fs.course.vo.FsCourseWatchLogStatisticsListVO">
-        select qw_user_id qwUserId, sum(amount) as redAmount,date_format(create_time,'%Y-%m-%d') createTime from fs_course_red_packet_log
+    <select id="selectFsCourseRedPacketLogByQwUserIdList"
+            resultType="com.fs.course.vo.FsCourseWatchLogStatisticsListVO">
+        select f1.qw_user_id qwUserId,f1.video_id videoId,f1.course_id courseId,f1.user_id userId,sum(f1.amount) as redAmount,
+         date_format(f1.create_time,'%Y-%m-%d') createTime from fs_course_red_packet_log f1
+        left join fs_course_watch_log f2 on f1.user_id = f2.user_id and f1.video_id = f2.video_id
         <where>
             <if test="param.companyId != null">
-                and company_id = #{param.companyId}
+                and f1.company_id = #{param.companyId}
             </if>
             <if test=" param.sTime != null and  param.eTime != null">
-                AND date_format(create_time,'%Y-%m-%d') &gt;=  date_format(#{param.sTime},'%Y-%m-%d') and date_format(create_time,'%Y-%m-%d') &lt;= date_format(#{param.eTime},'%Y-%m-%d')
+                AND date_format(f1.create_time,'%Y-%m-%d') &gt;=  date_format(#{param.sTime},'%Y-%m-%d') and date_format(f1.create_time,'%Y-%m-%d') &lt;= date_format(#{param.eTime},'%Y-%m-%d')
+            </if>
+            <if test ='param.courseId !=null'>
+                and f1.course_id = #{param.courseId}
+            </if>
+            <if test ='param.qwSopId !=null and param.qwSopId!=""'>
+                and f2.sop_id = #{param.qwSopId}
+            </if>
+            <if test ='param.videoId !=null'>
+                and f1.video_id = #{param.videoId}
             </if>
         </where>
-        group by qw_user_id,date_format(create_time,'%Y-%m-%d')
+        group by f1.qw_user_id,f1.video_id,f1.course_id,date_format(f1.create_time,'%Y-%m-%d')
     </select>