|  | @@ -1275,16 +1275,28 @@
 | 
	
		
			
				|  |  |          t1.totalRegimentalSettleAmount,
 | 
	
		
			
				|  |  |          t4.sendTotalCount,
 | 
	
		
			
				|  |  |          t4.sendPromoterCount,
 | 
	
		
			
				|  |  | -        t4.sendItemCount
 | 
	
		
			
				|  |  | +        t4.sendItemCount,
 | 
	
		
			
				|  |  | +        t1.voucherOrderNum,
 | 
	
		
			
				|  |  | +        t1.voucherValidOrderNum,
 | 
	
		
			
				|  |  | +        t1.voucherOrderAmount,
 | 
	
		
			
				|  |  | +        t1.voucherRegimentalPromotionAmount,
 | 
	
		
			
				|  |  | +        t1.voucherTotalRegimentalSettleAmount
 | 
	
		
			
				|  |  |          from (
 | 
	
		
			
				|  |  |          select collect_sample_id as 'collectSampleId',
 | 
	
		
			
				|  |  |          collect_sample_name as 'collectSampleName',
 | 
	
		
			
				|  |  |          sum(order_num) as 'orderNum',
 | 
	
		
			
				|  |  | +        IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_num ELSE 0 END), 0) AS 'voucherOrderNum',
 | 
	
		
			
				|  |  |          sum(valid_order_num) as 'validOrderNum',
 | 
	
		
			
				|  |  | +        IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN valid_order_num ELSE 0 END), 0) AS 'voucherValidOrderNum',
 | 
	
		
			
				|  |  |          round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
 | 
	
		
			
				|  |  |          sum(order_amount) as 'orderAmount',
 | 
	
		
			
				|  |  | +        IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_amount ELSE 0 END), 0) AS 'voucherOrderAmount',
 | 
	
		
			
				|  |  |          sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
 | 
	
		
			
				|  |  | -        sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
 | 
	
		
			
				|  |  | +        IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN regimental_promotion_amount ELSE 0 END), 0)
 | 
	
		
			
				|  |  | +        AS'voucherRegimentalPromotionAmount',
 | 
	
		
			
				|  |  | +        sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount',
 | 
	
		
			
				|  |  | +        IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN total_regimental_settle_amount ELSE 0 END), 0) AS
 | 
	
		
			
				|  |  | +        'voucherTotalRegimentalSettleAmount'
 | 
	
		
			
				|  |  |          from ruixuan.canal_management
 | 
	
		
			
				|  |  |          where 1 = 1
 | 
	
		
			
				|  |  |          <if test="start != null and start != ''">
 | 
	
	
		
			
				|  | @@ -1479,4 +1491,90 @@
 | 
	
		
			
				|  |  |          where   promoter_id  = #{promoterId}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  | +    <select id="exportBdReportList" resultType="com.alibaba.fastjson.JSONObject">
 | 
	
		
			
				|  |  | +        select
 | 
	
		
			
				|  |  | +        t1.collectSampleId,
 | 
	
		
			
				|  |  | +        t1.collectSampleName,
 | 
	
		
			
				|  |  | +        t2.promoterCount,
 | 
	
		
			
				|  |  | +        t3.sampleCount,
 | 
	
		
			
				|  |  | +        round(t3.sampleCount / t2.promoterCount * 100, 2) as 'sampleRate',
 | 
	
		
			
				|  |  | +        t2.promoterCount - t3.sampleCount as 'notSampleCount',
 | 
	
		
			
				|  |  | +        t1.orderNum,
 | 
	
		
			
				|  |  | +        t1.validOrderNum,
 | 
	
		
			
				|  |  | +        t1.validOrderRate,
 | 
	
		
			
				|  |  | +        round(t1.orderAmount / 100,2) as 'orderAmount',
 | 
	
		
			
				|  |  | +        round(t1.regimentalPromotionAmount / 100 ,2 ) as 'regimentalPromotionAmount',
 | 
	
		
			
				|  |  | +        round(t1.totalRegimentalSettleAmount / 100 , 2) as 'totalRegimentalSettleAmount',
 | 
	
		
			
				|  |  | +        t4.sendTotalCount,
 | 
	
		
			
				|  |  | +        t4.sendPromoterCount,
 | 
	
		
			
				|  |  | +        t4.sendItemCount,
 | 
	
		
			
				|  |  | +        t1.voucherOrderNum,
 | 
	
		
			
				|  |  | +        t1.voucherValidOrderNum,
 | 
	
		
			
				|  |  | +        round(t1.voucherOrderAmount / 100 ,2) as 'voucherOrderAmount',
 | 
	
		
			
				|  |  | +        round(t1.voucherRegimentalPromotionAmount / 100 ,2) as 'voucherRegimentalPromotionAmount',
 | 
	
		
			
				|  |  | +        round( t1.voucherTotalRegimentalSettleAmount / 100 , 2) as 'voucherTotalRegimentalSettleAmount'
 | 
	
		
			
				|  |  | +        from (
 | 
	
		
			
				|  |  | +        select collect_sample_id as 'collectSampleId',
 | 
	
		
			
				|  |  | +        collect_sample_name as 'collectSampleName',
 | 
	
		
			
				|  |  | +        sum(order_num) as 'orderNum',
 | 
	
		
			
				|  |  | +        IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_num ELSE 0 END), 0) AS 'voucherOrderNum',
 | 
	
		
			
				|  |  | +        sum(valid_order_num) as 'validOrderNum',
 | 
	
		
			
				|  |  | +        IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN valid_order_num ELSE 0 END), 0) AS 'voucherValidOrderNum',
 | 
	
		
			
				|  |  | +        round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
 | 
	
		
			
				|  |  | +        sum(order_amount) as 'orderAmount',
 | 
	
		
			
				|  |  | +        IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_amount ELSE 0 END), 0) AS 'voucherOrderAmount',
 | 
	
		
			
				|  |  | +        sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
 | 
	
		
			
				|  |  | +        IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN regimental_promotion_amount ELSE 0 END), 0)
 | 
	
		
			
				|  |  | +        AS'voucherRegimentalPromotionAmount',
 | 
	
		
			
				|  |  | +        sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount',
 | 
	
		
			
				|  |  | +        IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN total_regimental_settle_amount ELSE 0 END), 0) AS
 | 
	
		
			
				|  |  | +        'voucherTotalRegimentalSettleAmount'
 | 
	
		
			
				|  |  | +        from ruixuan.canal_management
 | 
	
		
			
				|  |  | +        where 1 = 1
 | 
	
		
			
				|  |  | +        <if test="start != null and start != ''">
 | 
	
		
			
				|  |  | +            and stat_date >= #{start}
 | 
	
		
			
				|  |  | +        </if>
 | 
	
		
			
				|  |  | +        <if test="end != null and end != ''">
 | 
	
		
			
				|  |  | +            and stat_date <= #{end}
 | 
	
		
			
				|  |  | +        </if>
 | 
	
		
			
				|  |  | +        <if test="collectSampleId != null and collectSampleId != ''">
 | 
	
		
			
				|  |  | +            and collect_sample_id = #{collectSampleId}
 | 
	
		
			
				|  |  | +        </if>
 | 
	
		
			
				|  |  | +        group by collect_sample_id) t1
 | 
	
		
			
				|  |  | +        left join (
 | 
	
		
			
				|  |  | +        select user_id as 'userId',
 | 
	
		
			
				|  |  | +        count(distinct promoter_id) as 'promoterCount'
 | 
	
		
			
				|  |  | +        from kuaishou_promoter
 | 
	
		
			
				|  |  | +        group by user_id) t2
 | 
	
		
			
				|  |  | +        on t1.collectSampleId = t2.userId
 | 
	
		
			
				|  |  | +        left join (
 | 
	
		
			
				|  |  | +        select collect_sample_id as 'collectSampleId',
 | 
	
		
			
				|  |  | +        count(distinct promoter_id) as 'sampleCount'
 | 
	
		
			
				|  |  | +        from kuaishou_item_collect_samples
 | 
	
		
			
				|  |  | +        where collect_sample_status > 2
 | 
	
		
			
				|  |  | +        group by collect_sample_id) t3
 | 
	
		
			
				|  |  | +        on t2.userId = t3.collectSampleId
 | 
	
		
			
				|  |  | +        left join (
 | 
	
		
			
				|  |  | +        select collect_sample_id as 'collectSampleId',
 | 
	
		
			
				|  |  | +        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
 | 
	
		
			
				|  |  | +        ) t4
 | 
	
		
			
				|  |  | +        on t1.collectSampleId = t4.collectSampleId
 | 
	
		
			
				|  |  | +        order by t1.orderNum desc
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  |  </mapper>
 |