|
@@ -143,6 +143,36 @@
|
|
|
</if>
|
|
|
</select>
|
|
|
|
|
|
+ <!-- 查看 快手 有效 计划 组-->
|
|
|
+ <select id="getKuaiShouAccountBaseByUserId" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ SELECT abi.account_id ,
|
|
|
+ SUM(abi.new_effect_num) as newEffectNum,
|
|
|
+ SUM(abi.new_campaign_num) as newCampaignNum,
|
|
|
+ SUM(abi.new_unit_num) as newUnitNum,
|
|
|
+ SUM( abi.new_video_num ) AS newVideoNum,
|
|
|
+ SUM( abi.new_hot_num ) AS newHotNum
|
|
|
+ from application.app_kuaishou_account_base_info_d abi,
|
|
|
+ `jeecg-boot`.ctop_user_allocation u
|
|
|
+ WHERE abi.account_id = u.account_id
|
|
|
+ and u.account_status = 0
|
|
|
+ <if test="startDate != null and startDate != '' ">
|
|
|
+ and abi.stat_date >= #{startDate}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != '' ">
|
|
|
+ and abi.stat_date <= #{endDate}
|
|
|
+ </if>
|
|
|
+ <if test="userId != null and userId != '' ">
|
|
|
+ and abi.user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ <if test="projectId != null and projectId != '' ">
|
|
|
+ and abi.project_id = #{projectId}
|
|
|
+ </if>
|
|
|
+ <if test="accountId != null and accountId != '' ">
|
|
|
+ and abi.account_id = #{accountId}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
|
|
|
|
|
|
<!-- 快手 快手-查询账户数据信息 -->
|
|
@@ -151,32 +181,13 @@
|
|
|
SUM( d.charge ) totalCost,
|
|
|
COUNT(DISTINCT d.account_id) accountNum,
|
|
|
d.user_id as userId,
|
|
|
- (SELECT u.realname from `jeecg-boot`.sys_user u where u.id = d.user_id) as userName,
|
|
|
- IFNULL(m.newEffectNum,0) as newEffectNum,
|
|
|
- IFNULL(m.newCampaignNum,0) as newCampaignNum,
|
|
|
- IFNULL(m.newUnitNum,0) as newUnitNum
|
|
|
+ (SELECT u.realname from `jeecg-boot`.sys_user u where u.id = d.user_id) as userName
|
|
|
FROM
|
|
|
application.kuaishou_account_report_daily_dw d
|
|
|
- LEFT JOIN
|
|
|
- (
|
|
|
- SELECT abi.account_id ,
|
|
|
- SUM(abi.new_effect_num) as newEffectNum,
|
|
|
- SUM(abi.new_campaign_num) as newCampaignNum,
|
|
|
- SUM(abi.new_unit_num) as newUnitNum
|
|
|
- from application.app_kuaishou_account_base_info_d abi
|
|
|
- <where>
|
|
|
- <if test="startDate != null and startDate != '' ">
|
|
|
- and abi.stat_date >= #{startDate}
|
|
|
- </if>
|
|
|
- <if test="endDate != null and endDate != '' ">
|
|
|
- and abi.stat_date <= #{endDate}
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- GROUP BY abi.account_id
|
|
|
- ) m
|
|
|
- on d.account_id = m.account_id
|
|
|
+ LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
|
|
|
WHERE
|
|
|
d.charge > 0
|
|
|
+ and u.account_status = 0
|
|
|
<if test="startDate != null and startDate != '' ">
|
|
|
and d.stat_date >= #{startDate}
|
|
|
</if>
|
|
@@ -201,6 +212,7 @@
|
|
|
COUNT( DISTINCT d.account_id ) AS accountNum,
|
|
|
d.project_id AS projectId,
|
|
|
d.project_name AS projectName,
|
|
|
+ d.user_id AS userId,
|
|
|
COUNT( DISTINCT d.user_id ) AS userNum,
|
|
|
IFNULL(SUM( d.activation ),0) AS activation,
|
|
|
IF(SUM( d.charge ) / SUM( d.activation ) > 0.0001,ROUND( SUM( d.charge ) / SUM( d.activation ), 2 ),0) AS activationPrice,
|
|
@@ -221,33 +233,13 @@
|
|
|
IFNULL(SUM( d.event_pay_purchase_amount_first_day ),0) AS eventPayPurchaseAmountFirstDay,
|
|
|
IFNULL(SUM( d.event_pay_first_day_roi ),0) AS eventPayFirstDayRoi,
|
|
|
IFNULL(SUM( d.form_count ),0) AS formCount,
|
|
|
- IFNULL(ROUND( SUM( d.charge ) / SUM( d.form_count ), 2 ),0) AS formCountPrice,
|
|
|
- IFNULL(m.newEffectNum,0) AS newEffectNum,
|
|
|
- IFNULL(m.newVideoNum,0) AS newVideoNum,
|
|
|
- IFNULL(m.newHotNum,0) AS newHotNum
|
|
|
+ IFNULL(ROUND( SUM( d.charge ) / SUM( d.form_count ), 2 ),0) AS formCountPrice
|
|
|
FROM
|
|
|
application.kuaishou_account_report_daily_dw d
|
|
|
- LEFT JOIN (
|
|
|
- SELECT
|
|
|
- abi.account_id,
|
|
|
- SUM( abi.new_effect_num ) AS newEffectNum,
|
|
|
- SUM( abi.new_video_num ) AS newVideoNum,
|
|
|
- SUM( abi.new_hot_num ) AS newHotNum
|
|
|
- FROM
|
|
|
- application.app_kuaishou_account_base_info_d abi
|
|
|
- <where>
|
|
|
- <if test="startDate != null and startDate != '' ">
|
|
|
- and abi.stat_date >= #{startDate}
|
|
|
- </if>
|
|
|
- <if test="endDate != null and endDate != '' ">
|
|
|
- and abi.stat_date <= #{endDate}
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- GROUP BY abi.account_id
|
|
|
- ) m
|
|
|
- on d.account_id = m.account_id
|
|
|
+ LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
|
|
|
WHERE
|
|
|
d.charge > 0
|
|
|
+ and u.account_status = 0
|
|
|
<if test="startDate != null and startDate != '' ">
|
|
|
and d.stat_date >= #{startDate}
|
|
|
</if>
|
|
@@ -278,6 +270,7 @@
|
|
|
d.account_name as accountName,
|
|
|
d.project_id AS projectId,
|
|
|
d.project_name AS projectName,
|
|
|
+ d.user_id AS userId,
|
|
|
COUNT( DISTINCT d.user_id ) AS userNum,
|
|
|
( SELECT u.realname FROM `jeecg-boot`.sys_user u WHERE u.id = d.user_id ) AS userName,
|
|
|
(SELECT u.warning_amount FROM `jeecg-boot`.ctop_user_allocation u where u.account_id = d.account_id) as warningAmount,
|
|
@@ -303,33 +296,13 @@
|
|
|
IFNULL(SUM( d.form_count ),0) AS formCount,
|
|
|
IFNULL(ROUND( SUM( d.charge ) / SUM( d.form_count ), 2 ),0) AS formCountPrice,
|
|
|
IFNULL(SUM(d.`show`),0) as photoShow,
|
|
|
- IFNULL(SUM(d.photo_click),0) as photoClick,
|
|
|
- IFNULL(m.newEffectNum,0) AS newEffectNum,
|
|
|
- IFNULL(m.newVideoNum,0) AS newVideoNum,
|
|
|
- IFNULL(m.newHotNum,0) AS newHotNum
|
|
|
+ IFNULL(SUM(d.photo_click),0) as photoClick
|
|
|
FROM
|
|
|
application.kuaishou_account_report_daily_dw d
|
|
|
- LEFT JOIN (
|
|
|
- SELECT
|
|
|
- abi.account_id,
|
|
|
- SUM( abi.new_effect_num ) AS newEffectNum,
|
|
|
- SUM( abi.new_video_num ) AS newVideoNum,
|
|
|
- SUM( abi.new_hot_num ) AS newHotNum
|
|
|
- FROM
|
|
|
- application.app_kuaishou_account_base_info_d abi
|
|
|
- <where>
|
|
|
- <if test="startDate != null and startDate != '' ">
|
|
|
- and abi.stat_date >= #{startDate}
|
|
|
- </if>
|
|
|
- <if test="endDate != null and endDate != '' ">
|
|
|
- and abi.stat_date <= #{endDate}
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- GROUP BY abi.account_id
|
|
|
- ) m
|
|
|
- on d.account_id = m.account_id
|
|
|
+ LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
|
|
|
WHERE
|
|
|
d.charge > 0
|
|
|
+ and u.account_status = 0
|
|
|
<if test="startDate != null and startDate != '' ">
|
|
|
and d.stat_date >= #{startDate}
|
|
|
</if>
|
|
@@ -963,6 +936,79 @@
|
|
|
</select>
|
|
|
|
|
|
|
|
|
+ <!-- 快手组实时数据查询-当天创建的组+当天有消耗的组 -->
|
|
|
+ <select id="kuaiShouRealTimeUnitDateInfo" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+
|
|
|
+ SELECT t.*,
|
|
|
+ l.bid_type bidType,
|
|
|
+ l.bid,
|
|
|
+ l.cpa_bid cpaBid,
|
|
|
+ l.put_status putStatus
|
|
|
+ from (
|
|
|
+ SELECT IFNULL(a.advertiser_id,b.dAccountId) accountId,
|
|
|
+ IFNULL(a.uid,b.dunit_id) unit_id,
|
|
|
+ a.*,b.*
|
|
|
+ from (
|
|
|
+ SELECT
|
|
|
+ ad.advertiser_id as advertiser_id,
|
|
|
+ ad.unit_id uid,
|
|
|
+ ad.ocpx_action_type
|
|
|
+ FROM
|
|
|
+ media_api.kuaishou_ad_unit_list ad
|
|
|
+ WHERE
|
|
|
+ ad.advertiser_id = #{accountId}
|
|
|
+ AND DATE_FORMAT( ad.create_time, "%Y%m%d" ) = #{nowDate}
|
|
|
+ ) a RIGHT JOIN
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ d.advertiser_id dAccountId,
|
|
|
+ d.campaign_id campaignId,
|
|
|
+ d.campaign_name campaignName,
|
|
|
+ d.unit_id dunit_id,
|
|
|
+ d.unit_name unitName,
|
|
|
+ IFNULL( SUM( d.charge ), 0 ) AS charge,
|
|
|
+ IFNULL( SUM( d.activation ), 0 ) AS activation,
|
|
|
+ IFNULL( ROUND( SUM( d.charge ) / SUM( d.activation ), 2 ), 0 ) AS activationPrice,
|
|
|
+ IFNULL( ROUND( SUM( d.charge ) / SUM( d.activation ), 2 ), 0 ) AS activationCost,
|
|
|
+ IF(SUM( d.event_next_day_stay ) / SUM( d.activation ) > 0.0001,CONCAT( ROUND( SUM( d.event_next_day_stay ) / SUM( d.activation ) * 100, 2 ), '%' ),0 ) AS `leave`,
|
|
|
+ IFNULL( SUM( d.event_pay ), 0 ) AS eventPay,
|
|
|
+ IFNULL( ROUND( SUM( d.charge ) / SUM( d.event_pay ), 2 ), 0 ) AS eventPayCost,
|
|
|
+ IF(SUM( d.event_pay ) / (SUM( d.activation ) + SUM( d.form_count )) > 0.0001,CONCAT(ROUND( SUM( d.event_pay ) / ( SUM( d.activation ) + SUM( d.form_count )) * 100, 2),'%'),0 ) AS eventPayRate,
|
|
|
+ IFNULL( SUM( d.event_new_user_pay ), 0 ) AS eventNewUserPay,
|
|
|
+ IFNULL( ROUND( SUM( d.charge ) / SUM( d.event_new_user_pay ), 2 ), 0 ) AS eventNewUserPayCost,
|
|
|
+ IFNULL( ROUND( SUM( d.event_new_user_pay ) / ( SUM( d.activation ) + SUM( d.form_count )), 2 ), 0 ) AS eventNewUserPayRate,
|
|
|
+ IFNULL( SUM( d.event_app_invoked ), 0 ) AS eventAppInvoked,
|
|
|
+ IFNULL( ROUND( SUM( d.charge ) / SUM( d.event_app_invoked ), 2 ), 0 ) AS eventAppInvokedCost,
|
|
|
+ IFNULL( SUM( d.event_register ), 0 ) AS eventRegister,
|
|
|
+ IFNULL( ROUND( SUM( d.charge ) / SUM( d.event_register ), 2 ), 0 ) AS eventRegisterCost,
|
|
|
+ IFNULL( SUM( d.key_action ), 0 ) AS keyAction,
|
|
|
+ IFNULL( ROUND( SUM( d.charge ) / SUM( d.key_action ), 2 ), 0 ) AS keyActionCost,
|
|
|
+ IF(SUM( d.key_action )/ SUM( d.activation ) > 0.0001,CONCAT( ROUND( SUM( d.key_action )/ SUM( d.activation ) * 100, 2 ), '%' ),0) AS keyActionRate,
|
|
|
+ IFNULL( SUM( d.event_pay_purchase_amount_first_day ), 0 ) AS eventPayPurchaseAmountFirstDay,
|
|
|
+ IFNULL( SUM( d.event_pay_first_day_roi ), 0 ) AS eventPayFirstDayRoi,
|
|
|
+ IFNULL( SUM( d.form_count ), 0 ) AS formCount,
|
|
|
+ IFNULL( ROUND( SUM( d.charge ) / SUM( d.form_count ), 2 ), 0 ) AS formCountPrice,
|
|
|
+ SUM(d.bclick) bClick
|
|
|
+ FROM
|
|
|
+ media_api.kuaishou_unit_report_hourly d
|
|
|
+ WHERE
|
|
|
+ d.advertiser_id = #{accountId}
|
|
|
+ AND d.stat_date = #{nowDate}
|
|
|
+ GROUP BY
|
|
|
+ d.unit_id
|
|
|
+ ) b
|
|
|
+ on a.uid = b.dunit_id
|
|
|
+ ) t
|
|
|
+ LEFT JOIN media_api.kuaishou_ad_unit_list l
|
|
|
+ on l.unit_id = t.unit_id
|
|
|
+ WHERE l.advertiser_id = #{accountId}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|