|
@@ -2,7 +2,7 @@
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.NewMonitorMapper">
|
|
|
<resultMap id="BaseResultMap" type="cn.com.ctop.kuaishou.modules.report.entity.NewMonitorInfo">
|
|
|
- <id column="id" property="user_id" />
|
|
|
+ <id column="id" property="user_id"/>
|
|
|
<result column="realname" property="user_name"/>
|
|
|
<result column="leader_id" property="parent_id"/>
|
|
|
<collection property="children" ofType="cn.com.ctop.kuaishou.modules.report.entity.NewMonitorInfo"
|
|
@@ -10,137 +10,174 @@
|
|
|
</collection>
|
|
|
</resultMap>
|
|
|
|
|
|
- <select id="getOperator" resultMap="BaseResultMap" parameterType="String">
|
|
|
- SELECT id,realname,leader_id
|
|
|
+ <select id="getOperator" resultMap="BaseResultMap" parameterType="String">
|
|
|
+ SELECT id, realname, leader_id
|
|
|
FROM sys_user
|
|
|
- WHERE leader_id=#{userId};
|
|
|
+ WHERE leader_id = #{userId};
|
|
|
</select>
|
|
|
|
|
|
<select id="getAllAccountId" resultType="Long">
|
|
|
- SELECT DISTINCT t.account_id as 'accountId' from ctop_user_allocation t where account_status=0 and media_id=#{type}
|
|
|
+ SELECT DISTINCT t.account_id as 'accountId'
|
|
|
+ from ctop_user_allocation t
|
|
|
+ where account_status = 0
|
|
|
+ and media_id = #{type}
|
|
|
</select>
|
|
|
<select id="getKuaiShouGroup" resultType="Map">
|
|
|
- SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.unit_id as 'unitId',t.group_create_time as 'groupCreatTime',DATE_FORMAT(DATE_ADD(t.group_create_time,INTERVAL 7 DAY),'%Y-%m-%d') as 'afterTime'
|
|
|
- from ctop_user_allocation t1 LEFT JOIN ctop_kuaishou_group t on t1.account_id=t.account_id
|
|
|
- <where>
|
|
|
- and t.account_id=#{accountId}
|
|
|
- <choose>
|
|
|
- <when test="date!= null and date!=''">
|
|
|
- and t.group_create_time >= DATE_SUB(#{date},INTERVAL 7 DAY)
|
|
|
- </when>
|
|
|
- <otherwise>
|
|
|
- and t.group_create_time >= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 YEAR),'%Y-%m-%d')
|
|
|
- </otherwise>
|
|
|
- </choose>
|
|
|
- </where>
|
|
|
+ SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.unit_id as
|
|
|
+ 'unitId',t.group_create_time as 'groupCreatTime',DATE_FORMAT(DATE_ADD(t.group_create_time,INTERVAL 7
|
|
|
+ DAY),'%Y-%m-%d') as 'afterTime'
|
|
|
+ from ctop_user_allocation t1 LEFT JOIN ctop_kuaishou_group t on t1.account_id=t.account_id
|
|
|
+ <where>
|
|
|
+ and t.account_id=#{accountId}
|
|
|
+ <choose>
|
|
|
+ <when test="date!= null and date!=''">
|
|
|
+ and t.group_create_time >= DATE_SUB(#{date},INTERVAL 7 DAY)
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ and t.group_create_time >= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 YEAR),'%Y-%m-%d')
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
+ </where>
|
|
|
</select>
|
|
|
|
|
|
<select id="getKuaiShouGroupNow" resultType="Map">
|
|
|
- SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.unit_id as 'unitId',t.group_create_time as 'groupCreatTime',DATE_FORMAT(DATE_ADD(t.group_create_time,INTERVAL 7 DAY),'%Y-%m-%d') as 'afterTime'
|
|
|
- from ctop_user_allocation t1 LEFT JOIN ctop_kuaishou_group t on t1.account_id=t.account_id
|
|
|
+ SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.unit_id as
|
|
|
+ 'unitId',t.group_create_time as 'groupCreatTime',DATE_FORMAT(DATE_ADD(t.group_create_time,INTERVAL 7
|
|
|
+ DAY),'%Y-%m-%d') as 'afterTime'
|
|
|
+ from ctop_user_allocation t1 LEFT JOIN ctop_kuaishou_group t on t1.account_id=t.account_id
|
|
|
<where>
|
|
|
and t.account_id=#{accountId}
|
|
|
- and t.group_create_time >= #{date}
|
|
|
+ and t.group_create_time >= #{date}
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
<select id="getKuaiShouCampaign" resultType="Map">
|
|
|
- SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.campaign_id as 'campaignId',t.put_create_time as 'campaignCreatTime',DATE_FORMAT(DATE_ADD(t.put_create_time,INTERVAL 7 DAY),'%Y-%m-%d') as 'afterTime'
|
|
|
- from ctop_user_allocation t1 LEFT JOIN ctop_kuaishou_campaign t on t1.account_id=t.account_id
|
|
|
+ SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.campaign_id as
|
|
|
+ 'campaignId',t.put_create_time as 'campaignCreatTime',DATE_FORMAT(DATE_ADD(t.put_create_time,INTERVAL 7
|
|
|
+ DAY),'%Y-%m-%d') as 'afterTime'
|
|
|
+ from ctop_user_allocation t1 LEFT JOIN ctop_kuaishou_campaign t on t1.account_id=t.account_id
|
|
|
<where>
|
|
|
and t.account_id=#{accountId}
|
|
|
<choose>
|
|
|
<when test="date != null and date !=''">
|
|
|
- and t.put_create_time >= DATE_SUB(#{date},INTERVAL 7 DAY)
|
|
|
+ and t.put_create_time >= DATE_SUB(#{date},INTERVAL 7 DAY)
|
|
|
</when>
|
|
|
<otherwise>
|
|
|
- and t.put_create_time >= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 YEAR),'%Y-%m-%d')
|
|
|
+ and t.put_create_time >= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 YEAR),'%Y-%m-%d')
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
<select id="getKuaiShouCampaignNow" resultType="Map">
|
|
|
- SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.campaign_id as 'campaignId',t.put_create_time as 'campaignCreatTime',DATE_FORMAT(DATE_ADD(t.put_create_time,INTERVAL 7 DAY),'%Y-%m-%d') as 'afterTime'
|
|
|
- from ctop_user_allocation t1 LEFT JOIN ctop_kuaishou_campaign t on t1.account_id=t.account_id
|
|
|
+ SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.campaign_id as
|
|
|
+ 'campaignId',t.put_create_time as 'campaignCreatTime',DATE_FORMAT(DATE_ADD(t.put_create_time,INTERVAL 7
|
|
|
+ DAY),'%Y-%m-%d') as 'afterTime'
|
|
|
+ from ctop_user_allocation t1 LEFT JOIN ctop_kuaishou_campaign t on t1.account_id=t.account_id
|
|
|
<where>
|
|
|
and t.account_id=#{accountId}
|
|
|
- and t.put_create_time >=#{date}
|
|
|
+ and t.put_create_time >=#{date}
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
<select id="getTouTiaoCampaign" resultType="Map">
|
|
|
- SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.id as 'campaignId',t.ad_create_time as 'campaignCreatTime',DATE_FORMAT(DATE_ADD(t.ad_create_time,INTERVAL 7 DAY),'%Y-%m-%d') as 'afterTime'
|
|
|
- from ctop_user_allocation t1 LEFT JOIN ctop_bytedance_advertise_plan t on t1.account_id=t.account_id
|
|
|
+ SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.id as
|
|
|
+ 'campaignId',t.ad_create_time as 'campaignCreatTime',DATE_FORMAT(DATE_ADD(t.ad_create_time,INTERVAL 7
|
|
|
+ DAY),'%Y-%m-%d') as 'afterTime'
|
|
|
+ from ctop_user_allocation t1 LEFT JOIN ctop_bytedance_advertise_plan t on t1.account_id=t.account_id
|
|
|
<where>
|
|
|
and t.account_id=#{accountId}
|
|
|
<choose>
|
|
|
<when test="date != null and date !=''">
|
|
|
- and t.ad_create_time >= DATE_SUB(#{date},INTERVAL 7 DAY)
|
|
|
+ and t.ad_create_time >= DATE_SUB(#{date},INTERVAL 7 DAY)
|
|
|
</when>
|
|
|
<otherwise>
|
|
|
- and t.ad_create_time >= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 YEAR),'%Y-%m-%d')
|
|
|
+ and t.ad_create_time >= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 YEAR),'%Y-%m-%d')
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
<select id="getTouTiaoCampaignNow" resultType="Map">
|
|
|
- SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.id as 'campaignId',t.ad_create_time as 'campaignCreatTime',DATE_FORMAT(DATE_ADD(t.ad_create_time,INTERVAL 7 DAY),'%Y-%m-%d') as 'afterTime'
|
|
|
- from ctop_user_allocation t1 LEFT JOIN ctop_bytedance_advertise_plan t on t1.account_id=t.account_id
|
|
|
+ SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.id as
|
|
|
+ 'campaignId',t.ad_create_time as 'campaignCreatTime',DATE_FORMAT(DATE_ADD(t.ad_create_time,INTERVAL 7
|
|
|
+ DAY),'%Y-%m-%d') as 'afterTime'
|
|
|
+ from ctop_user_allocation t1 LEFT JOIN ctop_bytedance_advertise_plan t on t1.account_id=t.account_id
|
|
|
<where>
|
|
|
and t.account_id=#{accountId}
|
|
|
- and t.ad_create_time >= #{date}
|
|
|
+ and t.ad_create_time >= #{date}
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
<select id="getGroupCharge" resultType="java.math.BigDecimal">
|
|
|
|
|
|
- select sum(charge) from ctop_kuaishou_report_daily_group t where t.stat_date < #{afterDate} and t.unit_id=#{unitId}
|
|
|
+ select sum(charge)
|
|
|
+ from ctop_kuaishou_report_daily_group t
|
|
|
+ where t.stat_date < #{afterDate}
|
|
|
+ and t.unit_id = #{unitId}
|
|
|
</select>
|
|
|
|
|
|
<select id="getCampaignCharge" resultType="java.math.BigDecimal">
|
|
|
|
|
|
- select sum(charge) from ctop_kuaishou_report_daily_campaign t where t.stat_date < #{afterDate} and t.campaign_id=#{campaignId}
|
|
|
+ select sum(charge)
|
|
|
+ from ctop_kuaishou_report_daily_campaign t
|
|
|
+ where t.stat_date < #{afterDate}
|
|
|
+ and t.campaign_id = #{campaignId}
|
|
|
</select>
|
|
|
|
|
|
<select id="getCampaignChargeTouTiao" resultType="java.math.BigDecimal">
|
|
|
|
|
|
- select sum(cost) from ctop_bytedance_report_plan_daily t where t.stat_datetime < #{afterDate} and t.ad_id=#{campaignId}
|
|
|
+ select sum(cost)
|
|
|
+ from ctop_bytedance_report_plan_daily t
|
|
|
+ where t.stat_datetime < #{afterDate}
|
|
|
+ and t.ad_id = #{campaignId}
|
|
|
</select>
|
|
|
|
|
|
<insert id="saveMonitorGroup">
|
|
|
- insert into ctop_new_monitor_group(account_id,account_name,operating_name,unit_id,create_time,project_type,effective) values
|
|
|
- (#{accountId},#{accountName},#{operatingName},#{unitId},#{createTime},#{projectType},#{effective})
|
|
|
+ insert into ctop_new_monitor_group(account_id, account_name, operating_name, unit_id, create_time, project_type,
|
|
|
+ effective)
|
|
|
+ values (#{accountId}, #{accountName}, #{operatingName}, #{unitId}, #{createTime}, #{projectType}, #{effective})
|
|
|
</insert>
|
|
|
|
|
|
<insert id="saveMonitorCampaign">
|
|
|
- insert into ctop_new_monitor_campaign (account_id,account_name,operating_name,campaign_id,create_time,project_type,effective) values
|
|
|
- (#{accountId},#{accountName},#{operatingName},#{campaignId},#{createTime},#{projectType},#{effective})
|
|
|
+ insert into ctop_new_monitor_campaign (account_id, account_name, operating_name, campaign_id, create_time,
|
|
|
+ project_type, effective)
|
|
|
+ values (#{accountId}, #{accountName}, #{operatingName}, #{campaignId}, #{createTime}, #{projectType},
|
|
|
+ #{effective})
|
|
|
</insert>
|
|
|
|
|
|
- <select id="getMonitorGroupByUnitId" resultType="String" >
|
|
|
- select t.effective from ctop_new_monitor_group t where t.unit_id=#{unitId}
|
|
|
+ <select id="getMonitorGroupByUnitId" resultType="String">
|
|
|
+ select t.effective
|
|
|
+ from ctop_new_monitor_group t
|
|
|
+ where t.unit_id = #{unitId}
|
|
|
</select>
|
|
|
|
|
|
- <select id="getMonitorPlanByCampaignId" resultType="String" >
|
|
|
- select t.effective from ctop_new_monitor_campaign t where t.campaign_id=#{campaignId}
|
|
|
+ <select id="getMonitorPlanByCampaignId" resultType="String">
|
|
|
+ select t.effective
|
|
|
+ from ctop_new_monitor_campaign t
|
|
|
+ where t.campaign_id = #{campaignId}
|
|
|
</select>
|
|
|
|
|
|
- <update id="updateMonitorGroupByUnitId" >
|
|
|
- update ctop_new_monitor_group t set t.effective=#{effective} where t.unit_id=#{unitId}
|
|
|
+ <update id="updateMonitorGroupByUnitId">
|
|
|
+ update ctop_new_monitor_group t
|
|
|
+ set t.effective=#{effective}
|
|
|
+ where t.unit_id = #{unitId}
|
|
|
</update>
|
|
|
|
|
|
- <update id="updateMonitorPlanByCampaignId" >
|
|
|
- update ctop_new_monitor_campaign t set t.effective=#{effective} where t.campaign_id=#{campaignId}
|
|
|
+ <update id="updateMonitorPlanByCampaignId">
|
|
|
+ update ctop_new_monitor_campaign t
|
|
|
+ set t.effective=#{effective}
|
|
|
+ where t.campaign_id = #{campaignId}
|
|
|
</update>
|
|
|
|
|
|
<select id="getKuaiShouGroupMessage" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- select account_id as 'accountId',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_group where ( create_time between #{startDate} and #{endDate})
|
|
|
+ select account_id as 'accountId',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_group where ( create_time between #{startDate} and #{endDate})
|
|
|
and account_id in
|
|
|
<foreach item="item" collection="array" separator="," open="(" close=")" index="">
|
|
|
- #{item}
|
|
|
+ #{item}
|
|
|
</foreach>
|
|
|
GROUP BY account_id
|
|
|
order by account_id desc
|
|
@@ -148,8 +185,11 @@
|
|
|
|
|
|
|
|
|
<select id="getPlanMessage" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- select account_id as 'accountId',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}
|
|
|
+ select account_id as 'accountId',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}
|
|
@@ -159,8 +199,9 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getKuaiShouGroupSum" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid',COUNT(t.effective) as 'new' from ctop_new_monitor_group t
|
|
|
- where create_time between #{startDate} and #{endDate}
|
|
|
+ SELECT COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid',COUNT(t.effective) as 'new' from
|
|
|
+ ctop_new_monitor_group t
|
|
|
+ where create_time between #{startDate} and #{endDate}
|
|
|
and t.account_id in
|
|
|
<foreach item="item" collection="array" separator="," open="(" close=")" index="">
|
|
|
#{item}
|
|
@@ -168,16 +209,17 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getPlanSum" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid',COUNT(t.effective) as 'new' from ctop_new_monitor_campaign t
|
|
|
- where (create_time between #{startDate} and #{endDate}) and project_type=#{project}
|
|
|
+ SELECT COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid',COUNT(t.effective) as 'new' from
|
|
|
+ ctop_new_monitor_campaign t
|
|
|
+ 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="getKuaiShouGroupMessageGroup" resultType="com.alibaba.fastjson.JSONObject" >
|
|
|
- SELECT
|
|
|
+ <select id="getKuaiShouGroupMessageGroup" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ SELECT
|
|
|
<choose>
|
|
|
<when test='group=="1"'>
|
|
|
DATE_FORMAT(t.create_time,'%Y-%m') as 'statDate',
|
|
@@ -186,23 +228,23 @@
|
|
|
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_group t
|
|
|
- where (create_time between #{startDate} and #{endDate}) and t.account_id in
|
|
|
+ COUNT(t.effective) as 'new',COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid' from ctop_new_monitor_group t
|
|
|
+ where (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')
|
|
|
+ GROUP BY DATE_FORMAT(t.create_time,'%Y-%m')
|
|
|
</when>
|
|
|
<otherwise>
|
|
|
- GROUP BY DATE_FORMAT(t.create_time,'%Y-%m-%d')
|
|
|
+ GROUP BY DATE_FORMAT(t.create_time,'%Y-%m-%d')
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
order by t.create_time asc
|
|
|
</select>
|
|
|
|
|
|
- <select id="getPlanMessageGroup" resultType="com.alibaba.fastjson.JSONObject" >
|
|
|
+ <select id="getPlanMessageGroup" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT
|
|
|
<choose>
|
|
|
<when test='group=="1"'>
|
|
@@ -212,22 +254,148 @@
|
|
|
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
|
|
|
+ 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')
|
|
|
+ GROUP BY DATE_FORMAT(t.create_time,'%Y-%m')
|
|
|
</when>
|
|
|
<otherwise>
|
|
|
- GROUP BY DATE_FORMAT(t.create_time,'%Y-%m-%d')
|
|
|
+ GROUP BY DATE_FORMAT(t.create_time,'%Y-%m-%d')
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
order by t.create_time asc
|
|
|
</select>
|
|
|
|
|
|
+ <select id="getPlanSumBytedance" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ SELECT COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid',COUNT(t.effective)+
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ IFNULL(SUM(promotion_num),0)
|
|
|
+ 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}
|
|
|
+ ) as 'new'
|
|
|
+ from ctop_new_monitor_campaign t
|
|
|
+ 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>
|