| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936 |
- <?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.shop_star as 'shopStar',
- t3.mall_logistics_score as 'mallLogisticsScore',
- t3.shop_score as 'shopScore',
- t3.mall_service_score as 'mallServiceScore',
- t3.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 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.shop_star as 'shopStar',
- t3.mall_logistics_score as 'mallLogisticsScore',
- t3.shop_score as 'shopScore',
- t3.mall_service_score as 'mallServiceScore',
- t3.mall_quality_score as 'mallQualityScore'
- 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'
- 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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>
- <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="updateRuiXuanOrderRegimentalSettleAmount">
- UPDATE ruixuan.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus},
- total_regimental_settle_amount = regimental_promotion_amount
- WHERE oid = #{oid}
- </update>
- <update id="updateMgsOrderRegimentalSettleAmount">
- UPDATE miaogousi.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus},
- total_regimental_settle_amount = regimental_promotion_amount
- WHERE oid = #{oid}
- </update>
- <update id="updateRocketOrderRegimentalSettleAmount">
- UPDATE rocket.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus},
- total_regimental_settle_amount = regimental_promotion_amount
- WHERE oid = #{oid}
- </update>
- <update id="updateYufuOrderRegimentalSettleAmount">
- UPDATE yufu.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus},
- total_regimental_settle_amount = regimental_promotion_amount
- WHERE oid = #{oid}
- </update>
- <update id="updateYuxiuOrderRegimentalSettleAmount">
- UPDATE yuxiu.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus},
- total_regimental_settle_amount = regimental_promotion_amount
- 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>
- <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 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',
- round(sum(pay_amount) / 100, 2) as 'charge' 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',
- round(sum(pay_amount) / 100, 2) as 'charge' 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',
- round(sum(pay_amount) / 100, 2) as 'charge' 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',
- round(sum(pay_amount) / 100, 2) as 'charge'
- 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',
- round(sum(pay_amount) / 100, 2) as 'charge'
- 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',
- round(sum(pay_amount) / 100, 2) as 'charge'
- 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',
- round(sum(total_pay_amount) / 100, 2) as 'charge' from 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',
- round(sum(total_pay_amount) / 100, 2) as 'charge' from 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',
- round(sum(total_pay_amount) / 100, 2) as 'charge' from 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',
- round(sum(total_pay_amount) / 100, 2) as 'charge' from 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',
- round(sum(total_pay_amount) / 100, 2) as 'charge' from 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',
- round(sum(total_pay_amount) / 100, 2) as 'charge' from 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
- )
- values
- <foreach collection="list" item="li" separator=",">
- (
- #{li.itemId},
- #{li.itemCategoryName},
- #{li.itemPrice},
- #{li.preActivityId},
- #{li.itemLeafCategoryId},
- #{li.itemCommissionRate},
- #{li.investmentPromotionRate}
- )
- </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
- )
- values
- <foreach collection="list" item="li" separator=",">
- (
- #{li.itemId},
- #{li.itemCategoryName},
- #{li.itemPrice},
- #{li.preActivityId},
- #{li.itemLeafCategoryId},
- #{li.itemCommissionRate},
- #{li.investmentPromotionRate}
- )
- </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
- )
- values
- <foreach collection="list" item="li" separator=",">
- (
- #{li.itemId},
- #{li.itemCategoryName},
- #{li.itemPrice},
- #{li.preActivityId},
- #{li.itemLeafCategoryId},
- #{li.itemCommissionRate},
- #{li.investmentPromotionRate}
- )
- </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
- )
- values
- <foreach collection="list" item="li" separator=",">
- (
- #{li.itemId},
- #{li.itemCategoryName},
- #{li.itemPrice},
- #{li.preActivityId},
- #{li.itemLeafCategoryId},
- #{li.itemCommissionRate},
- #{li.investmentPromotionRate}
- )
- </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
- )
- values
- <foreach collection="list" item="li" separator=",">
- (
- #{li.itemId},
- #{li.itemCategoryName},
- #{li.itemPrice},
- #{li.preActivityId},
- #{li.itemLeafCategoryId},
- #{li.itemCommissionRate},
- #{li.investmentPromotionRate}
- )
- </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="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},
- 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},
- 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},
- 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},
- store_score = #{storeScore}
- where item_id = #{itemId}
- </update>
- <update id="updateYuXiuOrder">
- UPDATE yuxiu.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus}
- WHERE oid = #{oid}
- </update>
- <update id="updateYuXiuOrderRegimentalSettleAmount">
- UPDATE yuxiu.kuaishou_supply_chain
- SET order_status = #{cpsOrderStatus},
- total_regimental_settle_amount = regimental_promotion_amount
- WHERE oid = #{oid}
- </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},
- store_score = #{storeScore}
- where item_id = #{itemId}
- </update>
- </mapper>
|