|
@@ -1447,6 +1447,12 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="selectOrderInfo" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ SELECT t1.*,
|
|
|
+ ROUND(((t1.validOrderNUm-t2.validOrderNUm)/t2.validOrderNUm)*100,2) as 'validOrderNUmRoi',
|
|
|
+ ROUND(((t1.allNumber-t1.validOrderNUm-t2.inValidOrderNUm)/t2.inValidOrderNUm)*100,2) as 'inValidOrderNUmRoi',
|
|
|
+ ROUND(((t1.baseAmount-t2.baseAmount)/t2.baseAmount)*100,2) as 'baseAmountRoi',
|
|
|
+ ROUND(((t1.regimentalPromotionAmount-t2.regimentalPromotionAmount)/t2.regimentalPromotionAmount)*100,2) as 'regimentalPromotionAmountRoi'
|
|
|
+ FROM(
|
|
|
SELECT
|
|
|
COUNT(DISTINCT promoter_id) as 'promoterCount',
|
|
|
COUNT(DISTINCT item_id) as 'itemCount',
|
|
@@ -1459,16 +1465,41 @@
|
|
|
FROM kuaishou_supply_chain
|
|
|
WHERE stat_date >= #{startDate}
|
|
|
AND stat_date <= #{endDate}
|
|
|
+ AND stat_hour <= #{hour}
|
|
|
<if test='promoterIds != null and promoterIds.size() > 0'>
|
|
|
AND promoter_id in
|
|
|
<foreach collection="promoterIds" item="item" separator=","
|
|
|
open="(" close=")">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
- </if>
|
|
|
+ </if>)t1
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
|
|
|
+ COUNT(oid)-IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) as 'inValidOrderNUm',
|
|
|
+ IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) as 'baseAmount',
|
|
|
+ IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
|
|
|
+ 'regimentalPromotionAmount'
|
|
|
+ FROM kuaishou_supply_chain
|
|
|
+ WHERE stat_date >= #{lastTimeStart}
|
|
|
+ AND stat_date <= #{lastTimeEnd}
|
|
|
+ AND stat_hour <= #{hour}
|
|
|
+ <if test='promoterIds != null and promoterIds.size() > 0'>
|
|
|
+ AND promoter_id in
|
|
|
+ <foreach collection="promoterIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>)t2 on 1=1
|
|
|
</select>
|
|
|
|
|
|
<select id="selectOrderInfoBytedance" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ SELECT t1.*,
|
|
|
+ ROUND(((t1.validOrderNUm-t2.validOrderNUm)/t2.validOrderNUm)*100,2) as 'validOrderNUmRoi',
|
|
|
+ ROUND(((t1.allNumber-t1.validOrderNUm-t2.inValidOrderNUm)/t2.inValidOrderNUm)*100,2) as 'inValidOrderNUmRoi',
|
|
|
+ ROUND(((t1.baseAmount-t2.baseAmount)/t2.baseAmount)*100,2) as 'baseAmountRoi',
|
|
|
+ ROUND(((t1.regimentalPromotionAmount-t2.regimentalPromotionAmount)/t2.regimentalPromotionAmount)*100,2) as 'regimentalPromotionAmountRoi'
|
|
|
+ FROM (
|
|
|
SELECT
|
|
|
COUNT(DISTINCT author_short_id) as 'promoterCount',
|
|
|
COUNT(DISTINCT product_id) as 'itemCount',
|
|
@@ -1488,8 +1519,33 @@
|
|
|
THEN second_estimated_commission
|
|
|
ELSE 0 END) ,0) AS 'secondEstimatedCommission'
|
|
|
FROM bytedance_order_list
|
|
|
- WHERE pay_success_time >= #{startDate}
|
|
|
- AND pay_success_time <= #{endDate}
|
|
|
+ WHERE pay_success_time >=#{startDate}
|
|
|
+ AND pay_success_time <=#{endDate}
|
|
|
+ AND pay_success_time_hour <=#{hour}
|
|
|
+ <if test='promoterIds != null and promoterIds.size() > 0'>
|
|
|
+ AND author_short_id in
|
|
|
+ <foreach collection="promoterIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ )t1
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
|
|
|
+ COUNT(order_id)-IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) as 'inValidOrderNUm',
|
|
|
+ IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END), 0) AS 'baseAmount',
|
|
|
+ IFNULL( sum(CASE
|
|
|
+ WHEN flow_point != 'REFUND' and colonel_type != 2
|
|
|
+ THEN colonel_estimated_commission
|
|
|
+ WHEN flow_point != 'REFUND' and colonel_type = 2
|
|
|
+ then second_estimated_commission
|
|
|
+ ELSE 0 END) * 0.9,0) AS
|
|
|
+ 'regimentalPromotionAmount'
|
|
|
+ FROM bytedance_order_list
|
|
|
+ WHERE pay_success_time >=#{lastTimeStart}
|
|
|
+ AND pay_success_time <=#{lastTimeEnd}
|
|
|
+ AND pay_success_time_hour <=#{hour}
|
|
|
<if test='promoterIds != null and promoterIds.size() > 0'>
|
|
|
AND author_short_id in
|
|
|
<foreach collection="promoterIds" item="item" separator=","
|
|
@@ -1497,12 +1553,17 @@
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
+ )t2 on 1 = 1
|
|
|
</select>
|
|
|
|
|
|
<select id="selectOrderInfoByItemIds" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT t.*,
|
|
|
- CONCAT(IFNULL(ROUND(sendCount / allNumber * 100, 2),0), '%') as 'sendRate'
|
|
|
- FROM (
|
|
|
+ SELECT t1.*,
|
|
|
+ CONCAT(IFNULL(ROUND(t1.sendCount / t1.allNumber * 100, 2),0), '%') as 'sendRate',
|
|
|
+ ROUND(((t1.validOrderNUm-t2.validOrderNUm)/t2.validOrderNUm)*100,2) as 'validOrderNUmRoi',
|
|
|
+ ROUND(((t1.allNumber-t1.validOrderNUm-t2.inValidOrderNUm)/t2.inValidOrderNUm)*100,2) as 'inValidOrderNUmRoi',
|
|
|
+ ROUND(((t1.baseAmount-t2.baseAmount)/t2.baseAmount)*100,2) as 'baseAmountRoi',
|
|
|
+ ROUND(((t1.regimentalPromotionAmount-t2.regimentalPromotionAmount)/t2.regimentalPromotionAmount)*100,2) as 'regimentalPromotionAmountRoi'
|
|
|
+ FROM(
|
|
|
SELECT
|
|
|
COUNT(DISTINCT promoter_id) as 'promoterCount',
|
|
|
COUNT(DISTINCT item_id) as 'itemCount',
|
|
@@ -1516,6 +1577,7 @@
|
|
|
FROM kuaishou_supply_chain
|
|
|
WHERE stat_date >= #{startDate}
|
|
|
AND stat_date <= #{endDate}
|
|
|
+ AND stat_hour <= #{hour}
|
|
|
<if test='itemIds != null and itemIds.size() > 0'>
|
|
|
AND item_id in
|
|
|
<foreach collection="itemIds" item="item" separator=","
|
|
@@ -1523,28 +1585,72 @@
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
- ) t
|
|
|
+ )t1
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
|
|
|
+ COUNT(oid)-IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) as 'inValidOrderNUm',
|
|
|
+ IFNULL(sum(base_amount), 0) as 'baseAmount',
|
|
|
+ IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
|
|
|
+ 'regimentalPromotionAmount'
|
|
|
+ FROM kuaishou_supply_chain
|
|
|
+ WHERE stat_date >= #{lastTimeStart}
|
|
|
+ AND stat_date <= #{lastTimeEnd}
|
|
|
+ AND stat_hour <= #{hour}
|
|
|
+ <if test='itemIds != null and itemIds.size() > 0'>
|
|
|
+ AND item_id in
|
|
|
+ <foreach collection="itemIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ )t2 on 1=1
|
|
|
</select>
|
|
|
|
|
|
<select id="selectOrderInfoByItemIdsBytedance" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ SELECT t1.*,
|
|
|
+ ROUND(((t1.validOrderNUm-t2.validOrderNUm)/t2.validOrderNUm)*100,2) as 'validOrderNUmRoi',
|
|
|
+ ROUND(((t1.allNumber-t1.validOrderNUm-t2.inValidOrderNUm)/t2.inValidOrderNUm)*100,2) as 'inValidOrderNUmRoi',
|
|
|
+ ROUND(((t1.baseAmount-t2.baseAmount)/t2.baseAmount)*100,2) as 'baseAmountRoi',
|
|
|
+ ROUND(((t1.regimentalPromotionAmount-t2.regimentalPromotionAmount)/t2.regimentalPromotionAmount)*100,2) as 'regimentalPromotionAmountRoi'
|
|
|
+ from (
|
|
|
SELECT
|
|
|
COUNT(DISTINCT author_short_id) as 'promoterCount',
|
|
|
COUNT(DISTINCT product_id) as 'itemCount',
|
|
|
COUNT(order_id) as 'allNumber',
|
|
|
IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
|
|
|
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END)/100, 0) AS 'orderAmount',
|
|
|
+ IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END)/100, 0) AS 'baseAmount',
|
|
|
IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9 /100,0) AS
|
|
|
'regimentalPromotionAmount'
|
|
|
FROM bytedance_order_list
|
|
|
WHERE pay_success_time >= #{startDate}
|
|
|
AND pay_success_time <= #{endDate}
|
|
|
+ AND pay_success_time_hour <=#{hour}
|
|
|
<if test='itemIds != null and itemIds.size() > 0'>
|
|
|
AND product_id in
|
|
|
<foreach collection="itemIds" item="item" separator=","
|
|
|
open="(" close=")">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
- </if>
|
|
|
+ </if>)t1
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
|
|
|
+ COUNT(order_id)-IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) as 'inValidOrderNUm',
|
|
|
+ IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END)/100, 0) AS 'baseAmount',
|
|
|
+ IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9 /100,0) AS
|
|
|
+ 'regimentalPromotionAmount'
|
|
|
+ FROM bytedance_order_list
|
|
|
+ WHERE pay_success_time >= #{lastTimeStart}
|
|
|
+ AND pay_success_time <= #{lastTimeEnd}
|
|
|
+ AND pay_success_time_hour <=#{hour}
|
|
|
+ <if test='itemIds != null and itemIds.size() > 0'>
|
|
|
+ AND product_id in
|
|
|
+ <foreach collection="itemIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>)t2 on 1=1
|
|
|
</select>
|
|
|
|
|
|
<select id="selectOrderRate" resultType="com.alibaba.fastjson.JSONObject">
|
|
@@ -2953,6 +3059,51 @@
|
|
|
order by stat_hour asc;
|
|
|
</select>
|
|
|
|
|
|
+ <select id="getKsChannelGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ SELECT
|
|
|
+ t1.time,
|
|
|
+ ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
|
|
|
+ FROM
|
|
|
+ (select stat_hour as 'time',
|
|
|
+ round(sum(pay_amount) / 100, 2) as 'charge' from kuaishou_supply_chain
|
|
|
+ where stat_date = #{date}
|
|
|
+ <if test='userList != null and userList.size() > 0'>
|
|
|
+ and promoter_id in (
|
|
|
+ select promoter_id
|
|
|
+ from kuaishou_promoter where
|
|
|
+ 1 = 1
|
|
|
+ and user_id in
|
|
|
+ <foreach collection="userList" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ group by promoter_id
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ group by stat_hour
|
|
|
+ ) t1
|
|
|
+ LEFT JOIN
|
|
|
+ (select stat_hour as 'time',
|
|
|
+ round(sum(pay_amount) / 100, 2) as 'charge' from kuaishou_supply_chain
|
|
|
+ where stat_date = DATE_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
|
|
|
+ <if test='userList != null and userList.size() > 0'>
|
|
|
+ and promoter_id in (
|
|
|
+ select promoter_id
|
|
|
+ from kuaishou_promoter where
|
|
|
+ 1 = 1
|
|
|
+ and user_id in
|
|
|
+ <foreach collection="userList" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ group by promoter_id
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ group by stat_hour
|
|
|
+ ) t2 ON t1.time =t2.time
|
|
|
+ ORDER BY `time`
|
|
|
+ </select>
|
|
|
+
|
|
|
|
|
|
<select id="getKsCourtshipGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
select stat_hour as 'time',
|
|
@@ -2976,6 +3127,54 @@
|
|
|
order by stat_hour asc;
|
|
|
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="getKsCourtshipGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ SELECT
|
|
|
+ t1.time,
|
|
|
+ ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
|
|
|
+ FROM
|
|
|
+ ( select stat_hour as 'time',
|
|
|
+ round(sum(pay_amount) / 100, 2) as 'charge'
|
|
|
+ from kuaishou_supply_chain
|
|
|
+ where stat_date = #{date}
|
|
|
+ <if test='userList != null and userList.size() > 0'>
|
|
|
+ and item_id in (
|
|
|
+ select item_id
|
|
|
+ from kuaishou_item_list where
|
|
|
+ 1 = 1
|
|
|
+ and user_id in
|
|
|
+ <foreach collection="userList" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ group by item_id
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ group by stat_hour
|
|
|
+ ) t1
|
|
|
+ LEFT JOIN
|
|
|
+ (
|
|
|
+ select stat_hour as 'time',
|
|
|
+ round(sum(pay_amount) / 100, 2) as 'charge'
|
|
|
+ from kuaishou_supply_chain
|
|
|
+ where stat_date = DATE_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
|
|
|
+ <if test='userList != null and userList.size() > 0'>
|
|
|
+ and item_id in (
|
|
|
+ select item_id
|
|
|
+ from kuaishou_item_list where
|
|
|
+ 1 = 1
|
|
|
+ and user_id in
|
|
|
+ <foreach collection="userList" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ group by item_id
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ group by stat_hour
|
|
|
+ ) t2 ON t1.time =t2.time
|
|
|
+ ORDER BY `time`
|
|
|
+ </select>
|
|
|
<select id="getBytedanceChannelGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
select pay_success_time_hour as 'time',
|
|
|
round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list where pay_success_time = #{date}
|
|
@@ -2996,6 +3195,53 @@
|
|
|
order by pay_success_time_hour asc;
|
|
|
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="getBytedanceChannelGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ SELECT
|
|
|
+ t1.time,
|
|
|
+ ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ select pay_success_time_hour as 'time',
|
|
|
+ round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list where pay_success_time = #{date}
|
|
|
+ <if test='userList != null and userList.size() > 0'>
|
|
|
+ and author_short_id in(
|
|
|
+ select promoter_id
|
|
|
+ from kuaishou_promoter where
|
|
|
+ 1 = 1
|
|
|
+ and user_id in
|
|
|
+ <foreach collection="userList" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ group by promoter_id
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ group by pay_success_time_hour
|
|
|
+ ) t1
|
|
|
+ LEFT JOIN
|
|
|
+ (
|
|
|
+ select pay_success_time_hour as 'time',
|
|
|
+ round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list
|
|
|
+ where pay_success_time = DATE_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
|
|
|
+ <if test='userList != null and userList.size() > 0'>
|
|
|
+ and author_short_id in(
|
|
|
+ select promoter_id
|
|
|
+ from kuaishou_promoter where
|
|
|
+ 1 = 1
|
|
|
+ and user_id in
|
|
|
+ <foreach collection="userList" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ group by promoter_id
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ group by pay_success_time_hour
|
|
|
+ ) t2 ON t1.time =t2.time
|
|
|
+ ORDER BY `time`
|
|
|
+ </select>
|
|
|
+
|
|
|
<select id="getBytedanceCourtshipGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
select pay_success_time_hour as 'time',
|
|
|
round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list where pay_success_time = #{date}
|
|
@@ -3016,6 +3262,53 @@
|
|
|
order by pay_success_time_hour asc;
|
|
|
</select>
|
|
|
|
|
|
+
|
|
|
+ <select id="getBytedanceCourtshipGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ SELECT
|
|
|
+ t1.time,
|
|
|
+ ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ select pay_success_time_hour as 'time',
|
|
|
+ round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list where pay_success_time = #{date}
|
|
|
+ <if test='userList != null and userList.size() > 0'>
|
|
|
+ and product_id in(
|
|
|
+ select item_id
|
|
|
+ from kuaishou_item_list where
|
|
|
+ 1 = 1
|
|
|
+ and user_id in
|
|
|
+ <foreach collection="userList" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ group by item_id
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ group by pay_success_time_hour
|
|
|
+ ) t1
|
|
|
+ LEFT JOIN
|
|
|
+ (
|
|
|
+ select pay_success_time_hour as 'time',
|
|
|
+ round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list
|
|
|
+ where pay_success_time = DATE_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
|
|
|
+ <if test='userList != null and userList.size() > 0'>
|
|
|
+ and product_id in(
|
|
|
+ select item_id
|
|
|
+ from kuaishou_item_list where
|
|
|
+ 1 = 1
|
|
|
+ and user_id in
|
|
|
+ <foreach collection="userList" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ group by item_id
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ group by pay_success_time_hour
|
|
|
+ ) t2 ON t1.time =t2.time
|
|
|
+ ORDER BY `time`
|
|
|
+ </select>
|
|
|
+
|
|
|
<insert id="replaceKuaiShouActivityOpenItemList">
|
|
|
replace into kuaishou_activity_open_item_list(
|
|
|
item_id,
|