| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706 |
- <?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.IJiaoYangDingMapper">
- <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>
- group by promoter_id
- </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>
- <select id="getSumInfo" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,
- round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) as 'orderNumRate',
- round((t.payAmount - tt.payAmount) / tt.payAmount * 100, 2) as 'payAmountRate',
- round((t.regimentalPromotionAmount - tt.regimentalPromotionAmount) / tt.regimentalPromotionAmount *100,2) as
- 'regimentalPromotionAmountRate',
- round((t.grossMargin - tt.grossMargin) / tt.grossMargin * 100, 2) as 'grossMarginRate'
- from (
- select 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) * 100, 2) as 'validRadio',
- sum(case when t2.type = 1 then 1 else 0 end) as 'zyOrderNUm',
- sum(case when t2.type = 2 then
- 1 else 0 end) as 'fxOrderNUm',
- round(sum(t1.pay_amount) / 100, 2) as 'payAmount',
- round(sum(case when order_status
- != 80 then t1.pay_amount else 0 end) / 100,
- 2) as 'validPayAmount',
- round(sum(case when t1.order_status != 80 then t1.pay_amount else 0 end) /
- sum(t1.pay_amount) * 100,
- 2) as 'validPayAmountRadio',
- round(sum(case when t2.type = 1 then t1.pay_amount else 0 end) / 1000000, 2) as 'zyPayAmount',
- round(sum(case when t2.type = 2 then t1.pay_amount else 0 end) / 1000000, 2) as 'fxPayAmount',
- 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 order_status != 80
- then 1
- else 0 end) *
- 100,
- 2) as 'deliveryRadio',
- count(distinct t1.clip_user_id) as 'promoterCount',
- count( distinct t3.promoter_id ) as 'addPromoterCount',
- count(distinct t1.item_id) as 'itemCount',
- count(distinct t4.item_id) as 'addItemCount',
- round(sum(case when t1.order_status != 80 then t1.mcn_promotion_amount else 0 end) / 100, 2) as
- 'regimentalPromotionAmount',
- round(sum(case when t1.order_status != 80 and t2.type = 1 then t1.mcn_promotion_amount else 0 end) / 100, 2) as
- 'zyRegimentalPromotionAmount',
- round(sum(case when t1.order_status != 80 and t2.type = 2 then t1.mcn_promotion_amount else 0 end) / 100, 2) as
- 'fxRegimentalPromotionAmount',
- round(sum(t1.mcn_promotion_amount) / sum(t1.pay_amount) * 100, 2) as 'grossMargin',
- round(sum(case when t2.type = 1 then t1.mcn_promotion_amount else 0 end) / sum(case when t2.type = 1 then
- t1.pay_amount else 0 end) * 100, 2) as 'zyGrossMargin',
- round(sum(case when t2.type = 2 then t1.mcn_promotion_amount else 0 end) /
- sum(case when t2.type = 2 then t1.pay_amount else 0 end) * 100, 2) as 'fxGrossMargin'
- from jy_order_list t1
- left join jy_kuaishou_promoter t2
- on t1.clip_user_id = t2.promoter_id
- left join (select *
- from jy_promoter_frist_order_date
- where frist_order_time >= #{start}
- and frist_order_time <= #{end}) t3 on t1.clip_user_id = t3.promoter_id
- left join (select *
- from jy_order_item_list
- where first_order_time >=#{start}
- and first_order_time <= #{end}) t4
- on t1.item_id = t4.item_id
- where t1.stat_date >= #{start}
- and t1.stat_date <= #{end}
- <if test='nowHour != null and nowHour != ""'>
- and t1.stat_hour <= #{nowHour}
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND t1.clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- ) t
- join (select count(oid) as 'orderNum', round(sum(pay_amount) / 100, 2) as 'payAmount', round(sum(case when
- order_status != 80 then mcn_promotion_amount else 0 end) / 100,
- 2) as 'regimentalPromotionAmount', round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'grossMargin'
- from jy_order_list
- where stat_date >= #{lastStart}
- and stat_date <= #{lastEnd}
- <if test='nowHour != null and nowHour != ""'>
- and stat_hour <= #{nowHour}
- </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>
- ) tt
- </select>
- <select id="getMonthInfo" resultType="com.alibaba.fastjson.JSONObject">
- select t1.*,
- round((t1.orderNum - t2.orderNum) / t2.orderNum * 100, 2) as 'orderNumRate',
- round((t1.payAmount - t2.payAmount) / t2.payAmount * 100, 2) as 'payAmountRate'
- from (select 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) * 100,
- 2) as 'validRadio',
- round(sum(pay_amount) / 100, 2) as 'payAmount',
- round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
- 2) as 'validPayAmount',
- round(sum(case when order_status != 80 then pay_amount else 0 end) / sum(pay_amount) * 100,
- 2) as 'validPayAmountRadio',
- count(distinct clip_user_id) as 'promoterCount',
- count(distinct item_id) as 'itemCount',
- sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum'
- from jy_order_list
- where stat_date >= #{monthStart}
- and stat_date <= #{monthEnd}
- <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 'orderNum',
- round(sum(pay_amount) / 100, 2) as 'payAmount'
- from jy_order_list
- where stat_date >= #{lastMonthStart}
- and stat_date <= #{lastMonthEnd}
- <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="getEchartData" resultType="com.alibaba.fastjson.JSONObject">
- select date_format(stat_date,'%m-%d') as 'date',
- 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 pay_amount else 0 end) / 100,
- 2) as 'validPayAmount',
- count(distinct clip_user_id) as 'promoterCount',
- count(distinct item_id) as 'itemCount'
- from jy_order_list
- where stat_date >= #{echartStart}
- and stat_date <= #{echartEnd}
- <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 stat_date
- order by stat_date asc
- </select>
- <select id="getGmvHours" resultType="com.alibaba.fastjson.JSONObject">
- select stat_hour as 'time', round(sum(order_amount) / 100, 2) as 'charge'
- from jy_order_list
- where stat_date = #{date}
- <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 stat_hour
- order by stat_hour
- </select>
- <select id="getTeamList" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,
- (select user.nick_name
- from sys_user user
- left join sys_user_role userRole on user.user_id = userRole.user_id
- left join sys_role role on userRole.role_id = role.role_id
- where user.dept_id = t.deptId
- and role.role_key in (
- 'jy_bd_manage', 'jy_scissors_manage', 'jy_out_operation_manager'
- )
- and user.status = 0
- limit 1) as 'leaderName',
- (select count(user.user_id)
- from sys_user user
- left join sys_user_role userRole on user.user_id = userRole.user_id
- left join sys_role role on userRole.role_id = role.role_id
- where user.dept_id = t.deptId
- and role.role_key not in (
- 'jy_expert_business', 'jy_expert_mentor'
- )
- and user.status = 0) as 'teamMember',
- round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) as 'orderNumRate',
- round((t.payAmount - tt.payAmount) / tt.payAmount * 100, 2) as 'payAmountRate'
- from (select t4.dept_id as 'deptId',
- t4.dept_name as 'deptName',
- count(t1.oid) as 'orderNum',
- round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid) * 100,
- 2) as 'validRadio',
- round(sum(pay_amount) / 100, 2) as 'payAmount',
- round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
- 2) as 'validPayAmount',
- round(sum(case when t1.order_status != 80 then pay_amount else 0 end) / sum(pay_amount) * 100,
- 2) as 'validPayAmountRadio',
- 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 order_status != 80
- then 1
- else 0 end) *
- 100,
- 2) as 'deliveryRadio',
- count(distinct t1.clip_user_id) as 'promoterCount',
- count(
- distinct t5.promoter_id
- ) as 'addPromoterCount',
- count(distinct t1.item_id) as 'itemCount',
- count(distinct t6.item_id) as 'addItemCount'
- from jy_order_list t1
- left join jy_kuaishou_promoter t2
- on t1.clip_user_id = t2.promoter_id
- left join sys_user t3 on t2.user_id = t3.user_id
- left join sys_dept t4 on t3.dept_id = t4.dept_id
- left join (select *
- from jy_promoter_frist_order_date
- where frist_order_time >= #{start}
- and frist_order_time <= #{end}) t5 on t1.clip_user_id = t5.promoter_id
- left join (select *
- from jy_order_item_list
- where first_order_time >= #{start}
- and first_order_time <= #{end}) t6
- on t1.item_id = t6.item_id
- where t1.stat_date >= #{start}
- and t1.stat_date <= #{end}
- <if test='nowHour != null and nowHour != ""'>
- and t1.stat_hour <= #{nowHour}
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND t1.clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- group by t4.dept_id) t
- left join (select t4.dept_id as 'deptId',
- count(t1.oid) as 'orderNum',
- round(sum(pay_amount) / 100, 2) as 'payAmount'
- from jy_order_list t1
- left join jy_kuaishou_promoter t2
- on t1.clip_user_id = t2.promoter_id
- left join sys_user t3 on t2.user_id = t3.user_id
- left join sys_dept t4 on t3.dept_id = t4.dept_id
- where t1.stat_date >= #{lastStart}
- and t1.stat_date <= #{lastEnd}
- <if test='nowHour != null and nowHour != ""'>
- and t1.stat_hour <= #{nowHour}
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND t1.clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- group by t4.dept_id) tt on t.deptId = tt.deptId
- where t.deptId is not null
- order by t.orderNum desc
- </select>
- <select id="getAddItemList" resultType="com.alibaba.fastjson.JSONObject">
- SELECT t1.item_id AS 'itemId', t1.item_title AS 'itemTitle', t1.image_url AS 'image_url', round(t1.reserve_price / 100, 2) AS 'reserve_price', t1.first_order_time AS 'firstOrderTime'
- FROM jy_order_item_list t1
- INNER JOIN (SELECT item_id
- FROM jy_order_list
- WHERE stat_date >= #{start}
- AND stat_date <= #{end}
- AND clip_user_id IN (SELECT promoter_id
- FROM jy_kuaishou_promoter
- WHERE user_id IN (SELECT user_id
- FROM sys_user
- WHERE dept_id = #{deptId})
- GROUP BY promoter_id)
- GROUP BY item_id) t2 ON t1.item_id = t2.item_id
- WHERE t1.first_order_time >= #{start}
- AND t1.first_order_time <= #{end}
- </select>
- <select id="getPeopleList" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,
- round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) as 'orderNumRate',
- round((t.payAmount - tt.payAmount) / tt.payAmount * 100, 2) as 'payAmountRate'
- from (select t2.user_id as 'userId',
- t2.user_name as 'userName',
- (select deap.dept_name
- from sys_user user
- left join sys_dept deap on user.dept_id = deap.dept_id
- where user.user_id = t2.user_id) as 'deapName',
- (select user.nick_name
- from sys_user user
- left join sys_user_role userrole on user.user_id
- = userrole.user_id
- left join sys_role role on userrole.role_id = role.role_id
- where user.dept_id = (select dept_id from sys_user where user_id = t2.user_id limit 1)
- and role.role_key in (
- 'jy_bd_manage', 'jy_scissors_manage', 'jy_out_operation_manager'
- )
- and user.status = 0
- limit 1) as 'leaderName',
- count(t1.oid) as 'orderNum',
- round(
- sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid) * 100,
- 2) as 'validRadio',
- round(sum(pay_amount) / 100, 2) as 'payAmount',
- round(sum(case when t1.order_status != 80 then t1.pay_amount else 0 end) / 100,
- 2) as 'validPayAmount',
- round(sum(case when t1.order_status != 80 then t1.pay_amount else 0 end) / sum(t1.pay_amount) * 100,
- 2) as 'validPayAmountRadio',
- 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) *
- 100,
- 2) as 'deliveryRadio',
- count(distinct t1.clip_user_id) as 'promoterCount',
- count(
- distinct t3.promoter_id
- ) as 'addPromoterCount',
- count(distinct t1.item_id) as 'itemCount',
- count(distinct t4.item_id) as 'addItemCount'
- from jy_order_list t1
- left join jy_kuaishou_promoter t2
- on t1.clip_user_id = t2.promoter_id
- left join (select *
- from jy_promoter_frist_order_date
- where frist_order_time >= #{start}
- and frist_order_time <= #{end}) t3 on t1.clip_user_id = t3.promoter_id
- left join (select *
- from jy_order_item_list
- where first_order_time >= #{start}
- and first_order_time <= #{end}) t4
- on t1.item_id = t4.item_id
- where t1.stat_date >= #{start}
- and t1.stat_date <= #{end}
- <if test='nowHour != null and nowHour != ""'>
- and t1.stat_hour <= #{nowHour}
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND t1.clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- group by t2.user_id) t
- left join (select t2.user_id as 'userId',
- count(t1.oid) as 'orderNum',
- round(sum(pay_amount) / 100, 2) as 'payAmount'
- from jy_order_list t1
- left join jy_kuaishou_promoter t2
- on t1.clip_user_id = t2.promoter_id
- where t1.stat_date >= #{lastStart}
- and t1.stat_date <= #{lastEnd}
- <if test='nowHour != null and nowHour != ""'>
- and t1.stat_hour <= #{nowHour}
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND t1.clip_user_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- group by t2.user_id) tt on t.userId = tt.userId
- order by t.orderNum desc
- </select>
- <select id="getAddItemListByUserId" resultType="com.alibaba.fastjson.JSONObject">
- SELECT t1.item_id AS 'itemId', t1.item_title AS 'itemTitle', t1.image_url AS 'image_url', round(t1.reserve_price / 100, 2) AS 'reserve_price', t1.first_order_time AS 'firstOrderTime'
- FROM jy_order_item_list t1
- INNER JOIN (SELECT item_id
- FROM jy_order_list
- WHERE stat_date >= #{start}
- AND stat_date <= #{end}
- AND clip_user_id IN (SELECT promoter_id
- FROM jy_kuaishou_promoter
- WHERE user_id = #{userId}
- GROUP BY promoter_id)
- GROUP BY item_id) t2 ON t1.item_id = t2.item_id
- WHERE t1.first_order_time >= #{start}
- AND t1.first_order_time <= #{end}
- </select>
- <select id="getPromoterList" resultType="com.alibaba.fastjson.JSONObject">
- select t1.*,
- t2.user_name as 'userName',
- (case
- when t2.type = 1 then '自营'
- when t2.type = 2 then '分销'
- else '-'
- end
- ) as 'promoterType',
- t2.promoter_url as 'promoterUrl',
- t3.videoCount as 'videoCount',
- round((t1.orderNum - t4.orderNum) / t4.orderNum * 100, 2) as 'orderNumRate',
- round((t1.payAmount - t4.payAmount) / t4.payAmount * 100, 2) as 'payAmountRate'
- from (select clip_user_id as 'clipUserId',
- clip_nick_name as 'clipNickName',
- count(oid) as 'orderNum',
- round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,
- 2) as 'validRadio',
- round(sum(pay_amount) / 100, 2) as 'payAmount',
- round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
- 2) as 'validPayAmount',
- round(sum(case when order_status != 80 then pay_amount else 0 end) / sum(pay_amount) * 100,
- 2) as 'validPayAmountRadio',
- 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) *
- 100,
- 2) as 'deliveryRadio',
- count(distinct item_id) as 'itemCount'
- from jy_order_list
- where stat_date >= #{start}
- and stat_date <= #{end}
- <if test='nowHour != null and nowHour != ""'>
- and stat_hour <= #{nowHour}
- </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 jy_kuaishou_promoter t2
- on t1.clipUserId = t2.promoter_id
- left join (select promoter_id as 'promoterId', count(photo_id) as 'videoCount'
- from kuaishou_open_photo_list
- where photo_create_time >= #{start}
- and photo_create_time <= #{end}
- group by promoter_id) t3 on t1.clipUserId = t3.promoterId
- left join (select clip_user_id as 'clipUserId',
- count(oid) as 'orderNum',
- round(sum(pay_amount) / 100, 2) as 'payAmount'
- from jy_order_list
- where stat_date >= #{lastStart}
- and stat_date <= #{lastEnd}
- <if test='nowHour != null and nowHour != ""'>
- and stat_hour <= #{nowHour}
- </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) t4 on t1.clipUserId = t4.clipUserId
- order by t1.orderNum desc
- </select>
- <select id="getItemList" resultType="com.alibaba.fastjson.JSONObject">
- select t1.*,
- round((t1.orderNum - t2.orderNum) / t2.orderNum * 100, 2) as 'orderNumRate',
- round((t1.payAmount - t2.payAmount) / t2.payAmount * 100, 2) as 'payAmountRate'
- from (select item_id as 'itemId',
- item_title as 'itemTitle',
- image_url as 'imageUrl',
- count(oid) as 'orderNum',
- round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,
- 2) as 'validRadio',
- round(sum(pay_amount) / 100, 2) as 'payAmount',
- round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
- 2) as 'validPayAmount',
- round(sum(case when order_status != 80 then pay_amount else 0 end) / sum(pay_amount) * 100,
- 2) as 'validPayAmountRadio',
- 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) *
- 100,
- 2) as 'deliveryRadio',
- round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'grossMargin',
- count(distinct clip_user_id) as 'promoterCount'
- from jy_order_list
- where stat_date >= #{start}
- and stat_date <= #{end}
- <if test="nowHour != null and nowHour != ''">
- and stat_hour <= #{nowHour}
- </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) t1
- left join (select item_id as 'itemId',
- image_url as 'imageUrl',
- count(oid) as 'orderNum',
- round(sum(pay_amount) / 100, 2) as 'payAmount'
- from jy_order_list
- where stat_date >= #{lastStart}
- and stat_date <= #{lastEnd}
- <if test="nowHour != null and nowHour != ''">
- and stat_hour <= #{nowHour}
- </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
- ) t2 on t1.itemId = t2.itemId
- order by t1.orderNum desc
- </select>
- <select id="getDingPanTuiGuangUserList" resultType="com.alibaba.fastjson.JSONObject">
- select t1.*,
- round((t1.orderNum - t2.orderNum) / t2.orderNum * 100, 2) as 'orderNumRate',
- round((t1.payAmount - t2.payAmount) / t2.payAmount * 100, 2) as 'payAmountRate'
- from (select promotion_id as 'promotionId',
- promotion_nick_name as 'promotionNickName',
- count(oid) as 'orderNum',
- round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,
- 2) as 'validRadio',
- round(sum(pay_amount) / 100, 2) as 'payAmount',
- round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
- 2) as 'validPayAmount',
- round(sum(case when order_status != 80 then pay_amount else 0 end) / sum(pay_amount) * 100,
- 2) as 'validPayAmountRadio',
- 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) *
- 100,
- 2) as 'deliveryRadio',
- count(distinct item_id) as 'itemCount',
- count(distinct clip_user_id) as 'promoterCount'
- from jy_order_list
- where stat_date >= #{start}
- and stat_date <= #{end}
- <if test='nowHour != null and nowHour != ""'>
- and stat_hour <= #{nowHour}
- </if>
- group by promotion_id) t1
- left join (select promotion_id as 'promotionId',
- count(oid) as 'orderNum',
- round(sum(pay_amount) / 100, 2) as 'payAmount'
- from ruixuan.jy_order_list
- where stat_date >= #{lastStart}
- and stat_date <= #{lastEnd}
- <if test='nowHour != null and nowHour != ""'>
- and stat_hour <= #{nowHour}
- </if>
- group by promotion_id) t2 on t1.promotionId = t2.promotionId
- </select>
- <select id="getDingPanMentorBusinessList" resultType="com.alibaba.fastjson.JSONObject">
- select * from (
- select t.*,
- round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) as 'orderNumRate',
- round((t.payAmount - tt.payAmount) / tt.payAmount * 100, 2) as 'payAmountRate'
- from (select '导师' as 'type',
- t1.expert_mentor_id as 'userId',
- t1.expert_mentor_name as 'userName',
- count(t2.oid) as 'orderNum',
- round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100,
- 2) as 'validRadio',
- round(sum(t2.pay_amount) / 100, 2) as 'payAmount',
- round(sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) / 100,
- 2) as 'validPayAmount',
- round(sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) / sum(t2.pay_amount) * 100,
- 2) as 'validPayAmountRadio',
- sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
- round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
- when t2.order_status != 80
- then 1
- else 0 end) *
- 100,
- 2) as 'deliveryRadio',
- count(distinct t2.clip_user_id) as 'promoterCount',
- count(distinct t2.item_id) as 'itemCount'
- from jy_kuaishou_promoter t1
- left join jy_order_list t2
- on t1.promoter_id = t2.clip_user_id
- where 1 = 1
- and t1.expert_mentor_id is not null
- and t2.stat_date >= #{start}
- and t2.stat_date <= #{end}
- <if test='nowHour != null and nowHour != ""'>
- and t2.stat_hour <= #{nowHour}
- </if>
- group by t1.expert_mentor_id) t
- left join (select t1.expert_mentor_id as 'userId',
- count(t2.oid) as 'orderNum',
- round(sum(t2.pay_amount) / 100, 2) as 'payAmount'
- from jy_kuaishou_promoter t1
- left join jy_order_list t2
- on t1.promoter_id = t2.clip_user_id
- where 1 = 1
- and t1.expert_mentor_id is not null
- and t2.stat_date >= #{lastStart}
- and t2.stat_date <= #{lastEnd}
- <if test='nowHour != null and nowHour != ""'>
- and t2.stat_hour <= #{nowHour}
- </if>
- group by t1.expert_mentor_id) tt on t.userId = tt.userId
- union all
- select t.*,
- round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) as 'orderNumRate',
- round((t.payAmount - tt.payAmount) / tt.payAmount * 100, 2) as 'payAmountRate'
- from (select '商务' as 'type',
- t1.expert_business_id as 'userId',
- t1.expert_business_name as 'userName',
- count(t2.oid) as 'orderNum',
- round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100,
- 2) as 'validRadio',
- round(sum(t2.pay_amount) / 100, 2) as 'payAmount',
- round(sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) / 100,
- 2) as 'validPayAmount',
- round(sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) / sum(t2.pay_amount) * 100,
- 2) as 'validPayAmountRadio',
- sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
- round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
- when t2.order_status != 80
- then 1
- else 0 end) *
- 100,
- 2) as 'deliveryRadio',
- count(distinct t2.clip_user_id) as 'promoterCount',
- count(distinct t2.item_id) as 'itemCount'
- from jy_kuaishou_promoter t1
- left join jy_order_list t2
- on t1.promoter_id = t2.clip_user_id
- where 1 = 1
- and t1.expert_business_id is not null
- and t2.stat_date >= #{start}
- and t2.stat_date <= #{end}
- <if test='nowHour != null and nowHour != ""'>
- and t2.stat_hour <= #{nowHour}
- </if>
- group by t1.expert_business_id) t
- left join (select t1.expert_business_id as 'userid',
- count(t2.oid) as 'orderNum',
- round(sum(t2.pay_amount) / 100, 2) as 'payAmount'
- from jy_kuaishou_promoter t1
- left join jy_order_list t2
- on t1.promoter_id = t2.clip_user_id
- where 1 = 1
- and t1.expert_business_id is not null
- and t2.stat_date >= #{lastStart}
- and t2.stat_date <= #{lastEnd}
- <if test='nowHour != null and nowHour != ""'>
- and t2.stat_hour <= #{nowHour}
- </if>
- group by t1.expert_business_id) tt
- on t.userId = tt.userid) tlist
- order by tlist.`type` asc ,tlist.`orderNum` desc
- </select>
- </mapper>
|