|
@@ -228,6 +228,132 @@
|
|
order by t.create_time asc
|
|
order by t.create_time asc
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
+ <select id="getPlanSumBytedance" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid',COUNT(t.effective) + t2.promotionNum as 'new'
|
|
|
|
+ from ctop_new_monitor_campaign t
|
|
|
|
+ LEFT JOIN (
|
|
|
|
+ SELECT user_id,
|
|
|
|
+ IFNULL(SUM(promotion_num),0) as 'promotionNum'
|
|
|
|
+ FROM application.app_bytedance_account_base_info_d
|
|
|
|
+ WHERE stat_date >= DATE_FORMAT(#{startDate},'%Y%m%d')
|
|
|
|
+ AND stat_date <=DATE_FORMAT(#{endDate},'%Y%m%d')
|
|
|
|
+ AND user_id = #{userId}
|
|
|
|
+ ) t2 on 1=1
|
|
|
|
+ where (create_time between #{startDate} and #{endDate}) and project_type=#{project}
|
|
|
|
+ and t.account_id in
|
|
|
|
+ <foreach item="item" collection="array" separator="," open="(" close=")" index="">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
|
|
|
|
+ <select id="getPlanMessageGroupBytedance" resultType="com.alibaba.fastjson.JSONObject" >
|
|
|
|
+ SELECT t1.statDate,
|
|
|
|
+ t1.promotionNum +IFNULL(t2.new,0) as 'new',
|
|
|
|
+ IFNULL(t2.valid,0) as 'valid'
|
|
|
|
+ FROM
|
|
|
|
+ (
|
|
|
|
+ SELECT
|
|
|
|
+ <choose>
|
|
|
|
+ <when test='group=="1"'>
|
|
|
|
+ DATE_FORMAT(stat_date,'%Y-%m') as 'statDate',
|
|
|
|
+ </when>
|
|
|
|
+ <otherwise>
|
|
|
|
+ DATE_FORMAT(stat_date,'%Y-%m-%d') as 'statDate',
|
|
|
|
+ </otherwise>
|
|
|
|
+ </choose>
|
|
|
|
+ IFNULL(SUM(promotion_num),0) as 'promotionNum'
|
|
|
|
+ FROM application.app_bytedance_account_base_info_d
|
|
|
|
+ WHERE stat_date >= DATE_FORMAT(#{startDate},'%Y%m%d')
|
|
|
|
+ AND stat_date <=DATE_FORMAT(#{endDate},'%Y%m%d')
|
|
|
|
+ AND user_id = #{userId}
|
|
|
|
+ <choose>
|
|
|
|
+ <when test='group=="1"'>
|
|
|
|
+ GROUP BY DATE_FORMAT(stat_date,'%Y-%m')
|
|
|
|
+ </when>
|
|
|
|
+ <otherwise>
|
|
|
|
+ GROUP BY stat_date
|
|
|
|
+ </otherwise>
|
|
|
|
+ </choose>
|
|
|
|
+ ) t1
|
|
|
|
+ LEFT JOIN (
|
|
|
|
+ SELECT
|
|
|
|
+ <choose>
|
|
|
|
+ <when test='group=="1"'>
|
|
|
|
+ DATE_FORMAT(t.create_time,'%Y-%m') as 'statDate',
|
|
|
|
+ </when>
|
|
|
|
+ <otherwise>
|
|
|
|
+ DATE_FORMAT(t.create_time,'%Y-%m-%d') as 'statDate',
|
|
|
|
+ </otherwise>
|
|
|
|
+ </choose>
|
|
|
|
+ COUNT(t.effective) as 'new',COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid' from ctop_new_monitor_campaign t
|
|
|
|
+ where project_type=#{project} and (create_time between #{startDate} and #{endDate}) and t.account_id in
|
|
|
|
+ <foreach item="item" collection="array" separator="," open="(" close=")" index="">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ <choose>
|
|
|
|
+ <when test='group=="1"'>
|
|
|
|
+ GROUP BY DATE_FORMAT(t.create_time,'%Y-%m')
|
|
|
|
+ </when>
|
|
|
|
+ <otherwise>
|
|
|
|
+ GROUP BY DATE_FORMAT(t.create_time,'%Y-%m-%d')
|
|
|
|
+ </otherwise>
|
|
|
|
+ </choose>
|
|
|
|
+ ) t2 ON t1.statDate = t2.statDate
|
|
|
|
+ WHERE t1.promotionNum +IFNULL(t2.new,0) >0
|
|
|
|
+ ORDER BY `statDate`
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ <select id="getPlanMessageBytedance" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
+ SELECT * FROM (
|
|
|
|
+ SELECT
|
|
|
|
+ IFNULL(t2.account_id,t1.account_id) as 'accountId',
|
|
|
|
+ IFNULL(t2.authName,t1.account_name) as 'authName',
|
|
|
|
+ IFNULL(t2.maxCreateTime,statDate) as 'maxCreateTime',
|
|
|
|
+ t1.promotionNum+IFNULL(t2.new,0) as 'new',
|
|
|
|
+ IFNULL(t2.userName,t1.user_name) as 'userName',
|
|
|
|
+ IFNULL(t2.valid ,0) as 'valid'
|
|
|
|
+ FROM
|
|
|
|
+ (
|
|
|
|
+ SELECT
|
|
|
|
+ account_id,
|
|
|
|
+ account_name,
|
|
|
|
+ user_name,
|
|
|
|
+ DATE_FORMAT(stat_date,'%Y-%m-%d') as 'statDate',
|
|
|
|
+ IFNULL(SUM(promotion_num),0) as 'promotionNum'
|
|
|
|
+ FROM application.app_bytedance_account_base_info_d
|
|
|
|
+ WHERE stat_date >= DATE_FORMAT(#{startDate},'%Y%m%d')
|
|
|
|
+ AND stat_date <=DATE_FORMAT(#{endDate},'%Y%m%d')
|
|
|
|
+ AND user_id = #{userId}
|
|
|
|
+ GROUP BY account_id
|
|
|
|
+ ) t1
|
|
|
|
+ LEFT JOIN (
|
|
|
|
+ SELECT
|
|
|
|
+ account_id,
|
|
|
|
+ account_name AS 'authName',
|
|
|
|
+ MAX( create_time ) AS 'maxCreateTime',
|
|
|
|
+ COUNT(
|
|
|
|
+ IF
|
|
|
|
+ ( effective = '1', TRUE, NULL )) AS 'valid',
|
|
|
|
+ count( effective ) AS 'new',
|
|
|
|
+ operating_name AS 'userName',
|
|
|
|
+ '' AS 'projectName'
|
|
|
|
+ FROM
|
|
|
|
+ ctop_new_monitor_campaign
|
|
|
|
+ WHERE
|
|
|
|
+ (create_time between #{startDate} and #{endDate})
|
|
|
|
+ and project_type=#{project}
|
|
|
|
+ AND account_id IN
|
|
|
|
+ <foreach item="item" collection="array" separator="," open="(" close=")" index="">
|
|
|
|
+ #{item}
|
|
|
|
+ </foreach>
|
|
|
|
+ GROUP BY
|
|
|
|
+ account_id
|
|
|
|
+ ) t2 ON t1.account_id = t2.account_id
|
|
|
|
+ ) t
|
|
|
|
+ WHERE new >0
|
|
|
|
+ ORDER BY maxCreateTime desc
|
|
|
|
+ </select>
|
|
|
|
|
|
</mapper>
|
|
</mapper>
|