| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265 |
- <?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',
- IFNULL(sum(
- CASE
- WHEN order_status != 80 THEN order_amount
- ELSE 0
- END
- ),0) 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(regimental_promotion_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 DATE_FORMAT(create_time, '%Y-%m-%d') >= #{start}
- AND DATE_FORMAT(create_time, '%Y-%m-%d') <= #{end}
- <if test="userList != null and userList.size() > 0 ">
- AND user_id in
- <foreach collection="userList" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY DATE_FORMAT(create_time, '%Y-%m-%d')
- ) t2 ON FROM_UNIXTIME(t1.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(regimental_promotion_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(regimental_promotion_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(regimental_promotion_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(regimental_promotion_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(regimental_promotion_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>
|