|
@@ -1866,4 +1866,365 @@
|
|
|
</select>
|
|
|
|
|
|
|
|
|
+ <select id="getBytedanceOperateProjectInfoNew"
|
|
|
+ resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo">
|
|
|
+ SELECT
|
|
|
+ COUNT( DISTINCT t1.account_id ) AS 'accountNum',
|
|
|
+ COUNT( DISTINCT t1.user_id ) AS 'userNum',
|
|
|
+ t1.project_id AS 'projectId',
|
|
|
+ t1.project_name AS 'projectName',
|
|
|
+ SUM( t1.cost ) AS 'totalCost',
|
|
|
+ t2.inventory,
|
|
|
+ t0.realname AS 'userName',
|
|
|
+ CONCAT(IFNULL(ROUND(((SUM( t1.cost )-t3.totalCost) / t3.totalCost) * 100,2),0),'%') AS 'yearOnYear',
|
|
|
+ CONCAT(IFNULL(ROUND(((SUM( t1.cost )-t5.totalCost) / t5.totalCost) * 100,2),0),'%') AS 'equallyRate',
|
|
|
+ t4.*
|
|
|
+ FROM
|
|
|
+ ${tableName} t1
|
|
|
+ LEFT JOIN `jeecg-boot`.sys_user t0 on t1.user_id = t0.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT project_id,
|
|
|
+ group_concat(concat(inventory_name,':',cost)) as 'inventory'
|
|
|
+ from (
|
|
|
+ select project_id,inventory_name,sum(cost) as cost from
|
|
|
+ application.bytedance_advertiser_inventory_report_daily_dw
|
|
|
+ where cost > 0
|
|
|
+ <if test="startDate != null and startDate != '' ">
|
|
|
+ and stat_datetime >= #{startDate}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != '' ">
|
|
|
+ and stat_datetime <= #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test='projectIds!=null and projectIds.size()>0'>
|
|
|
+ AND project_id IN
|
|
|
+ <foreach collection="projectIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ group by project_id, inventory_name
|
|
|
+ ORDER BY cost desc
|
|
|
+ )t
|
|
|
+ group by project_id
|
|
|
+ ) t2 on t1.project_id = t2.project_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ project_id,
|
|
|
+ SUM(cost) AS totalCost
|
|
|
+ FROM
|
|
|
+ ${tableName}
|
|
|
+ WHERE cost > 0
|
|
|
+ AND stat_datetime >= #{lastTimeStart}
|
|
|
+ AND stat_datetime <= #{lastTimeEnd}
|
|
|
+ <if test="hour != null and hour != '' ">
|
|
|
+ AND `hour` <= #{hour}
|
|
|
+ </if>
|
|
|
+ <if test='projectIds!=null and projectIds.size()>0'>
|
|
|
+ AND project_id IN
|
|
|
+ <foreach collection="projectIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ GROUP BY project_id
|
|
|
+ ) t3 ON t1.project_id = t3.project_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT tt1.project_id as 'pid' ,
|
|
|
+ IFNULL(SUM(tt1.new_effect_num),0) as 'newEffectNum',
|
|
|
+ IFNULL(SUM(tt1.new_campaign_num),0) as 'newCampaignNum',
|
|
|
+ IFNULL(SUM(tt1.new_ad_num),0)-IFNULL(SUM(tt1.trust_campaign_num),0) as 'trustUnitNum',
|
|
|
+ IFNULL(SUM(tt1.new_video_num),0) AS 'newVideoNum',
|
|
|
+ IFNULL(SUM(tt1.new_hot_num),0) AS 'newHotNum',
|
|
|
+ IFNULL(SUM(tt1.new_cpd_project_num),0) AS 'newProjectNum',
|
|
|
+ IFNULL(SUM(tt1.new_ad_num),0)+IFNULL(SUM(tt1.promotion_num),0) AS 'newUnitNum'
|
|
|
+ from application.app_bytedance_account_base_info_d tt1
|
|
|
+ LEFT JOIN `jeecg-boot`.ctop_user_allocation tt2 ON tt1.account_id = tt2.account_id
|
|
|
+ WHERE tt2.account_status = 0
|
|
|
+ <if test="startDate != null and startDate != '' ">
|
|
|
+ and tt1.stat_date >= #{startDate}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != '' ">
|
|
|
+ and tt1.stat_date <= #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test='projectIds!=null and projectIds.size()>0'>
|
|
|
+ AND tt1.project_id IN
|
|
|
+ <foreach collection="projectIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ GROUP BY tt1.project_id
|
|
|
+ ) t4 ON t1.project_id = t4.pid
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ project_id,
|
|
|
+ SUM(cost) AS totalCost
|
|
|
+ FROM
|
|
|
+ ${tableName}
|
|
|
+ WHERE cost > 0
|
|
|
+ AND stat_datetime >= #{startEqually}
|
|
|
+ AND stat_datetime <= #{endEqually}
|
|
|
+ <if test='projectIds!=null and projectIds.size()>0'>
|
|
|
+ AND project_id IN
|
|
|
+ <foreach collection="projectIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ GROUP BY project_id
|
|
|
+ ) t5 ON t1.project_id = t5.project_id
|
|
|
+ WHERE t1.cost > 0
|
|
|
+ <if test="startDate != null and startDate != '' ">
|
|
|
+ and t1.stat_datetime >= #{startDate}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != '' ">
|
|
|
+ and t1.stat_datetime <= #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test="hour != null and hour != '' ">
|
|
|
+ AND `hour` <= #{hour}
|
|
|
+ </if>
|
|
|
+ <if test='projectIds!=null and projectIds.size()>0'>
|
|
|
+ AND t1.project_id IN
|
|
|
+ <foreach collection="projectIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ GROUP BY t1.project_id
|
|
|
+ ORDER BY SUM(t1.cost) DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getBytedanceProjectList" resultType="Long">
|
|
|
+ SELECT
|
|
|
+ project_id
|
|
|
+ FROM
|
|
|
+ application.bytedance_advertiser_report_daily_dw
|
|
|
+ WHERE cost > 0
|
|
|
+ <if test="startDate != null and startDate != '' ">
|
|
|
+ and stat_datetime >= #{startDate}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != '' ">
|
|
|
+ and stat_datetime <= #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test='userIds!=null and userIds.size()>0'>
|
|
|
+ AND user_id IN
|
|
|
+ <foreach collection="userIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ GROUP BY project_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getKuaishouProjectList" resultType="Long">
|
|
|
+ SELECT
|
|
|
+ project_id
|
|
|
+ FROM
|
|
|
+ application.kuaishou_account_report_daily_dw d
|
|
|
+ WHERE charge > 0
|
|
|
+ <if test="startDate != null and startDate != '' ">
|
|
|
+ and stat_date >= #{startDate}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != '' ">
|
|
|
+ and stat_date <= #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test='userIds!=null and userIds.size()>0'>
|
|
|
+ AND user_id IN
|
|
|
+ <foreach collection="userIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ GROUP BY project_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <select id="getKuaiShouOperateProjectInfoNew" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo">
|
|
|
+ SELECT
|
|
|
+ t1.project_name AS projectName,
|
|
|
+ t1.project_id AS projectId,
|
|
|
+ SUM(t1.charge) AS totalCost,
|
|
|
+ COUNT(DISTINCT t1.account_id) AS accountNum,
|
|
|
+ COUNT(DISTINCT t1.user_id) AS userNum,
|
|
|
+ CONCAT(IFNULL(ROUND(((SUM(t1.charge )-t2.totalCost) / t2.totalCost) * 100,2),0),'%') AS 'yearOnYear',
|
|
|
+ CONCAT(IFNULL(ROUND(((SUM(t1.charge )-t3.totalCost) / t3.totalCost) * 100,2),0),'%') AS 'equallyRate',
|
|
|
+ IFNULL(newEffectNum,0) as 'newEffectNum',
|
|
|
+ IFNULL(newCampaignNum,0) as 'newCampaignNum',
|
|
|
+ IFNULL(newUnitNum,0) as 'newUnitNum',
|
|
|
+ IFNULL(newVideoNum,0) as 'newVideoNum',
|
|
|
+ IFNULL(newHotNum,0) as 'newHotNum',
|
|
|
+ IFNULL(trustUnitNum,0) as 'trustUnitNum',
|
|
|
+ IFNULL(t5.adspNum,0) as 'adspNum',
|
|
|
+ IFNULL(t6.mediaNum,0) as 'mediaNum',
|
|
|
+ t7.adSceneDate as 'adSceneDateStr'
|
|
|
+ FROM
|
|
|
+ ${tableName} t1
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ project_id,
|
|
|
+ SUM(charge) AS totalCost
|
|
|
+ FROM
|
|
|
+ ${tableName}
|
|
|
+ WHERE charge > 0
|
|
|
+ <if test="lastTimeStart != null and lastTimeStart != '' ">
|
|
|
+ and stat_date >= #{lastTimeStart}
|
|
|
+ </if>
|
|
|
+ <if test="lastTimeEnd != null and lastTimeEnd != '' ">
|
|
|
+ and stat_date <= #{lastTimeEnd}
|
|
|
+ </if>
|
|
|
+ <if test='projectIds!=null and projectIds.size()>0'>
|
|
|
+ AND project_id IN
|
|
|
+ <foreach collection="projectIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="hour != null and hour != '' ">
|
|
|
+ AND `hour` <= #{hour}
|
|
|
+ </if>
|
|
|
+ GROUP BY project_id
|
|
|
+ ) t2 ON t1.project_id = t2.project_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ project_id,
|
|
|
+ SUM(charge) AS totalCost
|
|
|
+ FROM
|
|
|
+ application.kuaishou_account_report_daily_dw
|
|
|
+ WHERE charge > 0
|
|
|
+ <if test="startEqually != null and startEqually != '' ">
|
|
|
+ and stat_date >= #{startEqually}
|
|
|
+ </if>
|
|
|
+ <if test="endEqually != null and endEqually != '' ">
|
|
|
+ and stat_date <= #{endEqually}
|
|
|
+ </if>
|
|
|
+ <if test='projectIds!=null and projectIds.size()>0'>
|
|
|
+ AND project_id IN
|
|
|
+ <foreach collection="projectIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ GROUP BY project_id
|
|
|
+ ) t3 ON t1.project_id = t3.project_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT project_id as 'pid',
|
|
|
+ IFNULL(SUM(new_effect_num),0) as newEffectNum,
|
|
|
+ IFNULL(SUM(new_campaign_num),0) as newCampaignNum,
|
|
|
+ IFNULL(SUM(new_unit_num),0) as newUnitNum,
|
|
|
+ IFNULL(SUM(new_video_num),0) AS newVideoNum,
|
|
|
+ IFNULL(SUM(new_hot_num),0) AS newHotNum,
|
|
|
+ IFNULL(SUM(trust_unit_num),0) AS trustUnitNum
|
|
|
+ from application.app_kuaishou_account_base_info_d
|
|
|
+ <where>
|
|
|
+ <if test="startDate != null and startDate != '' ">
|
|
|
+ and stat_date >= #{startDate}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != '' ">
|
|
|
+ and stat_date <= #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test='projectIds!=null and projectIds.size()>0'>
|
|
|
+ AND project_id IN
|
|
|
+ <foreach collection="projectIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY project_id
|
|
|
+ )t4 ON t1.project_id = t4.pid
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ project_id,
|
|
|
+ IFNULL( SUM( material_num ), 0 ) 'adspNum'
|
|
|
+ FROM
|
|
|
+ application.new_material_num_in_project
|
|
|
+ <where>
|
|
|
+ <if test="startDate != null and startDate != '' ">
|
|
|
+ and stat_date >= #{startDate}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != '' ">
|
|
|
+ and stat_date <= #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test='projectIds!=null and projectIds.size()>0'>
|
|
|
+ AND project_id IN
|
|
|
+ <foreach collection="projectIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY project_id
|
|
|
+ )t5 ON t1.project_id = t5.project_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ dimension,
|
|
|
+ IFNULL( SUM( material_upload_media_num ), 0 ) 'mediaNum'
|
|
|
+ FROM
|
|
|
+ application.today_material_upload_num
|
|
|
+ <where>
|
|
|
+ <if test="startDate != null and startDate != '' ">
|
|
|
+ and stat_date >= #{startDate}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != '' ">
|
|
|
+ and stat_date <= #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test='projectIds!=null and projectIds.size()>0'>
|
|
|
+ AND dimension IN
|
|
|
+ <foreach collection="projectIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY dimension
|
|
|
+ )t6 ON t1.project_id = t6.dimension
|
|
|
+ LEFT JOIN (
|
|
|
+ select project_id,CONCAT('[',group_concat(adSceneDate) ,']') as 'adSceneDate' from
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ project_id,
|
|
|
+ json_object('adSceneCost',IFNULL(SUM(charge),0),'adSceneName',ad_scene) as 'adSceneDate'
|
|
|
+ FROM
|
|
|
+ application.app_kuaishou_account_ad_scene_report_d
|
|
|
+ WHERE ad_scene!='全部'
|
|
|
+ <if test="startDate != null and startDate != '' ">
|
|
|
+ and stat_date >= #{startDate}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != '' ">
|
|
|
+ and stat_date <= #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test='projectIds!=null and projectIds.size()>0'>
|
|
|
+ AND project_id IN
|
|
|
+ <foreach collection="projectIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ GROUP BY project_id,ad_scene
|
|
|
+ order by project_id
|
|
|
+ )t
|
|
|
+ group by project_id
|
|
|
+ ) t7 ON t1.project_id = t7.project_id
|
|
|
+ WHERE t1.charge > 0
|
|
|
+ <if test="startDate != null and startDate != '' ">
|
|
|
+ and t1.stat_date >= #{startDate}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != '' ">
|
|
|
+ and t1.stat_date <= #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test='projectIds!=null and projectIds.size()>0'>
|
|
|
+ AND t1.project_id IN
|
|
|
+ <foreach collection="projectIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="hour != null and hour != '' ">
|
|
|
+ AND `hour` <= #{hour}
|
|
|
+ </if>
|
|
|
+ GROUP BY t1.project_id
|
|
|
+ ORDER BY SUM(t1.charge) DESC
|
|
|
+ </select>
|
|
|
</mapper>
|