| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ruixuan.bytedance.mapper.BytedancePromoterOrderListMapper">
- <resultMap type="com.ruixuan.bytedance.entity.BytedancePromoterOrderList" id="BytedancePromoterOrderListResult">
- <result property="orderId" column="order_id"/>
- <result property="productId" column="product_id"/>
- <result property="productName" column="product_name"/>
- <result property="productImg" column="product_img"/>
- <result property="productBindUserId" column="product_bind_user_id"/>
- <result property="productBindUserName" column="product_bind_user_name"/>
- <result property="shopId" column="shop_id"/>
- <result property="shopName" column="shop_name"/>
- <result property="totalPayAmount" column="total_pay_amount"/>
- <result property="flowPoint" column="flow_point"/>
- <result property="app" column="app"/>
- <result property="updateTime" column="update_time"/>
- <result property="paySuccessTime" column="pay_success_time"/>
- <result property="settleTime" column="settle_time"/>
- <result property="payGoodsAmount" column="total_pay_amount"/>
- <result property="settledGoodsAmount" column="total_pay_amount"/>
- <result property="itemNum" column="item_num"/>
- <result property="refundTime" column="refund_time"/>
- <result property="authorShortId" column="author_short_id"/>
- <result property="authorShortName" column="author_short_name"/>
- <result property="authorShortUrl" column="author_short_url"/>
- <result property="authorBindUserId" column="author_bind_user_id"/>
- <result property="authorBindUserName" column="author_bind_user_name"/>
- <result property="colonelType" column="colonel_type"/>
- <result property="mediaType" column="media_type"/>
- <result property="commissionRate" column="commission_rate"/>
- <result property="isTrusteeship" column="is_trusteeship"/>
- <result property="goodShareType" column="good_share_type"/>
- <result property="colonelCommissionRate" column="colonel_commission_rate"/>
- <result property="colonelActivityId" column="colonel_activity_id"/>
- <result property="colonelEstimatedCommission" column="colonel_estimated_commission"/>
- <result property="colonelRealCommission" column="colonel_real_commission"/>
- <result property="colonelTechServiceFeeRate" column="colonel_tech_service_fee_rate"/>
- <result property="colonelTechServiceFee" column="colonel_tech_service_fee"/>
- <result property="colonelSettledTechServiceFee" column="colonel_settled_tech_service_fee"/>
- <result property="colonelInstitutionId" column="colonel_institution_id"/>
- <result property="colonelInstitutionName" column="colonel_institution_name"/>
- <result property="secondCommissionRate" column="second_commission_rate"/>
- <result property="secondActivityId" column="second_activity_id"/>
- <result property="secondEstimatedCommission" column="second_estimated_commission"/>
- <result property="secondRealCommission" column="second_real_commission"/>
- <result property="createTime" column="create_time"/>
- <result property="statDate" column="stat_date"/>
- </resultMap>
- <sql id="SELECTBytedancePromoterOrderListVo">
- SELECT order_id,
- product_id,
- product_name,
- product_img,
- product_bind_user_id,
- product_bind_user_name,
- shop_id,
- shop_name,
- total_pay_amount,
- flow_point,
- app,
- update_time,
- pay_success_time,
- settle_time,
- total_pay_amount,
- total_pay_amount,
- item_num,
- refund_time,
- author_short_id,
- author_short_url,
- author_bind_user_id,
- author_bind_user_name,
- colonel_type,
- media_type,
- commission_rate,
- is_trusteeship,
- good_share_type,
- colonel_commission_rate,
- colonel_activity_id,
- colonel_estimated_commission,
- colonel_real_commission,
- colonel_tech_service_fee_rate,
- colonel_tech_service_fee,
- colonel_settled_tech_service_fee,
- colonel_institution_id,
- colonel_institution_name,
- second_commission_rate,
- second_activity_id,
- second_estimated_commission,
- second_real_commission,
- create_time,
- stat_date
- FROM bytedance_promoter_order_list
- </sql>
- <select id="SELECTBytedancePromoterOrderListList"
- parameterType="com.ruixuan.bytedance.entity.BytedancePromoterOrderList"
- resultMap="BytedancePromoterOrderListResult">
- <include refid="SELECTBytedancePromoterOrderListVo"/>
- <where>
- <if test="productId != null and productId != ''">and product_id = #{productId}</if>
- <if test="productName != null and productName != ''">and product_name like CONCAT('%', #{productName},
- '%')
- </if>
- <if test="productImg != null and productImg != ''">and product_img = #{productImg}</if>
- <if test="productBindUserId != null and productBindUserId != ''">and product_bind_user_id =
- #{productBindUserId}
- </if>
- <if test="productBindUserName != null and productBindUserName != ''">and product_bind_user_name like
- CONCAT('%', #{productBindUserName}, '%')
- </if>
- <if test="shopId != null ">and shop_id = #{shopId}</if>
- <if test="shopName != null and shopName != ''">and shop_name like CONCAT('%', #{shopName}, '%')</if>
- <if test="totalPayAmount != null ">and total_pay_amount = #{totalPayAmount}</if>
- <if test="flowPoint != null and flowPoint != ''">and flow_point = #{flowPoint}</if>
- <if test="app != null and app != ''">and app = #{app}</if>
- <if test="paySuccessTime != null ">and pay_success_time = #{paySuccessTime}</if>
- <if test="settleTime != null ">and settle_time = #{settleTime}</if>
- <if test="payGoodsAmount != null ">and total_pay_amount = #{payGoodsAmount}</if>
- <if test="settledGoodsAmount != null ">and total_pay_amount = #{settledGoodsAmount}</if>
- <if test="itemNum != null ">and item_num = #{itemNum}</if>
- <if test="refundTime != null ">and refund_time = #{refundTime}</if>
- <if test="authorShortId != null and authorShortId != ''">and author_short_id = #{authorShortId}</if>
- <if test="authorShortUrl != null and authorShortUrl != ''">and author_short_url = #{authorShortUrl}</if>
- <if test="authorBindUserId != null and authorBindUserId != ''">and author_bind_user_id =
- #{authorBindUserId}
- </if>
- <if test="authorBindUserName != null and authorBindUserName != ''">and author_bind_user_name like
- CONCAT('%', #{authorBindUserName}, '%')
- </if>
- <if test="colonelType != null and colonelType != ''">and colonel_type = #{colonelType}</if>
- <if test="mediaType != null and mediaType != ''">and media_type = #{mediaType}</if>
- <if test="commissionRate != null ">and commission_rate = #{commissionRate}</if>
- <if test="isTrusteeship != null and isTrusteeship != ''">and is_trusteeship = #{isTrusteeship}</if>
- <if test="goodShareType != null and goodShareType != ''">and good_share_type = #{goodShareType}</if>
- <if test="colonelCommissionRate != null ">and colonel_commission_rate = #{colonelCommissionRate}</if>
- <if test="colonelActivityId != null ">and colonel_activity_id = #{colonelActivityId}</if>
- <if test="colonelEstimatedCommission != null ">and colonel_estimated_commission =
- #{colonelEstimatedCommission}
- </if>
- <if test="colonelRealCommission != null ">and colonel_real_commission = #{colonelRealCommission}</if>
- <if test="colonelTechServiceFeeRate != null ">and colonel_tech_service_fee_rate =
- #{colonelTechServiceFeeRate}
- </if>
- <if test="colonelTechServiceFee != null ">and colonel_tech_service_fee = #{colonelTechServiceFee}</if>
- <if test="colonelSettledTechServiceFee != null ">and colonel_settled_tech_service_fee =
- #{colonelSettledTechServiceFee}
- </if>
- <if test="colonelInstitutionId != null ">and colonel_institution_id = #{colonelInstitutionId}</if>
- <if test="colonelInstitutionName != null and colonelInstitutionName != ''">and colonel_institution_name
- like CONCAT('%', #{colonelInstitutionName}, '%')
- </if>
- <if test="secondCommissionRate != null ">and second_commission_rate = #{secondCommissionRate}</if>
- <if test="secondActivityId != null ">and second_activity_id = #{secondActivityId}</if>
- <if test="secondEstimatedCommission != null ">and second_estimated_commission =
- #{secondEstimatedCommission}
- </if>
- <if test="secondRealCommission != null ">and second_real_commission = #{secondRealCommission}</if>
- </where>
- </select>
- <select id="SELECTBytedancePromoterOrderListByOrderId" parameterType="Long"
- resultMap="BytedancePromoterOrderListResult">
- <include refid="SELECTBytedancePromoterOrderListVo"/>
- WHERE order_id = #{orderId}
- </select>
- <select id="getBytedanceOrderList" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- t.*,
- ROUND(((t.orderNum-t2.orderNum)/t2.orderNum)*100,2) as 'orderNumRatio'
- FROM (
- SELECT
- IFNULL(t1.author_short_id,'-') AS 'promoterId',
- IFNULL(t1.author_short_name,'-') AS 'promoterNickName',
- count( t1.order_id ) AS 'orderNum',
- sum( CASE WHEN t1.flow_point != 'REFUND' THEN 1 ELSE 0 END ) AS 'validOrderNUm',
- CONCAT(round( sum( CASE WHEN t1.flow_point != 'REFUND' THEN 1 ELSE 0 END ) / count( t1.order_id )*100, 2 ),'%')
- AS
- 'validRadio',
- sum( t1.total_pay_amount )/100 AS 'payAmount',
- sum( CASE WHEN t1.flow_point != 'REFUND' THEN t1.total_pay_amount ELSE 0 END )/100 AS 'validPayAmount',
- sum(CASE
- WHEN t1.flow_point != 'REFUND' and t1.colonel_type != 2
- THEN t1.colonel_estimated_commission
- WHEN t1.flow_point != 'REFUND' and t1.colonel_type = 2
- then t1.second_estimated_commission
- ELSE 0 END) * 0.9 / 100 AS
- 'regimentalPromotionAmount',
- sum(CASE
- WHEN t1.flow_point != 'REFUND' and t1.colonel_type != 2
- THEN t1.second_estimated_commission
- ELSE 0 END) / 100 AS 'secondEstimatedCommission',
- t1.author_bind_user_id,
- IFNULL(t1.author_bind_user_name,'-') AS 'userName'
- FROM
- bytedance_promoter_order_list t1 LEFT JOIN
- bytedance_order_list t2 ON t1.order_id = t2.order_id
- <where>
- <if test="hour != null and hour != ''">
- and t2.pay_success_time_hour <= #{hour}
- </if>
- <if test="start != null and start != ''">
- and t2.pay_success_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t2.pay_success_time <= #{end}
- </if>
- <if test="promoterId != null and promoterId != ''">
- and t1.author_short_id = #{promoterId}
- </if>
- <if test="promoterNickName != null and promoterNickName != ''">
- and t1.author_short_name like CONCAT(CONCAT('%',#{promoterNickName}),'%')
- </if>
- </where>
- GROUP BY t1.author_short_id
- ) t
- LEFT JOIN (
- SELECT
- IFNULL(t1.author_short_id,'-') AS 'promoterId',
- count( t1.order_id ) AS 'orderNum'
- FROM
- bytedance_promoter_order_list t1 LEFT JOIN
- bytedance_order_list t2 ON t1.order_id = t2.order_id
- <where>
- <if test="hour != null and hour != ''">
- and t2.pay_success_time_hour <= #{hour}
- </if>
- <if test="lastTimeStart != null and lastTimeStart != ''">
- and t2.pay_success_time >= #{lastTimeStart}
- </if>
- <if test="lastTimeEnd != null and lastTimeEnd != ''">
- and t2.pay_success_time <= #{lastTimeEnd}
- </if>
- <if test="promoterId != null and promoterId != ''">
- and t1.author_short_id = #{promoterId}
- </if>
- <if test="promoterNickName != null and promoterNickName != ''">
- and t1.author_short_name like CONCAT(CONCAT('%',#{promoterNickName}),'%')
- </if>
- </where>
- GROUP BY t1.author_short_id
- ) t2 on t.promoterId = t2.promoterId
- ORDER BY t.orderNum desc
- </select>
- <select id="getTopOrders" resultType="com.alibaba.fastjson.JSONObject">
- SELECT *
- FROM
- (SELECT product_id AS 'itemId',
- product_name AS 'itemTitle',
- product_img AS 'imageUrl',
- count(order_id) AS 'orderNum'
- FROM bytedance_promoter_order_list
- WHERE author_short_id = #{promoterId}
- <if test="start != null and start != ''">
- and pay_success_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and pay_success_time <= #{end}
- </if>
- GROUP BY product_id) t
- ORDER BY t.orderNum desc limit 3
- </select>
- <select id="bytedanceBDReportList" 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,
- t1.orderAmount,
- t1.regimentalPromotionAmount,
- t1.totalRegimentalSettleAmount,
- t4.sendTotalCount,
- t4.sendPromoterCount,
- t4.sendItemCount,
- t1.voucherOrderNum,
- t1.voucherValidOrderNum,
- t1.voucherOrderAmount,
- t1.voucherRegimentalPromotionAmount,
- t1.voucherTotalRegimentalSettleAmount,
- IFNULL(t5.promoters_count,'-') AS 'promotersCount'
- FROM (
- SELECT author_bind_user_id AS 'collectSampleId',
- author_bind_user_name AS 'collectSampleName',
- count(order_id) AS 'orderNum',
- IFNULL(count(CASE WHEN sample_voucher_status = 2 THEN 1 ELSE 0 END), 0) AS 'voucherOrderNum',
- t0.validOrderNUm AS 'validOrderNUm',
- IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN 1 ELSE 0 END), 0) AS 'voucherValidOrderNum',
- CONCAT(round(t0.validOrderNUm / count(order_id) * 100, 2),'%') AS 'validOrderRate',
- sum(total_pay_amount)/100 AS 'orderAmount',
- IFNULL(round(SUM(CASE WHEN sample_voucher_status = 2 THEN total_pay_amount ELSE 0 END) / 100,2), 0) AS
- 'voucherOrderAmount',
- round( sum( CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END ) * 0.9 / 100, 2 ) AS
- 'regimentalPromotionAmount',
- IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN colonel_estimated_commission ELSE 0 END)/100, 0)
- AS'voucherRegimentalPromotionAmount',
- sum(colonel_real_commission)/100 AS 'totalRegimentalSettleAmount',
- IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN colonel_real_commission ELSE 0 END)/100, 0) AS
- 'voucherTotalRegimentalSettleAmount'
- FROM 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 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 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) 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
- LEFT JOIN (
- SELECT user_id,promoters_count
- FROM user_promoters_count
- WHERE media_id = 1
- ) t5
- on t1.collectSampleId = t5.user_id
- ORDER BY t1.orderNum desc
- </select>
- <select id="anchorBytedanceOrderDetail" resultType="com.alibaba.fastjson.JSONObject">
- SELECT t.*,
- t2.status,
- (
- case
- when t3.activity_item_status = 1 then '待审核'
- when t3.activity_item_status = 2 then '已上架'
- when t3.activity_item_status = 3 then '审核拒绝'
- when t3.activity_item_status = 4 then '活动失效'
- when t3.activity_item_status = 5 then '商品下架'
- else ''
- end
- ) AS 'activityItemStatus'
- FROM (
- SELECT
- tt.product_name AS 'itemTitle',
- tt.product_id AS 'itemId',
- tt.total_pay_amount/100 AS 'reservePrice',
- tt.product_img 'imageUrl',
- count(order_id) AS 'orderNum',
- sum( CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END ) AS 'validOrderNUm',
- CONCAT(round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id)*100,2),'%') as
- 'validRadio',
- sum(case when flow_point != 'REFUND' then total_pay_amount else 0 end)/100 AS 'payAmount',
- CONCAT(round(colonel_commission_rate/100,2),'%') AS 'regimentalPromotionRate'
- FROM bytedance_promoter_order_list tt
- WHERE 1= 1
- <if test="promoterId != null and promoterId != ''">
- and tt.author_short_id = #{promoterId}
- </if>
- <if test="start != null and start != ''">
- and tt.pay_success_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and tt.pay_success_time <= #{end}
- </if>
- <if test="itemId != null and itemId != ''">
- and tt.product_id = #{itemId}
- </if>
- <if test="itemTitle != null and itemTitle != ''">
- and tt.product_name like CONCAT(CONCAT('%',#{itemTitle}),'%')
- </if>
- GROUP BY tt.product_id) t
- LEFT JOIN
- ( SELECT item_id AS 'itemId', collect_sample_status AS 'status' FROM
- kuaishou_item_collect_samples WHERE promoter_id = #{promoterId}) t2
- on t.itemId = t2.itemId
- LEFT JOIN kuaishou_item_list t3 ON t.itemId = t3.item_id
- ORDER BY t.orderNum desc
- </select>
- <select id="bytedanceItemList" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- t.*,
- ROUND(((t.orderNum-t2.orderNum)/t2.orderNum)*100,2) as 'orderNumRatio'
- FROM (
- SELECT
- t1.product_bind_user_id AS 'userId',
- t1.product_bind_user_name AS 'userName',
- t1.product_id AS 'itemId',
- t1.total_pay_amount/100 AS 'reservePrice',
- t1.product_name AS 'itemTitle',
- t1.product_img AS 'imageUrl',
- count(t1.order_id) AS 'orderNum',
- sum(case when t1.flow_point != 'REFUND' then 1 else 0 end) AS 'validOrderNUm',
- CONCAT(round(sum(case when t1.flow_point != 'REFUND' then 1 else 0 end) / count(t1.order_id)*100, 2),'%') as
- 'validRadio',
- CONCAT(Round(t1.commission_rate/100,2),'%') AS 'itemCommissionRate',
- SUM(CASE
- WHEN t1.flow_point != 'REFUND' and t1.colonel_type != 2
- THEN t1.colonel_estimated_commission
- WHEN t1.flow_point != 'REFUND' and t1.colonel_type = 2
- then t1.second_estimated_commission
- ELSE 0 END) * 0.9 / 100 AS 'regimentalPromotionAmount',
- SUM(CASE
- WHEN t1.flow_point != 'REFUND' and t1.colonel_type != 2 THEN t1.second_estimated_commission
- ELSE 0 END) / 100 AS 'secondEstimatedCommission'
- FROM bytedance_promoter_order_list t1
- LEFT JOIN bytedance_order_list t2 ON t1.order_id = t2.order_id
- <where>
- <if test="hour != null and hour != ''">
- and t2.pay_success_time_hour <= #{hour}
- </if>
- <if test="start != null and start != ''">
- and t2.pay_success_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t2.pay_success_time <= #{end}
- </if>
- <if test="itemId != null and itemId != ''">
- and t1.product_id = #{itemId}
- </if>
- <if test="itemTitle != null and itemTitle != ''">
- and t1.product_name like CONCAT(CONCAT('%',#{itemTitle}),'%')
- </if>
- <if test="userId != null and userId != ''">
- and t1.product_bind_user_id = #{userId}
- </if>
- </where>
- GROUP BY t1.product_id
- ) t
- LEFT JOIN(
- SELECT
- t1.product_id AS 'itemId',
- count(t1.order_id) AS 'orderNum'
- FROM bytedance_promoter_order_list t1
- LEFT JOIN bytedance_order_list t2 ON t1.order_id = t2.order_id
- <where>
- <if test="hour != null and hour != ''">
- and t2.pay_success_time_hour <= #{hour}
- </if>
- <if test="lastTimeStart != null and lastTimeStart != ''">
- and t2.pay_success_time >= #{lastTimeStart}
- </if>
- <if test="lastTimeEnd != null and lastTimeEnd != ''">
- and t2.pay_success_time <= #{lastTimeEnd}
- </if>
- <if test="itemId != null and itemId != ''">
- and t1.product_id = #{itemId}
- </if>
- <if test="itemTitle != null and itemTitle != ''">
- and t1.product_name like CONCAT(CONCAT('%',#{itemTitle}),'%')
- </if>
- <if test="userId != null and userId != ''">
- and t1.product_bind_user_id = #{userId}
- </if>
- </where>
- GROUP BY t1.product_id
- ) t2 ON t.itemId = t2.itemId
- ORDER BY t.${fieId} ${sort}
- </select>
- <select id="adminBytedanceReportList" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- t.*,
- t1.sendSampleCount,
- ROUND(((t.orderNum-t2.orderNum)/t2.orderNum)*100,2) as 'orderNumRatio'
- FROM (
- SELECT
- t2.product_bind_user_id AS 'userId',
- t2.product_bind_user_name AS 'userName',
- count(distinct t2.product_id) AS 'itemCount',
- 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
- 'validRadio',
- sum(case when t2.flow_point = 'REFUND' then 1 else 0 end) AS 'invalidOrderNUm',
- sum(case when t2.flow_point != 'REFUND' then t2.total_pay_amount else 0 end)/100 AS 'payAmount',
- sum(CASE
- WHEN t2.flow_point != 'REFUND' and t2.colonel_type != 2
- THEN t2.colonel_estimated_commission
- WHEN t2.flow_point != 'REFUND' and t2.colonel_type = 2
- then t2.second_estimated_commission
- ELSE 0 END) * 0.9 / 100 AS
- 'regimentalPromotionAmount',
- sum(CASE
- WHEN t2.flow_point != 'REFUND' and t2.colonel_type != 2
- THEN t2.second_estimated_commission
- ELSE 0 END) / 100 AS 'secondEstimatedCommission',
- sum(case when t2.flow_point != 'REFUND' then t2.colonel_real_commission else 0 end)/100 as
- 'totalRegimentalSettleAmount'
- FROM bytedance_promoter_order_list t2
- LEFT JOIN bytedance_order_list t3 ON t3.order_id = t2.order_id
- WHERE product_bind_user_id is not null
- <if test="hour != null and hour != ''">
- and t3.pay_success_time_hour <= #{hour}
- </if>
- <if test="start != null and start != ''">
- and t3.pay_success_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t3.pay_success_time <= #{end}
- </if>
- GROUP BY t2.product_bind_user_id
- ) t
- LEFT JOIN(
- SELECT item_create_id,count(1) AS 'sendSampleCount' FROM kuaishou_item_collect_samples
- WHERE courier_number_time >= CONCAT(#{start},' 00:00:00')
- and courier_number_time <= CONCAT(#{end},' 23:59:59')
- GROUP BY item_create_id
- ) t1 on t.userId = t1.item_create_id
- LEFT JOIN(
- SELECT
- t2.product_bind_user_id,
- count(t2.order_id) AS 'orderNum'
- FROM bytedance_promoter_order_list t2
- LEFT JOIN bytedance_order_list t3 ON t3.order_id = t2.order_id
- WHERE product_bind_user_id is not null
- <if test="hour != null and hour != ''">
- and t3.pay_success_time_hour <= #{hour}
- </if>
- <if test="lastTimeStart != null and lastTimeStart != ''">
- and t3.pay_success_time >= #{lastTimeStart}
- </if>
- <if test="lastTimeEnd != null and lastTimeEnd != ''">
- and t3.pay_success_time <= #{lastTimeEnd}
- </if>
- GROUP BY t2.product_bind_user_id
- ) t2 on t.userId = t2.product_bind_user_id
- <where>
- <if test="userId != null and userId != ''">
- and t.userId = #{userId}
- </if>
- </where>
- ORDER BY t.orderNum desc
- </select>
- <select id="adminBytedanceReportListByBind" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- t.*,
- t2.sendSampleCount,
- ROUND(((t.orderNum-t3.orderNum)/t3.orderNum)*100,2) as 'orderNumRatio'
- FROM (
- SELECT
- t1.user_id AS 'userId',
- t1.user_name AS 'userName',
- count(distinct t1.item_id) AS 'itemCount',
- 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
- 'validRadio',
- sum(case when t2.flow_point = 'REFUND' then 1 else 0 end) AS 'invalidOrderNUm',
- sum(case when t2.flow_point != 'REFUND' then t2.total_pay_amount else 0 end)/100 AS 'payAmount',
- sum(CASE
- WHEN t2.flow_point != 'REFUND' and t2.colonel_type != 2
- THEN t2.colonel_estimated_commission
- WHEN t2.flow_point != 'REFUND' and t2.colonel_type = 2
- then t2.second_estimated_commission
- ELSE 0 END) * 0.9 / 100 AS
- 'regimentalPromotionAmount',
- sum(CASE
- WHEN t2.flow_point != 'REFUND' and t2.colonel_type != 2
- THEN t2.second_estimated_commission
- ELSE 0 END) / 100 AS 'secondEstimatedCommission',
- sum(case when t2.flow_point != 'REFUND' then t2.colonel_real_commission else 0 end) / 100 as
- 'totalRegimentalSettleAmount'
- FROM (select * from kuaishou_item_list where create_time >= CONCAT(date_format(#{start},'%Y-%m-%d'),' 00:00:00')
- and create_time <= CONCAT(date_format(#{end},'%Y-%m-%d'),' 23:59:59')
- and media_id = 1
- ) t1
- LEFT JOIN (
- SELECT
- t1.product_id,
- t1.order_id,
- t1.flow_point,
- t1.total_pay_amount,
- t1.colonel_estimated_commission,
- t1.colonel_real_commission,
- t1.colonel_type,
- t1.second_estimated_commission
- FROM bytedance_promoter_order_list t1
- LEFT JOIN bytedance_order_list t2 ON t1.order_id = t2.order_id
- WHERE t2.pay_success_time >= #{start}
- <if test="hour != null and hour != ''">
- and t2.pay_success_time_hour <= #{hour}
- </if>
- ) t2
- on t1.item_id = t2.product_id
- <if test="userId != null and userId != ''">
- and t1.userId = #{userId}
- </if>
- GROUP BY t1.user_id
- ) t
- LEFT JOIN (
- SELECT t1.user_id,count(distinct courier_number) AS 'sendSampleCount'
- FROM kuaishou_item_list t1
- LEFT JOIN kuaishou_item_collect_samples t2 ON t1.item_id = t2.item_id
- WHERE t1.create_time >=CONCAT(date_format(#{start},'%Y-%m-%d'),' 00:00:00')
- and t1.create_time <= CONCAT(date_format(#{end},'%Y-%m-%d'),' 23:59:59')
- and t2.courier_number_time >= CONCAT(date_format(#{start},'%Y-%m-%d'),' 00:00:00')
- GROUP BY t1.user_id
- ) t2 on t.userId = t2.user_id
- LEFT JOIN (
- SELECT
- t1.user_id,
- count(t2.order_id) AS 'orderNum'
- FROM (
- select item_id,user_id
- from kuaishou_item_list
- where create_time >= CONCAT(date_format(#{lastTimeStart},'%Y-%m-%d'),' 00:00:00')
- and create_time <= CONCAT(date_format(#{lastTimeEnd},'%Y-%m-%d'),' 23:59:59')
- and media_id = 1
- ) t1
- LEFT JOIN (
- SELECT
- t1.product_id,
- t1.order_id
- FROM bytedance_promoter_order_list t1
- LEFT JOIN bytedance_order_list t2 ON t1.order_id = t2.order_id
- WHERE t2.pay_success_time >= #{lastTimeStart}
- AND t2.pay_success_time <= #{lastTimeEnd}
- <if test="hour != null and hour != ''">
- and t2.pay_success_time_hour <= #{hour}
- </if>
- ) t2 ON t1.item_id = t2.product_id
- <if test="userId != null and userId != ''">
- and t1.userId = #{userId}
- </if>
- GROUP BY t1.user_id
- ) t3 ON t.userId = t3.user_id
- ORDER BY t.orderNum desc
- </select>
- <select id="getBytedanceTopPromoterByItemId" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- *
- FROM
- (
- SELECT author_short_id AS 'promoterId',
- author_short_name AS 'promoterNickName',
- count(order_id) AS 'orderNum'
- FROM bytedance_promoter_order_list
- WHERE product_id = #{itemId}
- AND 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>
- GROUP BY author_bind_user_id) t
- ORDER BY t.orderNum desc
- limit 3
- </select>
- <select id="bytedanceOrderStatistics" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- DATE_FORMAT(t.pay_success_time , '%Y-%m-%d') AS 'date',
- count(t.order_id) AS 'orderNum'
- FROM (
- SELECT
- order_id,
- pay_success_time
- FROM bytedance_promoter_order_list
- WHERE 1 = 1
- <if test="promoterId != null and promoterId != ''">
- and author_short_id = #{promoterId}
- </if>
- <if test="start != null and start != ''">
- and pay_success_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and pay_success_time <= #{end}
- </if>
- ) t
- GROUP BY DATE_FORMAT(t.pay_success_time , '%Y-%m-%d')
- ORDER BY DATE_FORMAT(t.pay_success_time , '%Y-%m-%d') asc
- </select>
- <select id="bytedanceItemDetail" resultType="com.alibaba.fastjson.JSONObject">
- SELECT *
- FROM (
- SELECT
- author_short_id AS 'promoterId',
- author_short_name AS 'promoterNickName',
- count(order_id) AS 'orderNum',
- sum(case when flow_point = 'REFUND' then total_pay_amount else 0 end) AS 'payAmount',
- CONCAT(round(colonel_commission_rate/100,2),'%') AS 'regimentalPromotionRate',
- sum(case when flow_point = 'REFUND' then 1 else 0 end) AS 'validOrderNUm',
- CONCAT(round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id)*100, 2),'%') as
- 'validRadio'
- FROM bytedance_promoter_order_list
- WHERE 1= 1
- <if test="itemId != null and itemId != ''">
- and product_id = #{itemId}
- </if>
- <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="promoterId != null and promoterId != ''">
- and author_short_id = #{promoterId}
- </if>
- <if test="promoterNickName != null and promoterNickName != ''">
- and author_bind_user_name like CONCAT(CONCAT('%',#{promoterNickName}),'%')
- </if>
- GROUP BY author_bind_user_id) t
- ORDER BY t.orderNum desc
- </select>
- <select id="bytedanceBDTotal" resultType="com.alibaba.fastjson.JSONObject">
- 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 t1.stat_date <= #{end}
- </if>
- <if test="collectSampleId != null and collectSampleId != ''">
- 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 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 t1.stat_date <= #{end}
- </if>
- <if test="collectSampleId != null and collectSampleId != ''">
- 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">
- 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 'validRadio',
- sum( CASE WHEN t2.flow_point = 'REFUND' THEN 1 ELSE 0 END ) AS 'invalidOrderNUm',
- sum( CASE WHEN t2.flow_point != 'REFUND' THEN t2.total_pay_amount ELSE 0 END ) AS 'payAmount',
- sum( CASE WHEN t2.flow_point != 'REFUND' THEN t2.colonel_estimated_commission ELSE 0 END ) * 0.9 AS
- 'regimentalPromotionAmount',
- sum( CASE WHEN t2.flow_point != 'REFUND' THEN t2.colonel_real_commission ELSE 0 END ) AS
- 'totalRegimentalSettleAmount'
- FROM bytedance_promoter_order_list t2
- WHERE
- 1 = 1
- <if test="start != null and start != ''">
- and t2.pay_success_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t2.pay_success_time <= #{end}
- </if>
- <if test="userId != null and userId != ''">
- AND t2.product_bind_user_id = #{userId}
- </if>
- </select>
- <select id="bytedanceUserItemDetail" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- product_bind_user_id AS 'user_id',
- product_bind_user_name AS 'userName',
- product_id AS 'itemId',
- product_name AS 'itemTitle',
- product_img AS 'imageUrl',
- total_pay_amount/100 AS 'reservePrice',
- count( order_id ) AS 'orderNum',
- sum( CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END ) AS 'validOrderNUm',
- CONCAT(round( sum( CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END ) / count( order_id )*100, 2),'%') AS
- 'validRadio',
- sum( CASE WHEN flow_point = 'REFUND' THEN 1 ELSE 0 END ) AS 'invalidOrderNUm',
- round( sum( CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END )/ 100, 2 ) AS 'payAmount',
- CONCAT(round(colonel_commission_rate/100,2),'%') AS 'regimentalPromotionRate',
- round( sum( CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END ) * 0.9 / 100, 2 ) AS
- 'regimentalPromotionAmount',
- round( sum( CASE WHEN flow_point != 'REFUND' THEN colonel_real_commission ELSE 0 END ) / 100, 2 ) AS
- 'totalRegimentalSettleAmount',
- CONCAT(round(colonel_commission_rate/100,2),'%') AS 'itemCommissionRate'
- FROM bytedance_promoter_order_list
- WHERE
- product_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="itemId != null and itemId != ''">
- and product_id = #{itemId}
- </if>
- <if test="itemTitle != null and itemTitle != ''">
- and product_name like CONCAT(CONCAT('%',#{itemTitle}),'%')
- </if>
- <if test="userId != null and userId != ''">
- and product_bind_user_id = #{userId}
- </if>
- GROUP BY product_id
- ORDER BY orderNum desc
- </select>
- <select id="exportBytedancePromoter" resultType="com.alibaba.fastjson.JSONObject">
- SELECT *
- FROM (
- SELECT
- author_short_id AS 'promoterId',
- author_short_name AS 'promoterNickName',
- product_id AS 'itemId',
- product_name AS 'itemTitle',
- product_img AS 'imageUrl',
- count(order_id) AS 'orderNum',
- sum(case when flow_point != 'REFUND' then 1 else 0 end) AS 'validOrderNUm',
- CONCAT(round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id)*100, 2),'%') AS
- 'validRadio'
- FROM bytedance_promoter_order_list
- WHERE author_short_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="promoterId != null and promoterId != ''">
- and author_short_id = #{promoterId}
- </if>
- <if test="promoterNickName != null and promoterNickName != ''">
- and author_short_name like CONCAT(CONCAT('%',#{promoterNickName}),'%')
- </if>
- <if test="itemId != null and itemId != ''">
- and product_id = #{itemId}
- </if>
- <if test="itemTitle != null and itemTitle != ''">
- and product_name like CONCAT(CONCAT('%',#{itemTitle}),'%')
- </if>
- GROUP BY author_short_id,product_id) t
- 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,
- ROUND(((t.orderNum-t11.orderNum)/t11.orderNum)*100,2) as 'orderNumRatio',
- 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',
- sum(CASE
- WHEN t2.flow_point != 'REFUND' and t2.colonel_type != 2
- THEN t2.colonel_estimated_commission
- WHEN t2.flow_point != 'REFUND' and t2.colonel_type = 2
- then t2.second_estimated_commission
- ELSE 0 END) * 0.9 / 100 AS
- 'regimentalPromotionAmount',
- sum(CASE
- WHEN t2.flow_point != 'REFUND' and t2.colonel_type != 2
- THEN t2.second_estimated_commission
- ELSE 0 END) /
- 100 AS 'secondEstimatedCommission',
- round(sum(t2.colonel_real_commission) / 100, 2) as 'totalRegimentalSettleAmount'
- from (select user_id, user_name, promoter_id, stat_date
- from promoter_bind_channel_date
- where media_id = 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 user_id = #{collectSampleId}
- </if>
- ) t1
- left join (
- select *
- from bytedance_order_list
- <where>
- <if test="hour != null and hour != ''">
- and pay_success_time_hour <= #{hour}
- </if>
- <if test="start != null and start != ''">
- and pay_success_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and pay_success_time <= #{end}
- </if>
- </where>
- ) t2
- on t1.promoter_id = t2.author_short_id and t1.stat_date = t2.pay_success_time
- group by t1.user_id
- ) t
- LEFT JOIN (
- select t1.user_id,
- count(t2.order_id) as 'orderNum'
- from (select user_id, promoter_id, stat_date
- from promoter_bind_channel_date
- where media_id = 1
- <if test="lastTimeStart != null and lastTimeStart != ''">
- and stat_date >= #{lastTimeStart}
- </if>
- <if test="lastTimeEnd != null and lastTimeEnd != ''">
- and stat_date <= #{lastTimeEnd}
- </if>
- <if test="collectSampleId != null and collectSampleId != ''">
- and user_id = #{collectSampleId}
- </if>
- ) t1
- left join (
- select author_short_id,
- order_id,
- pay_success_time
- from bytedance_order_list
- <where>
- <if test="hour != null and hour != ''">
- and pay_success_time_hour <= #{hour}
- </if>
- <if test="lastTimeStart != null and lastTimeStart != ''">
- and pay_success_time >= #{lastTimeStart}
- </if>
- <if test="lastTimeEnd != null and lastTimeEnd != ''">
- and pay_success_time <= #{lastTimeEnd}
- </if>
- </where>
- ) t2 ON t1.promoter_id = t2.author_short_id and t1.stat_date = t2.pay_success_time
- group by t1.user_id
- ) t11 ON t11.user_id = t.collectSampleId
- 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,
- ROUND(((t.orderNum-t11.orderNum)/t11.orderNum)*100,2) as 'orderNumRatio',
- 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',
- sum(CASE
- WHEN t2.flow_point != 'REFUND' and t2.colonel_type != 2
- THEN t2.colonel_estimated_commission
- WHEN t2.flow_point != 'REFUND' and t2.colonel_type = 2
- then t2.second_estimated_commission
- ELSE 0 END) * 0.9 / 100 AS
- 'regimentalPromotionAmount',
- sum(CASE
- WHEN t2.flow_point != 'REFUND' and t2.colonel_type != 2
- THEN t2.second_estimated_commission
- ELSE 0 END) / 100 AS 'secondEstimatedCommission',
- round(sum(t2.colonel_real_commission) / 100, 2) as 'totalRegimentalSettleAmount'
- from kuaishou_promoter t1
- left join
- (
- select t1.*
- from bytedance_promoter_order_list t1
- LEFT JOIN bytedance_order_list t2 ON t1.order_id = t2.order_id
- where t2.pay_success_time >= #{bindStartDate}
- and t2.pay_success_time_hour <= #{hour}
- ) 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 t1.user_id,
- count(t2.order_id) as 'orderNum'
- from kuaishou_promoter t1
- left join
- (select t1.order_id,t1.author_short_id
- from bytedance_promoter_order_list t1
- LEFT JOIN bytedance_order_list t2 ON t1.order_id = t2.order_id
- where t2.pay_success_time >= #{lastTimeStart}
- AND t2.pay_success_time <= #{lastTimeEnd}
- and t2.pay_success_time_hour <= #{hour}
- ) 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(#{lastTimeStart}, '%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(#{lastTimeEnd}, '%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
- )t11 ON t.collectSampleId = t11.user_id
- 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>
- <select id="getproDate" resultType="com.alibaba.fastjson.JSONObject">
- select promoter_id as 'promoter_id', min(stat_date) as 'start', max(stat_date) as 'end'
- from promoter_bind_channel_date
- where user_name = '胡勤朴'
- and stat_date >= 20240101
- and stat_date <= 20240131
- group by promoter_id
- </select>
- <select id="getCount" resultType="java.math.BigDecimal">
- select 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 / 100 AS
- 'regimentalPromotionAmount'
- from bytedance_order_list
- where author_short_id = #{promoterId}
- and pay_success_time >= #{start}
- and pay_success_time <= #{end}
- </select>
- </mapper>
|