| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363 |
- <?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>
- <update id="updateOrder">
- UPDATE kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus}
- WHERE oid = #{oid}
- </update>
- <update id="updateOrderRegimentalSettleAmount">
- UPDATE kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus},
- total_regimental_settle_amount = regimental_promotion_amount
- WHERE oid = #{oid}
- </update>
- <update id="updateItem">
- UPDATE kuaishou_item_list
- SET activity_item_status = #{status}
- WHERE item_id = #{itemId}
- </update>
- <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 t.*,t2.userName,
- IFNULL(ROUND(((t.orderNum-t3.orderNum)/t3.orderNum)*100,2),0) as 'orderNumRoi'
- 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(pay_amount) as 'payAmount',
- sum(case when order_status != 80 then pay_amount else 0 end) as 'validPayAmount',
- sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
- 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 'shippingGreen',
- sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
- 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 send_status = 1
- then 1 else 0 end),4) as 'deliveryRadio',
- sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount'
- from kuaishou_supply_chain
- where stat_hour <= #{hour}
- <if test="start != null and start != ''">
- and stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- <if test="promoterId != null and promoterId != ''">
- and promoter_id = #{promoterId}
- </if>
- <if test="promoterNickName != null and promoterNickName != ''">
- and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
- </if>
- group by promoter_id
- ) t left join (
- select promoter_id as 'promoterId',group_concat(user_name) as 'userName' from kuaishou_promoter where media_id =
- 2
- group by promoter_id
- ) t2 on t.promoterId = t2.promoterId
- left join (
- select promoter_id as 'promoterId',
- count(oid) as 'orderNum'
- from kuaishou_supply_chain
- where stat_hour <= #{hour}
- <if test="lastTimeStart != null and lastTimeStart != ''">
- and stat_date >= #{lastTimeStart}
- </if>
- <if test="lastTimeEnd != null and lastTimeEnd != ''">
- and stat_date <= #{lastTimeEnd}
- </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
- ) t3 on t.promoterId = t3.promoterId
- 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 stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- group by item_id) t
- order by t.orderNum desc limit 3
- </select>
- <select id="anchorOrderDetail" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,
- t2.status,
- (
- case
- when t3.activity_item_status = 1 then '待审核'
- when t3.activity_item_status = 2 then '已上架'
- when t3.activity_item_status = 3 then '审核拒绝'
- when t3.activity_item_status = 4 then '活动失效'
- when t3.activity_item_status = 5 then '商品下架'
- else ''
- end
- ) as 'activityItemStatus'
- from (select
- 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 then 1 else 0 end) as 'deliveryNum',
- 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 'shippingGreen',
- sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
- 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 send_status = 1
- 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 stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- <if test="itemId != null and itemId != ''">
- and item_id = #{itemId}
- </if>
- <if test="itemTitle != null and itemTitle != ''">
- and item_title like concat(concat('%',#{itemTitle}),'%')
- </if>
- group by item_id) t left join ( select item_id as 'itemId', collect_sample_status as 'status' from
- kuaishou_item_collect_samples where promoter_id = #{promoterId}) t2
- on t.itemId = t2.itemId
- left join kuaishou_item_list t3
- on t.itemId = t3.item_id
- order by t.orderNum desc
- </select>
- <select id="orderStatistics" resultType="com.alibaba.fastjson.JSONObject">
- select stat_date as 'date',
- count(t.oid) as 'orderNum'
- from (select oid,
- stat_date
- 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 stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- ) t
- group by stat_date
- order by stat_date 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',
- IFNULL(ROUND(((count(t1.oid)-t6.orderNum)/t6.orderNum)*100,2),0) as 'orderNumRoi',
- 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 then 1 else 0 end) as 'deliveryNum',
- 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 'shippingGreen',
- sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
- 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
- send_status = 1 then 1 else 0 end), 4) as 'deliveryRadio',
- t1.item_commission_rate as 'itemCommissionRate',
- (case
- when t3.ccr_value is null or t3.ccr_value = 0
- then '0%'
- else concat(round(t3.ccr_value / 100, 2), '%')
- end
- ) as 'ccrValue',
- (case
- when t3.ccr_value is null or t3.ccr_value = 0
- then 0
- else round(t3.ccr_value / 100 , 2)
- end
- ) as 'ccrInt',
- t3.store_score as 'storeScore',
- (
- case when t5.is_presale = 1
- then '否'
- when t5.is_presale = 2
- then '是'
- else '-'
- end
- ) as 'isPresale',
- round(t3.investment_promotion_rate / 10, 2) as 'investmentPromotionRate'
- from kuaishou_supply_chain t1
- left join kuaishou_item_bind_user t2
- on t1.item_id = t2.item_id
- left join kuaishou_activity_open_item_list t3
- on t1.item_id = t3.item_id
- left join kuaishou_item_list t5
- on t1.item_id = t5.item_id
- left join (
- select
- item_id as 'itemId',
- count(oid) as 'orderNum'
- from kuaishou_supply_chain
- where stat_hour <= #{hour}
- <if test="lastTimeStart != null and lastTimeStart != ''">
- and stat_date >= #{lastTimeStart}
- </if>
- <if test="lastTimeEnd != null and lastTimeEnd != ''">
- and stat_date <= #{lastTimeEnd}
- </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) t6 on t1.item_id = t6.itemId
- where t1.stat_hour <= #{hour}
- <if test="start != null and start != ''">
- and t1.stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t1.stat_date <= #{end}
- </if>
- <if test="itemId != null and itemId != ''">
- and t1.item_id = #{itemId}
- </if>
- <if test="itemTitle != null and itemTitle != ''">
- and t1.item_title like concat(concat('%',#{itemTitle}),'%')
- </if>
- group by t1.item_id) t
- where 1 = 1
- <if test="userId != null and userId != ''">
- and t.userId = #{userId}
- </if>
- order by ${fieId} ${sort}
- </select>
- <select id="itemBindList" resultType="com.alibaba.fastjson.JSONObject">
- select t1.*,t2.*,
- (
- case when t4.is_presale = 1
- then '否'
- when t4.is_presale = 2
- then '是'
- else '-'
- end
- ) as 'isPresale',
- t3.store_score as 'storeScore'
- from (select t.item_id as 'itemId', t.item_title as 'itemTitle', t.user_id as 'userId', t.user_name as
- 'userName',
- (case
- when tt.ccr_value is null or tt.ccr_value = 0
- then '0%'
- else concat(round(tt.ccr_value / 100, 2), '%')
- end
- ) as 'ccrValue',
- (case
- when tt.ccr_value is null or tt.ccr_value = 0
- then 0
- else round(tt.ccr_value / 100 , 2)
- end
- ) as 'ccrInt',
- round(tt.investment_promotion_rate / 10, 2) as 'investmentPromotionRate'
- from kuaishou_item_list t left join kuaishou_activity_open_item_list tt
- on t.item_id = tt.item_id
- where
- t.create_time >= str_to_date(concat(#{bindStartDate},' 00:00:01'),'%Y-%m-%d
- %H:%i:%s')
- and
- t.create_time <= str_to_date(concat(#{bindEndDate},' 23:59:59'),'%Y-%m-%d
- %H:%i:%s')
- ) t1
- left join
- (select item_id as 'orderItemId',
- reserve_price as 'reservePrice',
- 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',
- 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 'shippingGreen',
- sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
- 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
- send_status = 1
- then 1
- else 0 end),
- 4) as 'deliveryRadio',
- item_commission_rate as 'itemCommissionRate'
- from kuaishou_supply_chain
- where stat_date >= #{start}
- group by item_id) t2 on t1.itemId = t2.orderItemId
- left join kuaishou_activity_open_item_list t3
- on t1.itemId = t3.item_id
- left join kuaishou_item_list t4
- on t1.itemId = t4.item_id
- where 1 = 1
- <if test="itemId != null and itemId != ''">
- and t1.itemId = #{itemId}
- </if>
- <if test="itemTitle != null and itemTitle != ''">
- and t1.itemTitle like concat(concat('%',#{itemTitle}),'%')
- </if>
- <if test="userId != null and userId != ''">
- and t1.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 stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- group by promoter_id) t
- order by t.orderNum desc limit 3
- </select>
- <select id="itemDetail" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,tt.userName
- 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 then 1 else 0 end) as 'deliveryNum',
- 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 'shippingGreen',
- sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
- 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 send_status = 1
- 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 stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{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 left join (select promoter_id,group_concat(user_name) as 'userName',user_id as 'userId'
- from
- kuaishou_promoter group by promoter_id) tt
- on t.promoterId = tt.promoter_id
- where 1 =1
- <if test="userId != null and userId != ''">
- and tt.userId = #{userId}
- </if>
- 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 then 1 else 0 end) as 'deliveryNum',
- 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 'shippingGreen',
- sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
- 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 send_status = 1
- 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 stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- <if test="itemId != null and itemId != ''">
- and item_id = #{itemId}
- </if>
- <if test="itemTitle != null and itemTitle != ''">
- and item_title like concat(concat('%',#{itemTitle}),'%')
- </if>
- 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 stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{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 stat_date = #{nowStartHourTemp}
- </if>
- <if test="hour != null and hour != ''">
- and `stat_hour` <= #{hour}
- </if>
- ) t1
- join (select count(oid) as 'oid'
- from kuaishou_supply_chain
- where 1=1
- <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
- and stat_date = #{yesterdayStartHourTemp}
- </if>
- <if test="hour != null and hour != ''">
- and `stat_hour` <= #{hour}
- </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 stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{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 stat_date = #{nowStartHourTemp}
- </if>
- <if test="hour != null and hour != ''">
- and `stat_hour` <= #{hour}
- </if>
- ) t1
- join (select sum(pay_amount) as 'payAmount'
- from kuaishou_supply_chain
- where 1=1
- <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
- and stat_date = #{yesterdayStartHourTemp}
- </if>
- <if test="hour != null and hour != ''">
- and `stat_hour` <= #{hour}
- </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 stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{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 stat_date = #{nowStartHourTemp}
- </if>
- <if test="hour != null and hour != ''">
- and `stat_hour` <= #{hour}
- </if>
- group by item_id
- ) t1
- left join (select
- item_id as 'itemId',
- count(oid) as 'orderNum'
- from kuaishou_supply_chain
- where 1=1
- <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
- and stat_date = #{yesterdayStartHourTemp}
- </if>
- <if test="hour != null and hour != ''">
- and `stat_hour` <= #{hour}
- </if>
- group by item_id
- ) t2 on t1.itemId = t2.itemId
- order by t1.orderNum desc
- </select>
- <select id="getOrderRankRatioListBytedance" resultType="com.alibaba.fastjson.JSONObject">
- select
- t1.*,
- round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
- from (
- select
- product_id as 'itemId',
- product_name as 'itemTitle',
- product_img as 'imageUrl',
- count(order_id) as 'orderNum',
- sum(case when flow_point != 'REFUND' then 1 else 0 end) as 'validOrderNUm',
- round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id),4) as 'validRadio'
- from ruixuan.bytedance_order_list
- where 1= 1
- <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
- and pay_success_time >= #{nowStartHourTemp}
- </if>
- <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
- and pay_success_time <= #{nowEndHourTemp}
- </if>
- <if test="hour != null and hour != ''">
- and pay_success_time_hour <= #{hour}
- </if>
- group by product_id
- ) t1
- left join (select
- product_id as 'itemId',
- count(order_id) as 'orderNum'
- from ruixuan.bytedance_order_list
- where 1=1
- <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
- and pay_success_time >= #{yesterdayStartHourTemp}
- </if>
- <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
- and pay_success_time <= #{yesterdayEndHourTemp}
- </if>
- <if test="hour != null and hour != ''">
- and pay_success_time_hour <= #{hour}
- </if>
- group by product_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 stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- group by item_id) t
- order by t.orderNum desc
- </select>
- <select id="getOrderRankListBytedance" resultType="com.alibaba.fastjson.JSONObject">
- select * from (
- select
- product_id as 'itemId',
- product_name as 'itemTitle',
- product_img as 'imageUrl',
- count(order_id) as 'orderNum',
- sum(case when flow_point != 'REFUND' then 1 else 0 end) as 'validOrderNUm',
- round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id),4) as 'validRadio'
- from ruixuan.bytedance_order_list
- where 1= 1
- <if test="start != null and start != ''">
- and pay_success_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and pay_success_time <= #{end}
- </if>
- group by product_id) t
- order by t.orderNum desc
- </select>
- <select id="getPromoterRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
- select
- t1.*,
- round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
- from (
- select
- t.promoter_id as 'promoterId',
- t.promoter_nick_name as 'promoterNickName',
- tt.promoter_url as 'promoterUrl',
- 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 t
- left join (select * from kuaishou_promoter group by promoter_id) tt on t.promoter_id = tt.promoter_id
- where 1= 1
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND t.promoter_id IN
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
- and stat_date = #{nowStartHourTemp}
- </if>
- <if test="hour != null and hour != ''">
- and `stat_hour` <= #{hour}
- </if>
- group by t.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 stat_date = #{yesterdayStartHourTemp}
- </if>
- <if test="hour != null and hour != ''">
- and `stat_hour` <= #{hour}
- </if>
- group by promoter_id
- ) t2 on t1.promoterId = t2.promoterId
- order by t1.orderNum desc
- </select>
- <select id="getPromoterRankRatioListBytedance" resultType="com.alibaba.fastjson.JSONObject">
- select
- t1.*,
- round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
- from (
- select
- author_short_id as 'promoterId',
- author_account as 'promoterNickName',
- count(order_id) as 'orderNum',
- sum(case when flow_point != 'REFUND' then 1 else 0 end) as 'validOrderNUm',
- round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id),4) as 'validRadio'
- from ruixuan.bytedance_order_list
- where author_short_id is not null
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND author_short_id IN
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
- and pay_success_time >= #{nowStartHourTemp}
- </if>
- <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
- and pay_success_time <= #{nowEndHourTemp}
- </if>
- <if test="hour != null and hour != ''">
- and pay_success_time_hour <= #{hour}
- </if>
- group by author_short_id
- ) t1
- left join (
- select
- author_short_id as 'promoterId',
- count(order_id) as 'orderNum'
- from ruixuan.bytedance_order_list
- where 1=1
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND author_short_id IN
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
- and pay_success_time >= #{yesterdayStartHourTemp}
- </if>
- <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
- and pay_success_time <= #{yesterdayEndHourTemp}
- </if>
- <if test="hour != null and hour != ''">
- and pay_success_time_hour <= #{hour}
- </if>
- group by author_short_id
- ) t2 on t1.promoterId = t2.promoterId
- order by t1.orderNum desc
- </select>
- <select id="getPromoterRatioList" resultType="com.alibaba.fastjson.JSONObject">
- select * from (
- select
- t1.promoter_id as 'promoterId',
- t1.promoter_nick_name as 'promoterNickName',
- count(oid) as 'orderNum',
- tt.promoter_url as 'promoterUrl',
- 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 t1
- left join kuaishou_promoter tt on t1.promoter_id = tt.promoter_id
- where 1= 1
- <if test="start != null and start != ''">
- and stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- group by t1.promoter_id) t
- order by t.orderNum desc
- </select>
- <select id="getPromoterRatioListBytedance" resultType="com.alibaba.fastjson.JSONObject">
- select * from (
- select
- author_short_id as 'promoterId',
- author_account as 'promoterNickName',
- count(order_id) as 'orderNum',
- sum(case when flow_point != 'REFUND' then 1 else 0 end) as 'validOrderNUm',
- round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id),4) as 'validRadio'
- from ruixuan.bytedance_order_list
- where author_short_id is not null
- <if test="start != null and start != ''">
- and pay_success_time >= #{start}
- </if>
- <if test="end != null and end != ''">
- and pay_success_time <= #{end}
- </if>
- group by author_short_id) t
- order by t.orderNum desc
- </select>
- <select id="exportPromoterTotal" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,
- IFNULL(ROUND(((t.orderNum-t3.orderNum)/t3.orderNum)*100,2),0) as 'orderNumRoi'
- 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',
- 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 regimental_promotion_amount else 0 end) / 100, 2) as
- 'regimentalPromotionAmount'
- from kuaishou_supply_chain
- where stat_hour <= #{hour}
- <if test="start != null and start != ''">
- and stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- <if test="promoterId != null and promoterId != ''">
- and 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
- left join (
- select promoter_id as 'promoterId',
- count(oid) as 'orderNum'
- from kuaishou_supply_chain
- where stat_hour <= #{hour}
- <if test="lastTimeStart != null and lastTimeStart != ''">
- and stat_date >= #{lastTimeStart}
- </if>
- <if test="lastTimeEnd != null and lastTimeEnd != ''">
- and stat_date <= #{lastTimeEnd}
- </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
- ) t3 on t.promoterId = t3.promoterId
- 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 stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{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',
- IFNULL(ROUND(((count(t1.oid)-t6.orderNum)/t6.orderNum)*100,2),0) as 'orderNumRoi',
- 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',
- (case
- when t4.ccr_value is null or t4.ccr_value = 0
- then '0%'
- else concat(round(t4.ccr_value / 100, 2), '%')
- end
- ) as 'ccrValue'
- ,
- t4.shop_star as 'shopStar',
- t4.mall_logistics_score as 'mallLogisticsScore',
- t4.shop_score as 'shopScore',
- t4.mall_service_score as 'mallServiceScore',
- t4.mall_quality_score as 'mallQualityScore',
- (
- case when t5.is_presale = 1
- then '否'
- when t5.is_presale = 2
- then '是'
- else '-'
- end
- ) as 'isPresale'
- from kuaishou_supply_chain t1
- left join kuaishou_item_bind_user t2
- on t1.item_id = t2.item_id
- left join kuaishou_activity_open_item_list t4
- on t1.item_id = t4.item_id
- left join kuaishou_item_list t5
- on t1.item_id = t5.item_id
- left join (
- select
- item_id as 'itemId',
- count(oid) as 'orderNum'
- from kuaishou_supply_chain
- where stat_hour <= #{hour}
- <if test="lastTimeStart != null and lastTimeStart != ''">
- and stat_date >= #{lastTimeStart}
- </if>
- <if test="lastTimeEnd != null and lastTimeEnd != ''">
- and stat_date <= #{lastTimeEnd}
- </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) t6 on t1.item_id = t6.itemId
- where t1.stat_hour <= #{hour}
- <if test="start != null and start != ''">
- and t1.stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t1.stat_date <= #{end}
- </if>
- <if test="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 *
- FROM (SELECT t3.user_id AS 'userId',
- t3.nick_name AS 'nickMame',
- t1.role_name AS 'roleName',
- t3.status,
- t3.create_time
- 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 (
- 'association',
- 'associationManager',
- 'bd',
- 'bdManager'
- )
- AND t3.status = 0
- GROUP BY t3.user_id) t
- WHERE t.userId IS NOT NULL
- ORDER BY t.create_time DESC
- </select>
- <select id="adminReportList" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,
- t1.sendSampleCount,
- IFNULL(ROUND(((t.orderNum-t3.orderNum)/t3.orderNum)*100,2),0) as 'orderNumRoi'
- 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 then 1 else 0 end) as 'deliveryNum',
- 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 'shippingGreen',
- sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
- 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 send_status = 1
- 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',
- round( sum(case
- when t2.order_status != 80 then t2.regimental_promotion_amount
- else 0 end) / sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) ,5 ) as 'avgServiceRate'
- from kuaishou_item_bind_user t1
- left join kuaishou_supply_chain t2
- on t1.item_id = t2.item_id
- where t2.stat_hour <= #{hour}
- <if test="start != null and start != ''">
- and t2.stat_date >=#{start}
- </if>
- <if test="end != null and end != ''">
- and t2.stat_date <= #{end}
- </if>
- group by t1.user_id
- ) t left join (
- select item_create_id,count(1) as 'sendSampleCount' from kuaishou_item_collect_samples
- where courier_number_time >= #{startDate}
- and courier_number_time <= #{endDate}
- group by item_create_id
- ) t1 on t.userId = t1.item_create_id
- left join (
- select t1.user_id as 'userId',
- count(t2.oid) as 'orderNum'
- from kuaishou_item_bind_user t1
- left join kuaishou_supply_chain t2
- on t1.item_id = t2.item_id
- where t2.stat_hour <= #{hour}
- <if test="lastTimeStart != null and lastTimeStart != ''">
- and t2.stat_date >= #{lastTimeStart}
- </if>
- <if test="lastTimeEnd != null and lastTimeEnd != ''">
- and t2.stat_date <= #{lastTimeEnd}
- </if>
- group by t1.user_id
- ) t3 on t.userId = t3.userId
- 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
- THEN 1
- ELSE 0
- END
- ) AS 'deliveryNum',
- 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 'shippingGreen',
- sum(
- CASE
- WHEN t2.send_status = 1
- AND t2.order_status != 80 THEN 1
- ELSE 0
- END
- ) AS 'effDeliveryNum',
- 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.send_status = 1 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',
- (case
- when t3.ccr_value is null or t3.ccr_value = 0
- then '0%'
- else concat(round(t3.ccr_value / 100, 2), '%')
- end
- ) as 'ccrValue',
- (case
- when t3.ccr_value is null or t3.ccr_value = 0
- then 0
- else round(t3.ccr_value / 100 , 2)
- end
- ) as 'ccrInt'
- FROM
- kuaishou_item_bind_user t1
- LEFT JOIN
- kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
- left join kuaishou_activity_open_item_list t3 on t1.item_id = t3.item_id
- WHERE
- 1 = 1
- <if test="start != null and start != ''">
- and t2.stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t2.stat_date <= #{end}
- </if>
- <if test="itemId != null and itemId != ''">
- and t1.item_id = #{itemId}
- </if>
- <if test="itemTitle != null and itemTitle != ''">
- and t2.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 stat_date >= #{thisCycleStartTemp}
- </if>
- <if test="thisCycleEndTemp != null and thisCycleEndTemp != ''">
- and stat_date <= #{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 stat_date >= #{lastCycleStartTemp}
- </if>
- <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
- and stat_date <= #{lastCycleEndTemp}
- </if>
- ) t2
- </select>
- <select id="indexStatistics" resultType="com.alibaba.fastjson.JSONObject">
- select stat_date as 'date',
- <if test="type == 'orderNum' ">
- count(t.oid) as 'orderNum'
- </if>
- <if test="type == 'validOrderNum' ">
- sum(case when t.order_status = 80 then 1 else 0 end) as 'validOrderNum'
- </if>
- <if test="type == 'orderAmount' ">
- sum(t.order_amount) as 'orderAmount'
- </if>
- <if test="type == 'baseAmount' ">
- sum(t.base_amount) as 'baseAmount'
- </if>
- <if test="type == 'deliveryNum' ">
- sum(case when t.send_status = 1 and t.order_status != 80 then 1 else 0 end) as 'deliveryNum'
- </if>
- from (select
- oid,
- order_status,
- order_amount,
- base_amount,
- send_status,
- stat_date
- from kuaishou_supply_chain
- where 1 = 1
- <if test="startTemp != null and startTemp != ''">
- and stat_date >= #{startTemp}
- </if>
- <if test="endTemp != null and endTemp != ''">
- and stat_date <= #{endTemp}
- </if>
- ) t
- group by stat_date
- order by stat_date 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
- THEN 1
- ELSE 0
- END
- ) AS 'deliveryNum',
- 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 'shippingGreen',
- sum(
- CASE
- WHEN t2.send_status = 1
- AND t2.order_status != 80 THEN 1
- ELSE 0
- END
- ) AS 'effDeliveryNum',
- 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.send_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.stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t2.stat_date <= #{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',
- (case
- when t3.ccr_value is null or t3.ccr_value = 0
- then '0%'
- else concat(round(t3.ccr_value / 100, 2), '%')
- end
- ) as 'ccrValue'
- FROM
- kuaishou_item_bind_user t1
- LEFT JOIN
- kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
- left join kuaishou_activity_open_item_list t3 on t1.item_id = t3.item_id
- WHERE
- 1 = 1
- <if test="start != null and start != ''">
- and t2.stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t2.stat_date <= #{end}
- </if>
- <if test="itemId != null and itemId != ''">
- and t1.item_id = #{itemId}
- </if>
- <if test="itemTitle != null and itemTitle != ''">
- and t1.item_title like concat(concat('%',#{itemTitle}),'%')
- </if>
- GROUP BY
- t1.item_id
- ) t
- 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 kuaishou_supply_chain_cookie
- WHERE id = #{regId} limit 1
- </select>
- <select id="selectOrderInfo" resultType="com.alibaba.fastjson.JSONObject">
- SELECT t1.*,
- ROUND(((t1.validOrderNUm-t2.validOrderNUm)/t2.validOrderNUm)*100,2) as 'validOrderNUmRoi',
- ROUND(((t1.allNumber-t1.validOrderNUm-t2.inValidOrderNUm)/t2.inValidOrderNUm)*100,2) as 'inValidOrderNUmRoi',
- ROUND(((t1.baseAmount-t2.baseAmount)/t2.baseAmount)*100,2) as 'baseAmountRoi',
- ROUND(((t1.regimentalPromotionAmount-t2.regimentalPromotionAmount)/t2.regimentalPromotionAmount)*100,2) as
- 'regimentalPromotionAmountRoi'
- FROM(
- SELECT
- COUNT(DISTINCT promoter_id) as 'promoterCount',
- COUNT(DISTINCT item_id) as 'itemCount',
- COUNT(oid) as 'allNumber',
- IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
- IFNULL(SUM(order_amount), 0) AS 'orderAmount',
- IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
- 'regimentalPromotionAmount',
- IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) as 'baseAmount'
- FROM kuaishou_supply_chain
- WHERE stat_date >= #{startDate}
- AND stat_date <= #{endDate}
- AND stat_hour <= #{hour}
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND promoter_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- )t1
- LEFT JOIN (
- SELECT
- IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
- COUNT(oid)-IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) as 'inValidOrderNUm',
- IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) as 'baseAmount',
- IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
- 'regimentalPromotionAmount'
- FROM kuaishou_supply_chain
- WHERE stat_date >= #{lastTimeStart}
- AND stat_date <= #{lastTimeEnd}
- AND stat_hour <= #{hour}
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND promoter_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- )t2 on 1=1
- </select>
- <select id="selectOrderInfoBytedance" resultType="com.alibaba.fastjson.JSONObject">
- SELECT t1.*,
- ROUND(((t1.validOrderNUm-t2.validOrderNUm)/t2.validOrderNUm)*100,2) as 'validOrderNUmRoi',
- ROUND(((t1.allNumber-t1.validOrderNUm-t2.inValidOrderNUm)/t2.inValidOrderNUm)*100,2) as 'inValidOrderNUmRoi',
- ROUND(((t1.baseAmount-t2.baseAmount)/t2.baseAmount)*100,2) as 'baseAmountRoi',
- ROUND(((t1.regimentalPromotionAmount-t2.regimentalPromotionAmount)/t2.regimentalPromotionAmount)*100,2) as
- 'regimentalPromotionAmountRoi'
- FROM (
- SELECT
- COUNT(DISTINCT author_short_id) as 'promoterCount',
- COUNT(DISTINCT product_id) as 'itemCount',
- COUNT(order_id) as 'allNumber',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
- IFNULL(SUM(total_pay_amount), 0) AS 'orderAmount',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END), 0) AS 'baseAmount',
- IFNULL( sum(CASE
- WHEN flow_point != 'REFUND' and colonel_type != 2
- THEN colonel_estimated_commission
- WHEN flow_point != 'REFUND' and colonel_type = 2
- then second_estimated_commission
- ELSE 0 END) * 0.9,0) AS
- 'regimentalPromotionAmount',
- IFNULL( sum(CASE
- WHEN flow_point != 'REFUND' and colonel_type != 2
- THEN second_estimated_commission
- ELSE 0 END) ,0) AS 'secondEstimatedCommission'
- FROM ruixuan.bytedance_order_list
- WHERE pay_success_time >=#{startDate}
- AND pay_success_time <=#{endDate}
- AND pay_success_time_hour <=#{hour}
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND author_short_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- )t1
- LEFT JOIN (
- SELECT
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
- COUNT(order_id)-IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) as 'inValidOrderNUm',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END), 0) AS 'baseAmount',
- IFNULL( sum(CASE
- WHEN flow_point != 'REFUND' and colonel_type != 2
- THEN colonel_estimated_commission
- WHEN flow_point != 'REFUND' and colonel_type = 2
- then second_estimated_commission
- ELSE 0 END) * 0.9,0) AS
- 'regimentalPromotionAmount'
- FROM ruixuan.bytedance_order_list
- WHERE pay_success_time >=#{lastTimeStart}
- AND pay_success_time <=#{lastTimeEnd}
- AND pay_success_time_hour <=#{hour}
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND author_short_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- )t2 on 1 = 1
- </select>
- <select id="selectOrderInfoByItemIds" resultType="com.alibaba.fastjson.JSONObject">
- SELECT t1.*,
- CONCAT(IFNULL(ROUND(t1.sendCount / t1.allNumber * 100, 2),0), '%') as 'sendRate',
- ROUND(((t1.validOrderNUm-t2.validOrderNUm)/t2.validOrderNUm)*100,2) as 'validOrderNUmRoi',
- ROUND(((t1.allNumber-t1.validOrderNUm-t2.inValidOrderNUm)/t2.inValidOrderNUm)*100,2) as 'inValidOrderNUmRoi',
- ROUND(((t1.baseAmount-t2.baseAmount)/t2.baseAmount)*100,2) as 'baseAmountRoi',
- ROUND(((t1.regimentalPromotionAmount-t2.regimentalPromotionAmount)/t2.regimentalPromotionAmount)*100,2) as
- 'regimentalPromotionAmountRoi'
- FROM(
- SELECT
- COUNT(DISTINCT promoter_id) as 'promoterCount',
- COUNT(DISTINCT item_id) as 'itemCount',
- COUNT(oid) as 'allNumber',
- IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
- IFNULL(SUM(order_amount), 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}
- AND stat_hour <= #{hour}
- <if test='itemIds != null and itemIds.size() > 0'>
- AND item_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- )t1
- LEFT JOIN (
- SELECT
- IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
- COUNT(oid)-IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) as 'inValidOrderNUm',
- IFNULL(sum(base_amount), 0) as 'baseAmount',
- IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
- 'regimentalPromotionAmount'
- FROM kuaishou_supply_chain
- WHERE stat_date >= #{lastTimeStart}
- AND stat_date <= #{lastTimeEnd}
- AND stat_hour <= #{hour}
- <if test='itemIds != null and itemIds.size() > 0'>
- AND item_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- )t2 on 1=1
- </select>
- <select id="selectOrderInfoByItemIdsBytedance" resultType="com.alibaba.fastjson.JSONObject">
- SELECT t1.*,
- ROUND(((t1.validOrderNUm-t2.validOrderNUm)/t2.validOrderNUm)*100,2) as 'validOrderNUmRoi',
- ROUND(((t1.allNumber-t1.validOrderNUm-t2.inValidOrderNUm)/t2.inValidOrderNUm)*100,2) as 'inValidOrderNUmRoi',
- ROUND(((t1.baseAmount-t2.baseAmount)/t2.baseAmount)*100,2) as 'baseAmountRoi',
- ROUND(((t1.regimentalPromotionAmount-t2.regimentalPromotionAmount)/t2.regimentalPromotionAmount)*100,2) as
- 'regimentalPromotionAmountRoi'
- from (
- SELECT
- COUNT(DISTINCT author_short_id) as 'promoterCount',
- COUNT(DISTINCT product_id) as 'itemCount',
- COUNT(order_id) as 'allNumber',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END)/100, 0) AS 'baseAmount',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9 /100,0) AS
- 'regimentalPromotionAmount'
- FROM ruixuan.bytedance_order_list
- WHERE pay_success_time >= #{startDate}
- AND pay_success_time <= #{endDate}
- AND pay_success_time_hour <=#{hour}
- <if test='itemIds != null and itemIds.size() > 0'>
- AND product_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- )t1
- LEFT JOIN (
- SELECT
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
- COUNT(order_id)-IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) as 'inValidOrderNUm',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END)/100, 0) AS 'baseAmount',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9 /100,0) AS
- 'regimentalPromotionAmount'
- FROM ruixuan.bytedance_order_list
- WHERE pay_success_time >= #{lastTimeStart}
- AND pay_success_time <= #{lastTimeEnd}
- AND pay_success_time_hour <=#{hour}
- <if test='itemIds != null and itemIds.size() > 0'>
- AND product_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- )t2 on 1=1
- </select>
- <select id="selectOrderRate" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- count(oid) as 'allNumber',
- IFNULL(sum(order_amount),0) AS 'orderAmount'
- FROM kuaishou_supply_chain
- WHERE stat_date >= #{statDate}
- AND stat_date <= #{endDate}
- AND stat_hour <=#{hour}
- <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="selectOrderRateBytedance" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- count(order_id) as 'allNumber',
- IFNULL(sum(
- CASE
- WHEN flow_point != 'REFUND' THEN total_pay_amount
- ELSE 0
- END
- )/100,0) AS 'orderAmount'
- FROM ruixuan.bytedance_order_list
- WHERE pay_success_time >= #{statDate}
- AND pay_success_time <= #{endDate}
- <if test='hour != null'>
- AND pay_success_time_hour <=#{hour}
- </if>
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND author_short_id in
- <foreach collection="promoterIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- <if test='itemIds != null and itemIds.size() > 0'>
- AND product_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="getMonthOrderAmount" resultType="com.alibaba.fastjson.JSONObject">
- select t.* ,t2.valid_order_rate as 'validOrderRate',
- t2.valid_gmv_rate as 'validGmvRate'
- from (
- SELECT
- stat_date as 'date',
- DATE_FORMAT(stat_date, '%Y%m%d') as 'dateInt',
- count(1) AS 'orderCount',
- IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
- IFNULL(SUM(order_amount),0) AS 'orderAmount',
- IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) AS 'validOrderAmount',
- concat( round(IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) / count(1) * 100,2 ),'%') as
- 'validOrderCountRate',
- concat( round(IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END), 0) /IFNULL(SUM(
- order_amount),0) * 100,2 ),'%') as 'validOrderAmountRate',
- IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
- 'regimentalPromotionAmount',
- COUNT(DISTINCT promoter_id) as 'promoterCount'
- FROM kuaishou_supply_chain t1
- WHERE stat_date >= #{startLong}
- AND stat_date <= #{endLong}
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND promoter_id in
- <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY stat_date) t left join valid_order_gmv_rate t2
- on t.dateInt = t2.stat_date
- </select>
- <select id="getMonthOrderAmountBytedance" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,t2.valid_order_rate as 'validOrderRate', t2.valid_gmv_rate as 'validGmvRate'
- from(
- SELECT
- DATE_FORMAT(pay_success_time, '%Y-%m-%d') as 'date',
- pay_success_time as 'dateInt',
- count(1) AS 'orderCount',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
- IFNULL(SUM( total_pay_amount),0) AS 'orderAmount',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END),0) AS 'validOrderAmount',
- concat( round(IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) / count(1) * 100,2 ),'%') as
- 'validOrderCountRate',
- concat( round(IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END), 0) /IFNULL(SUM(
- total_pay_amount),0) * 100,2 ),'%') as 'validOrderAmountRate',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9 ,0) AS
- 'regimentalPromotionAmount',
- COUNT(DISTINCT author_short_id) as 'promoterCount'
- FROM ruixuan.bytedance_order_list
- WHERE pay_success_time >= #{startLong}
- AND pay_success_time <= #{endLong}
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND author_short_id in
- <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY pay_success_time) t left join ruixuan.bytedance_valid_order_gmv_rate t2
- on t.dateInt = t2.stat_date
- </select>
- <select id="getMonthOrderAmountByItems" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,t2.valid_order_rate as 'validOrderRate',
- t2.valid_gmv_rate as 'validGmvRate'
- from (
- SELECT
- stat_date as 'date',
- DATE_FORMAT(stat_date, '%Y%m%d') as 'dateInt',
- count(1) AS 'orderCount',
- IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
- IFNULL(SUM(order_amount),0) AS 'orderAmount',
- IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) AS 'validOrderAmount',
- concat( round(IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) / count(1) * 100,2 ),'%') as
- 'validOrderCountRate',
- concat( round(IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END), 0) /IFNULL(SUM(
- order_amount),0) * 100,2 ),'%') as 'validOrderAmountRate',
- IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
- 'regimentalPromotionAmount'
- FROM kuaishou_supply_chain
- WHERE stat_date >= #{IntStart}
- AND stat_date <= #{IntEnd}
- <if test='itemIds != null and itemIds.size() > 0'>
- AND item_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY stat_date) t left join valid_order_gmv_rate t2
- on t.dateInt = t2.stat_date
- </select>
- <select id="getMonthOrderAmountByItemsBytedance" resultType="com.alibaba.fastjson.JSONObject">
- select t.*, t2.valid_order_rate as 'validOrderRate',
- t2.valid_gmv_rate as 'validGmvRate'
- from (
- SELECT
- DATE_FORMAT(pay_success_time, '%Y-%m-%d') as 'date',
- pay_success_time as 'dateInt',
- count(1) AS 'orderCount',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END),0) AS 'orderAmount',
- concat( round(IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) / count(1) * 100,2 ),'%') as
- 'validOrderCountRate',
- concat( round(IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END), 0) /IFNULL(SUM(
- total_pay_amount),0) * 100,2 ),'%') as 'validOrderAmountRate',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
- 'regimentalPromotionAmount'
- FROM ruixuan.bytedance_order_list
- WHERE pay_success_time >= #{startLong}
- AND pay_success_time <= #{endLong}
- <if test='itemIds != null and itemIds.size() > 0'>
- AND product_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- GROUP BY pay_success_time) t left join ruixuan.bytedance_valid_order_gmv_rate t2
- on t.dateInt = t2.stat_date
- </select>
- <select id="getMonthOrderAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- t1.orderAmount,
- t1.regimentalPromotionAmount,
- CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
- CONCAT(IFNULL(ROUND(t2.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
- 'regimentalPromotionAmountRate'
- FROM
- (
- SELECT
- IFNULL(SUM(order_amount),0) AS 'orderAmount',
- IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount'
- 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 stat_date >= #{startLong}
- AND stat_date <= #{endLong}) t1
- LEFT JOIN
- (
- SELECT
- IFNULL(SUM(order_amount),0) AS 'orderAmount',
- IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount'
- 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 stat_date >= #{endLong})t2 ON 1=1
- </select>
- <select id="getMonthOrderAmountTotalBytedance" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- t1.orderAmount,
- t1.regimentalPromotionAmount,
- CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
- CONCAT(IFNULL(ROUND(t2.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
- 'regimentalPromotionAmountRate'
- FROM
- (
- SELECT
- IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
- 'regimentalPromotionAmount'
- FROM ruixuan.bytedance_order_list t1
- WHERE flow_point != 'REFUND'
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND author_short_id in
- <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- AND pay_success_time >= #{startLong}
- AND pay_success_time <= #{endLong}) t1
- LEFT JOIN
- (
- SELECT
- IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
- 'regimentalPromotionAmount'
- FROM ruixuan.bytedance_order_list t1
- WHERE flow_point != 'REFUND'
- <if test='promoterIds != null and promoterIds.size() > 0'>
- AND author_short_id in
- <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- AND pay_success_time >= #{toStartLong}
- AND pay_success_time <= #{endLong})t2 ON 1=1
- </select>
- <select id="getMonthOrderAmountTotalByItems" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- t1.orderAmount,
- t1.regimentalPromotionAmount,
- 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.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
- 'regimentalPromotionAmountRate'
- FROM
- (
- SELECT
- IFNULL(SUM(order_amount),0) AS 'orderAmount',
- IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount',
- 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 stat_date >= #{IntStart}
- AND stat_date <= #{IntEnd}
- )t1
- LEFT JOIN
- (
- SELECT
- IFNULL(SUM(order_amount),0) AS 'orderAmount',
- IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount',
- 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 stat_date = #{IntEnd}
- )t2 ON 1=1
- </select>
- <select id="getMonthOrderAmountTotalByItemsBytedance" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- t1.orderAmount,
- t1.regimentalPromotionAmount,
- 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.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
- 'regimentalPromotionAmountRate'
- FROM
- (
- SELECT
- IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
- 'regimentalPromotionAmount',
- COUNT(order_id) as 'orderCount'
- FROM ruixuan.bytedance_order_list t1
- WHERE flow_point != 'REFUND'
- <if test='itemIds != null and itemIds.size() > 0'>
- AND product_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- AND pay_success_time >= #{IntStart}
- AND pay_success_time <= #{IntEnd}
- )t1
- LEFT JOIN
- (
- SELECT
- IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
- IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
- 'regimentalPromotionAmount',
- COUNT(order_id) as 'orderCount'
- FROM ruixuan.bytedance_order_list t1
- WHERE flow_point != 'REFUND'
- <if test='itemIds != null and itemIds.size() > 0'>
- AND product_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- AND pay_success_time >= #{IntStart}
- AND pay_success_time <= #{IntEnd}
- )t2 ON 1=1
- </select>
- <select id="bdReportList" resultType="com.alibaba.fastjson.JSONObject">
- select
- t1.collectSampleId,
- t1.collectSampleName,
- t2.promoterCount,
- t3.sampleCount,
- round(t3.sampleCount / t2.promoterCount * 100, 2) as 'sampleRate',
- t2.promoterCount - t3.sampleCount as 'notSampleCount',
- t1.orderNum,
- t1.validOrderNum,
- t1.validOrderRate,
- t1.orderAmount,
- t1.regimentalPromotionAmount,
- t1.totalRegimentalSettleAmount,
- t4.sendTotalCount,
- t4.sendPromoterCount,
- t4.sendItemCount,
- t1.voucherOrderNum,
- t1.voucherValidOrderNum,
- t1.voucherOrderAmount,
- t1.voucherRegimentalPromotionAmount,
- t1.voucherTotalRegimentalSettleAmount,
- IFNULL(t5.promoters_count,'-') as 'promotersCount'
- from (
- select collect_sample_id as 'collectSampleId',
- collect_sample_name as 'collectSampleName',
- sum(order_num) as 'orderNum',
- IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_num ELSE 0 END), 0) AS 'voucherOrderNum',
- sum(valid_order_num) as 'validOrderNum',
- IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN valid_order_num ELSE 0 END), 0) AS 'voucherValidOrderNum',
- round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
- sum(order_amount) as 'orderAmount',
- IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_amount ELSE 0 END), 0) AS 'voucherOrderAmount',
- sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
- IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN regimental_promotion_amount ELSE 0 END), 0)
- AS'voucherRegimentalPromotionAmount',
- sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount',
- IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN total_regimental_settle_amount ELSE 0 END), 0) AS
- 'voucherTotalRegimentalSettleAmount'
- from promoter_item_order_count1
- where 1 = 1
- <if test="start != null and start != ''">
- and stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- <if test="collectSampleId != null and collectSampleId != ''">
- and collect_sample_id = #{collectSampleId}
- </if>
- group by collect_sample_id) t1
- left join (
- select user_id as 'userId',
- count(distinct promoter_id) as 'promoterCount'
- from kuaishou_promoter
- group by user_id) t2
- on t1.collectSampleId = t2.userId
- left join (
- select collect_sample_id as 'collectSampleId',
- count(distinct promoter_id) as 'sampleCount'
- from kuaishou_item_collect_samples
- where collect_sample_status > 2
- group by collect_sample_id) t3
- on t2.userId = t3.collectSampleId
- left join (
- select collect_sample_id as 'collectSampleId',
- count(1) as 'sendTotalCount',
- count(distinct promoter_id) as 'sendPromoterCount',
- count(distinct item_id) as 'sendItemCount'
- from kuaishou_item_collect_samples
- where collect_sample_status > 2
- <if test="collectSampleId != null and collectSampleId != ''">
- and collect_sample_id = #{collectSampleId}
- </if>
- <if test="start != null and start != ''">
- and create_time >= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
- %H:%i:%s')
- </if>
- <if test="end != null and end != ''">
- and create_time <= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
- </if>
- group by collect_sample_id
- ) t4
- on t1.collectSampleId = t4.collectSampleId
- left join (
- select user_id,promoters_count
- from user_promoters_count
- where media_id = 2
- ) t5
- on t1.collectSampleId = t5.user_id
- order by t1.orderNum desc
- </select>
- <select id="bdDetailList" resultType="com.alibaba.fastjson.JSONObject">
- select
- t1.promoterId,
- t1.promoterName,
- t1.promoterUrl,
- t2.sampleCount,
- t1.orderNum,
- t1.validOrderNum,
- t1.validOrderRate,
- t1.orderAmount,
- t1.regimentalPromotionAmount,
- t1.totalRegimentalSettleAmount
- from (
- select promoter_id as 'promoterId',
- promoter_name as 'promoterName',
- promoter_url as 'promoterUrl',
- sum(order_num) as 'orderNum',
- sum(valid_order_num) as 'validOrderNum',
- round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
- sum(order_amount) as 'orderAmount',
- sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
- sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
- from promoter_item_order_count1
- where 1 = 1
- <if test="start != null and start != ''">
- and stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- <if test="collectSampleId != null and collectSampleId != ''">
- and collect_sample_id = #{collectSampleId}
- </if>
- group by promoter_id) t1
- left join (
- select promoter_id as 'promoterId',
- count(distinct item_id) as 'sampleCount'
- from kuaishou_item_collect_samples
- where collect_sample_status > 2
- <if test="collectSampleId != null and collectSampleId != ''">
- and collect_sample_id = #{collectSampleId}
- </if>
- group by promoter_id) t2
- on t1.promoterId = t2.promoterId
- order by ${fieId} ${sort}
- </select>
- <select id="bdTotal" resultType="com.alibaba.fastjson.JSONObject">
- select
- t2.sampleCount,
- t1.orderNum,
- t1.validOrderNum,
- t1.validOrderRate,
- t1.orderAmount,
- t1.regimentalPromotionAmount,
- t1.totalRegimentalSettleAmount
- from (
- select
- sum(order_num) as 'orderNum',
- sum(valid_order_num) as 'validOrderNum',
- round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
- sum(order_amount) as 'orderAmount',
- sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
- sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
- from promoter_item_order_count1
- where 1 = 1
- <if test="start != null and start != ''">
- and stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- <if test="collectSampleId != null and collectSampleId != ''">
- and collect_sample_id = #{collectSampleId}
- </if>
- ) t1
- join (
- select
- count(distinct item_id) as 'sampleCount'
- from kuaishou_item_collect_samples
- where collect_sample_status > 2
- <if test="collectSampleId != null and collectSampleId != ''">
- and collect_sample_id = #{collectSampleId}
- </if>
- ) t2
- </select>
- <select id="exportBdDetail" resultType="com.alibaba.fastjson.JSONObject">
- select
- t1.promoterId,
- t1.promoterName,
- t1.promoterUrl,
- t2.sampleCount,
- t1.orderNum,
- t1.validOrderNum,
- t1.validOrderRate,
- t1.orderAmount,
- t1.regimentalPromotionAmount,
- t1.totalRegimentalSettleAmount
- from (
- select promoter_id as 'promoterId',
- promoter_name as 'promoterName',
- promoter_url as 'promoterUrl',
- sum(order_num) as 'orderNum',
- sum(valid_order_num) as 'validOrderNum',
- round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
- sum(order_amount) as 'orderAmount',
- sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
- sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
- from promoter_item_order_count1
- where 1 = 1
- <if test="start != null and start != ''">
- and stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- <if test="collectSampleId != null and collectSampleId != ''">
- and collect_sample_id = #{collectSampleId}
- </if>
- group by promoter_id) t1
- left join (
- select promoter_id as 'promoterId',
- count(distinct item_id) as 'sampleCount'
- from kuaishou_item_collect_samples
- where collect_sample_status > 2
- <if test="collectSampleId != null and collectSampleId != ''">
- and collect_sample_id = #{collectSampleId}
- </if>
- group by promoter_id) t2
- on t1.promoterId = t2.promoterId
- order by t1.orderNum desc
- </select>
- <select id="getUserList" resultType="com.alibaba.fastjson.JSONObject">
- select promoter_id as 'promoterId', group_concat(user_name) as 'userName'
- from kuaishou_promoter where promoter_id in
- <foreach collection="map.values" item="v" separator="," open="(" close=")">
- ${v}
- </foreach>
- GROUP BY promoter_id
- </select>
- <select id="getUserName" resultType="java.lang.String" parameterType="java.lang.Long">
- SELECT group_concat(user_name) AS 'userName'
- FROM kuaishou_promoter
- WHERE promoter_id = #{promoterId}
- </select>
- <select id="exportBdReportList" resultType="com.alibaba.fastjson.JSONObject">
- select
- t1.collectSampleId,
- t1.collectSampleName,
- t2.promoterCount,
- t3.sampleCount,
- round(t3.sampleCount / t2.promoterCount * 100, 2) as 'sampleRate',
- t2.promoterCount - t3.sampleCount as 'notSampleCount',
- t1.orderNum,
- t1.validOrderNum,
- t1.validOrderRate,
- round(t1.orderAmount / 100,2) as 'orderAmount',
- round(t1.regimentalPromotionAmount / 100 ,2 ) as 'regimentalPromotionAmount',
- round(t1.totalRegimentalSettleAmount / 100 , 2) as 'totalRegimentalSettleAmount',
- t4.sendTotalCount,
- t4.sendPromoterCount,
- t4.sendItemCount,
- t1.voucherOrderNum,
- t1.voucherValidOrderNum,
- round(t1.voucherOrderAmount / 100 ,2) as 'voucherOrderAmount',
- round(t1.voucherRegimentalPromotionAmount / 100 ,2) as 'voucherRegimentalPromotionAmount',
- round( t1.voucherTotalRegimentalSettleAmount / 100 , 2) as 'voucherTotalRegimentalSettleAmount'
- from (
- select collect_sample_id as 'collectSampleId',
- collect_sample_name as 'collectSampleName',
- sum(order_num) as 'orderNum',
- IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_num ELSE 0 END), 0) AS 'voucherOrderNum',
- sum(valid_order_num) as 'validOrderNum',
- IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN valid_order_num ELSE 0 END), 0) AS 'voucherValidOrderNum',
- round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
- sum(order_amount) as 'orderAmount',
- IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_amount ELSE 0 END), 0) AS 'voucherOrderAmount',
- sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
- IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN regimental_promotion_amount ELSE 0 END), 0)
- AS'voucherRegimentalPromotionAmount',
- sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount',
- IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN total_regimental_settle_amount ELSE 0 END), 0) AS
- 'voucherTotalRegimentalSettleAmount'
- from promoter_item_order_count1
- where 1 = 1
- <if test="start != null and start != ''">
- and stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- <if test="collectSampleId != null and collectSampleId != ''">
- and collect_sample_id = #{collectSampleId}
- </if>
- group by collect_sample_id) t1
- left join (
- select user_id as 'userId',
- count(distinct promoter_id) as 'promoterCount'
- from kuaishou_promoter
- group by user_id) t2
- on t1.collectSampleId = t2.userId
- left join (
- select collect_sample_id as 'collectSampleId',
- count(distinct promoter_id) as 'sampleCount'
- from kuaishou_item_collect_samples
- where collect_sample_status > 2
- group by collect_sample_id) t3
- on t2.userId = t3.collectSampleId
- left join (
- select collect_sample_id as 'collectSampleId',
- count(1) as 'sendTotalCount',
- count(distinct promoter_id) as 'sendPromoterCount',
- count(distinct item_id) as 'sendItemCount'
- from kuaishou_item_collect_samples
- where collect_sample_status > 2
- <if test="collectSampleId != null and collectSampleId != ''">
- and collect_sample_id = #{collectSampleId}
- </if>
- <if test="start != null and start != ''">
- and create_time >= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
- %H:%i:%s')
- </if>
- <if test="end != null and end != ''">
- and create_time <= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
- </if>
- group by collect_sample_id
- ) t4
- on t1.collectSampleId = t4.collectSampleId
- order by t1.orderNum desc
- </select>
- <select id="exportAdminReportList" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,
- t1.sendSampleCount,
- IFNULL(ROUND(((t.orderNum-t3.orderNum)/t3.orderNum)*100,2),0) as 'orderNumRoi'
- 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) * 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',
- 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',
- round( sum(case
- when t2.order_status != 80 then t2.regimental_promotion_amount
- else 0 end) / sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) * 100 ,2) as 'avgServiceRate'
- from kuaishou_item_bind_user t1
- left join kuaishou_supply_chain t2
- on t1.item_id = t2.item_id
- where t2.stat_hour <= #{hour}
- <if test="startDate != null and startDate != ''">
- and t2.stat_date >= DATE_FORMAT(#{startDate},'%Y%m%d')
- </if>
- <if test="endDate != null and endDate != ''">
- and t2.stat_date <= DATE_FORMAT(#{endDate},'%Y%m%d')
- </if>
- group by t1.user_id) t left join (
- select item_create_id,count(1) as 'sendSampleCount' from kuaishou_item_collect_samples
- where courier_number_time >= #{startDate}
- and courier_number_time <= #{endDate}
- group by item_create_id
- ) t1 on t.userId = t1.item_create_id
- left join (
- select t1.user_id as 'userId',
- count(t2.oid) as 'orderNum'
- from kuaishou_item_bind_user t1
- left join kuaishou_supply_chain t2
- on t1.item_id = t2.item_id
- where t2.stat_hour <= #{hour}
- <if test="lastTimeStart != null and lastTimeStart != ''">
- and t2.stat_date >= #{lastTimeStart}
- </if>
- <if test="lastTimeEnd != null and lastTimeEnd != ''">
- and t2.stat_date <= #{lastTimeEnd}
- </if>
- group by t1.user_id
- ) t3 on t.userId = t3.userId
- where 1 =1
- <if test="userId != null and userId != ''">
- and t.userId = #{userId}
- </if>
- order by t.orderNum desc
- </select>
- <select id="getSupplyChainCourtshipUserList" 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 (
- 'courtship',
- 'courtshipManager'
- )
- AND t3.status = 0
- GROUP BY t3.user_id
- ORDER BY t3.create_time ASC
- </select>
- <select id="adminReportListByBind" resultType="com.alibaba.fastjson.JSONObject">
- select * from (
- select t1.user_id as 'userId',
- t1.user_name as 'userName',
- count(distinct t1.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 then 1 else 0 end) as 'deliveryNum',
- 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 'shippingGreen',
- sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
- 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.send_status = 1
- 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',
- round( sum(case
- when t2.order_status != 80 then t2.regimental_promotion_amount
- else 0 end) / sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) ,5) as 'avgServiceRate'
- from kuaishou_item_list t1
- left join (select item_id,
- oid,
- order_status,
- send_status,
- pay_amount,
- regimental_promotion_amount,
- total_regimental_settle_amount
- from kuaishou_supply_chain
- where stat_date >= DATE_FORMAT(#{startDate},'%Y%m%d') ) t2
- on t1.item_id = t2.item_id
- where t1.create_time >= #{startDate}
- and t1.create_time <= #{endDate}
- <if test="userId != null and userId != ''">
- and t1.user_id = #{userId}
- </if>
- group by t1.user_id ) t left join (
- select t1.user_id,count(distinct courier_number) as 'sendSampleCount' from kuaishou_item_list t1 left join
- kuaishou_item_collect_samples t2
- on t1.item_id = t2.item_id
- where t1.create_time >= #{startDate}
- and t1.create_time <= #{endDate}
- and t2.courier_number_time >= #{startDate}
- group by t1.user_id
- ) t2 on t.userId = t2.user_id order by t.orderNum desc
- </select>
- <select id="exportAdminReportListByBind" resultType="com.alibaba.fastjson.JSONObject">
- select * from (
- select t1.user_id as 'userId',
- t1.user_name as 'userName',
- count(distinct t1.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) * 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',
- 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',
- round( sum(case
- when t2.order_status != 80 then t2.regimental_promotion_amount
- else 0 end) / sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) * 100 ,2) as 'avgServiceRate'
- from kuaishou_item_list t1
- left join (select item_id,
- oid,
- order_status,
- send_status,
- pay_amount,
- regimental_promotion_amount,
- total_regimental_settle_amount
- from kuaishou_supply_chain
- where stat_date >= DATE_FORMAT(#{startDate},'%Y%m%d') ) t2
- on t1.item_id = t2.item_id
- where t1.create_time >= #{startDate}
- and t1.create_time <= #{endDate}
- <if test="userId != null and userId != ''">
- and t1.userId = #{userId}
- </if>
- group by t1.user_id ) t left join (
- select t1.user_id,count(distinct courier_number) as 'sendSampleCount' from kuaishou_item_list t1 left join
- kuaishou_item_collect_samples t2
- on t1.item_id = t2.item_id
- where t1.create_time >= #{startDate}
- and t1.create_time <= #{endDate}
- and t2.courier_number_time >= #{startDate}
- group by t1.user_id
- ) t2 on t.userId = t2.user_id order by t.orderNum desc;
- </select>
- <select id="bdReportListV2" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,
- tt.promoterCount,
- ttt.sampleCount,
- tttt.sendTotalCount,
- tttt.sendPromoterCount,
- tttt.sendItemCount,
- IFNULL( ttttt.promoters_count,'-') as 'promotersCount',
- concat(round(ttt.sampleCount / tt.promoterCount * 100, 2), '%') as 'sampleRate',
- tt.promoterCount - ttt.sampleCount as 'notSampleCount'
- from (
- select t1.user_id as 'collectSampleId',
- t1.user_name as 'collectSampleName',
- sum(t2.orderNum) as 'orderNum',
- sum(t2.validOrderNum) as 'validOrderNum',
- concat(round( sum(t2.validOrderNum) / sum(t2.orderNum) * 100,
- 2),
- '%') as 'validOrderRate',
- round(sum(t2.orderAmount) / 100, 2) as 'orderAmount',
- round(sum(t2.regimentalPromotionAmount) / 100, 2) as 'regimentalPromotionAmount',
- round(sum(t2.totalRegimentalSettleAmount) / 100, 2) as 'totalRegimentalSettleAmount'
- from promoter_bind_channel_date t1
- left join (select promoter_id as 'promoter_id',
- stat_date as 'stat_date',
- count(oid) as 'orderNum',
- sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNum',
- sum(order_amount) as 'orderAmount',
- 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 stat_date >= #{start}
- and stat_date <= #{end}
- group by promoter_id, stat_date) t2
- on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
- where 1 = 1
- and t1.media_id = 2
- <if test="start != null and start != ''">
- and t1.stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t1.stat_date <= #{end}
- </if>
- <if test="collectSampleId != null and collectSampleId != ''">
- and t1.user_id = #{collectSampleId}
- </if>
- group by t1.user_id) t
- left join (select user_id,
- count(distinct promoter_id) as 'promoterCount'
- from kuaishou_promoter
- group by user_id) tt on t.collectSampleId = tt.user_id
- left join (select collect_sample_id as 'user_id',
- count(distinct promoter_id) as 'sampleCount'
- from kuaishou_item_collect_samples
- where collect_sample_status > 2
- group by collect_sample_id) ttt on t.collectSampleId = ttt.user_id
- left join (select collect_sample_id as 'user_id',
- count(1) as 'sendTotalCount',
- count(distinct promoter_id) as 'sendPromoterCount',
- count(distinct item_id) as 'sendItemCount'
- from kuaishou_item_collect_samples
- where collect_sample_status > 2
- <if test="collectSampleId != null and collectSampleId != ''">
- and collect_sample_id = #{collectSampleId}
- </if>
- <if test="start != null and start != ''">
- and create_time >= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
- %H:%i:%s')
- </if>
- <if test="end != null and end != ''">
- and create_time <= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
- </if>
- group by collect_sample_id) tttt on t.collectSampleId = tttt.user_id
- left join (select user_id, promoters_count
- from user_promoters_count
- where media_id = 2) ttttt
- on t.collectSampleId = ttttt.user_id
- where t.orderNum > 0
- order by t.orderNum desc
- </select>
- <select id="bdTotalV2" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,tt.sampleCount
- from (select t1.user_id as 'collectSampleId',
- t1.user_name as 'collectSampleName',
- count(t2.oid) as 'orderNum',
- sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNum',
- concat(round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100, 2), '%') as
- 'validOrderRate',
- round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
- 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'
- from promoter_bind_channel_date t1
- left join kuaishou_supply_chain t2
- on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
- where 1 = 1
- <if test="start != null and start != '' ">
- and t1.stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t1.stat_date <= #{end}
- </if>
- <if test="collectSampleId != null and collectSampleId != ''">
- and t1.user_id = #{collectSampleId}
- </if>
- group by t1.user_id) t
- join (select count(distinct item_id) as 'sampleCount'
- from kuaishou_item_collect_samples
- where collect_sample_status > 2
- and collect_sample_id = #{collectSampleId} ) tt
- </select>
- <select id="bdDetailListV2" resultType="com.alibaba.fastjson.JSONObject">
- select t.*, tt.sampleCount
- from (select t1.promoter_id as 'promoterId',
- t1.promoter_name as 'promoterName',
- t1.promoter_url as 'promoterUrl',
- count(t2.oid) as 'orderNum',
- sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNum',
- concat(round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100, 2), '%') as
- 'validOrderRate',
- round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
- 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'
- from promoter_bind_channel_date t1
- left join kuaishou_supply_chain t2
- on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
- where 1 = 1
- <if test="start != null and start != '' ">
- and t1.stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and t1.stat_date <= #{end}
- </if>
- <if test="collectSampleId != null and collectSampleId != ''">
- and t1.user_id = #{collectSampleId}
- </if>
- group by t1.promoter_id) t
- left join (select promoter_id,
- count(distinct item_id) as 'sampleCount'
- from kuaishou_item_collect_samples
- where collect_sample_status > 2
- and collect_sample_id = #{collectSampleId}
- group by promoter_id) tt on t.promoterId = tt.promoter_id
- where t.orderNum > 0
- order by ${fieId} ${sort}
- </select>
- <select id="bdReportListV2ByBind" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,
- tt.promoterCount,
- ttt.sampleCount,
- tttt.sendTotalCount,
- tttt.sendPromoterCount,
- tttt.sendItemCount,
- IFNULL(ttttt.promoters_count, '-') as 'promotersCount'
- from (select t1.user_id as 'collectSampleId',
- t1.user_name as 'collectSampleName',
- count(t2.oid) as 'orderNum',
- sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNum',
- concat(round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100, 2), '%') as
- 'validOrderRate',
- round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
- round(sum(t2.regimental_promotion_amount) / 100, 2) as 'regimentalPromotionAmount',
- round(sum(t2.total_regimental_settle_amount) / 100, 2) as 'totalRegimentalSettleAmount'
- from kuaishou_promoter t1
- left join(select *
- from kuaishou_supply_chain
- where stat_date >= #{bindStartDate}) t2
- on t1.promoter_id = t2.promoter_id
- where 1 = 1
- <if test="bindStartDate != null and bindStartDate != '' ">
- and t1.create_time >= str_to_date(concat(date_format(#{bindStartDate}, '%Y-%m-%d'), '00:00:01'),
- '%Y-%m-%d %H:%i:%s')
- </if>
- <if test="bindEndDate != null and bindEndDate != '' ">
- and t1.create_time <= str_to_date(concat(date_format(#{bindEndDate}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d
- %H:%i:%s')
- </if>
- <if test="collectSampleId != null and collectSampleId != '' ">
- and t1.user_id = #{collectSampleId}
- </if>
- group by t1.user_id) t
- left join (select user_id,
- count(distinct promoter_id) as 'promoterCount'
- from kuaishou_promoter
- where 1 = 1
- <if test="collectSampleId != null and collectSampleId != '' ">
- and user_id = #{collectSampleId}
- </if>
- group by user_id) tt on t.collectSampleId = tt.user_id
- left join (select collect_sample_id as 'user_id',
- count(distinct promoter_id) as 'sampleCount'
- from kuaishou_item_collect_samples
- where collect_sample_status > 2
- <if test="collectSampleId != null and collectSampleId != '' ">
- and collect_sample_id = #{collectSampleId}
- </if>
- group by collect_sample_id) ttt on t.collectSampleId = ttt.user_id
- left join (select collect_sample_id as 'user_id',
- count(1) as 'sendTotalCount',
- count(distinct promoter_id) as 'sendPromoterCount',
- count(distinct item_id) as 'sendItemCount'
- from kuaishou_item_collect_samples
- where collect_sample_status > 2
- <if test="collectSampleId != null and collectSampleId != '' ">
- and collect_sample_id = #{collectSampleId}
- </if>
- <if test="bindStartDate != null and bindStartDate != '' ">
- and create_time >= str_to_date(concat(date_format(#{bindStartDate}, '%Y-%m-%d'), '00:00:01'),
- '%Y-%m-%d %H:%i:%s')
- </if>
- <if test="bindEndDate != null and bindEndDate != '' ">
- and create_time <= str_to_date(concat(date_format(#{bindEndDate}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d
- %H:%i:%s')
- </if>
- group by collect_sample_id) tttt on t.collectSampleId = tttt.user_id
- left join (select user_id, promoters_count
- from user_promoters_count
- where media_id = 2
- <if test="collectSampleId != null and collectSampleId != '' ">
- and user_id = #{collectSampleId}
- </if>
- ) ttttt
- on t.collectSampleId = ttttt.user_id
- order by t.orderNum desc
- </select>
- <select id="exportBindOrder" resultType="com.alibaba.fastjson.JSONObject">
- select *, (case
- when t4.ccr_value is null or t4.ccr_value = 0
- then '0%'
- else concat(round(t4.ccr_value / 100, 2), '%')
- end
- ) as 'ccrValue',
- t4.shop_star as 'shopStar',
- t4.mall_logistics_score as 'mallLogisticsScore',
- t4.shop_score as 'shopScore',
- t4.mall_service_score as 'mallServiceScore',
- t4.mall_quality_score as 'mallQualityScore',
- (
- case when t5.is_presale = 1
- then '否'
- when t5.is_presale = 2
- then '是'
- else '-'
- end
- ) as 'isPresale'
- from (select item_id as 'itemId', item_title as 'itemTitle', user_id as 'userId', user_name as 'userName'
- from kuaishou_item_list
- where
- create_time >= str_to_date(concat(#{bindStartDate},' 00:00:01'),'%Y-%m-%d
- %H:%i:%s')
- and
- create_time <= str_to_date(concat(#{bindEndDate},' 23:59:59'),'%Y-%m-%d
- %H:%i:%s')
- ) t1
- left join
- (select item_id as 'itemId',
- 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',
- round(item_commission_rate / 10,2) as 'itemCommissionRate'
- from kuaishou_supply_chain
- where stat_date >= #{start}
- group by item_id) t2 on t1.itemId = t2.itemId
- left join kuaishou_activity_open_item_list t4
- on t1.itemId = t4.item_id
- left join kuaishou_item_list t5
- on t1.itemId = t5.item_id
- where 1 = 1
- <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="userId != null and userId != ''">
- and t1.userId = #{userId}
- </if>
- order by t2.orderNum desc
- </select>
- <insert id="replaceKuaishouActivityInfo">
- replace into kuaishou_activity_info(
- activity_id,
- regimental_id,
- activity_title,
- activity_type,
- activity_begin_time,
- activity_end_time,
- activity_status,
- apply_item_count,
- wait_audit_item_count,
- audit_pass_item_count
- )
- values
- <foreach collection="list" item="add" separator=",">
- (
- #{add.activityId},
- #{add.regimentalId},
- #{add.activityTitle},
- #{add.activityType},
- #{add.activityBeginTime},
- #{add.activityEndTime},
- #{add.activityStatus},
- #{add.applyItemCount},
- #{add.waitAuditItemCount},
- #{add.auditPassItemCount}
- )
- </foreach>
- </insert>
- <insert id="replaceMgsKuaishouActivityInfo">
- replace into miaogousi.kuaishou_activity_info(
- activity_id,
- regimental_id,
- activity_title,
- activity_type,
- activity_begin_time,
- activity_end_time,
- activity_status,
- apply_item_count,
- wait_audit_item_count,
- audit_pass_item_count
- )
- values
- <foreach collection="list" item="add" separator=",">
- (
- #{add.activityId},
- #{add.regimentalId},
- #{add.activityTitle},
- #{add.activityType},
- #{add.activityBeginTime},
- #{add.activityEndTime},
- #{add.activityStatus},
- #{add.applyItemCount},
- #{add.waitAuditItemCount},
- #{add.auditPassItemCount}
- )
- </foreach>
- </insert>
- <insert id="replaceRocketKuaishouActivityInfo">
- replace into rocket.kuaishou_activity_info(
- activity_id,
- regimental_id,
- activity_title,
- activity_type,
- activity_begin_time,
- activity_end_time,
- activity_status,
- apply_item_count,
- wait_audit_item_count,
- audit_pass_item_count
- )
- values
- <foreach collection="list" item="add" separator=",">
- (
- #{add.activityId},
- #{add.regimentalId},
- #{add.activityTitle},
- #{add.activityType},
- #{add.activityBeginTime},
- #{add.activityEndTime},
- #{add.activityStatus},
- #{add.applyItemCount},
- #{add.waitAuditItemCount},
- #{add.auditPassItemCount}
- )
- </foreach>
- </insert>
- <insert id="replaceYufuKuaishouActivityInfo">
- replace into yufu.kuaishou_activity_info(
- activity_id,
- regimental_id,
- activity_title,
- activity_type,
- activity_begin_time,
- activity_end_time,
- activity_status,
- apply_item_count,
- wait_audit_item_count,
- audit_pass_item_count
- )
- values
- <foreach collection="list" item="add" separator=",">
- (
- #{add.activityId},
- #{add.regimentalId},
- #{add.activityTitle},
- #{add.activityType},
- #{add.activityBeginTime},
- #{add.activityEndTime},
- #{add.activityStatus},
- #{add.applyItemCount},
- #{add.waitAuditItemCount},
- #{add.auditPassItemCount}
- )
- </foreach>
- </insert>
- <insert id="replaceYuxiuKuaishouActivityInfo">
- replace into yuxiu.kuaishou_activity_info(
- activity_id,
- regimental_id,
- activity_title,
- activity_type,
- activity_begin_time,
- activity_end_time,
- activity_status,
- apply_item_count,
- wait_audit_item_count,
- audit_pass_item_count
- )
- values
- <foreach collection="list" item="add" separator=",">
- (
- #{add.activityId},
- #{add.regimentalId},
- #{add.activityTitle},
- #{add.activityType},
- #{add.activityBeginTime},
- #{add.activityEndTime},
- #{add.activityStatus},
- #{add.applyItemCount},
- #{add.waitAuditItemCount},
- #{add.auditPassItemCount}
- )
- </foreach>
- </insert>
- <insert id="replaceZhishuiKuaishouActivityInfo">
- replace into zhishui.kuaishou_activity_info(
- activity_id,
- regimental_id,
- activity_title,
- activity_type,
- activity_begin_time,
- activity_end_time,
- activity_status,
- apply_item_count,
- wait_audit_item_count,
- audit_pass_item_count
- )
- values
- <foreach collection="list" item="add" separator=",">
- (
- #{add.activityId},
- #{add.regimentalId},
- #{add.activityTitle},
- #{add.activityType},
- #{add.activityBeginTime},
- #{add.activityEndTime},
- #{add.activityStatus},
- #{add.applyItemCount},
- #{add.waitAuditItemCount},
- #{add.auditPassItemCount}
- )
- </foreach>
- </insert>
- <update id="updateKuaishouSupplyChain">
- update ruixuan.kuaishou_supply_chain set send_status = 1
- where oid in
- <foreach collection="list" item="id" separator=","
- open="(" close=")">
- #{id}
- </foreach>
- </update>
- <update id="updateMgsKuaishouSupplyChain">
- update miaogousi.kuaishou_supply_chain set send_status = 1
- where oid in
- <foreach collection="list" item="id" separator=","
- open="(" close=")">
- #{id}
- </foreach>
- </update>
- <update id="updateRocketKuaishouSupplyChain">
- update rocket.kuaishou_supply_chain set send_status = 1
- where oid in
- <foreach collection="list" item="id" separator=","
- open="(" close=")">
- #{id}
- </foreach>
- </update>
- <update id="updateYufuKuaishouSupplyChain">
- update yufu.kuaishou_supply_chain set send_status = 1
- where oid in
- <foreach collection="list" item="id" separator=","
- open="(" close=")">
- #{id}
- </foreach>
- </update>
- <update id="updateYuxiuKuaishouSupplyChain">
- update yuxiu.kuaishou_supply_chain set send_status = 1
- where oid in
- <foreach collection="list" item="id" separator=","
- open="(" close=")">
- #{id}
- </foreach>
- </update>
- <update id="updateZhishuiKuaishouSupplyChain">
- update zhishui.kuaishou_supply_chain set send_status = 1
- where oid in
- <foreach collection="list" item="id" separator=","
- open="(" close=")">
- #{id}
- </foreach>
- </update>
- <update id="updateRuiXuanOrderRegimentalSettleAmount">
- UPDATE ruixuan.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus},
- <choose>
- <when test='cpsOrderStatus == 60 '>
- total_regimental_settle_amount = regimental_promotion_amount
- </when>
- <otherwise>
- send_status = 1
- </otherwise>
- </choose>
- WHERE oid = #{oid}
- </update>
- <update id="updateMgsOrderRegimentalSettleAmount">
- UPDATE miaogousi.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus},
- <choose>
- <when test='cpsOrderStatus == 60 '>
- total_regimental_settle_amount = regimental_promotion_amount
- </when>
- <otherwise>
- send_status = 1
- </otherwise>
- </choose>
- WHERE oid = #{oid}
- </update>
- <update id="updateRocketOrderRegimentalSettleAmount">
- UPDATE rocket.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus},
- <choose>
- <when test='cpsOrderStatus == 60 '>
- total_regimental_settle_amount = regimental_promotion_amount
- </when>
- <otherwise>
- send_status = 1
- </otherwise>
- </choose>
- WHERE oid = #{oid}
- </update>
- <update id="updateRocketOrderRegimentalSettleAmountCS">
- UPDATE rocket.kuaishou_supply_chain_ceshi
- SET order_status = #{cpsOrderStatus},
- <choose>
- <when test='cpsOrderStatus == 60 '>
- total_regimental_settle_amount = regimental_promotion_amount
- </when>
- <otherwise>
- send_status = 1
- </otherwise>
- </choose>
- WHERE oid = #{oid}
- </update>
- <update id="updateYufuOrderRegimentalSettleAmount">
- UPDATE yufu.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus},
- <choose>
- <when test='cpsOrderStatus == 60 '>
- total_regimental_settle_amount = regimental_promotion_amount
- </when>
- <otherwise>
- send_status = 1
- </otherwise>
- </choose>
- WHERE oid = #{oid}
- </update>
- <update id="updateYuxiuOrderRegimentalSettleAmount">
- UPDATE yuxiu.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus},
- <choose>
- <when test='cpsOrderStatus == 60 '>
- total_regimental_settle_amount = regimental_promotion_amount
- </when>
- <otherwise>
- send_status = 1
- </otherwise>
- </choose>
- WHERE oid = #{oid}
- </update>
- <update id="updateZhishuiOrderRegimentalSettleAmount">
- UPDATE zhishui.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus},
- <choose>
- <when test='cpsOrderStatus == 60 '>
- total_regimental_settle_amount = regimental_promotion_amount
- </when>
- <otherwise>
- send_status = 1
- </otherwise>
- </choose>
- WHERE oid = #{oid}
- </update>
- <update id="updateRuixuanOrder">
- UPDATE ruixuan.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus}
- WHERE oid = #{oid}
- </update>
- <update id="updateMgsOrder">
- UPDATE miaogousi.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus}
- WHERE oid = #{oid}
- </update>
- <update id="updateRocketOrder">
- UPDATE rocket.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus}
- WHERE oid = #{oid}
- </update>
- <update id="updateYufuOrder">
- UPDATE yufu.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus}
- WHERE oid = #{oid}
- </update>
- <update id="updateYuXiuOrder">
- UPDATE yuxiu.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus}
- WHERE oid = #{oid}
- </update>
- <update id="updateZhishuiOrder">
- UPDATE zhishui.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus}
- WHERE oid = #{oid}
- </update>
- <select id="getBytedanceOrderHourDataList" resultType="com.alibaba.fastjson.JSONObject">
- SELECT pay_success_time_hour AS 'hour', IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNum', IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END), 0) AS 'baseAmount'
- FROM ruixuan.bytedance_order_list
- WHERE pay_success_time = #{date}
- GROUP BY pay_success_time_hour
- ORDER BY pay_success_time_hour
- </select>
- <select id="getKuaishouOrderHourDataList" resultType="com.alibaba.fastjson.JSONObject">
- SELECT stat_hour AS 'hour', 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 'baseAmount'
- FROM kuaishou_supply_chain
- WHERE stat_date = #{date}
- GROUP BY stat_hour
- ORDER BY stat_hour
- </select>
- <select id="exportItemDetail" resultType="com.alibaba.fastjson.JSONObject">
- select t.*,tt.userName
- from (
- select
- promoter_nick_name as 'promoterNickName',
- promoter_id as 'promoterId',
- count(oid) as 'orderNum',
- round(sum(case when order_status != 80 then pay_amount else 0 end)/100,2 )as 'payAmount',
- round(regimental_promotion_rate / 10 ,2) 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) * 100,2) as 'validRadio',
- sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
- 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 'shippingGreen',
- sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
- 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 send_status = 1
- then 1 else 0 end) *100,2) 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 stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{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 left join (select promoter_id,group_concat(user_name) as 'userName',user_id as 'userId'
- from
- kuaishou_promoter group by promoter_id) tt
- on t.promoterId = tt.promoter_id
- where 1 =1
- <if test="userId != null and userId != ''">
- and tt.userId = #{userId}
- </if>
- order by t.orderNum desc
- </select>
- <select id="getKsChannelGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
- select stat_hour as 'time',
- <if test="hourType == 1 ">
- round(sum(pay_amount) / 100, 2) as 'charge'
- </if>
- <if test="hourType == 2 ">
- count(1) as 'charge'
- </if>
- from kuaishou_supply_chain
- where stat_date = #{date}
- <if test='userList != null and userList.size() > 0'>
- and promoter_id in (
- select promoter_id
- from kuaishou_promoter where
- 1 = 1
- and user_id in
- <foreach collection="userList" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- group by promoter_id
- )
- </if>
- group by stat_hour
- order by stat_hour asc;
- </select>
- <select id="getKsChannelGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- t1.time,
- ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
- FROM
- (
- select stat_hour as 'time',
- <if test="hourType == 1 ">
- round(sum(pay_amount) / 100, 2) as 'charge'
- </if>
- <if test="hourType == 2 ">
- count(1) as 'charge'
- </if>
- from kuaishou_supply_chain
- where stat_date = #{date}
- <if test='userList != null and userList.size() > 0'>
- and promoter_id in (
- select promoter_id
- from kuaishou_promoter where
- 1 = 1
- and user_id in
- <foreach collection="userList" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- group by promoter_id
- )
- </if>
- group by stat_hour
- ) t1
- LEFT JOIN
- (select stat_hour as 'time',
- <if test="hourType == 1 ">
- round(sum(pay_amount) / 100, 2) as 'charge'
- </if>
- <if test="hourType == 2 ">
- count(1) as 'charge'
- </if>
- from kuaishou_supply_chain
- where stat_date = DATE_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
- <if test='userList != null and userList.size() > 0'>
- and promoter_id in (
- select promoter_id
- from kuaishou_promoter where
- 1 = 1
- and user_id in
- <foreach collection="userList" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- group by promoter_id
- )
- </if>
- group by stat_hour
- ) t2 ON t1.time =t2.time
- ORDER BY `time`
- </select>
- <select id="getKsCourtshipGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
- select stat_hour as 'time',
- <if test="hourType == 1 ">
- round(sum(pay_amount) / 100, 2) as 'charge'
- </if>
- <if test="hourType == 2 ">
- count(1) as 'charge'
- </if>
- from kuaishou_supply_chain
- where stat_date = #{date}
- <if test='userList != null and userList.size() > 0'>
- and item_id in (
- select item_id
- from kuaishou_item_list where
- 1 = 1
- and user_id in
- <foreach collection="userList" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- group by item_id
- )
- </if>
- group by stat_hour
- order by stat_hour asc;
- </select>
- <select id="getKsCourtshipGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- t1.time,
- ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
- FROM
- ( select stat_hour as 'time',
- <if test="hourType == 1 ">
- round(sum(pay_amount) / 100, 2) as 'charge'
- </if>
- <if test="hourType == 2 ">
- count(1) as 'charge'
- </if>
- from kuaishou_supply_chain
- where stat_date = #{date}
- <if test='userList != null and userList.size() > 0'>
- and item_id in (
- select item_id
- from kuaishou_item_list where
- 1 = 1
- and user_id in
- <foreach collection="userList" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- group by item_id
- )
- </if>
- group by stat_hour
- ) t1
- LEFT JOIN
- (
- select stat_hour as 'time',
- <if test="hourType == 1 ">
- round(sum(pay_amount) / 100, 2) as 'charge'
- </if>
- <if test="hourType == 2 ">
- count(1) as 'charge'
- </if>
- from kuaishou_supply_chain
- where stat_date = DATE_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
- <if test='userList != null and userList.size() > 0'>
- and item_id in (
- select item_id
- from kuaishou_item_list where
- 1 = 1
- and user_id in
- <foreach collection="userList" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- group by item_id
- )
- </if>
- group by stat_hour
- ) t2 ON t1.time =t2.time
- ORDER BY `time`
- </select>
- <select id="getBytedanceChannelGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
- select pay_success_time_hour as 'time',
- <if test="hourType == 1 ">
- round(sum(total_pay_amount) / 100, 2) as 'charge'
- </if>
- <if test="hourType == 2 ">
- count(1) as 'charge'
- </if>
- from ruixuan.bytedance_order_list where pay_success_time = #{date}
- <if test='userList != null and userList.size() > 0'>
- and author_short_id in(
- select promoter_id
- from kuaishou_promoter where
- 1 = 1
- and user_id in
- <foreach collection="userList" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- group by promoter_id
- )
- </if>
- group by pay_success_time_hour
- order by pay_success_time_hour asc;
- </select>
- <select id="getBytedanceChannelGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- t1.time,
- ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
- FROM
- (
- select pay_success_time_hour as 'time',
- <if test="hourType == 1 ">
- round(sum(total_pay_amount) / 100, 2) as 'charge'
- </if>
- <if test="hourType == 2 ">
- count(1) as 'charge'
- </if>
- from ruixuan.bytedance_order_list where pay_success_time = #{date}
- <if test='userList != null and userList.size() > 0'>
- and author_short_id in(
- select promoter_id
- from kuaishou_promoter where
- 1 = 1
- and user_id in
- <foreach collection="userList" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- group by promoter_id
- )
- </if>
- group by pay_success_time_hour
- ) t1
- LEFT JOIN
- (
- select pay_success_time_hour as 'time',
- <if test="hourType == 1 ">
- round(sum(total_pay_amount) / 100, 2) as 'charge'
- </if>
- <if test="hourType == 2 ">
- count(1) as 'charge'
- </if>
- from ruixuan.bytedance_order_list
- where pay_success_time = DATE_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
- <if test='userList != null and userList.size() > 0'>
- and author_short_id in(
- select promoter_id
- from kuaishou_promoter where
- 1 = 1
- and user_id in
- <foreach collection="userList" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- group by promoter_id
- )
- </if>
- group by pay_success_time_hour
- ) t2 ON t1.time =t2.time
- ORDER BY `time`
- </select>
- <select id="getBytedanceCourtshipGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
- select pay_success_time_hour as 'time',
- <if test="hourType == 1 ">
- round(sum(total_pay_amount) / 100, 2) as 'charge'
- </if>
- <if test="hourType == 2 ">
- count(1) as 'charge'
- </if>
- from ruixuan.bytedance_order_list where pay_success_time = #{date}
- <if test='userList != null and userList.size() > 0'>
- and product_id in(
- select item_id
- from kuaishou_item_list where
- 1 = 1
- and user_id in
- <foreach collection="userList" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- group by item_id
- )
- </if>
- group by pay_success_time_hour
- order by pay_success_time_hour asc;
- </select>
- <select id="getBytedanceCourtshipGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
- SELECT
- t1.time,
- ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
- FROM
- (
- select pay_success_time_hour as 'time',
- <if test="hourType == 1 ">
- round(sum(total_pay_amount) / 100, 2) as 'charge'
- </if>
- <if test="hourType == 2 ">
- count(1) as 'charge'
- </if>
- from ruixuan.bytedance_order_list where pay_success_time = #{date}
- <if test='userList != null and userList.size() > 0'>
- and product_id in(
- select item_id
- from kuaishou_item_list where
- 1 = 1
- and user_id in
- <foreach collection="userList" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- group by item_id
- )
- </if>
- group by pay_success_time_hour
- ) t1
- LEFT JOIN
- (
- select pay_success_time_hour as 'time',
- <if test="hourType == 1 ">
- round(sum(total_pay_amount) / 100, 2) as 'charge'
- </if>
- <if test="hourType == 2 ">
- count(1) as 'charge'
- </if>
- from ruixuan.bytedance_order_list
- where pay_success_time = DATE_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
- <if test='userList != null and userList.size() > 0'>
- and product_id in(
- select item_id
- from kuaishou_item_list where
- 1 = 1
- and user_id in
- <foreach collection="userList" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- group by item_id
- )
- </if>
- group by pay_success_time_hour
- ) t2 ON t1.time =t2.time
- ORDER BY `time`
- </select>
- <insert id="replaceKuaiShouActivityOpenItemList">
- replace into kuaishou_activity_open_item_list(
- item_id,
- item_category_name,
- item_price,
- pre_activity_id,
- item_leaf_category_id,
- item_commission_rate,
- investment_promotion_rate,
- shop_id
- )
- values
- <foreach collection="list" item="li" separator=",">
- (
- #{li.itemId},
- #{li.itemCategoryName},
- #{li.itemPrice},
- #{li.preActivityId},
- #{li.itemLeafCategoryId},
- #{li.itemCommissionRate},
- #{li.investmentPromotionRate},
- #{li.shopId}
- )
- </foreach>
- </insert>
- <insert id="replaceMgsKuaiShouActivityOpenItemList">
- replace into miaogousi.kuaishou_activity_open_item_list(
- item_id,
- item_category_name,
- item_price,
- pre_activity_id,
- item_leaf_category_id,
- item_commission_rate,
- investment_promotion_rate,
- shop_id
- )
- values
- <foreach collection="list" item="li" separator=",">
- (
- #{li.itemId},
- #{li.itemCategoryName},
- #{li.itemPrice},
- #{li.preActivityId},
- #{li.itemLeafCategoryId},
- #{li.itemCommissionRate},
- #{li.investmentPromotionRate},
- #{li.shopId}
- )
- </foreach>
- </insert>
- <insert id="replaceRocketKuaiShouActivityOpenItemList">
- replace into rocket.kuaishou_activity_open_item_list(
- item_id,
- item_category_name,
- item_price,
- pre_activity_id,
- item_leaf_category_id,
- item_commission_rate,
- investment_promotion_rate,
- shop_id
- )
- values
- <foreach collection="list" item="li" separator=",">
- (
- #{li.itemId},
- #{li.itemCategoryName},
- #{li.itemPrice},
- #{li.preActivityId},
- #{li.itemLeafCategoryId},
- #{li.itemCommissionRate},
- #{li.investmentPromotionRate},
- #{li.shopId}
- )
- </foreach>
- </insert>
- <insert id="replaceYufuKuaiShouActivityOpenItemList">
- replace into yufu.kuaishou_activity_open_item_list(
- item_id,
- item_category_name,
- item_price,
- pre_activity_id,
- item_leaf_category_id,
- item_commission_rate,
- investment_promotion_rate,
- shop_id
- )
- values
- <foreach collection="list" item="li" separator=",">
- (
- #{li.itemId},
- #{li.itemCategoryName},
- #{li.itemPrice},
- #{li.preActivityId},
- #{li.itemLeafCategoryId},
- #{li.itemCommissionRate},
- #{li.investmentPromotionRate},
- #{li.shopId}
- )
- </foreach>
- </insert>
- <insert id="replaceYuxiuKuaiShouActivityOpenItemList">
- replace into yuxiu.kuaishou_activity_open_item_list(
- item_id,
- item_category_name,
- item_price,
- pre_activity_id,
- item_leaf_category_id,
- item_commission_rate,
- investment_promotion_rate,
- shop_id
- )
- values
- <foreach collection="list" item="li" separator=",">
- (
- #{li.itemId},
- #{li.itemCategoryName},
- #{li.itemPrice},
- #{li.preActivityId},
- #{li.itemLeafCategoryId},
- #{li.itemCommissionRate},
- #{li.investmentPromotionRate},
- #{li.shopId}
- )
- </foreach>
- </insert>
- <insert id="replaceZhishuiKuaiShouActivityOpenItemList">
- replace into zhishui.kuaishou_activity_open_item_list(
- item_id,
- item_category_name,
- item_price,
- pre_activity_id,
- item_leaf_category_id,
- item_commission_rate,
- investment_promotion_rate,
- shop_id
- )
- values
- <foreach collection="list" item="li" separator=",">
- (
- #{li.itemId},
- #{li.itemCategoryName},
- #{li.itemPrice},
- #{li.preActivityId},
- #{li.itemLeafCategoryId},
- #{li.itemCommissionRate},
- #{li.investmentPromotionRate},
- #{li.shopId}
- )
- </foreach>
- </insert>
- <select id="getKuaishouActivityInfoList" resultType="Long">
- SELECT DISTINCT activity_id
- FROM kuaishou_activity_info
- WHERE activity_status = 2
- OR activity_status = 3
- </select>
- <select id="getMgsKuaishouActivityInfoList" resultType="Long">
- SELECT DISTINCT activity_id
- FROM miaogousi.kuaishou_activity_info
- WHERE activity_status = 2
- OR activity_status = 3
- </select>
- <select id="getRocketKuaishouActivityInfoList" resultType="Long">
- SELECT DISTINCT activity_id
- FROM rocket.kuaishou_activity_info
- WHERE activity_status = 2
- OR activity_status = 3
- </select>
- <select id="getYufuKuaishouActivityInfoList" resultType="Long">
- SELECT DISTINCT activity_id
- FROM yufu.kuaishou_activity_info
- WHERE activity_status = 2
- OR activity_status = 3
- </select>
- <select id="getYuxiuKuaishouActivityInfoList" resultType="Long">
- SELECT DISTINCT activity_id
- FROM yuxiu.kuaishou_activity_info
- WHERE activity_status = 2
- OR activity_status = 3
- </select>
- <select id="getZhishuiKuaishouActivityInfoList" resultType="Long">
- SELECT DISTINCT activity_id
- FROM zhishui.kuaishou_activity_info
- WHERE activity_status = 2
- OR activity_status = 3
- </select>
- <select id="getPromoterId" resultType="com.alibaba.fastjson.JSONObject" parameterType="java.lang.Long">
- SELECT tag, proportion
- FROM promoter_tag
- WHERE promoter_id = #{promoterId}
- ORDER BY tag_oid_num DESC limit 5
- </select>
- <select id="shopList" resultType="com.alibaba.fastjson.JSONObject">
- select t2.seller_name as 'sellerName', t1.*
- from (select seller_id as 'sellerId',
- count(oid) as 'orderNum',
- round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
- 2) as 'payAmount',
- round(regimental_promotion_rate / 10, 2) 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) * 100,
- 2) as 'validRadio',
- sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
- 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 'shippingGreen',
- sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
- 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 send_status = 1
- then 1
- else 0 end) * 100,
- 2) as 'deliveryRadio'
- from kuaishou_supply_chain
- where 1 = 1
- <if test="start != null and start != ''">
- and stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- <if test="sellerId != null and sellerId != ''">
- and seller_id = #{sellerId}
- </if>
- <if test='itemIds != null and itemIds.size() > 0'>
- and item_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- group by seller_id) t1
- left join kuaishou_seller_info t2
- on t1.sellerId = t2.seller_id
- order by ${fieId} ${sort}
- </select>
- <select id="shopDetail" resultType="com.alibaba.fastjson.JSONObject">
- SELECT t1.*,
- (case
- when t2.ccr_value is null or t2.ccr_value = 0
- then '0%'
- else concat(round(t2.ccr_value / 100, 2), '%')
- end
- ) as 'ccrValue',
- (case
- when t2.ccr_value is null or t2.ccr_value = 0
- then 0
- else round(t2.ccr_value / 100 , 2)
- end
- ) as 'ccrInt',
- t3.userName
- from (
- select item_id as 'itemId',
- item_title as 'itemTitle',
- image_url as 'imageUrl',
- round(reserve_price / 100 , 2) as 'reservePrice',
- count(oid) as 'orderNum',
- round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
- 2) as 'payAmount',
- round(regimental_promotion_rate / 10, 2) 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) * 100,
- 2) as 'validRadio',
- sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
- 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 'shippingGreen',
- sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
- 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 send_status = 1
- then 1
- else 0 end) * 100,
- 2) as 'deliveryRadio'
- from kuaishou_supply_chain
- where 1 = 1
- <if test="start != null and start != ''">
- and stat_date >= #{start}
- </if>
- <if test="end != null and end != ''">
- and stat_date <= #{end}
- </if>
- <if test="sellerId != null and sellerId != ''">
- and seller_id = #{sellerId}
- </if>
- <if test="itemId != null and itemId != ''">
- and item_id = #{itemId}
- </if>
- <if test="itemTitle != null and itemTitle != ''">
- and item_title like concat(concat('%',#{itemTitle}),'%')
- </if>
- <if test='itemIds != null and itemIds.size() > 0'>
- and item_id in
- <foreach collection="itemIds" item="item" separator=","
- open="(" close=")">
- #{item}
- </foreach>
- </if>
- group by item_id) t1 left join kuaishou_activity_open_item_list t2
- on t1.itemId = t2.item_id
- LEFT JOIN (select item_id as 'itemId',user_name as 'userName' from kuaishou_item_list WHERE media_id = 2 group
- by item_id) t3
- on t1.itemId = t3.itemId
- order by t1.orderNum desc
- </select>
- <select id="getItemIdsByUserId" resultType="java.lang.Long" parameterType="java.lang.Long">
- SELECT item_id
- FROM kuaishou_item_list
- WHERE user_id = #{userId}
- GROUP BY item_id
- </select>
- <select id="getItemIdsByDeptId" resultType="java.lang.Long" parameterType="java.lang.Long">
- SELECT item_id
- FROM kuaishou_item_list
- WHERE user_id IN (SELECT sys_user.user_id
- FROM sys_user
- WHERE dept_id = #{deptId})
- GROUP BY item_id
- </select>
- <update id="updateKuaiShouActivityOpenItemList">
- UPDATE ruixuan.kuaishou_activity_open_item_list
- SET shop_star = #{shopStar},
- mall_logistics_score = #{mallLogisticsScore},
- shop_score = #{shopScore},
- mall_service_score = #{mallServiceScore},
- mall_quality_score = #{mallQualityScore},
- base_order_status = #{baseOrderStatus},
- ccr_value = #{ccrValue},
- shop_title = #{shopTitle},
- store_score = #{storeScore}
- where item_id = #{itemId}
- </update>
- <update id="updateMgsKuaiShouActivityOpenItemList">
- UPDATE miaogousi.kuaishou_activity_open_item_list
- SET shop_star = #{shopStar},
- mall_logistics_score = #{mallLogisticsScore},
- shop_score = #{shopScore},
- mall_service_score = #{mallServiceScore},
- mall_quality_score = #{mallQualityScore},
- base_order_status = #{baseOrderStatus},
- ccr_value = #{ccrValue},
- shop_title = #{shopTitle},
- store_score = #{storeScore}
- where item_id = #{itemId}
- </update>
- <update id="updateRocketKuaiShouActivityOpenItemList">
- update rocket.kuaishou_activity_open_item_list
- set shop_star = #{shopStar},
- mall_logistics_score = #{mallLogisticsScore},
- shop_score = #{shopScore},
- mall_service_score = #{mallServiceScore},
- mall_quality_score = #{mallQualityScore},
- base_order_status = #{baseOrderStatus},
- ccr_value = #{ccrValue},
- shop_title = #{shopTitle},
- store_score = #{storeScore}
- where item_id = #{itemId}
- </update>
- <update id="updateYufuKuaiShouActivityOpenItemList">
- UPDATE yufu.kuaishou_activity_open_item_list
- SET shop_star = #{shopStar},
- mall_logistics_score = #{mallLogisticsScore},
- shop_score = #{shopScore},
- mall_service_score = #{mallServiceScore},
- mall_quality_score = #{mallQualityScore},
- base_order_status = #{baseOrderStatus},
- ccr_value = #{ccrValue},
- shop_title = #{shopTitle},
- store_score = #{storeScore}
- where item_id = #{itemId}
- </update>
- <update id="updateYuxiuKuaiShouActivityOpenItemList">
- UPDATE yuxiu.kuaishou_activity_open_item_list
- SET shop_star = #{shopStar},
- mall_logistics_score = #{mallLogisticsScore},
- shop_score = #{shopScore},
- mall_service_score = #{mallServiceScore},
- mall_quality_score = #{mallQualityScore},
- base_order_status = #{baseOrderStatus},
- ccr_value = #{ccrValue},
- shop_title = #{shopTitle},
- store_score = #{storeScore}
- where item_id = #{itemId}
- </update>
- <update id="updateZhishuiKuaiShouActivityOpenItemList">
- UPDATE zhishui.kuaishou_activity_open_item_list
- SET shop_star = #{shopStar},
- mall_logistics_score = #{mallLogisticsScore},
- shop_score = #{shopScore},
- mall_service_score = #{mallServiceScore},
- mall_quality_score = #{mallQualityScore},
- base_order_status = #{baseOrderStatus},
- ccr_value = #{ccrValue},
- shop_title = #{shopTitle},
- store_score = #{storeScore}
- where item_id = #{itemId}
- </update>
- <insert id="replaceOne">
- replace into
- <choose>
- <when test='ownership == null '>
- kuaishou_supply_chain_ceshi
- </when>
- <otherwise>
- ${ownership}.kuaishou_supply_chain_ceshi
- </otherwise>
- </choose>
- (
- regimental_id,
- oid,
- item_id,
- item_title,
- reserve_price,
- image_url,
- order_status,
- order_create_time,
- send_status,
- settlement_biz_type,
- settlement_biz_type_desc,
- send_time,
- recv_time,
- seller_id,
- promoter_id,
- promoter_nick_name,
- activity_id,
- order_amount,
- pay_amount,
- regimental_promotion_rate,
- share_rate,
- base_amount,
- service_amount,
- regimental_promotion_amount,
- total_regimental_settle_amount,
- stat_date,
- stat_hour,
- item_commission_rate,
- second_activity_user_id,
- second_activity_id,
- seller_nick_name,
- sku_id,
- num,
- expend_regimental_settle_amount,
- expend_estimate_settle_amount,
- expend_regimental_promotion_rate,
- excitation_income,
- service_income,
- fund_type,
- second_service_amount,
- promoter_commission_rate
- )
- value
- (
- #{supplyChain.regimentalId},
- #{supplyChain.oid},
- #{supplyChain.itemId},
- #{supplyChain.itemTitle},
- #{supplyChain.reservePrice},
- #{supplyChain.imageUrl},
- #{supplyChain.orderStatus},
- #{supplyChain.orderCreateTime},
- #{supplyChain.sendStatus},
- #{supplyChain.settlementBizType},
- #{supplyChain.settlementBizTypeDesc},
- #{supplyChain.sendTime},
- #{supplyChain.recvTime},
- #{supplyChain.sellerId},
- #{supplyChain.promoterId},
- #{supplyChain.promoterNickName},
- #{supplyChain.activityId},
- #{supplyChain.orderAmount},
- #{supplyChain.payAmount},
- #{supplyChain.regimentalPromotionRate},
- #{supplyChain.shareRate},
- #{supplyChain.baseAmount},
- #{supplyChain.serviceAmount},
- #{supplyChain.regimentalPromotionAmount},
- #{supplyChain.totalRegimentalSettleAmount},
- #{supplyChain.statDate},
- #{supplyChain.statHour},
- #{supplyChain.itemCommissionRate},
- #{supplyChain.secondActivityUserId},
- #{supplyChain.secondActivityId},
- #{supplyChain.sellerNickName},
- #{supplyChain.skuId},
- #{supplyChain.num},
- #{supplyChain.expendRegimentalSettleAmount},
- #{supplyChain.expendEstimateSettleAmount},
- #{supplyChain.expendRegimentalPromotionRate},
- #{supplyChain.excitationIncome},
- #{supplyChain.serviceIncome},
- #{supplyChain.fundType},
- #{supplyChain.secondServiceAmount},
- #{supplyChain.promoterCommissionRate}
- )
- </insert>
- <insert id="replaceBatchOrder">
- replace into
- <choose>
- <when test='ownership == null '>
- kuaishou_supply_chain_ceshi
- </when>
- <otherwise>
- ${ownership}.kuaishou_supply_chain_ceshi
- </otherwise>
- </choose>
- (
- regimental_id,
- oid,
- item_id,
- item_title,
- reserve_price,
- image_url,
- order_status,
- order_create_time,
- send_status,
- settlement_biz_type,
- settlement_biz_type_desc,
- send_time,
- recv_time,
- seller_id,
- promoter_id,
- promoter_nick_name,
- activity_id,
- order_amount,
- pay_amount,
- regimental_promotion_rate,
- share_rate,
- base_amount,
- service_amount,
- regimental_promotion_amount,
- total_regimental_settle_amount,
- stat_date,
- stat_hour,
- item_commission_rate,
- second_activity_user_id,
- second_activity_id,
- seller_nick_name,
- sku_id,
- num,
- expend_regimental_settle_amount,
- expend_estimate_settle_amount,
- expend_regimental_promotion_rate,
- excitation_income,
- service_income,
- fund_type,
- second_service_amount,
- promoter_commission_rate
- )
- values
- <foreach collection="supplyChainList" item="supplyChain" separator=",">
- (
- #{supplyChain.regimentalId},
- #{supplyChain.oid},
- #{supplyChain.itemId},
- #{supplyChain.itemTitle},
- #{supplyChain.reservePrice},
- #{supplyChain.imageUrl},
- #{supplyChain.orderStatus},
- #{supplyChain.orderCreateTime},
- #{supplyChain.sendStatus},
- #{supplyChain.settlementBizType},
- #{supplyChain.settlementBizTypeDesc},
- #{supplyChain.sendTime},
- #{supplyChain.recvTime},
- #{supplyChain.sellerId},
- #{supplyChain.promoterId},
- #{supplyChain.promoterNickName},
- #{supplyChain.activityId},
- #{supplyChain.orderAmount},
- #{supplyChain.payAmount},
- #{supplyChain.regimentalPromotionRate},
- #{supplyChain.shareRate},
- #{supplyChain.baseAmount},
- #{supplyChain.serviceAmount},
- #{supplyChain.regimentalPromotionAmount},
- #{supplyChain.totalRegimentalSettleAmount},
- #{supplyChain.statDate},
- #{supplyChain.statHour},
- #{supplyChain.itemCommissionRate},
- #{supplyChain.secondActivityUserId},
- #{supplyChain.secondActivityId},
- #{supplyChain.sellerNickName},
- #{supplyChain.skuId},
- #{supplyChain.num},
- #{supplyChain.expendRegimentalSettleAmount},
- #{supplyChain.expendEstimateSettleAmount},
- #{supplyChain.expendRegimentalPromotionRate},
- #{supplyChain.excitationIncome},
- #{supplyChain.serviceIncome},
- #{supplyChain.fundType},
- #{supplyChain.secondServiceAmount},
- #{supplyChain.promoterCommissionRate}
- )
- </foreach>
- </insert>
- </mapper>
|