|
@@ -15,13 +15,19 @@ import java.util.List;
|
|
|
@Mapper
|
|
@Mapper
|
|
|
public interface CommonPushTaskMapper extends BaseMapper<CommonPushTask> {
|
|
public interface CommonPushTaskMapper extends BaseMapper<CommonPushTask> {
|
|
|
|
|
|
|
|
|
|
+ String NUM_SUM_REAL_SEND = "IFNULL(SUM(CAST(IFNULL(n.real_send, 0) AS UNSIGNED)), 0)";
|
|
|
|
|
+ String NUM_SUM_REAL_DELIVERED = "IFNULL(SUM(CAST(IFNULL(n.real_delivered, 0) AS UNSIGNED)), 0)";
|
|
|
|
|
+ String NUM_SUM_CLICK = "IFNULL(SUM(CAST(IFNULL(n.click_sum, 0) AS UNSIGNED)), 0)";
|
|
|
|
|
+ String NUM_SUM_SHOW = "IFNULL(SUM(CAST(IFNULL(n.show_sum, 0) AS UNSIGNED)), 0)";
|
|
|
|
|
+ String NUM_JOIN = "LEFT JOIN common_push_task_num n ON n.push_task_id = t.id AND n.delete_flag = 0 ";
|
|
|
|
|
+
|
|
|
@Select("<script>" +
|
|
@Select("<script>" +
|
|
|
"SELECT " +
|
|
"SELECT " +
|
|
|
- "IFNULL(SUM(CASE WHEN u.status IN (2, 3) THEN 1 ELSE 0 END), 0) AS sentCount, " +
|
|
|
|
|
- "IFNULL(SUM(CASE WHEN u.status = 3 THEN 1 ELSE 0 END), 0) AS deliveredCount, " +
|
|
|
|
|
- "IFNULL(SUM(CASE WHEN u.user_add = 1 THEN 1 ELSE 0 END), 0) AS clickCount " +
|
|
|
|
|
|
|
+ NUM_SUM_REAL_SEND + " AS sentCount, " +
|
|
|
|
|
+ NUM_SUM_REAL_DELIVERED + " AS deliveredCount, " +
|
|
|
|
|
+ NUM_SUM_CLICK + " AS clickCount " +
|
|
|
"FROM common_push_task t " +
|
|
"FROM common_push_task t " +
|
|
|
- "LEFT JOIN common_push_task_user u ON u.push_task_id = t.id AND u.delete_flag = 0 " +
|
|
|
|
|
|
|
+ NUM_JOIN +
|
|
|
"WHERE t.delete_flag = 0 " +
|
|
"WHERE t.delete_flag = 0 " +
|
|
|
"<if test='taskNo != null and taskNo != \"\"'>AND t.task_no = #{taskNo} </if>" +
|
|
"<if test='taskNo != null and taskNo != \"\"'>AND t.task_no = #{taskNo} </if>" +
|
|
|
"<if test='keyword != null and keyword != \"\"'>AND (t.title LIKE CONCAT('%', #{keyword}, '%') OR t.task_no LIKE CONCAT('%', #{keyword}, '%')) </if>" +
|
|
"<if test='keyword != null and keyword != \"\"'>AND (t.title LIKE CONCAT('%', #{keyword}, '%') OR t.task_no LIKE CONCAT('%', #{keyword}, '%')) </if>" +
|
|
@@ -30,8 +36,8 @@ public interface CommonPushTaskMapper extends BaseMapper<CommonPushTask> {
|
|
|
"<if test='channel != null and channel != \"\"'>AND t.channels LIKE CONCAT('%', #{channel}, '%') </if>" +
|
|
"<if test='channel != null and channel != \"\"'>AND t.channels LIKE CONCAT('%', #{channel}, '%') </if>" +
|
|
|
"<if test='startTime != null'>AND t.created_time >= #{startTime} </if>" +
|
|
"<if test='startTime != null'>AND t.created_time >= #{startTime} </if>" +
|
|
|
"<if test='endTime != null'>AND t.created_time < #{endTime} </if>" +
|
|
"<if test='endTime != null'>AND t.created_time < #{endTime} </if>" +
|
|
|
- "<if test='startTime != null'>AND u.created_time >= #{startTime} </if>" +
|
|
|
|
|
- "<if test='endTime != null'>AND u.created_time < #{endTime} </if>" +
|
|
|
|
|
|
|
+ "<if test='startTime != null'>AND n.created_time >= #{startTime} </if>" +
|
|
|
|
|
+ "<if test='endTime != null'>AND n.created_time < #{endTime} </if>" +
|
|
|
"</script>")
|
|
"</script>")
|
|
|
CommonPushTaskStatsDto selectStatisticsSummary(@Param("taskNo") String taskNo,
|
|
CommonPushTaskStatsDto selectStatisticsSummary(@Param("taskNo") String taskNo,
|
|
|
@Param("keyword") String keyword,
|
|
@Param("keyword") String keyword,
|
|
@@ -44,12 +50,12 @@ public interface CommonPushTaskMapper extends BaseMapper<CommonPushTask> {
|
|
|
@Select("<script>" +
|
|
@Select("<script>" +
|
|
|
"SELECT t.id, t.task_no AS taskNo, t.title, t.push_type AS pushType, t.status, " +
|
|
"SELECT t.id, t.task_no AS taskNo, t.title, t.push_type AS pushType, t.status, " +
|
|
|
"t.channels, t.estimated_count AS estimatedCount, t.created_time AS createdTime, " +
|
|
"t.channels, t.estimated_count AS estimatedCount, t.created_time AS createdTime, " +
|
|
|
- "IFNULL(SUM(CASE WHEN u.status IN (2, 3) THEN 1 ELSE 0 END), 0) AS sentCount, " +
|
|
|
|
|
- "IFNULL(SUM(CASE WHEN u.status = 3 THEN 1 ELSE 0 END), 0) AS deliveredCount, " +
|
|
|
|
|
- "IFNULL(SUM(CASE WHEN u.show_info = 1 THEN 1 ELSE 0 END), 0) AS showCount, " +
|
|
|
|
|
- "IFNULL(SUM(CASE WHEN u.user_add = 1 THEN 1 ELSE 0 END), 0) AS clickCount " +
|
|
|
|
|
|
|
+ NUM_SUM_REAL_SEND + " AS sentCount, " +
|
|
|
|
|
+ NUM_SUM_REAL_DELIVERED + " AS deliveredCount, " +
|
|
|
|
|
+ NUM_SUM_SHOW + " AS showCount, " +
|
|
|
|
|
+ NUM_SUM_CLICK + " AS clickCount " +
|
|
|
"FROM common_push_task t " +
|
|
"FROM common_push_task t " +
|
|
|
- "LEFT JOIN common_push_task_user u ON u.push_task_id = t.id AND u.delete_flag = 0 " +
|
|
|
|
|
|
|
+ NUM_JOIN +
|
|
|
"WHERE t.delete_flag = 0 " +
|
|
"WHERE t.delete_flag = 0 " +
|
|
|
"<if test='taskNo != null and taskNo != \"\"'>AND t.task_no = #{taskNo} </if>" +
|
|
"<if test='taskNo != null and taskNo != \"\"'>AND t.task_no = #{taskNo} </if>" +
|
|
|
"<if test='keyword != null and keyword != \"\"'>AND (t.title LIKE CONCAT('%', #{keyword}, '%') OR t.task_no LIKE CONCAT('%', #{keyword}, '%')) </if>" +
|
|
"<if test='keyword != null and keyword != \"\"'>AND (t.title LIKE CONCAT('%', #{keyword}, '%') OR t.task_no LIKE CONCAT('%', #{keyword}, '%')) </if>" +
|
|
@@ -58,8 +64,8 @@ public interface CommonPushTaskMapper extends BaseMapper<CommonPushTask> {
|
|
|
"<if test='channel != null and channel != \"\"'>AND t.channels LIKE CONCAT('%', #{channel}, '%') </if>" +
|
|
"<if test='channel != null and channel != \"\"'>AND t.channels LIKE CONCAT('%', #{channel}, '%') </if>" +
|
|
|
"<if test='startTime != null'>AND t.created_time >= #{startTime} </if>" +
|
|
"<if test='startTime != null'>AND t.created_time >= #{startTime} </if>" +
|
|
|
"<if test='endTime != null'>AND t.created_time < #{endTime} </if>" +
|
|
"<if test='endTime != null'>AND t.created_time < #{endTime} </if>" +
|
|
|
- "<if test='startTime != null'>AND u.created_time >= #{startTime} </if>" +
|
|
|
|
|
- "<if test='endTime != null'>AND u.created_time < #{endTime} </if>" +
|
|
|
|
|
|
|
+ "<if test='startTime != null'>AND n.created_time >= #{startTime} </if>" +
|
|
|
|
|
+ "<if test='endTime != null'>AND n.created_time < #{endTime} </if>" +
|
|
|
"GROUP BY t.id, t.task_no, t.title, t.push_type, t.status, t.channels, t.estimated_count, t.created_time " +
|
|
"GROUP BY t.id, t.task_no, t.title, t.push_type, t.status, t.channels, t.estimated_count, t.created_time " +
|
|
|
"ORDER BY t.created_time DESC" +
|
|
"ORDER BY t.created_time DESC" +
|
|
|
"</script>")
|
|
"</script>")
|
|
@@ -74,15 +80,15 @@ public interface CommonPushTaskMapper extends BaseMapper<CommonPushTask> {
|
|
|
|
|
|
|
|
@Select("<script>" +
|
|
@Select("<script>" +
|
|
|
"SELECT " +
|
|
"SELECT " +
|
|
|
- "IFNULL(SUM(CASE WHEN u.status IN (2, 3) THEN 1 ELSE 0 END), 0) AS sentCount, " +
|
|
|
|
|
- "IFNULL(SUM(CASE WHEN u.status = 3 THEN 1 ELSE 0 END), 0) AS deliveredCount, " +
|
|
|
|
|
- "IFNULL(SUM(CASE WHEN u.show_info = 1 THEN 1 ELSE 0 END), 0) AS showCount, " +
|
|
|
|
|
- "IFNULL(SUM(CASE WHEN u.user_add = 1 THEN 1 ELSE 0 END), 0) AS clickCount " +
|
|
|
|
|
- "FROM common_push_task_user u " +
|
|
|
|
|
- "WHERE u.delete_flag = 0 " +
|
|
|
|
|
- "<if test='startTime != null'>AND u.created_time >= #{startTime} </if>" +
|
|
|
|
|
- "<if test='endTime != null'>AND u.created_time < #{endTime} </if>" +
|
|
|
|
|
- "<if test='phoneType != null and phoneType != \"\"'>AND u.phone_type = #{phoneType} </if>" +
|
|
|
|
|
|
|
+ NUM_SUM_REAL_SEND + " AS sentCount, " +
|
|
|
|
|
+ NUM_SUM_REAL_DELIVERED + " AS deliveredCount, " +
|
|
|
|
|
+ NUM_SUM_SHOW + " AS showCount, " +
|
|
|
|
|
+ NUM_SUM_CLICK + " AS clickCount " +
|
|
|
|
|
+ "FROM common_push_task_num n " +
|
|
|
|
|
+ "WHERE n.delete_flag = 0 " +
|
|
|
|
|
+ "<if test='startTime != null'>AND n.created_time >= #{startTime} </if>" +
|
|
|
|
|
+ "<if test='endTime != null'>AND n.created_time < #{endTime} </if>" +
|
|
|
|
|
+ "<if test='phoneType != null and phoneType != \"\"'>AND n.phone_type = #{phoneType} </if>" +
|
|
|
"</script>")
|
|
"</script>")
|
|
|
CommonPushTaskStatsDto selectUserStats(@Param("startTime") Date startTime,
|
|
CommonPushTaskStatsDto selectUserStats(@Param("startTime") Date startTime,
|
|
|
@Param("endTime") Date endTime,
|
|
@Param("endTime") Date endTime,
|
|
@@ -90,14 +96,14 @@ public interface CommonPushTaskMapper extends BaseMapper<CommonPushTask> {
|
|
|
|
|
|
|
|
@Select("<script>" +
|
|
@Select("<script>" +
|
|
|
"SELECT t.id, t.title, " +
|
|
"SELECT t.id, t.title, " +
|
|
|
- "IFNULL(SUM(CASE WHEN u.status IN (2, 3) THEN 1 ELSE 0 END), 0) AS sentCount, " +
|
|
|
|
|
- "IFNULL(SUM(CASE WHEN u.status = 3 THEN 1 ELSE 0 END), 0) AS deliveredCount, " +
|
|
|
|
|
- "IFNULL(SUM(CASE WHEN u.user_add = 1 THEN 1 ELSE 0 END), 0) AS clickCount " +
|
|
|
|
|
|
|
+ NUM_SUM_REAL_SEND + " AS sentCount, " +
|
|
|
|
|
+ NUM_SUM_REAL_DELIVERED + " AS deliveredCount, " +
|
|
|
|
|
+ NUM_SUM_CLICK + " AS clickCount " +
|
|
|
"FROM common_push_task t " +
|
|
"FROM common_push_task t " +
|
|
|
- "INNER JOIN common_push_task_user u ON u.push_task_id = t.id AND u.delete_flag = 0 " +
|
|
|
|
|
|
|
+ "INNER JOIN common_push_task_num n ON n.push_task_id = t.id AND n.delete_flag = 0 " +
|
|
|
"WHERE t.delete_flag = 0 " +
|
|
"WHERE t.delete_flag = 0 " +
|
|
|
- "<if test='startTime != null'>AND u.created_time >= #{startTime} </if>" +
|
|
|
|
|
- "<if test='endTime != null'>AND u.created_time < #{endTime} </if>" +
|
|
|
|
|
|
|
+ "<if test='startTime != null'>AND n.created_time >= #{startTime} </if>" +
|
|
|
|
|
+ "<if test='endTime != null'>AND n.created_time < #{endTime} </if>" +
|
|
|
"GROUP BY t.id, t.title " +
|
|
"GROUP BY t.id, t.title " +
|
|
|
"HAVING deliveredCount > 0 " +
|
|
"HAVING deliveredCount > 0 " +
|
|
|
"ORDER BY (clickCount / deliveredCount) DESC " +
|
|
"ORDER BY (clickCount / deliveredCount) DESC " +
|