|
@@ -120,6 +120,34 @@
|
|
|
</select>
|
|
|
|
|
|
|
|
|
+ <select id="selectReportDetailGroupAccountIdByDate" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ select
|
|
|
+ sum(charge) cost, -- 消耗
|
|
|
+ sum(photo_show) photoShow, -- 封面展示
|
|
|
+ sum(photo_click) photoClick, -- 封面点击
|
|
|
+ sum(aclick) aclick, -- 素材曝光数
|
|
|
+ (sum(photo_click) / sum(photo_show)) photoClickRatio, -- 封面点击率
|
|
|
+ (sum(form_count) / sum(bclick)) cvr,
|
|
|
+ ((sum(charge) / (sum(photo_show)) * 1000)) cpm,
|
|
|
+ sum(bclick) bClick,-- 行为数
|
|
|
+ sum(form_count) formCount,
|
|
|
+ (sum(charge) / sum(form_count)) formPrice, -- 表单提交单价
|
|
|
+ sum(activation) activationCount, -- 激活数
|
|
|
+ (sum(charge) / sum(activation)) activationPrice, -- 激活单价
|
|
|
+ account_id accountId,
|
|
|
+ (select auth_name from ctop_user_allocation where account_id = accountId limit 1) accountName
|
|
|
+ from
|
|
|
+ ctop_kuaishou_report_daily_account
|
|
|
+ where stat_date = #{statDate}
|
|
|
+ and account_id in
|
|
|
+ <foreach item="item" index="index" collection="accountIds"
|
|
|
+ open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ group by account_id;
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
<select id="selectMaxHourByDate" resultType="java.lang.Integer">
|
|
|
select
|
|
|
max(stat_hour)
|
|
@@ -298,4 +326,189 @@
|
|
|
</select>
|
|
|
|
|
|
|
|
|
+ <select id="selectSummaryByMap" parameterType="Map" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ select
|
|
|
+ sum(charge) cost, -- 消耗
|
|
|
+ (case
|
|
|
+ when sum(charge) != 0
|
|
|
+ then (sum(charge) / #{discount})
|
|
|
+ else 0
|
|
|
+ end
|
|
|
+ ) discountCost, -- 封面点击率
|
|
|
+
|
|
|
+ sum(photo_show) photoShow, -- 封面展示
|
|
|
+ sum(photo_click) photoClick, -- 封面点击
|
|
|
+ sum(aclick) aclick, -- 素材曝光数
|
|
|
+
|
|
|
+ (case
|
|
|
+ when sum(photo_show) != 0
|
|
|
+ then (sum(photo_click) / sum(photo_show))
|
|
|
+ else 0
|
|
|
+ end
|
|
|
+ ) photoClickRatio, -- 封面点击率
|
|
|
+
|
|
|
+ (case
|
|
|
+ when sum(bclick) != 0
|
|
|
+ then (sum(form_count) / sum(bclick))
|
|
|
+ else 0
|
|
|
+ end
|
|
|
+ ) cvr,
|
|
|
+
|
|
|
+ (case
|
|
|
+ when sum(photo_show) != 0
|
|
|
+ then ((sum(charge) / (sum(photo_show)) * 1000))
|
|
|
+ else 0
|
|
|
+ end
|
|
|
+ ) cpm,
|
|
|
+
|
|
|
+ sum(bclick) bClick,-- 行为数
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(form_count) != 0 THEN
|
|
|
+ sum(form_count)
|
|
|
+ WHEN sum(activation) != 0 THEN
|
|
|
+ sum(activation)
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+ ) conversions, -- 转化数
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(form_count) != 0 THEN
|
|
|
+ sum(charge) / sum(form_count)
|
|
|
+ WHEN sum(activation) != 0 THEN
|
|
|
+ sum(charge) / sum(activation)
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+ ) conversionPrice, -- 转化单价
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(form_count) != 0 THEN
|
|
|
+ (sum(charge) / sum(form_count)) / #{discount}
|
|
|
+ WHEN sum(activation) != 0 THEN
|
|
|
+ (sum(charge) / sum(activation)) / #{discount}
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+ ) discountConversionPrice
|
|
|
+
|
|
|
+ from
|
|
|
+ ctop_kuaishou_report_daily_account
|
|
|
+
|
|
|
+ <where>
|
|
|
+ <if test="statDate != null">
|
|
|
+ and stat_date = #{statDate}
|
|
|
+ </if>
|
|
|
+ <if test="startDate != null">
|
|
|
+ and stat_date >= #{startDate}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null">
|
|
|
+ and stat_date <= #{endDate}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="accountIds != null">
|
|
|
+ and account_id in
|
|
|
+ <foreach collection="accountIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="selectHourSummaryByMap" parameterType="Map" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+
|
|
|
+ select
|
|
|
+ sum(charge) cost, -- 消耗
|
|
|
+ (case
|
|
|
+ when sum(charge) != 0
|
|
|
+ then (sum(charge) / #{discount})
|
|
|
+ else 0
|
|
|
+ end
|
|
|
+ ) discountCost, -- 封面点击率
|
|
|
+
|
|
|
+ sum(photo_show) photoShow, -- 封面展示
|
|
|
+ sum(photo_click) photoClick, -- 封面点击
|
|
|
+ sum(aclick) aclick, -- 素材曝光数
|
|
|
+
|
|
|
+ (case
|
|
|
+ when sum(photo_show) != 0
|
|
|
+ then (sum(photo_click) / sum(photo_show))
|
|
|
+ else 0
|
|
|
+ end
|
|
|
+ ) photoClickRatio, -- 封面点击率
|
|
|
+
|
|
|
+ (case
|
|
|
+ when sum(bclick) != 0
|
|
|
+ then (sum(form_count) / sum(bclick))
|
|
|
+ else 0
|
|
|
+ end
|
|
|
+ ) cvr,
|
|
|
+
|
|
|
+ (case
|
|
|
+ when sum(photo_show) != 0
|
|
|
+ then ((sum(charge) / (sum(photo_show)) * 1000))
|
|
|
+ else 0
|
|
|
+ end
|
|
|
+ ) cpm,
|
|
|
+
|
|
|
+ sum(bclick) bClick,-- 行为数
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(form_count) != 0 THEN
|
|
|
+ sum(form_count)
|
|
|
+ WHEN sum(activation) != 0 THEN
|
|
|
+ sum(activation)
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+ ) conversions, -- 转化数
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(form_count) != 0 THEN
|
|
|
+ sum(charge) / sum(form_count)
|
|
|
+ WHEN sum(activation) != 0 THEN
|
|
|
+ sum(charge) / sum(activation)
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+ ) conversionPrice, -- 转化单价
|
|
|
+ (
|
|
|
+ CASE
|
|
|
+ WHEN sum(form_count) != 0 THEN
|
|
|
+ (sum(charge) / sum(form_count)) / #{discount}
|
|
|
+ WHEN sum(activation) != 0 THEN
|
|
|
+ (sum(charge) / sum(activation)) / #{discount}
|
|
|
+ ELSE
|
|
|
+ 0
|
|
|
+ END
|
|
|
+ ) discountConversionPrice
|
|
|
+
|
|
|
+ from
|
|
|
+ ctop_kuaishou_report_hourly_account
|
|
|
+
|
|
|
+ <where>
|
|
|
+ <if test="statDate != null">
|
|
|
+ and stat_date = #{statDate}
|
|
|
+ </if>
|
|
|
+ <if test="statHour != null">
|
|
|
+ and stat_hour <= #{statHour}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="accountIds != null">
|
|
|
+ and account_id in
|
|
|
+ <foreach collection="accountIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|