|
@@ -587,124 +587,70 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="bytedanceBDTotal" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT
|
|
|
- t2.sampleCount,
|
|
|
- t1.orderNum,
|
|
|
- t1.validOrderNum,
|
|
|
- t1.validOrderRate,
|
|
|
- t1.orderAmount,
|
|
|
- t1.regimentalPromotionAmount,
|
|
|
- t1.totalRegimentalSettleAmount
|
|
|
- FROM (
|
|
|
- SELECT
|
|
|
- count(order_id) AS 'orderNum',
|
|
|
- t0.validOrderNUm,
|
|
|
- CONCAT(round(t0.validOrderNUm / count(order_id) * 100, 2),'%') AS 'validOrderRate',
|
|
|
- sum(total_pay_amount)/100 AS 'orderAmount',
|
|
|
- sum(colonel_estimated_commission)/100 AS 'regimentalPromotionAmount',
|
|
|
- sum(colonel_real_commission)/100 AS 'totalRegimentalSettleAmount'
|
|
|
- FROM ruixuan.bytedance_promoter_order_list t
|
|
|
- LEFT JOIN (
|
|
|
- SELECT author_bind_user_id AS 'collectSampleId',
|
|
|
- sum(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END) AS 'validOrderNUm'
|
|
|
- FROM ruixuan.bytedance_promoter_order_list
|
|
|
- WHERE author_bind_user_id is not null
|
|
|
- <if test="start != null and start != ''">
|
|
|
- and pay_success_time >= #{start}
|
|
|
- </if>
|
|
|
- <if test="end != null and end != ''">
|
|
|
- and pay_success_time <= #{end}
|
|
|
- </if>
|
|
|
- <if test="collectSampleId != null and collectSampleId != ''">
|
|
|
- and author_bind_user_id = #{collectSampleId}
|
|
|
- </if>
|
|
|
- GROUP BY author_bind_user_id
|
|
|
- ) t0 ON t.author_bind_user_id= t0.collectSampleId
|
|
|
- WHERE 1 = 1
|
|
|
- <if test="start != null and start != ''">
|
|
|
- and pay_success_time >= #{start}
|
|
|
+ select t.*, tt.sampleCount
|
|
|
+ from (select
|
|
|
+ count(t2.order_id) as 'orderNum',
|
|
|
+ sum(case when t2.flow_point != 'REFUND' then 1 else 0 end) AS 'validOrderNum',
|
|
|
+ concat(round(sum(case when t2.flow_point != 'REFUND' then 1 else 0 end) / count(t2.order_id) * 100, 2), '%') as 'validOrderRate',
|
|
|
+ round(sum(t2.total_pay_amount) / 100, 2) as 'orderAmount',
|
|
|
+ round(sum(t2.pay_goods_amount) / 100, 2) as 'regimentalPromotionAmount',
|
|
|
+ round(sum(t2.settled_goods_amount) / 100, 2) as 'totalRegimentalSettleAmount'
|
|
|
+ from promoter_bind_channel_date t1
|
|
|
+ left join bytedance_promoter_order_list t2
|
|
|
+ on t1.promoter_id = t2.author_short_id and t1.stat_date = t2.pay_success_time
|
|
|
+ where 1 = 1
|
|
|
+ <if test="start != null and start != '' ">
|
|
|
+ and t1.stat_date >= #{start}
|
|
|
</if>
|
|
|
<if test="end != null and end != ''">
|
|
|
- and pay_success_time <= #{end}
|
|
|
+ and t1.stat_date <= #{end}
|
|
|
</if>
|
|
|
<if test="collectSampleId != null and collectSampleId != ''">
|
|
|
- and author_bind_user_id = #{collectSampleId}
|
|
|
- </if>
|
|
|
- ) t1
|
|
|
- join (
|
|
|
- SELECT
|
|
|
- count(distinct item_id) AS 'sampleCount'
|
|
|
- FROM kuaishou_item_collect_samples
|
|
|
- WHERE collect_sample_status > 2
|
|
|
- <if test="collectSampleId != null and collectSampleId != ''">
|
|
|
- and collect_sample_id = #{collectSampleId}
|
|
|
- </if>
|
|
|
- ) t2
|
|
|
+ and t1.user_id = #{collectSampleId}
|
|
|
+ </if>) t
|
|
|
+ join (select promoter_id,
|
|
|
+ count(distinct item_id) as 'sampleCount'
|
|
|
+ from kuaishou_item_collect_samples
|
|
|
+ where collect_sample_status > 2
|
|
|
+ and collect_sample_id = #{collectSampleId}
|
|
|
+ ) tt
|
|
|
+
|
|
|
+
|
|
|
</select>
|
|
|
|
|
|
<select id="bytedanceBDDetailList" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
- SELECT
|
|
|
- t1.promoterId,
|
|
|
- t1.promoterName,
|
|
|
- t1.promoterUrl,
|
|
|
- t2.sampleCount,
|
|
|
- t1.orderNum,
|
|
|
- t1.validOrderNum,
|
|
|
- t1.validOrderRate,
|
|
|
- t1.orderAmount,
|
|
|
- t1.regimentalPromotionAmount,
|
|
|
- t1.totalRegimentalSettleAmount
|
|
|
- FROM (
|
|
|
- SELECT
|
|
|
- author_short_id AS 'promoterId',
|
|
|
- author_short_name AS 'promoterName',
|
|
|
- author_short_url AS 'promoterUrl',
|
|
|
- count(order_id) AS 'orderNum',
|
|
|
- t0.validOrderNUm,
|
|
|
- CONCAT(round(t0.validOrderNUm / count(order_id) * 100, 2),'%') AS 'validOrderRate',
|
|
|
- sum(total_pay_amount)/100 AS 'orderAmount',
|
|
|
- sum(colonel_estimated_commission)/100 AS 'regimentalPromotionAmount',
|
|
|
- sum(colonel_real_commission)/100 AS 'totalRegimentalSettleAmount'
|
|
|
- FROM ruixuan.bytedance_promoter_order_list t
|
|
|
- LEFT JOIN (
|
|
|
- SELECT author_bind_user_id AS 'collectSampleId',
|
|
|
- sum(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END) AS 'validOrderNUm'
|
|
|
- FROM ruixuan.bytedance_promoter_order_list
|
|
|
- WHERE author_short_id is not null
|
|
|
- <if test="start != null and start != ''">
|
|
|
- and pay_success_time >= #{start}
|
|
|
+ select t.*, tt.sampleCount
|
|
|
+ from (select t1.promoter_id as 'promoterId',
|
|
|
+ t1.promoter_name as 'promoterName',
|
|
|
+ t1.promoter_url as 'promoterUrl',
|
|
|
+ count(t2.order_id) as 'orderNum',
|
|
|
+ sum(case when t2.flow_point != 'REFUND' then 1 else 0 end) AS 'validOrderNum',
|
|
|
+ concat(round(sum(case when t2.flow_point != 'REFUND' then 1 else 0 end) / count(t2.order_id) * 100, 2), '%') as 'validOrderRate',
|
|
|
+ round(sum(t2.total_pay_amount) / 100, 2) as 'orderAmount',
|
|
|
+ round(sum(t2.pay_goods_amount) / 100, 2) as 'regimentalPromotionAmount',
|
|
|
+ round(sum(t2.settled_goods_amount) / 100, 2) as 'totalRegimentalSettleAmount'
|
|
|
+ from promoter_bind_channel_date t1
|
|
|
+ left join bytedance_promoter_order_list t2
|
|
|
+ on t1.promoter_id = t2.author_short_id and t1.stat_date = t2.pay_success_time
|
|
|
+ where 1 = 1
|
|
|
+ <if test="start != null and start != '' ">
|
|
|
+ and t1.stat_date >= #{start}
|
|
|
</if>
|
|
|
<if test="end != null and end != ''">
|
|
|
- and pay_success_time <= #{end}
|
|
|
+ and t1.stat_date <= #{end}
|
|
|
</if>
|
|
|
<if test="collectSampleId != null and collectSampleId != ''">
|
|
|
- and author_bind_user_id = #{collectSampleId}
|
|
|
- </if>
|
|
|
- GROUP BY author_bind_user_id
|
|
|
- ) t0 ON t.author_bind_user_id= t0.collectSampleId
|
|
|
- WHERE 1 = 1
|
|
|
- <if test="start != null and start != ''">
|
|
|
- and pay_success_time >= #{start}
|
|
|
- </if>
|
|
|
- <if test="end != null and end != ''">
|
|
|
- and pay_success_time <= #{end}
|
|
|
- </if>
|
|
|
- <if test="collectSampleId != null and collectSampleId != ''">
|
|
|
- and author_bind_user_id = #{collectSampleId}
|
|
|
- </if>
|
|
|
- GROUP BY author_short_id) t1
|
|
|
- LEFT JOIN (
|
|
|
- SELECT
|
|
|
- promoter_id AS 'promoterId',
|
|
|
- count(distinct item_id) AS 'sampleCount'
|
|
|
- FROM kuaishou_item_collect_samples
|
|
|
- WHERE collect_sample_status > 2
|
|
|
- <if test="collectSampleId != null and collectSampleId != ''">
|
|
|
- and collect_sample_id = #{collectSampleId}
|
|
|
- </if>
|
|
|
- GROUP BY promoter_id) t2
|
|
|
- on t1.promoterId = t2.promoterId
|
|
|
- ORDER BY ${fieId} ${sort}
|
|
|
+ and t1.user_id = #{collectSampleId}
|
|
|
+ </if>
|
|
|
+ group by t1.promoter_id) t
|
|
|
+ left join (select promoter_id,
|
|
|
+ count(distinct item_id) as 'sampleCount'
|
|
|
+ from kuaishou_item_collect_samples
|
|
|
+ where collect_sample_status > 2
|
|
|
+ and collect_sample_id = #{collectSampleId}
|
|
|
+ group by promoter_id) tt on t.promoterId = tt.promoter_id
|
|
|
+ where t.orderNum > 0
|
|
|
+ order by ${fieId} ${sort}
|
|
|
</select>
|
|
|
|
|
|
<select id="bytedanceUserItemTotal" resultType="com.alibaba.fastjson.JSONObject">
|
|
@@ -813,4 +759,153 @@
|
|
|
ORDER BY t.promoterId,t.itemId desc
|
|
|
</select>
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ <select id="bdReportList" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ select t.*,
|
|
|
+ tt.promoterCount,
|
|
|
+ ttt.sampleCount,
|
|
|
+ tttt.sendTotalCount,
|
|
|
+ tttt.sendPromoterCount,
|
|
|
+ tttt.sendItemCount,
|
|
|
+ IFNULL( ttttt.promoters_count,'-') as 'promotersCount',
|
|
|
+ concat(round(ttt.sampleCount / tt.promoterCount * 100, 2), '%') as 'sampleRate',
|
|
|
+ tt.promoterCount - ttt.sampleCount as 'notSampleCount'
|
|
|
+ from (
|
|
|
+ select t1.user_id as 'collectSampleId',
|
|
|
+ t1.user_name as 'collectSampleName',
|
|
|
+ count(t2.order_id) as 'orderNum',
|
|
|
+ sum(case when t2.flow_point != 'REFUND' then 1 else 0 end) AS 'validOrderNum',
|
|
|
+ concat(round(sum(case when t2.flow_point != 'REFUND' then 1 else 0 end) / count(t2.order_id) * 100, 2), '%') as 'validOrderRate',
|
|
|
+ round(sum(t2.total_pay_amount) / 100, 2) as 'orderAmount',
|
|
|
+ round(sum(t2.colonel_estimated_commission) / 100, 2) as 'regimentalPromotionAmount',
|
|
|
+ round(sum(t2.colonel_real_commission) / 100, 2) as 'totalRegimentalSettleAmount'
|
|
|
+ from promoter_bind_channel_date t1
|
|
|
+ left join bytedance_promoter_order_list t2
|
|
|
+ on t1.promoter_id = t2.author_short_id and t1.stat_date = t2.pay_success_time
|
|
|
+ where 1 = 1
|
|
|
+ <if test="start != null and start != ''">
|
|
|
+ and t1.stat_date >= #{start}
|
|
|
+ </if>
|
|
|
+ <if test="end != null and end != ''">
|
|
|
+ and t1.stat_date <= #{end}
|
|
|
+ </if>
|
|
|
+ <if test="collectSampleId != null and collectSampleId != ''">
|
|
|
+ and t1.user_id = #{collectSampleId}
|
|
|
+ </if>
|
|
|
+ group by t1.user_id) t
|
|
|
+ left join (select user_id,
|
|
|
+ count(distinct promoter_id) as 'promoterCount'
|
|
|
+ from kuaishou_promoter
|
|
|
+ group by user_id) tt on t.collectSampleId = tt.user_id
|
|
|
+ left join (select collect_sample_id as 'user_id',
|
|
|
+ count(distinct promoter_id) as 'sampleCount'
|
|
|
+ from kuaishou_item_collect_samples
|
|
|
+ where collect_sample_status > 2
|
|
|
+ group by collect_sample_id) ttt on t.collectSampleId = ttt.user_id
|
|
|
+ left join (select collect_sample_id as 'user_id',
|
|
|
+ count(1) as 'sendTotalCount',
|
|
|
+ count(distinct promoter_id) as 'sendPromoterCount',
|
|
|
+ count(distinct item_id) as 'sendItemCount'
|
|
|
+ from kuaishou_item_collect_samples
|
|
|
+ where collect_sample_status > 2
|
|
|
+ <if test="collectSampleId != null and collectSampleId != ''">
|
|
|
+ and collect_sample_id = #{collectSampleId}
|
|
|
+ </if>
|
|
|
+ <if test="start != null and start != ''">
|
|
|
+ and create_time >= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
|
|
|
+ %H:%i:%s')
|
|
|
+ </if>
|
|
|
+ <if test="end != null and end != ''">
|
|
|
+ and create_time <= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
|
|
|
+ </if>
|
|
|
+ group by collect_sample_id) tttt on t.collectSampleId = tttt.user_id
|
|
|
+ left join (select user_id, promoters_count
|
|
|
+ from user_promoters_count
|
|
|
+ where media_id = 1) ttttt
|
|
|
+ on t.collectSampleId = ttttt.user_id
|
|
|
+ where t.orderNum > 0
|
|
|
+ order by t.orderNum desc
|
|
|
+ </select>
|
|
|
+ <select id="bdReportListByBind" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ select t.*,
|
|
|
+ tt.promoterCount,
|
|
|
+ ttt.sampleCount,
|
|
|
+ tttt.sendTotalCount,
|
|
|
+ tttt.sendPromoterCount,
|
|
|
+ tttt.sendItemCount,
|
|
|
+ IFNULL(ttttt.promoters_count, '-') as 'promotersCount'
|
|
|
+ from (select t1.user_id as 'collectSampleId',
|
|
|
+ t1.user_name as 'collectSampleName',
|
|
|
+ count(t2.order_id) as 'orderNum',
|
|
|
+ sum(case when t2.flow_point != 'REFUND' then 1 else 0 end) as 'validOrderNum',
|
|
|
+ concat(round(sum(case when t2.flow_point != 'REFUND' then 1 else 0 end) / count(t2.order_id) * 100, 2), '%') as 'validOrderRate',
|
|
|
+ round(sum(t2.total_pay_amount) / 100, 2) as 'orderAmount',
|
|
|
+ round(sum(t2.colonel_estimated_commission) / 100, 2) as 'regimentalPromotionAmount',
|
|
|
+ round(sum(t2.colonel_real_commission) / 100, 2) as 'totalRegimentalSettleAmount'
|
|
|
+ from kuaishou_promoter t1
|
|
|
+ left join(select *
|
|
|
+ from bytedance_promoter_order_list
|
|
|
+ where pay_success_time >= #{bindStartDate}) t2
|
|
|
+ on t1.promoter_id = t2.author_short_id
|
|
|
+ where 1 = 1
|
|
|
+ <if test="bindStartDate != null and bindStartDate != '' ">
|
|
|
+ and t1.create_time >= str_to_date(concat(date_format(#{bindStartDate}, '%Y-%m-%d'), '00:00:01'),
|
|
|
+ '%Y-%m-%d %H:%i:%s')
|
|
|
+ </if>
|
|
|
+ <if test="bindEndDate != null and bindEndDate != '' ">
|
|
|
+ and t1.create_time <= str_to_date(concat(date_format(#{bindEndDate}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d
|
|
|
+ %H:%i:%s')
|
|
|
+ </if>
|
|
|
+ <if test="collectSampleId != null and collectSampleId != '' ">
|
|
|
+ and t1.user_id = #{collectSampleId}
|
|
|
+ </if>
|
|
|
+ group by t1.user_id) t
|
|
|
+ left join (select user_id,
|
|
|
+ count(distinct promoter_id) as 'promoterCount'
|
|
|
+ from kuaishou_promoter
|
|
|
+ where 1 = 1
|
|
|
+ <if test="collectSampleId != null and collectSampleId != '' ">
|
|
|
+ and user_id = #{collectSampleId}
|
|
|
+ </if>
|
|
|
+ group by user_id) tt on t.collectSampleId = tt.user_id
|
|
|
+ left join (select collect_sample_id as 'user_id',
|
|
|
+ count(distinct promoter_id) as 'sampleCount'
|
|
|
+ from kuaishou_item_collect_samples
|
|
|
+ where collect_sample_status > 2
|
|
|
+ <if test="collectSampleId != null and collectSampleId != '' ">
|
|
|
+ and collect_sample_id = #{collectSampleId}
|
|
|
+ </if>
|
|
|
+ group by collect_sample_id) ttt on t.collectSampleId = ttt.user_id
|
|
|
+ left join (select collect_sample_id as 'user_id',
|
|
|
+ count(1) as 'sendTotalCount',
|
|
|
+ count(distinct promoter_id) as 'sendPromoterCount',
|
|
|
+ count(distinct item_id) as 'sendItemCount'
|
|
|
+ from kuaishou_item_collect_samples
|
|
|
+ where collect_sample_status > 2
|
|
|
+ <if test="collectSampleId != null and collectSampleId != '' ">
|
|
|
+ and collect_sample_id = #{collectSampleId}
|
|
|
+ </if>
|
|
|
+ <if test="bindStartDate != null and bindStartDate != '' ">
|
|
|
+ and create_time >= str_to_date(concat(date_format(#{bindStartDate}, '%Y-%m-%d'), '00:00:01'),
|
|
|
+ '%Y-%m-%d %H:%i:%s')
|
|
|
+ </if>
|
|
|
+ <if test="bindEndDate != null and bindEndDate != '' ">
|
|
|
+ and create_time <= str_to_date(concat(date_format(#{bindEndDate}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d
|
|
|
+ %H:%i:%s')
|
|
|
+ </if>
|
|
|
+ group by collect_sample_id) tttt on t.collectSampleId = tttt.user_id
|
|
|
+ left join (select user_id, promoters_count
|
|
|
+ from user_promoters_count
|
|
|
+ where media_id = 2
|
|
|
+ <if test="collectSampleId != null and collectSampleId != '' ">
|
|
|
+ and user_id = #{collectSampleId}
|
|
|
+ </if>
|
|
|
+ ) ttttt
|
|
|
+ on t.collectSampleId = ttttt.user_id
|
|
|
+ where t.orderNum > 0
|
|
|
+ order by t.orderNum desc
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|