| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260 |
- <?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.isc.mapper.SupplyChainMapper">
- <insert id="bindUser">
- insert into kuaishou_item_bind_user(item_id, user_id, user_name)
- value
- (#{itemId},#{userId},#{nikeName})
- </insert>
- <delete id="unbindUser" parameterType="java.lang.Long">
- delete
- from kuaishou_item_bind_user
- where item_id = #{itemId}
- </delete>
- <select id="getOrderList" resultType="com.alibaba.fastjson.JSONObject">
- select *
- from (
- select promoter_id as 'promoterId',
- promoter_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(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 kuaishou_supply_chain
- where 1= 1
- <if test="start != null and start != ''">
- and order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and order_create_time <= #{end}
- </if>
- <if test="promoterId != null and promoterId != ''">
- and promoter_id = #{promoterId}
- </if>
- <if test="promoterNickName != null and promoterNickName != ''">
- and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
- </if>
- group by promoter_id) t
- order by t.orderNum desc
- </select>
- <select id="getTopOrders" resultType="com.alibaba.fastjson.JSONObject">
- select *
- from
- (select item_id as 'itemId',
- item_title as 'itemTitle',
- image_url as 'imageUrl',
- count(oid) as 'orderNum'
- from kuaishou_supply_chain
- where promoter_id = #{promoterId}
- <if test="start != null and start != ''">
- and order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and order_create_time <= #{end}
- </if>
- group by item_id) t
- order by t.orderNum desc limit 3
- </select>
- <select id="anchorOrderDetail" resultType="com.alibaba.fastjson.JSONObject">
- select *
- 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 kuaishou_supply_chain
- where 1= 1
- <if test="promoterId != null and promoterId != ''">
- and promoter_id = #{promoterId}
- </if>
- <if test="start != null and start != ''">
- and order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and order_create_time <= #{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>
- group by item_id) t
- order by t.orderNum desc
- </select>
- <select id="orderStatistics" resultType="com.alibaba.fastjson.JSONObject">
- select FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') as 'date',
- count(t.oid) as 'orderNum'
- from (select oid,
- order_create_time
- from kuaishou_supply_chain
- where 1 = 1
- <if test="promoterId != null and promoterId != ''">
- and promoter_id = #{promoterId}
- </if>
- <if test="start != null and start != ''">
- and order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and order_create_time <= #{end}
- </if>
- ) t
- group by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d')
- order by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') asc
- </select>
- <select id="itemList" resultType="com.alibaba.fastjson.JSONObject">
- select *
- from (select t2.user_id as 'userId',
- t2.user_name as 'userName',
- 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.item_commission_rate as 'itemCommissionRate'
- from kuaishou_supply_chain t1
- left join kuaishou_item_bind_user t2
- on t1.item_id = t2.item_id
- where 1 = 1
- <if test="start != null and start != ''">
- and t1.order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t1.order_create_time <= #{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
- where 1 = 1
- <if test="userId != null and userId != ''">
- and t.userId = #{userId}
- </if>
- order by ${fieId} ${sort}
- </select>
- <select id="getTopPromoterByItemId" resultType="com.alibaba.fastjson.JSONObject">
- select
- *
- from
- (select promoter_id as 'promoterId',
- promoter_nick_name as 'promoterNickName',
- count(oid) as 'orderNum'
- from kuaishou_supply_chain
- where item_id = #{itemId}
- <if test="start != null and start != ''">
- and order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and order_create_time <= #{end}
- </if>
- group by promoter_id) t
- order by t.orderNum desc limit 3
- </select>
- <select id="itemDetail" resultType="com.alibaba.fastjson.JSONObject">
- select *
- from (
- select
- promoter_nick_name as 'promoterNickName',
- promoter_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 kuaishou_supply_chain
- where 1= 1
- <if test="itemId != null and itemId != ''">
- and item_id = #{itemId}
- </if>
- <if test="start != null and start != ''">
- and order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and order_create_time <= #{end}
- </if>
- <if test="promoterId != null and promoterId != ''">
- and promoter_id = #{promoterId}
- </if>
- <if test="promoterNickName != null and promoterNickName != ''">
- and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
- </if>
- group by promoter_id) t
- order by t.orderNum desc
- </select>
- <select id="itemServiceCharge" 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',
- sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
- regimental_promotion_rate as 'regimentalPromotionRate',
- sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
- sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount',
- sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
- 'totalRegimentalSettleAmount',
- item_commission_rate as 'itemCommissionRate'
- from kuaishou_supply_chain
- where 1= 1
- <if test="start != null and start != ''">
- and order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and order_create_time <= #{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>
- group by item_id) t
- order by t.orderNum desc
- </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 kuaishou_supply_chain
- where 1= 1
- <if test="start != null and start != ''">
- and order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and order_create_time <= #{end}
- </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 kuaishou_supply_chain
- where 1= 1
- <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
- and order_create_time >= #{nowStartHourTemp}
- </if>
- <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
- and order_create_time <= #{nowEndHourTemp}
- </if>
- ) t1
- join (select count(oid) as 'oid'
- from kuaishou_supply_chain
- where 1=1
- <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
- and order_create_time >= #{yesterdayStartHourTemp}
- </if>
- <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
- and order_create_time <= #{yesterdayEndHourTemp}
- </if>
- ) t2
- </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 regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount',
- sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
- 'totalRegimentalSettleAmount'
- from kuaishou_supply_chain
- where 1= 1
- <if test="start != null and start != ''">
- and order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and order_create_time <= #{end}
- </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 kuaishou_supply_chain
- where 1= 1
- <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
- and order_create_time >= #{nowStartHourTemp}
- </if>
- <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
- and order_create_time <= #{nowEndHourTemp}
- </if>
- ) t1
- join (select sum(pay_amount) as 'payAmount'
- from kuaishou_supply_chain
- where 1=1
- <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
- and order_create_time >= #{yesterdayStartHourTemp}
- </if>
- <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
- and order_create_time <= #{yesterdayEndHourTemp}
- </if>
- ) t2
- </select>
- <select id="getServiceAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
- select
- count(distinct promoter_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 kuaishou_supply_chain
- where 1= 1
- <if test="start != null and start != ''">
- and order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and order_create_time <= #{end}
- </if>
- </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'
- from kuaishou_supply_chain
- where 1= 1
- <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
- and order_create_time >= #{nowStartHourTemp}
- </if>
- <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
- and order_create_time <= #{nowEndHourTemp}
- </if>
- group by item_id
- ) t1
- left join (select
- item_id as 'itemId',
- count(oid) as 'orderNum'
- from kuaishou_supply_chain
- where 1=1
- <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
- and order_create_time >= #{yesterdayStartHourTemp}
- </if>
- <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
- and order_create_time <= #{yesterdayEndHourTemp}
- </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'
- from kuaishou_supply_chain
- where 1= 1
- <if test="start != null and start != ''">
- and order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and order_create_time <= #{end}
- </if>
- group by item_id) t
- order by t.orderNum desc
- </select>
- <select id="getPromoterRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
- select
- t1.*,
- round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
- from (
- select
- promoter_id as 'promoterId',
- promoter_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 kuaishou_supply_chain
- where 1= 1
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND promoter_id IN
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
- and order_create_time >= #{nowStartHourTemp}
- </if>
- <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
- and order_create_time <= #{nowEndHourTemp}
- </if>
- group by promoter_id
- ) t1
- left join (select
- promoter_id as 'promoterId',
- count(oid) as 'orderNum'
- from kuaishou_supply_chain
- where 1=1
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND promoter_id IN
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
- and order_create_time >= #{yesterdayStartHourTemp}
- </if>
- <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
- and order_create_time <= #{yesterdayEndHourTemp}
- </if>
- group by promoter_id
- ) t2 on t1.promoterId = t2.promoterId
- order by t1.orderNum desc
- </select>
- <select id="getPromoterRatioList" resultType="com.alibaba.fastjson.JSONObject">
- select * from (
- select
- promoter_id as 'promoterId',
- promoter_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 kuaishou_supply_chain
- where 1= 1
- <if test="start != null and start != ''">
- and order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and order_create_time <= #{end}
- </if>
- group by promoter_id) t
- order by t.orderNum desc
- </select>
- <select id="exportPromoterTotal" resultType="com.alibaba.fastjson.JSONObject">
- select *
- from (
- select
- promoter_id as 'promoterId',
- promoter_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) * 100,2) 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) * 100,2) as 'deliveryRadio'
- from kuaishou_supply_chain
- where 1= 1
- <if test="start != null and start != ''">
- and order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and order_create_time <= #{end}
- </if>
- <if test="promoterId != null and promoterId != ''">
- and promoter_id = #{promoterId}
- </if>
- <if test="promoterNickName != null and promoterNickName != ''">
- and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
- </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>
- group by promoter_id) t
- order by t.orderNum desc
- </select>
- <select id="exportPromoter" resultType="com.alibaba.fastjson.JSONObject">
- select *
- from (
- select
- promoter_id as 'promoterId',
- promoter_nick_name as 'promoterNickName',
- 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) * 100,2) 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) * 100,2) as 'deliveryRadio'
- from kuaishou_supply_chain
- where 1= 1
- <if test="start != null and start != ''">
- and order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and order_create_time <= #{end}
- </if>
- <if test="promoterId != null and promoterId != ''">
- and promoter_id = #{promoterId}
- </if>
- <if test="promoterNickName != null and promoterNickName != ''">
- and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
- </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>
- group by promoter_id,item_id) t
- order by t.promoterId,t.orderNum desc
- </select>
- <select id="exportOrder" resultType="com.alibaba.fastjson.JSONObject">
- select *
- from (select
- t2.user_id as 'userId',
- t2.user_name as 'userName',
- t1.item_id as 'itemId',
- 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) * 100, 2) 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 order_status != 80 then 1 else 0 end) / sum(case when t1.order_status
- != 80 then 1 else 0 end) * 100, 2) as 'deliveryRadio',
- round(t1.item_commission_rate / 10,2) as 'itemCommissionRate'
- from kuaishou_supply_chain t1
- left join kuaishou_item_bind_user t2
- on t1.item_id = t2.item_id
- where 1 = 1
- <if test="start != null and start != ''">
- and t1.order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t1.order_create_time <= #{end}
- </if>
- <if test="promoterId != null and promoterId != ''">
- and t1.promoter_id = #{promoterId}
- </if>
- <if test="promoterNickName != null and promoterNickName != ''">
- and t1.promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
- </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
- where 1 = 1
- <if test="userId != null and userId != ''">
- and t.userId = #{userId}
- </if>
- order by t.orderNum desc
- </select>
- <select id="bindUserItemList" resultType="com.alibaba.fastjson.JSONObject">
- select *
- from (select t1.item_id as 'itemId',
- t1.item_title as 'itemTitle',
- t1.reserve_price as 'reservePrice',
- t1.image_url as 'imageUrl',
- t1.activity_id as 'activityId',
- t1.regimental_promotion_rate as 'regimentalPromotionRate',
- t2.user_id as 'userId',
- case when t2.user_id is null then 1 else 2 end as 'status',
- t2.user_name as 'userName',
- t2.create_time as 'bindTime',
- t1.item_commission_rate as 'itemCommissionRate'
- from kuaishou_item_info t1
- left join kuaishou_item_bind_user t2 on t1.item_id = t2.item_id
- where 1 = 1
- <if test="userId != null and userId != ''">
- and t2.user_id = #{userId}
- </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>
- <if test="activityId != null and activityId != ''">
- and t1.activity_id = #{activityId}
- </if>
- order by t1.create_time desc) t
- where 1 = 1
- <if test="status != null and status != ''">
- and t.status = #{status}
- </if>
- </select>
- <select id="getSupplyChainUserList" resultType="com.alibaba.fastjson.JSONObject">
- select t3.user_id as 'userId', t3.nick_name as 'nickMame', t1.role_name as 'roleName', t3.status
- from sys_role t1
- left join sys_user_role t2 on t1.role_id = t2.role_id
- left join sys_user t3 on t2.user_id = t3.user_id
- where t1.role_key in (
- 'supplyChainAdmin',
- 'associationManager',
- 'bd',
- 'bdManager',
- 'association',
- 'courtshipManager',
- 'courtship'
- )
- group by t3.user_id
- order by t3.create_time asc
- </select>
- <select id="adminReportList" resultType="com.alibaba.fastjson.JSONObject">
- select *
- from (select t1.user_id as 'userId',
- t1.user_name as 'userName',
- count(distinct t2.item_id) as 'itemCount',
- count(t2.oid) as 'orderNum',
- sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
- round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid),4) as 'validRadio',
- sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
- 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),
- 4) as 'deliveryRadio',
- sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
- sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) as 'payAmount',
- sum(case
- when t2.order_status != 80 then t2.regimental_promotion_amount
- else 0 end) as 'regimentalPromotionAmount',
- sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
- 'totalRegimentalSettleAmount'
- from kuaishou_item_bind_user t1
- left join kuaishou_supply_chain t2
- on t1.item_id = t2.item_id
- where 1= 1
- <if test="start != null and start != ''">
- and t2.order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t2.order_create_time <= #{end}
- </if>
- group by t1.user_id) t
- where 1 =1
- <if test="userId != null and userId != ''">
- and t.userId = #{userId}
- </if>
- order by t.orderNum desc
- </select>
- <select id="userItemDetail" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- *
- FROM
- (
- SELECT
- t1.user_id,
- t1.user_name AS 'userName',
- t2.item_id AS 'itemId',
- t2.item_title AS 'itemTitle',
- t2.image_url AS 'imageUrl',
- t2.reserve_price AS 'reservePrice',
- count(t2.oid) AS 'orderNum',
- sum(
- CASE
- WHEN t2.order_status != 80 THEN 1
- ELSE 0
- END
- ) AS 'validOrderNUm',
- round(
- sum(
- CASE
- WHEN t2.order_status != 80 THEN 1
- ELSE 0
- END
- ) / count(t2.oid),
- 4
- ) AS 'validRadio',
- sum(
- CASE
- WHEN t2.send_status = 1
- AND t2.order_status != 80 THEN 1
- ELSE 0
- END
- ) AS 'deliveryNum',
- 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
- ),
- 4
- ) AS 'deliveryRadio',
- sum(
- CASE
- WHEN t2.order_status = 80 THEN 1
- ELSE 0
- END
- ) AS 'invalidOrderNUm',
- sum(
- CASE
- WHEN t2.order_status != 80 THEN t2.pay_amount
- ELSE 0
- END
- ) AS 'payAmount',
- t2.regimental_promotion_rate AS 'regimentalPromotionRate',
- sum(
- CASE
- WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
- ELSE 0
- END
- ) AS 'regimentalPromotionAmount',
- sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
- 'totalRegimentalSettleAmount',
- t2.item_commission_rate as 'itemCommissionRate'
- FROM
- kuaishou_item_bind_user t1
- LEFT JOIN
- kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
- WHERE
- 1 = 1
- <if test="start != null and start != ''">
- and t2.order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t2.order_create_time <= #{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
- where 1 = 1
- <if test="userId != null and userId != ''">
- and t.user_id = #{userId}
- </if>
- order by ${fieId} ${sort}
- </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 kuaishou_supply_chain
- where 1= 1
- <if test="thisCycleStartTemp != null and thisCycleStartTemp != ''">
- and order_create_time >= #{thisCycleStartTemp}
- </if>
- <if test="thisCycleEndTemp != null and thisCycleEndTemp != ''">
- and order_create_time <= #{thisCycleEndTemp}
- </if>
- ) t1
- join (
- select count(oid) as 'oid',
- sum(order_amount) as 'orderAmount'
- from kuaishou_supply_chain
- where 1=1
- <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
- and order_create_time >= #{lastCycleStartTemp}
- </if>
- <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
- and order_create_time <= #{lastCycleEndTemp}
- </if>
- ) t2
- </select>
- <select id="indexStatistics" resultType="com.alibaba.fastjson.JSONObject">
- select FROM_UNIXTIME(t.order_create_time / 1000, '%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,
- order_create_time
- from kuaishou_supply_chain
- where 1 = 1
- <if test="startTemp != null and startTemp != ''">
- and order_create_time >= #{startTemp}
- </if>
- <if test="endTemp != null and endTemp != ''">
- and order_create_time <= #{endTemp}
- </if>
- ) t
- group by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d')
- order by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') asc
- </select>
- <select id="itemBindSummary" resultType="com.alibaba.fastjson.JSONObject">
- select count(t1.item_id) as 'itemTotal', sum(case when t2.item_id is not null then 1 else 0 end) as 'claimCount', sum(case when t2.item_id is null then 1 else 0 end) as 'unClaimCount'
- from kuaishou_item_info t1
- left join kuaishou_item_bind_user t2
- on t1.item_id = t2.item_id
- where 1 = 1
- </select>
- <select id="userItemTotal" resultType="com.alibaba.fastjson.JSONObject">
- SELECT count(t2.oid) AS 'orderNum',
- sum(
- CASE
- WHEN t2.order_status != 80 THEN 1
- ELSE 0
- END
- ) AS 'validOrderNUm',
- round(
- sum(
- CASE
- WHEN t2.order_status != 80 THEN 1
- ELSE 0
- END
- ) / count(t2.oid),
- 4
- ) AS 'validRadio',
- sum(
- CASE
- WHEN t2.send_status = 1
- AND t2.order_status != 80 THEN 1
- ELSE 0
- END
- ) AS 'deliveryNum',
- 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
- ),
- 4
- ) AS 'deliveryRadio',
- sum(
- CASE
- WHEN t2.order_status = 80 THEN 1
- ELSE 0
- END
- ) AS 'invalidOrderNUm',
- sum(
- CASE
- WHEN t2.order_status != 80 THEN t2.pay_amount
- ELSE 0
- END
- ) AS 'payAmount',
- sum(
- CASE
- WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
- ELSE 0
- END
- ) AS 'regimentalPromotionAmount',
- sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
- 'totalRegimentalSettleAmount'
- FROM kuaishou_item_bind_user t1
- LEFT JOIN
- kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
- WHERE 1 = 1
- <if test="start != null and start != ''">
- and t2.order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t2.order_create_time <= #{end}
- </if>
- <if test="userId != null and userId != ''">
- and t1.user_id = #{userId}
- </if>
- </select>
- <select id="exportUserItemDetail" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- *
- FROM
- (
- SELECT
- t1.user_id as 'user_id',
- t1.user_name AS 'userName',
- t2.item_id AS 'itemId',
- t2.item_title AS 'itemTitle',
- t2.image_url AS 'imageUrl',
- round(t2.reserve_price / 100,2) AS 'reservePrice',
- count(t2.oid) AS 'orderNum',
- sum(
- CASE
- WHEN t2.order_status != 80 THEN 1
- ELSE 0
- END
- ) AS 'validOrderNUm',
- round(
- sum(
- CASE
- WHEN t2.order_status != 80 THEN 1
- ELSE 0
- END
- ) / count(t2.oid) * 100,
- 2
- ) AS 'validRadio',
- sum(
- CASE
- WHEN t2.send_status = 1
- AND t2.order_status != 80 THEN 1
- ELSE 0
- END
- ) AS 'deliveryNum',
- 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',
- sum(
- CASE
- WHEN t2.order_status = 80 THEN 1
- ELSE 0
- END
- ) AS 'invalidOrderNUm',
- round( sum(
- CASE
- WHEN t2.order_status != 80 THEN t2.pay_amount
- ELSE 0
- END
- )/ 100,2 )AS 'payAmount',
- concat(round(t2.regimental_promotion_rate / 10 ,2),'%') AS 'regimentalPromotionRate',
- round(
- sum(
- CASE
- WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
- ELSE 0
- END
- ) / 100 , 2)AS 'regimentalPromotionAmount',
- round(
- sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100,2) as
- 'totalRegimentalSettleAmount',
- concat(round(t2.item_commission_rate / 10),'%') as 'itemCommissionRate'
- FROM
- kuaishou_item_bind_user t1
- LEFT JOIN
- kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
- WHERE
- 1 = 1
- <if test="start != null and start != ''">
- and t2.order_create_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t2.order_create_time <= #{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
- where 1 = 1
- <if test="userId != null and userId != ''">
- and t.user_id = #{userId}
- </if>
- order by t.orderNum desc
- </select>
- <select id="getCookie" resultType="java.lang.String">
- select cookie
- from ruixuan.kuaishou_supply_chain_cookie limit 1
- </select>
- <select id="selectOrderInfo" resultType="com.alibaba.fastjson.JSONObject">
- SELECT COUNT(oid) as 'allNumber', IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS
- 'validOrderNUm', IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END), 0) AS 'orderAmount',
- IFNULL(
- SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),
- 0) AS 'regimentalPromotionAmount', IFNULL(sum(base_amount), 0) as 'baseAmount'
- FROM kuaishou_supply_chain
- WHERE stat_date >= #{startDate}
- AND stat_date <= #{endDate}
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND promoter_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="selectOrderInfoByItemIds" resultType="com.alibaba.fastjson.JSONObject">
- SELECT t.*,
- CONCAT(IFNULL(ROUND(sendCount / allNumber * 100, 2),0), '%') as 'sendRate'
- FROM (SELECT COUNT(oid) as 'allNumber',
- IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS
- 'validOrderNUm',
- IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END), 0) AS 'orderAmount',
- IFNULL(
- SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),
- 0) AS 'regimentalPromotionAmount',
- IFNULL(sum(base_amount), 0) as 'baseAmount',
- IFNULL(COUNT(CASE WHEN send_status = 1 THEN oid ELSE null END), 0) AS 'sendCount'
- FROM kuaishou_supply_chain
- WHERE stat_date >= #{startDate}
- AND stat_date <= #{endDate}
- <if test='itemIds != null and itemIds.size() > 0'>
- AND item_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- ) t
- </select>
- <select id="selectOrderRate" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- count(oid) as 'allNumber',
- sum(
- CASE
- WHEN order_status != 80 THEN order_amount
- ELSE 0
- END
- ) AS 'orderAmount'
- FROM kuaishou_supply_chain
- WHERE stat_date >= #{statDate}
- AND stat_date <= #{endDate}
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND promoter_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test='itemIds != null and itemIds.size() > 0'>
- AND item_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="getMonthOrderAmount" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') as 'date',
- IFNULL(SUM(order_amount),0) AS 'orderAmount',
- IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount',
- IFNULL(promoterCount,0) AS 'promoterCount'
- FROM kuaishou_supply_chain t1
- LEFT JOIN (
- SELECT count(promoter_id) as 'promoterCount', DATE_FORMAT(create_time, '%Y-%m-%d') as 'date'
- FROM kuaishou_promoter
- WHERE user_id = #{userId}
- AND DATE_FORMAT(create_time, '%Y-%m-%d') >= #{start}
- AND DATE_FORMAT(create_time, '%Y-%m-%d') <= #{end}
- GROUP BY DATE_FORMAT(create_time, '%Y-%m-%d')
- ) t2 ON t1.FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') = t2.date
- WHERE order_status != 80
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND promoter_id in
- <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- AND order_create_time >= #{startLong}
- AND order_create_time <= #{endLong}
- GROUP BY FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d')
- </select>
- <select id="getMonthOrderAmountByItems" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') as 'date',
- IFNULL(SUM(order_amount),0) AS 'orderAmount',
- IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount',
- count(oid) AS 'orderCount'
- FROM kuaishou_supply_chain
- WHERE order_status != 80
- <if test='itemIds != null and itemIds.size() > 0'>
- AND item_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- AND order_create_time >= #{startLong}
- AND order_create_time <= #{endLong}
- GROUP BY FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d')
- </select>
- <select id="getMonthOrderAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- t1.orderAmount,
- t1.totalRegimentalSettleAmount,
- CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
- CONCAT(IFNULL(ROUND(t2.totalRegimentalSettleAmount/t1.totalRegimentalSettleAmount*100,2),0),'%') as
- 'totalRegimentalSettleAmountRate'
- FROM
- (
- SELECT
- IFNULL(SUM(order_amount),0) AS 'orderAmount',
- IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount'
- FROM kuaishou_supply_chain t1
- WHERE order_status != 80
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND promoter_id in
- <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- AND order_create_time >= #{startLong}
- AND order_create_time <= #{endLong}) t1
- LEFT JOIN
- (
- SELECT
- IFNULL(SUM(order_amount),0) AS 'orderAmount',
- IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount'
- FROM kuaishou_supply_chain t1
- WHERE order_status != 80
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND promoter_id in
- <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- AND order_create_time >= #{toStartLong}
- AND order_create_time <= #{endLong})t2 ON 1=1
- </select>
- <select id="getMonthOrderAmountTotalByItems" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- t1.orderAmount,
- t1.totalRegimentalSettleAmount,
- t1.orderCount,
- CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
- CONCAT(IFNULL(ROUND(t2.orderCount/t1.orderCount*100,2),0),'%') as 'orderCountRate',
- CONCAT(IFNULL(ROUND(t2.totalRegimentalSettleAmount/t1.totalRegimentalSettleAmount*100,2),0),'%') as
- 'totalRegimentalSettleAmountRate'
- FROM
- (
- SELECT
- IFNULL(SUM(order_amount),0) AS 'orderAmount',
- IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount',
- COUNT(oid) as 'orderCount'
- FROM kuaishou_supply_chain t1
- WHERE order_status != 80
- <if test='itemIds != null and itemIds.size() > 0'>
- AND item_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- AND order_create_time >= #{startLong}
- AND order_create_time <= #{endLong}
- )t1
- LEFT JOIN
- (
- SELECT
- IFNULL(SUM(order_amount),0) AS 'orderAmount',
- IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount',
- COUNT(oid) as 'orderCount'
- FROM kuaishou_supply_chain t1
- WHERE order_status != 80
- <if test='itemIds != null and itemIds.size() > 0'>
- AND item_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- AND order_create_time >= #{toStartLong}
- AND order_create_time <= #{endLong}
- )t2 ON 1=1
- </select>
- </mapper>
|