Browse Source

商城订单处理筛选后导出数据不一致问题处理,处理APPID转换异常问题

yjwang 1 month ago
parent
commit
a81d659420

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

@@ -820,4 +820,6 @@ public interface FsCourseWatchLogMapper extends BaseMapper<FsCourseWatchLog> {
      */
     List<com.fs.course.vo.CourseStatisticsUserDetailVO> selectCourseStatisticsUserDetailExportList(
             @Param("param") com.fs.course.param.CourseStatisticsUserDetailParam param);
+
+    FSActualCompletionVO selectActualCompletionList(@Param("periodId") Long periodId, @Param("videoId") Long videoId);
 }

+ 21 - 16
fs-service/src/main/java/com/fs/course/service/impl/FsCourseWatchLogServiceImpl.java

@@ -1807,23 +1807,28 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
             }
         }
 
-        // 第2-n次观看数据:view_start不在首次点播窗口内的记录(窗口外=首次窗口前或窗口后)
+//        // 第2-n次观看数据:view_start不在首次点播窗口内的记录(窗口外=首次窗口前或窗口后)
+//        if (periodId != null && videoId != null) {
+//            Map<String, Object> repeatStats = fsCourseWatchLogMapper.selectRepeatPlaybackStats(videoId, periodId);
+//            if (repeatStats != null && !repeatStats.isEmpty()) {
+//                Long repeatWatch = getLongFromMap(repeatStats, "repeatWatchCount");
+//                Long repeat20 = getLongFromMap(repeatStats, "repeatWatch20MinCount");
+//                Long repeat30 = getLongFromMap(repeatStats, "repeatWatch30MinCount");
+//                vo.setRepeatWatchCount(repeatWatch != null ? repeatWatch : 0L);
+//                vo.setRepeatWatch20MinCount(repeat20 != null ? repeat20 : 0L);
+//                vo.setRepeatWatch30MinCount(repeat30 != null ? repeat30 : 0L);
+//                if (repeatWatch != null && repeatWatch > 0) {
+//                    vo.setRepeatCompleteRate20Min(BigDecimal.valueOf(repeat20 != null ? repeat20 : 0)
+//                            .divide(BigDecimal.valueOf(repeatWatch), 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)));
+//                    vo.setRepeatCompleteRate30Min(BigDecimal.valueOf(repeat30 != null ? repeat30 : 0)
+//                            .divide(BigDecimal.valueOf(repeatWatch), 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)));
+//                }
+//            }
+//        }
+
+        //实际看课数据
         if (periodId != null && videoId != null) {
-            Map<String, Object> repeatStats = fsCourseWatchLogMapper.selectRepeatPlaybackStats(videoId, periodId);
-            if (repeatStats != null && !repeatStats.isEmpty()) {
-                Long repeatWatch = getLongFromMap(repeatStats, "repeatWatchCount");
-                Long repeat20 = getLongFromMap(repeatStats, "repeatWatch20MinCount");
-                Long repeat30 = getLongFromMap(repeatStats, "repeatWatch30MinCount");
-                vo.setRepeatWatchCount(repeatWatch != null ? repeatWatch : 0L);
-                vo.setRepeatWatch20MinCount(repeat20 != null ? repeat20 : 0L);
-                vo.setRepeatWatch30MinCount(repeat30 != null ? repeat30 : 0L);
-                if (repeatWatch != null && repeatWatch > 0) {
-                    vo.setRepeatCompleteRate20Min(BigDecimal.valueOf(repeat20 != null ? repeat20 : 0)
-                            .divide(BigDecimal.valueOf(repeatWatch), 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)));
-                    vo.setRepeatCompleteRate30Min(BigDecimal.valueOf(repeat30 != null ? repeat30 : 0)
-                            .divide(BigDecimal.valueOf(repeatWatch), 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)));
-                }
-            }
+            vo.setFsActualCompletionVO(fsCourseWatchLogMapper.selectActualCompletionList(periodId,videoId));
         }
 
         // 订单数据:fs_store_order_scrm order_type=3,videoId+periodId 匹配,paid=1

+ 3 - 0
fs-service/src/main/java/com/fs/course/vo/CourseStatisticsDetailVO.java

@@ -69,4 +69,7 @@ public class CourseStatisticsDetailVO implements Serializable {
     private Long redPacketUserCount;
     /** 单品销量统计 */
     private java.util.List<CourseProductSalesVO> productList;
+
+    /** 实际完播统计 */
+    private FSActualCompletionVO fsActualCompletionVO;
 }

+ 42 - 0
fs-service/src/main/java/com/fs/course/vo/FSActualCompletionVO.java

@@ -0,0 +1,42 @@
+package com.fs.course.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 实际完播统计VO
+ * **/
+@Data
+public class FSActualCompletionVO implements Serializable {
+    /**
+     * 实际到课人数
+     */
+    private Integer totalStudents;
+
+    /**
+     * 实际完课人数
+     */
+    private Integer completedCount;
+
+    /**
+     * 实际完课率(百分比)
+     */
+    private BigDecimal actualCompletionRate;
+
+    /**
+     * 人均看课时长(分钟)
+     */
+    private BigDecimal avgWatchDurationMinutes;
+
+    /**
+     * 人均完课时长(分钟)
+     */
+    private BigDecimal avgCompletedDuration;
+
+    /**
+     * 人均完课完播率(百分比)
+     */
+    private BigDecimal avgCompletionPlaybackRate;
+}

+ 7 - 2
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderItemScrmMapper.java

@@ -129,8 +129,13 @@ public interface FsStoreOrderItemScrmMapper
             "<if test = 'maps.companyId != null    '> " +
             "and o.company_id =#{maps.companyId} " +
             "</if>" +
+            "            <if test=\"maps.realName != null and  maps.realName !=''\">\n" +
+            "                and o.real_name like CONCAT('%',#{maps.realName},'%')\n" +
+            "            </if>"+
             "<if test = 'maps.isHealth != null and maps.isHealth !=  \"\"  '> " +
-            "and (o.company_id is null or o.order_type = 2 ) " +
+//            "and (o.company_id is null or o.order_type = 2 ) " +
+            "              and (o.company_id is null\n" +
+            "                or o.order_type = 2 or o.order_type = 3)"+
             "</if>" +
             "<if test = 'maps.notHealth != null and maps.notHealth !=  \"\"  '> " +
             "and o.company_id is not null " +
@@ -175,7 +180,7 @@ public interface FsStoreOrderItemScrmMapper
             "<if test = 'maps.isAudit != null'> " +
             "and o.is_audit = #{maps.isAudit} " +
             "</if>" +
-            " order by o.id desc limit 50000"+
+            "GROUP BY  o.id order by o.id desc limit 50000"+
             "</script>"})
     List<FsStoreOrderItemExportVO> selectFsStoreOrderItemListExportVO(@Param("maps")FsStoreOrderParam fsStoreOrder);
 

+ 6 - 1
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderVO.java

@@ -1,5 +1,6 @@
 package com.fs.hisStore.vo;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fs.common.annotation.Excel;
 import lombok.Data;
@@ -58,6 +59,10 @@ public class FsStoreOrderVO implements Serializable
     @Excel(name = "收货人姓名")
     private String realName;
 
+    @TableField(exist = false)
+    @Excel(name = "用户昵称")
+    private String userNickName;
+
     /** 用户电话 */
     @Excel(name = "收货人电话")
     private String userPhone;
@@ -262,7 +267,7 @@ public class FsStoreOrderVO implements Serializable
 
     //小程序名称
     private String miniProgramName;
-    private Long appId;
+    private String appId;
 
 
     //erp推送号码

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

@@ -1494,4 +1494,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ORDER BY ua.max_create_time DESC
         LIMIT 50000
     </select>
+
+    <select id="selectActualCompletionList" resultType="com.fs.course.vo.FSActualCompletionVO">
+        SELECT
+            a.totalStudents,
+            a.completedCount,
+            ROUND((a.completedCount / a.totalStudents) * 100, 2) AS actualCompletionRate,
+            ROUND((a.totalViewingDuration / a.totalStudents) / 60, 2) AS avgWatchDurationMinutes,
+            ROUND((a.totalDurationOfCompleters/a.completedCount)/60,2) AS avgCompletedDuration,
+            ROUND(((a.totalDurationOfCompleters/a.completedCount)/a.duration) * 100,2) AS avgCompletionPlaybackRate
+        FROM
+            (
+                SELECT
+                    COUNT(*) AS totalStudents,
+                    SUM(CASE WHEN wl.log_type = 2 THEN 1 ELSE 0 END) AS completedCount,
+                    SUM(wl.duration) AS totalViewingDuration,
+                    SUM(CASE WHEN wl.log_type = 2 THEN wl.duration ELSE 0 END) AS totalDurationOfCompleters,
+                    cv.duration
+                FROM
+                    fs_user_course_period_days pd
+                        INNER JOIN fs_course_watch_log wl ON pd.period_id = wl.period_id
+                        INNER JOIN fs_user_course_video cv ON pd.video_id = cv.video_id
+                        AND pd.video_id = wl.video_id
+                WHERE
+                    pd.period_id = #{periodId}
+                  AND pd.video_id = #{videoId}
+                GROUP BY
+                    pd.period_id
+            ) a
+    </select>
 </mapper>

+ 1 - 1
fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml

@@ -1733,7 +1733,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectFsStoreOrderListVO" resultType="com.fs.hisStore.vo.FsStoreOrderVO">
         select DISTINCT o.id,o.order_code,o.extend_order_id,o.pay_order_id,o.bank_order_id,o.user_id,o.real_name,o.user_phone,o.user_address,o.cart_id,o.freight_price,o.total_num,o.total_price,o.total_postage,o.pay_price,o.pay_postage,o.pay_delivery,o.pay_money,o.deduction_price,o.coupon_id,o.coupon_price,o.paid,o.pay_time,o.pay_type,o.create_time,o.update_time,o.status,o.refund_status,o.refund_reason_wap_img,o.refund_reason_wap_explain,o.refund_reason_time,o.refund_reason_wap,o.refund_reason,o.refund_price,o.delivery_sn,o.delivery_name,o.delivery_type,o.delivery_id,o.gain_integral,o.use_integral,o.pay_integral,o.back_integral,o.mark,o.is_del,o.remark,o.verify_code,o.store_id,o.shipping_type,o.is_channel,o.is_remind,o.is_sys_del,o.is_prescribe,o.prescribe_id,o.company_id,o.company_user_id,o.is_package,o.package_json,o.order_type,o.package_id,o.finish_time,o.delivery_status,o.delivery_pay_status,o.delivery_time,o.delivery_pay_time,o.delivery_pay_money,o.tui_money,o.tui_money_status,o.delivery_import_time,o.tui_user_id,o.tui_user_money_status,o.order_create_type,o.store_house_code,o.dept_id,o.is_edit_money,o.customer_id,o.is_pay_remain,o.delivery_send_time,o.certificates,o.upload_time,o.item_json,o.schedule_id,o.delivery_pay_type,o.order_visit,o.service_fee,o.cycle,o.prescribe_price,o.follow_doctor_id,o.follow_time,o.user_coupon_id,o.order_medium,o.erp_phone,o.order_type
         ,u.phone,u.register_code,u.register_date,u.source, c.company_name ,cu.nick_name as company_user_nick_name ,cu.phonenumber as company_usere_phonenumber
-        , csc.name miniProgramName,fsp.cost, fspc.cate_name,spavs.bar_code, sp_latest.bank_transaction_id as bankTransactionId,sp_latest.app_id, o.is_audit, o.audit_time
+        , csc.name miniProgramName,fsp.cost, fspc.cate_name,spavs.bar_code, sp_latest.bank_transaction_id as bankTransactionId,sp_latest.app_id, o.is_audit, o.audit_time,u.nick_name AS userNickName,oi.json_info
         from fs_store_order_scrm o
         left join fs_user u on o.user_id=u.user_id
         left join company c on c.company_id=o.company_id