| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906 |
- <?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.jiaoyang.mapper.JiaoYangReportMapper">
- <insert id="replaceItems">
- replace into jy_auth_order(
- item_id,
- item_name,
- item_image_url,
- item_price_view,
- commission_rate_view,
- promoter_id,
- promoter_nick,
- promoter_photo,
- mcn_commission_rate_view,
- sort_count
- )
- values
- <foreach collection="adds" item="add" separator=",">
- (
- #{add.itemId},
- #{add.itemName},
- #{add.itemImageUrl},
- #{add.itemPriceView},
- #{add.commissionRateView},
- #{add.promoterId},
- #{add.promoterNick},
- #{add.promoterPhoto},
- #{add.mcnCommissionRateView},
- #{add.sortCount}
- )
- </foreach>
- </insert>
- <delete id="deleteAuthItem">
- delete
- from jy_auth_order
- where 1 = 1
- </delete>
- <select id="item" resultType="com.alibaba.fastjson.JSONObject">
- select t.* from (
- select
- t1.item_id as 'itemId',
- t1.reserve_price as 'reservePrice',
- t1.item_title as 'itemTitle',
- t1.image_url as 'imageUrl',
- count(t1.oid) as 'orderNum',
- sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
- round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid), 4) as 'validRadio',
- sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'deliveryNum',
- sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
- round(sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) / sum(case when
- t1.order_status != 80 then 1 else 0 end), 4) as 'deliveryRadio',
- t1.commission_rate as 'itemCommissionRate'
- from jy_order_list t1
- 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="itemId != null and itemId != ''">
- and t1.item_id = #{itemId}
- </if>
- <if test="itemTitle != null and itemTitle != ''">
- and t1.item_title like concat(concat('%',#{itemTitle}),'%')
- </if>
- group by t1.item_id) t
- order by ${fieId} ${sort}
- </select>
- <select id="itemDetail" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,tt.headImg,ttt.type,ttt.user_name as 'userName'
- from (
- select
- clip_nick_name as 'promoterNickName',
- clip_user_id as 'promoterId',
- count(oid) as 'orderNum',
- sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
- regimental_promotion_rate as 'regimentalPromotionRate',
- sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
- round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
- sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
- sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
- round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
- then 1 else 0 end),4) as 'deliveryRadio'
- from jy_order_list
- where 1= 1
- <if test="itemId != null and itemId != ''">
- and item_id = #{itemId}
- </if>
- <if test="start != null and start != ''">
- and stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- <if test="promoterId != null and promoterId != ''">
- and clip_user_id = #{promoterId}
- </if>
- <if test="promoterNickName != null and promoterNickName != ''">
- and clip_nick_name like concat(concat('%',#{promoterNickName}),'%')
- </if>
- group by clip_user_id) t
- left join (select clip_id,head_img as 'headImg' from jy_clip_cooperation where stat_date =
- DATE_FORMAT(NOW(),'%Y%m%d') ) tt on t.promoterId = tt.clip_id
- left join jy_kuaishou_promoter ttt on t.promoterId = ttt.promoter_id
- order by t.orderNum desc
- </select>
- <select id="promoter" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,
- tt.head_img as 'headImg',
- tt.video_count as 'videoCount',
- tt.video_show as 'videoShow',
- ttt.type as 'type',
- ttt.user_name as 'userName',
- ttt.expert_mentor_name as 'expertMentorName',
- ttt.expert_business_name as 'expertBusinessName'
- from (
- select clip_user_id as 'promoterId',
- clip_nick_name as 'promoterNickName',
- count(oid) as 'orderNum',
- sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
- round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
- sum(pay_amount) as 'payAmount',
- sum(case when order_status != 80 then pay_amount else 0
- end) as 'validPayAmount',
- sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
- sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
- round(
- sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
- when order_status != 80
- then 1
- else 0 end),
- 4) as 'deliveryRadio',
- sum(case when order_status != 80 then mcn_promotion_amount else 0 end) as 'regimentalPromotionAmount'
- from jy_order_list
- 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="promoterId != null and promoterId != '' ">
- and clip_user_id = #{promoterId}
- </if>
- <if test="promoterNickName != null and promoterNickName != '' ">
- and clip_nick_name like concat(concat('%',#{promoterNickName}),'%')
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- group by clip_user_id) t
- left join ( select * from jy_clip_cooperation where stat_date = DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -1
- DAY),'%Y%m%d') ) tt on t.promoterId = tt.clip_id
- left join jy_kuaishou_promoter ttt on t.promoterId = ttt.promoter_id
- where 1 = 1
- <if test="type != null and type != '' ">
- and ttt.type = #{type}
- </if>
- order by t.payAmount desc
- </select>
- <select id="anchorOrderDetail" resultType="com.alibaba.fastjson.JSONObject">
- select t.*
- from (select
- item_title as 'itemTitle',
- item_id as 'itemId',
- reserve_price as 'reservePrice',
- image_url 'imageUrl',
- count(oid) as 'orderNum',
- sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
- round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
- sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
- regimental_promotion_rate as 'regimentalPromotionRate',
- sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
- sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
- round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
- then 1 else 0 end),4) as 'deliveryRadio'
- from jy_order_list
- where 1= 1
- <if test="promoterId != null and promoterId != ''">
- and clip_user_id = #{promoterId}
- </if>
- <if test="start != null and start != ''">
- and stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- <if test="itemId != null and itemId != ''">
- and item_id = #{itemId}
- </if>
- <if test="itemTitle != null and itemTitle != ''">
- and item_title like concat(concat('%',#{itemTitle}),'%')
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- group by item_id) t
- order by t.orderNum desc
- </select>
- <select id="promoterStatistics" resultType="com.alibaba.fastjson.JSONObject">
- select date_format(t.stat_date, '%Y-%m-%d') as 'date',
- count(t.oid) as 'orderNum'
- from (select oid,
- stat_date
- from jy_order_list
- where 1 = 1
- <if test="promoterId != null and promoterId != ''">
- and clip_user_id = #{promoterId}
- </if>
- <if test="start != null and start != ''">
- and stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- ) t
- group by t.stat_date
- order by t.stat_date asc
- </select>
- <select id="getClipCooperation" resultType="com.alibaba.fastjson.JSONObject">
- select clip_id as 'clipId',
- clip_name as 'clipName',
- head_img as 'headImg',
- fans_num as 'fansNum',
- gmv_30d as 'gmv30d',
- start_time as 'startTime',
- end_time as 'endTime',
- (case when status = 1
- then '上架'
- when status = 3
- then '已结束'
- when status = 2
- then '待确认'
- else '-'
- end
- ) as 'status',
- termination_reason as 'terminationReason',
- concat(commission_rate_view,'%') as 'commissionRateView',
- shop_score as 'shopScore',
- clip_gmv_30d as 'clipGmv30d',
- auth_item_gmv_30d as 'authItemGmv30d',
- video_count as 'videoCount',
- video_count as 'videoShow',
- stat_date as 'statDate'
- from jy_clip_cooperation
- where
- stat_date = #{date}
- <if test="promoterId != null and promoterId != ''">
- and clip_id = #{promoterId}
- </if>
- <if test="promoterName != null and promoterName != ''">
- and clip_name like concat(concat('%',#{promoterName}),'%')
- </if>
- </select>
- <select id="getOrderTotal" resultType="com.alibaba.fastjson.JSONObject">
- select
- count(oid) as 'orderNum',
- sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
- sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm'
- from jy_order_list
- 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='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="getOrderTotalRatio" resultType="java.lang.Double">
- select
- round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio'
- from (select count(oid) as 'oid'
- from jy_order_list
- where 1= 1
- <if test="nowDate != null and nowDate != ''">
- and stat_date = #{nowDate}
- </if>
- <if test="hour != null and hour != ''">
- and stat_hour <= #{hour}
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- ) t1
- join (select count(oid) as 'oid'
- from jy_order_list
- where 1=1
- <if test="yesDate != null and yesDate != ''">
- and stat_date = #{yesDate}
- </if>
- <if test="hour != null and hour != ''">
- and stat_hour <= #{hour}
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- ) t2
- </select>
- <select id="getServiceAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
- select
- count(distinct clip_user_id) as 'promoterNum',
- sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
- sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
- round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
- as 'deliveryRadio'
- from jy_order_list
- 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='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="getAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
- select
- sum(order_amount) as 'orderAmount',
- sum(base_amount) as 'baseAmount',
- sum(case when order_status != 80 then mcn_promotion_amount else 0 end) as 'regimentalPromotionAmount',
- sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
- 'totalRegimentalSettleAmount'
- from jy_order_list
- 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='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="getAmountTotalRatio" resultType="java.lang.Double">
- select
- round((t1.payAmount -t2.payAmount) / t2.payAmount , 4) as 'amountTotalRatio'
- from (select sum(pay_amount) as 'payAmount'
- from jy_order_list
- where 1= 1
- <if test="nowDate != null and nowDate != ''">
- and stat_date = #{nowDate}
- </if>
- <if test="hour != null and hour != ''">
- and stat_hour <= #{hour}
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- ) t1
- join (select sum(pay_amount) as 'payAmount'
- from jy_order_list
- where 1=1
- <if test="yesDate != null and yesDate != ''">
- and stat_date = #{yesDate}
- </if>
- <if test="hour != null and jhour != ''">
- and stat_hour <= #{hour}
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- ) t2
- </select>
- <select id="getPromoterRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
- select
- t1.*,
- round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
- from (
- select
- clip_user_id as 'promoterId',
- clip_nick_name as 'promoterNickName',
- count(oid) as 'orderNum',
- sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
- round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
- from jy_order_list
- where 1= 1
- <if test="nowDate != null and nowDate != ''">
- and stat_date = #{nowDate}
- </if>
- <if test="hour != null and hour != ''">
- and stat_hour <= #{hour}
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- group by clip_user_id
- ) t1
- left join (select
- clip_user_id as 'promoterId',
- count(oid) as 'orderNum'
- from jy_order_list
- where 1=1
- <if test="yesDate != null and yesDate != ''">
- and stat_date = #{yesDate}
- </if>
- <if test="hour != null and hour != ''">
- and stat_hour <= #{hour}
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- group by clip_user_id
- ) t2 on t1.promoterId = t2.promoterId
- order by t1.orderNum desc
- </select>
- <select id="getPromoterRatioList" resultType="com.alibaba.fastjson.JSONObject">
- select * from (
- select
- clip_user_id as 'promoterId',
- clip_nick_name as 'promoterNickName',
- count(oid) as 'orderNum',
- sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
- round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
- from jy_order_list
- 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='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- group by clip_user_id) t
- order by t.orderNum desc
- </select>
- <select id="getOrderRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
- select
- t1.*,
- round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
- from (select
- item_id as 'itemId',
- item_title as 'itemTitle',
- image_url as 'imageUrl',
- count(oid) as 'orderNum',
- sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
- round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
- sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
- sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
- round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
- as 'deliveryRadio',
- concat(round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2),'%' )as 'grossMargin'
- from jy_order_list
- where 1= 1
- <if test="nowDate != null and nowDate != ''">
- and stat_date = #{nowDate}
- </if>
- <if test="hour != null and hour != ''">
- and stat_hour <= #{hour}
- </if>
- group by item_id
- ) t1
- left join (select
- item_id as 'itemId',
- count(oid) as 'orderNum'
- from jy_order_list
- where 1=1
- <if test="yesDate != null and yesDate != ''">
- and stat_date = #{yesDate}
- </if>
- <if test="hour != null and hour != ''">
- and stat_hour <= #{hour}
- </if>
- group by item_id
- ) t2 on t1.itemId = t2.itemId
- order by t1.orderNum desc
- </select>
- <select id="getOrderRankList" resultType="com.alibaba.fastjson.JSONObject">
- select * from (
- select
- item_id as 'itemId',
- item_title as 'itemTitle',
- image_url as 'imageUrl',
- count(oid) as 'orderNum',
- sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
- round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
- sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
- sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
- round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
- then 1 else 0 end),4) as 'deliveryRadio',
- concat(round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2),'%' )as 'grossMargin'
- from jy_order_list
- 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>
- group by item_id) t
- order by t.orderNum desc
- </select>
- <select id="indexStatistics" resultType="com.alibaba.fastjson.JSONObject">
- select date_format(t.stat_date,'%Y-%m-%d') as 'date',
- <if test="type == 'orderNum' ">
- count(t.oid) as 'orderNum'
- </if>
- <if test="type == 'validOrderNum' ">
- sum(case when t.order_status = 80 then 1 else 0 end) as 'validOrderNum'
- </if>
- <if test="type == 'orderAmount' ">
- sum(t.order_amount) as 'orderAmount'
- </if>
- <if test="type == 'baseAmount' ">
- sum(t.base_amount) as 'baseAmount'
- </if>
- <if test="type == 'deliveryNum' ">
- sum(case when t.send_status = 1 and t.order_status != 80 then 1 else 0 end) as 'deliveryNum'
- </if>
- from (select
- oid,
- order_status,
- order_amount,
- base_amount,
- send_status,
- stat_date
- from jy_order_list
- 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='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- ) t
- group by t.stat_date
- order by t.stat_date asc
- </select>
- <select id="getTimeIntervalRatio" resultType="com.alibaba.fastjson.JSONObject">
- select
- round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio',
- round((t1.orderAmount -t2.orderAmount) / t2.orderAmount , 4) as 'orderAmountRatio'
- from (
- select count(oid) as 'oid',
- sum(order_amount) as 'orderAmount'
- from jy_order_list
- where 1= 1
- <if test="thisCycleStartTemp != null and thisCycleStartTemp != ''">
- and stat_date >= #{thisCycleStartTemp}
- </if>
- <if test="thisCycleEndTemp != null and thisCycleEndTemp != ''">
- and stat_date <= #{thisCycleEndTemp}
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- ) t1
- join (
- select count(oid) as 'oid',
- sum(order_amount) as 'orderAmount'
- from jy_order_list
- where 1=1
- <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
- and stat_date >= #{lastCycleStartTemp}
- </if>
- <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
- and stat_date <= #{lastCycleEndTemp}
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- ) t2
- </select>
- <select id="getPromoterIdsByUserIds" resultType="java.lang.Long">
- select promoter_id from jy_kuaishou_promoter where
- 1 = 1
- and user_id in
- <foreach collection="userIds" item="userId" separator="," open="(" close=")">
- #{userId}
- </foreach>
- </select>
- <select id="dayData" resultType="com.alibaba.fastjson.JSONObject">
- select *,
- t1.gmv - t2.lastGmv as 'gvmGap',
- t1.orderNum - t2.lastOrderNum as 'orderNumGap',
- t1.validGmv - t2.lastValidGmv as 'validGmvGap',
- t1.validOrderNUm - t2.lastValidOrderNUm as 'validOrderNumGap',
- t1.mcnPromotionAmount - t2.lastMcnPromotionAmount as 'mcnPromotionAmountGap',
- t1.grossMargin - t2.lastGrossMargin as 'grossMarginGap'
- from (select
- concat(concat(concat( date_format(#{startDate},'%m%d'),'~')), date_format(#{endDate},'%m%d') ) as 'date',
- round(sum(pay_amount) / 100, 2) as 'gmv',
- count(oid) as 'orderNum',
- round(sum(case when order_status != 80 then pay_amount else 0 end) / 100, 2) as 'validGmv',
- sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNum',
- round(sum(mcn_promotion_amount) / 100, 2) as 'mcnPromotionAmount',
- round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'grossMargin'
- from jy_order_list t1
- where 1 = 1
- and t1.stat_date >= #{startDate}
- and t1.stat_date <= #{endDate}
- <if test='dataType == "1" '>
- and t1.clip_user_id in (
- select promoter_id from jy_kuaishou_promoter
- where `type` = 1
- group by promoter_id
- )
- </if>
- <if test=' dataType == "2" '>
- and t1.clip_user_id not in (
- select promoter_id from jy_kuaishou_promoter
- where `type` = 1
- group by promoter_id
- )
- </if>
- ) t1
- join
- (
- select
- concat(concat(concat( date_format(#{lastStart},'%m%d'),'~')), date_format(#{lastEnd},'%m%d') ) as
- 'lastDate',
- round(sum(pay_amount) / 100, 2) as 'lastGmv',
- count(oid) as 'lastOrderNum',
- round(sum(case when order_status != 80 then pay_amount else 0 end) / 100, 2) as 'lastValidGmv',
- sum(case when order_status != 80 then 1 else 0 end) as 'lastValidOrderNum',
- round(sum(mcn_promotion_amount) / 100, 2) as 'lastMcnPromotionAmount',
- round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'lastGrossMargin'
- from jy_order_list t1
- where 1 = 1
- and t1.stat_date >= #{lastStart}
- and t1.stat_date <= #{lastEnd}
- <if test='dataType == "1"'>
- and t1.clip_user_id in (
- select promoter_id from jy_kuaishou_promoter
- where `type` = 1
- group by promoter_id
- )
- </if>
- <if test='dataType == "2" '>
- and t1.clip_user_id not in (
- select promoter_id from jy_kuaishou_promoter
- where `type` = 1
- group by promoter_id
- )
- </if>
- ) t2
- </select>
- <select id="monthData" resultType="com.alibaba.fastjson.JSONObject">
- select *,
- concat(ROUND((t1.gmv - t2.lastGmv) / t2.lastGmv * 100, 2) ,'%') as 'gvmRadio',
- concat(ROUND((t1.orderNum - t2.lastOrderNum) / t2.lastOrderNum * 100, 2),'%') as 'orderNumRadio',
- concat(ROUND((t1.validGmv - t2.lastValidGmv) / t2.lastValidGmv * 100, 2) ,'%')as 'validGmvRadio',
- concat(ROUND((t1.validOrderNUm - t2.lastValidOrderNUm) / t2.lastValidOrderNUm * 100,
- 2) ,'%')as 'validOrderNumRadio',
- concat(ROUND((t1.mcnPromotionAmount - t2.lastMcnPromotionAmount) / t2.lastMcnPromotionAmount * 100,
- 2) ,'%')as 'mcnPromotionAmountRadio',
- ROUND((t1.grossMargin - t2.lastGrossMargin) / t2.lastGrossMargin * 100,
- 2) as 'grossMarginRadio'
- from (select CONCAT(date_format(#{nowMonthEndDate} ,'%Y/%m/%d') , '合计') as 'date',
- round(sum(pay_amount) / 100, 2) as 'gmv',
- count(oid) as 'orderNum',
- round(sum(case when order_status != 80 then pay_amount else 0 end) / 100, 2) as 'validGmv',
- sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNum',
- round(sum(mcn_promotion_amount) / 100, 2) as 'mcnPromotionAmount',
- round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'grossMargin'
- from jy_order_list t1
- where t1.stat_date >= #{nowMonthStartDate}
- and t1.stat_date <= #{nowMonthEndDate}
- <if test='dataType == "1"'>
- and t1.clip_user_id in (
- select promoter_id from jy_kuaishou_promoter
- where `type` = 1
- group by promoter_id
- )
- </if>
- <if test='dataType == "2" '>
- and t1.clip_user_id not in (
- select promoter_id from jy_kuaishou_promoter
- where `type` = 1
- group by promoter_id
- )
- </if>
- ) t1
- join (select CONCAT(date_format(#{lastMonthEndDate} ,'%Y/%m/%d') , '合计') as 'lastDate',
- round(sum(pay_amount) / 100, 2) as 'lastGmv',
- count(oid) as 'lastOrderNum',
- round(sum(case when order_status != 80 then pay_amount else 0 end) / 100, 2) as 'lastValidGmv',
- sum(case when order_status != 80 then 1 else 0 end) as 'lastValidOrderNum',
- round(sum(mcn_promotion_amount) / 100, 2) as 'lastMcnPromotionAmount',
- round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'lastGrossMargin'
- from jy_order_list t1
- where t1.stat_date >= #{lastMonthStartDate}
- and t1.stat_date <= #{lastMonthEndDate}
- <if test='dataType == "1"'>
- and t1.clip_user_id in (
- select promoter_id from jy_kuaishou_promoter
- where `type` = 1
- group by promoter_id
- )
- </if>
- <if test='dataType == "2"'>
- and t1.clip_user_id not in (
- select promoter_id from jy_kuaishou_promoter
- where `type` = 1
- group by promoter_id
- )
- </if>
- ) t2
- </select>
- <select id="getTopItem" resultType="com.alibaba.fastjson.JSONObject">
- select t1.*,
- t2.promotionVolume as 'yesPromotionVolume',
- t1.promotionVolume - t2.promotionVolume as 'difference',
- round((t1.promotionVolume - t2.promotionVolume) / t2.promotionVolume * 100, 2) as 'increaseInPrice',
- (
- case when t2.itemId is null
- then 1
- else 2
- end
- ) as 'isNew'
- from (select clip_id as 'clipId',
- clip_name as 'clipName',
- item_id as 'itemId',
- item_name as 'itemName',
- item_img_url as 'itemImgUrl',
- item_price as 'itemPrice',
- promotion_volume as 'promotionVolume',
- promotion_promoter_count as 'promotionPromoterCount'
- from jy_clip_top_list
- where stat_date = #{date}
- <if test="promoterId != null and promoterId != ''">
- and clip_id = #{promoterId}
- </if>
- ) t1
- left join (select clip_id as 'clipId',
- item_id as 'itemId',
- promotion_volume as 'promotionVolume'
- from jy_clip_top_list
- where stat_date = DATE_FORMAT(DATE_ADD(#{date}, INTERVAL -1 DAY),'%Y%m%d')
- <if test="promoterId != null and promoterId != ''">
- and clip_id = #{promoterId}
- </if>
- ) t2
- on t1.clipId = t2.clipId and t1.itemId = t2.itemId
- order by ${fieId} ${sort}
- </select>
- <select id="getTopItemUser" resultType="com.alibaba.fastjson.JSONObject">
- select id, name
- from jy_fx_top_item_config
- </select>
- <select id="getDataByDate" resultType="com.alibaba.fastjson.JSONObject" parameterType="java.lang.Long">
- select stat_hour as 'time', round(sum(order_amount) / 100, 2) as 'charge'
- from jy_order_list
- where stat_date = #{date}
- group by stat_hour
- order by stat_hour
- </select>
- <select id="getJiaoYangCookie" resultType="java.lang.String">
- select cookie
- from jy_fx_cookie limit 1
- </select>
- <select id="getAuthItemList" resultType="com.alibaba.fastjson.JSONObject">
- select
- cast(item_id as char ) as 'itemId',
- item_name as 'itemName',
- item_image_url as 'itemImageUrl',
- item_price_view as 'itemPriceView',
- commission_rate_view as 'commissionRateView',
- promoter_id as 'promoterId',
- promoter_nick as 'promoterNick',
- promoter_photo as 'promoterPhoto',
- mcn_commission_rate_view as 'mcnCommissionRateView'
- from jy_auth_order
- where 1 = 1
- <if test="itemId != null and itemId != ''">
- and item_id = #{itemId}
- </if>
- <if test="itemName != null and itemName != ''">
- and item_name like concat(concat('%',#{itemName}),'%')
- </if>
- <if test="promoterId != null and promoterId != ''">
- and promoter_id = #{promoterId}
- </if>
- <if test="promoterNick != null and promoterNick != ''">
- and promoter_nick like concat(concat('%',#{promoterNick}),'%')
- </if>
- order by sort_count asc
- </select>
- <select id="getTypeData" resultType="com.alibaba.fastjson.JSONObject">
- select concat('自营:', t1.orderNum) as 'selfOrderNum', t1.gmv as 'selfGmv', concat(t1.grossMargin,'%' )as 'selfGrossProfit', concat('分销:', t2.orderNum) as 'disOrderNum', t2.gmv as 'disGmv', concat(t2.grossMargin,'%') as 'disGrossProfit'
- from (select count(oid) as 'orderNum', round(sum(pay_amount) / 100, 2) as 'gmv', round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'grossMargin'
- from jy_order_list
- where 1 = 1
- and stat_date >= #{start}
- and stat_date <= #{end}
- and clip_user_id in (select promoter_id
- from jy_kuaishou_promoter
- where `type` = 1
- group by promoter_id)) t1
- join (select count(oid) as 'orderNum', round(sum(pay_amount) / 100, 2) as 'gmv', round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'grossMargin'
- from jy_order_list
- where 1 = 1
- and stat_date >= #{start}
- and stat_date <= #{end}
- and clip_user_id not in (select promoter_id
- from jy_kuaishou_promoter
- where `type` = 1
- group by promoter_id)) t2
- </select>
- <select id="getPromoterIdsByBusinessId" resultType="java.lang.Long" parameterType="java.lang.Long">
- select promoter_id
- from jy_kuaishou_promoter
- where expert_business_id = #{userId}
- group by promoter_id
- </select>
- <select id="getPromoterIdsByMentorId" resultType="java.lang.Long" parameterType="java.lang.Long">
- select promoter_id
- from jy_kuaishou_promoter
- where expert_mentor_id = #{userId}
- group by promoter_id
- </select>
- </mapper>
|