SupplyChainMapper.xml 168 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruixuan.isc.mapper.SupplyChainMapper">
  6. <insert id="bindUser">
  7. INSERT INTO kuaishou_item_bind_user(item_id, user_id, user_name)
  8. VALUE
  9. (#{itemId},#{userId},#{nikeName})
  10. </insert>
  11. <update id="updateOrder">
  12. UPDATE kuaishou_supply_chain
  13. SET order_status = #{cpsOrderStatus}
  14. WHERE oid = #{oid}
  15. </update>
  16. <update id="updateOrderRegimentalSettleAmount">
  17. UPDATE kuaishou_supply_chain
  18. SET order_status = #{cpsOrderStatus},
  19. total_regimental_settle_amount = regimental_promotion_amount
  20. WHERE oid = #{oid}
  21. </update>
  22. <update id="updateItem">
  23. UPDATE kuaishou_item_list
  24. SET activity_item_status = #{status}
  25. WHERE item_id = #{itemId}
  26. </update>
  27. <delete id="unbindUser" parameterType="java.lang.Long">
  28. DELETE
  29. FROM kuaishou_item_bind_user
  30. WHERE item_id = #{itemId}
  31. </delete>
  32. <select id="getOrderList" resultType="com.alibaba.fastjson.JSONObject">
  33. select t.*,t2.userName,
  34. IFNULL(ROUND(((t.orderNum-t3.orderNum)/t3.orderNum)*100,2),0) as 'orderNumRoi'
  35. from (
  36. select promoter_id as 'promoterId',
  37. promoter_nick_name as 'promoterNickName',
  38. count(oid) as 'orderNum',
  39. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  40. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  41. sum(pay_amount) as 'payAmount',
  42. sum(case when order_status != 80 then pay_amount else 0 end) as 'validPayAmount',
  43. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  44. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  45. then 1 else 0 end),4) as 'shippingGreen',
  46. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  47. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  48. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when send_status = 1
  49. then 1 else 0 end),4) as 'deliveryRadio',
  50. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount'
  51. from kuaishou_supply_chain
  52. where stat_hour &lt;= #{hour}
  53. <if test="start != null and start != ''">
  54. and stat_date &gt;= #{start}
  55. </if>
  56. <if test="end != null and end != ''">
  57. and stat_date &lt;= #{end}
  58. </if>
  59. <if test="promoterId != null and promoterId != ''">
  60. and promoter_id = #{promoterId}
  61. </if>
  62. <if test="promoterNickName != null and promoterNickName != ''">
  63. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  64. </if>
  65. group by promoter_id
  66. ) t left join (
  67. select promoter_id as 'promoterId',group_concat(user_name) as 'userName' from kuaishou_promoter where media_id =
  68. 2
  69. group by promoter_id
  70. ) t2 on t.promoterId = t2.promoterId
  71. left join (
  72. select promoter_id as 'promoterId',
  73. count(oid) as 'orderNum'
  74. from kuaishou_supply_chain
  75. where stat_hour &lt;= #{hour}
  76. <if test="lastTimeStart != null and lastTimeStart != ''">
  77. and stat_date &gt;= #{lastTimeStart}
  78. </if>
  79. <if test="lastTimeEnd != null and lastTimeEnd != ''">
  80. and stat_date &lt;= #{lastTimeEnd}
  81. </if>
  82. <if test="promoterId != null and promoterId != ''">
  83. and promoter_id = #{promoterId}
  84. </if>
  85. <if test="promoterNickName != null and promoterNickName != ''">
  86. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  87. </if>
  88. group by promoter_id
  89. ) t3 on t.promoterId = t3.promoterId
  90. order by t.orderNum desc
  91. </select>
  92. <select id="getTopOrders" resultType="com.alibaba.fastjson.JSONObject">
  93. select *
  94. from
  95. (select item_id as 'itemId',
  96. item_title as 'itemTitle',
  97. image_url as 'imageUrl',
  98. count(oid) as 'orderNum'
  99. from kuaishou_supply_chain
  100. where promoter_id = #{promoterId}
  101. <if test="start != null and start != ''">
  102. and stat_date &gt;= #{start}
  103. </if>
  104. <if test="end != null and end != ''">
  105. and stat_date &lt;= #{end}
  106. </if>
  107. group by item_id) t
  108. order by t.orderNum desc limit 3
  109. </select>
  110. <select id="anchorOrderDetail" resultType="com.alibaba.fastjson.JSONObject">
  111. select t.*,
  112. t2.status,
  113. (
  114. case
  115. when t3.activity_item_status = 1 then '待审核'
  116. when t3.activity_item_status = 2 then '已上架'
  117. when t3.activity_item_status = 3 then '审核拒绝'
  118. when t3.activity_item_status = 4 then '活动失效'
  119. when t3.activity_item_status = 5 then '商品下架'
  120. else ''
  121. end
  122. ) as 'activityItemStatus'
  123. from (select
  124. item_title as 'itemTitle',
  125. item_id as 'itemId',
  126. reserve_price as 'reservePrice',
  127. image_url 'imageUrl',
  128. count(oid) as 'orderNum',
  129. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  130. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  131. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  132. regimental_promotion_rate as 'regimentalPromotionRate',
  133. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  134. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  135. then 1 else 0 end),4) as 'shippingGreen',
  136. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  137. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  138. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when send_status = 1
  139. then 1 else 0 end),4) as 'deliveryRadio'
  140. from kuaishou_supply_chain
  141. where 1= 1
  142. <if test="promoterId != null and promoterId != ''">
  143. and promoter_id = #{promoterId}
  144. </if>
  145. <if test="start != null and start != ''">
  146. and stat_date &gt;= #{start}
  147. </if>
  148. <if test="end != null and end != ''">
  149. and stat_date &lt;= #{end}
  150. </if>
  151. <if test="itemId != null and itemId != ''">
  152. and item_id = #{itemId}
  153. </if>
  154. <if test="itemTitle != null and itemTitle != ''">
  155. and item_title like concat(concat('%',#{itemTitle}),'%')
  156. </if>
  157. group by item_id) t left join ( select item_id as 'itemId', collect_sample_status as 'status' from
  158. kuaishou_item_collect_samples where promoter_id = #{promoterId}) t2
  159. on t.itemId = t2.itemId
  160. left join kuaishou_item_list t3
  161. on t.itemId = t3.item_id
  162. order by t.orderNum desc
  163. </select>
  164. <select id="orderStatistics" resultType="com.alibaba.fastjson.JSONObject">
  165. select stat_date as 'date',
  166. count(t.oid) as 'orderNum'
  167. from (select oid,
  168. stat_date
  169. from kuaishou_supply_chain
  170. where 1 = 1
  171. <if test="promoterId != null and promoterId != ''">
  172. and promoter_id = #{promoterId}
  173. </if>
  174. <if test="start != null and start != ''">
  175. and stat_date &gt;= #{start}
  176. </if>
  177. <if test="end != null and end != ''">
  178. and stat_date &lt;= #{end}
  179. </if>
  180. ) t
  181. group by stat_date
  182. order by stat_date asc
  183. </select>
  184. <select id="itemList" resultType="com.alibaba.fastjson.JSONObject">
  185. select *
  186. from (
  187. select
  188. t2.user_id as 'userId',
  189. t2.user_name as 'userName',
  190. t1.item_id as 'itemId',
  191. t1.reserve_price as 'reservePrice',
  192. t1.item_title as 'itemTitle',
  193. t1.image_url as 'imageUrl',
  194. count(t1.oid) as 'orderNum',
  195. IFNULL(ROUND(((count(t1.oid)-t6.orderNum)/t6.orderNum)*100,2),0) as 'orderNumRoi',
  196. sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  197. round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid), 4) as 'validRadio',
  198. sum(case when t1.send_status = 1 then 1 else 0 end) as 'deliveryNum',
  199. round(sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) / sum(case when
  200. t1.order_status != 80
  201. then 1 else 0 end),4) as 'shippingGreen',
  202. sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  203. sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  204. round(sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) / sum(case when
  205. send_status = 1 then 1 else 0 end), 4) as 'deliveryRadio',
  206. t1.item_commission_rate as 'itemCommissionRate',
  207. (case
  208. when t3.ccr_value is null or t3.ccr_value = 0
  209. then '0%'
  210. else concat(round(t3.ccr_value / 100, 2), '%')
  211. end
  212. ) as 'ccrValue',
  213. (case
  214. when t3.ccr_value is null or t3.ccr_value = 0
  215. then 0
  216. else round(t3.ccr_value / 100 , 2)
  217. end
  218. ) as 'ccrInt',
  219. t3.store_score as 'storeScore',
  220. (
  221. case when t5.is_presale = 1
  222. then '否'
  223. when t5.is_presale = 2
  224. then '是'
  225. else '-'
  226. end
  227. ) as 'isPresale',
  228. round(t3.investment_promotion_rate / 10, 2) as 'investmentPromotionRate'
  229. from kuaishou_supply_chain t1
  230. left join kuaishou_item_bind_user t2
  231. on t1.item_id = t2.item_id
  232. left join kuaishou_activity_open_item_list t3
  233. on t1.item_id = t3.item_id
  234. left join kuaishou_item_list t5
  235. on t1.item_id = t5.item_id
  236. left join (
  237. select
  238. item_id as 'itemId',
  239. count(oid) as 'orderNum'
  240. from kuaishou_supply_chain
  241. where stat_hour &lt;= #{hour}
  242. <if test="lastTimeStart != null and lastTimeStart != ''">
  243. and stat_date &gt;= #{lastTimeStart}
  244. </if>
  245. <if test="lastTimeEnd != null and lastTimeEnd != ''">
  246. and stat_date &lt;= #{lastTimeEnd}
  247. </if>
  248. <if test="itemId != null and itemId != ''">
  249. and item_id = #{itemId}
  250. </if>
  251. <if test="itemTitle != null and itemTitle != ''">
  252. and item_title like concat(concat('%',#{itemTitle}),'%')
  253. </if>
  254. group by item_id) t6 on t1.item_id = t6.itemId
  255. where t1.stat_hour &lt;= #{hour}
  256. <if test="start != null and start != ''">
  257. and t1.stat_date &gt;= #{start}
  258. </if>
  259. <if test="end != null and end != ''">
  260. and t1.stat_date &lt;= #{end}
  261. </if>
  262. <if test="itemId != null and itemId != ''">
  263. and t1.item_id = #{itemId}
  264. </if>
  265. <if test="itemTitle != null and itemTitle != ''">
  266. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  267. </if>
  268. group by t1.item_id) t
  269. where 1 = 1
  270. <if test="userId != null and userId != ''">
  271. and t.userId = #{userId}
  272. </if>
  273. order by ${fieId} ${sort}
  274. </select>
  275. <select id="itemBindList" resultType="com.alibaba.fastjson.JSONObject">
  276. select t1.*,t2.*,
  277. (
  278. case when t4.is_presale = 1
  279. then '否'
  280. when t4.is_presale = 2
  281. then '是'
  282. else '-'
  283. end
  284. ) as 'isPresale',
  285. t3.store_score as 'storeScore'
  286. from (select t.item_id as 'itemId', t.item_title as 'itemTitle', t.user_id as 'userId', t.user_name as
  287. 'userName',
  288. (case
  289. when tt.ccr_value is null or tt.ccr_value = 0
  290. then '0%'
  291. else concat(round(tt.ccr_value / 100, 2), '%')
  292. end
  293. ) as 'ccrValue',
  294. (case
  295. when tt.ccr_value is null or tt.ccr_value = 0
  296. then 0
  297. else round(tt.ccr_value / 100 , 2)
  298. end
  299. ) as 'ccrInt',
  300. round(tt.investment_promotion_rate / 10, 2) as 'investmentPromotionRate'
  301. from kuaishou_item_list t left join kuaishou_activity_open_item_list tt
  302. on t.item_id = tt.item_id
  303. where
  304. t.create_time &gt;= str_to_date(concat(#{bindStartDate},' 00:00:01'),'%Y-%m-%d
  305. %H:%i:%s')
  306. and
  307. t.create_time &lt;= str_to_date(concat(#{bindEndDate},' 23:59:59'),'%Y-%m-%d
  308. %H:%i:%s')
  309. ) t1
  310. left join
  311. (select item_id as 'orderItemId',
  312. reserve_price as 'reservePrice',
  313. image_url as 'imageUrl',
  314. count(oid) as 'orderNum',
  315. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  316. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),
  317. 4) as 'validRadio',
  318. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  319. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  320. then 1 else 0 end),4) as 'shippingGreen',
  321. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  322. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  323. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
  324. when
  325. send_status = 1
  326. then 1
  327. else 0 end),
  328. 4) as 'deliveryRadio',
  329. item_commission_rate as 'itemCommissionRate'
  330. from kuaishou_supply_chain
  331. where stat_date &gt;= #{start}
  332. group by item_id) t2 on t1.itemId = t2.orderItemId
  333. left join kuaishou_activity_open_item_list t3
  334. on t1.itemId = t3.item_id
  335. left join kuaishou_item_list t4
  336. on t1.itemId = t4.item_id
  337. where 1 = 1
  338. <if test="itemId != null and itemId != ''">
  339. and t1.itemId = #{itemId}
  340. </if>
  341. <if test="itemTitle != null and itemTitle != ''">
  342. and t1.itemTitle like concat(concat('%',#{itemTitle}),'%')
  343. </if>
  344. <if test="userId != null and userId != ''">
  345. and t1.userId = #{userId}
  346. </if>
  347. order by ${fieId} ${sort}
  348. </select>
  349. <select id="getTopPromoterByItemId" resultType="com.alibaba.fastjson.JSONObject">
  350. select
  351. *
  352. from
  353. (select promoter_id as 'promoterId',
  354. promoter_nick_name as 'promoterNickName',
  355. count(oid) as 'orderNum'
  356. from kuaishou_supply_chain
  357. where item_id = #{itemId}
  358. <if test="start != null and start != ''">
  359. and stat_date &gt;= #{start}
  360. </if>
  361. <if test="end != null and end != ''">
  362. and stat_date &lt;= #{end}
  363. </if>
  364. group by promoter_id) t
  365. order by t.orderNum desc limit 3
  366. </select>
  367. <select id="itemDetail" resultType="com.alibaba.fastjson.JSONObject">
  368. select t.*,tt.userName
  369. from (
  370. select
  371. promoter_nick_name as 'promoterNickName',
  372. promoter_id as 'promoterId',
  373. count(oid) as 'orderNum',
  374. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  375. regimental_promotion_rate as 'regimentalPromotionRate',
  376. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  377. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  378. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  379. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  380. then 1 else 0 end),4) as 'shippingGreen',
  381. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  382. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  383. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when send_status = 1
  384. then 1 else 0 end),4) as 'deliveryRadio'
  385. from kuaishou_supply_chain
  386. where 1= 1
  387. <if test="itemId != null and itemId != ''">
  388. and item_id = #{itemId}
  389. </if>
  390. <if test="start != null and start != ''">
  391. and stat_date &gt;= #{start}
  392. </if>
  393. <if test="end != null and end != ''">
  394. and stat_date &lt;= #{end}
  395. </if>
  396. <if test="promoterId != null and promoterId != ''">
  397. and promoter_id = #{promoterId}
  398. </if>
  399. <if test="promoterNickName != null and promoterNickName != ''">
  400. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  401. </if>
  402. group by promoter_id) t left join (select promoter_id,group_concat(user_name) as 'userName',user_id as 'userId'
  403. from
  404. kuaishou_promoter group by promoter_id) tt
  405. on t.promoterId = tt.promoter_id
  406. where 1 =1
  407. <if test="userId != null and userId != ''">
  408. and tt.userId = #{userId}
  409. </if>
  410. order by t.orderNum desc
  411. </select>
  412. <select id="itemServiceCharge" resultType="com.alibaba.fastjson.JSONObject">
  413. select *
  414. from (
  415. select
  416. item_id as 'itemId',
  417. item_title as 'itemTitle',
  418. image_url as 'imageUrl',
  419. count(oid) as 'orderNum',
  420. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  421. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  422. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  423. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  424. then 1 else 0 end),4) as 'shippingGreen',
  425. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  426. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  427. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when send_status = 1
  428. then 1 else 0 end),4) as 'deliveryRadio',
  429. sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  430. regimental_promotion_rate as 'regimentalPromotionRate',
  431. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  432. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount',
  433. sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
  434. 'totalRegimentalSettleAmount',
  435. item_commission_rate as 'itemCommissionRate'
  436. from kuaishou_supply_chain
  437. where 1= 1
  438. <if test="start != null and start != ''">
  439. and stat_date &gt;= #{start}
  440. </if>
  441. <if test="end != null and end != ''">
  442. and stat_date &lt;= #{end}
  443. </if>
  444. <if test="itemId != null and itemId != ''">
  445. and item_id = #{itemId}
  446. </if>
  447. <if test="itemTitle != null and itemTitle != ''">
  448. and item_title like concat(concat('%',#{itemTitle}),'%')
  449. </if>
  450. group by item_id) t
  451. order by t.orderNum desc
  452. </select>
  453. <select id="getOrderTotal" resultType="com.alibaba.fastjson.JSONObject">
  454. select
  455. count(oid) as 'orderNum',
  456. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  457. sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm'
  458. from kuaishou_supply_chain
  459. where 1= 1
  460. <if test="start != null and start != ''">
  461. and stat_date &gt;= #{start}
  462. </if>
  463. <if test="end != null and end != ''">
  464. and stat_date &lt;= #{end}
  465. </if>
  466. </select>
  467. <select id="getOrderTotalRatio" resultType="java.lang.Double">
  468. select
  469. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio'
  470. from (select count(oid) as 'oid'
  471. from kuaishou_supply_chain
  472. where 1= 1
  473. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  474. and stat_date = #{nowStartHourTemp}
  475. </if>
  476. <if test="hour != null and hour != ''">
  477. and `stat_hour` &lt;= #{hour}
  478. </if>
  479. ) t1
  480. join (select count(oid) as 'oid'
  481. from kuaishou_supply_chain
  482. where 1=1
  483. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  484. and stat_date = #{yesterdayStartHourTemp}
  485. </if>
  486. <if test="hour != null and hour != ''">
  487. and `stat_hour` &lt;= #{hour}
  488. </if>
  489. ) t2
  490. </select>
  491. <select id="getAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  492. select
  493. sum(order_amount) as 'orderAmount',
  494. sum(base_amount) as 'baseAmount',
  495. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount',
  496. sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
  497. 'totalRegimentalSettleAmount'
  498. from kuaishou_supply_chain
  499. where 1= 1
  500. <if test="start != null and start != ''">
  501. and stat_date &gt;= #{start}
  502. </if>
  503. <if test="end != null and end != ''">
  504. and stat_date &lt;= #{end}
  505. </if>
  506. </select>
  507. <select id="getAmountTotalRatio" resultType="java.lang.Double">
  508. select
  509. round((t1.payAmount -t2.payAmount) / t2.payAmount , 4) as 'amountTotalRatio'
  510. from (select sum(pay_amount) as 'payAmount'
  511. from kuaishou_supply_chain
  512. where 1= 1
  513. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  514. and stat_date = #{nowStartHourTemp}
  515. </if>
  516. <if test="hour != null and hour != ''">
  517. and `stat_hour` &lt;= #{hour}
  518. </if>
  519. ) t1
  520. join (select sum(pay_amount) as 'payAmount'
  521. from kuaishou_supply_chain
  522. where 1=1
  523. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  524. and stat_date = #{yesterdayStartHourTemp}
  525. </if>
  526. <if test="hour != null and hour != ''">
  527. and `stat_hour` &lt;= #{hour}
  528. </if>
  529. ) t2
  530. </select>
  531. <select id="getServiceAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  532. select
  533. count(distinct promoter_id) as 'promoterNum',
  534. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  535. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  536. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  537. as 'deliveryRadio'
  538. from kuaishou_supply_chain
  539. where 1= 1
  540. <if test="start != null and start != ''">
  541. and stat_date &gt;= #{start}
  542. </if>
  543. <if test="end != null and end != ''">
  544. and stat_date &lt;= #{end}
  545. </if>
  546. </select>
  547. <select id="getOrderRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  548. select
  549. t1.*,
  550. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  551. from (select
  552. item_id as 'itemId',
  553. item_title as 'itemTitle',
  554. image_url as 'imageUrl',
  555. count(oid) as 'orderNum',
  556. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  557. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  558. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  559. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  560. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  561. as 'deliveryRadio'
  562. from kuaishou_supply_chain
  563. where 1= 1
  564. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  565. and stat_date = #{nowStartHourTemp}
  566. </if>
  567. <if test="hour != null and hour != ''">
  568. and `stat_hour` &lt;= #{hour}
  569. </if>
  570. group by item_id
  571. ) t1
  572. left join (select
  573. item_id as 'itemId',
  574. count(oid) as 'orderNum'
  575. from kuaishou_supply_chain
  576. where 1=1
  577. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  578. and stat_date = #{yesterdayStartHourTemp}
  579. </if>
  580. <if test="hour != null and hour != ''">
  581. and `stat_hour` &lt;= #{hour}
  582. </if>
  583. group by item_id
  584. ) t2 on t1.itemId = t2.itemId
  585. order by t1.orderNum desc
  586. </select>
  587. <select id="getOrderRankRatioListBytedance" resultType="com.alibaba.fastjson.JSONObject">
  588. select
  589. t1.*,
  590. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  591. from (
  592. select
  593. product_id as 'itemId',
  594. product_name as 'itemTitle',
  595. product_img as 'imageUrl',
  596. count(order_id) as 'orderNum',
  597. sum(case when flow_point != 'REFUND' then 1 else 0 end) as 'validOrderNUm',
  598. round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id),4) as 'validRadio'
  599. from ruixuan.bytedance_order_list
  600. where 1= 1
  601. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  602. and pay_success_time &gt;= #{nowStartHourTemp}
  603. </if>
  604. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  605. and pay_success_time &lt;= #{nowEndHourTemp}
  606. </if>
  607. <if test="hour != null and hour != ''">
  608. and pay_success_time_hour &lt;= #{hour}
  609. </if>
  610. group by product_id
  611. ) t1
  612. left join (select
  613. product_id as 'itemId',
  614. count(order_id) as 'orderNum'
  615. from ruixuan.bytedance_order_list
  616. where 1=1
  617. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  618. and pay_success_time &gt;= #{yesterdayStartHourTemp}
  619. </if>
  620. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  621. and pay_success_time &lt;= #{yesterdayEndHourTemp}
  622. </if>
  623. <if test="hour != null and hour != ''">
  624. and pay_success_time_hour &lt;= #{hour}
  625. </if>
  626. group by product_id
  627. ) t2 on t1.itemId = t2.itemId
  628. order by t1.orderNum desc
  629. </select>
  630. <select id="getOrderRankList" resultType="com.alibaba.fastjson.JSONObject">
  631. select * from (
  632. select
  633. item_id as 'itemId',
  634. item_title as 'itemTitle',
  635. image_url as 'imageUrl',
  636. count(oid) as 'orderNum',
  637. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  638. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  639. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  640. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  641. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  642. then 1 else 0 end),4) as 'deliveryRadio'
  643. from kuaishou_supply_chain
  644. where 1= 1
  645. <if test="start != null and start != ''">
  646. and stat_date &gt;= #{start}
  647. </if>
  648. <if test="end != null and end != ''">
  649. and stat_date &lt;= #{end}
  650. </if>
  651. group by item_id) t
  652. order by t.orderNum desc
  653. </select>
  654. <select id="getOrderRankListBytedance" resultType="com.alibaba.fastjson.JSONObject">
  655. select * from (
  656. select
  657. product_id as 'itemId',
  658. product_name as 'itemTitle',
  659. product_img as 'imageUrl',
  660. count(order_id) as 'orderNum',
  661. sum(case when flow_point != 'REFUND' then 1 else 0 end) as 'validOrderNUm',
  662. round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id),4) as 'validRadio'
  663. from ruixuan.bytedance_order_list
  664. where 1= 1
  665. <if test="start != null and start != ''">
  666. and pay_success_time &gt;= #{start}
  667. </if>
  668. <if test="end != null and end != ''">
  669. and pay_success_time &lt;= #{end}
  670. </if>
  671. group by product_id) t
  672. order by t.orderNum desc
  673. </select>
  674. <select id="getPromoterRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  675. select
  676. t1.*,
  677. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  678. from (
  679. select
  680. t.promoter_id as 'promoterId',
  681. t.promoter_nick_name as 'promoterNickName',
  682. tt.promoter_url as 'promoterUrl',
  683. count(oid) as 'orderNum',
  684. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  685. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  686. from kuaishou_supply_chain t
  687. left join (select * from kuaishou_promoter group by promoter_id) tt on t.promoter_id = tt.promoter_id
  688. where 1= 1
  689. <if test='promoterIds != null and promoterIds.size() > 0'>
  690. AND t.promoter_id IN
  691. <foreach collection="promoterIds" item="item" separator=","
  692. open="(" close=")">
  693. #{item}
  694. </foreach>
  695. </if>
  696. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  697. and stat_date = #{nowStartHourTemp}
  698. </if>
  699. <if test="hour != null and hour != ''">
  700. and `stat_hour` &lt;= #{hour}
  701. </if>
  702. group by t.promoter_id
  703. ) t1
  704. left join (select
  705. promoter_id as 'promoterId',
  706. count(oid) as 'orderNum'
  707. from kuaishou_supply_chain
  708. where 1=1
  709. <if test='promoterIds != null and promoterIds.size() > 0'>
  710. AND promoter_id IN
  711. <foreach collection="promoterIds" item="item" separator=","
  712. open="(" close=")">
  713. #{item}
  714. </foreach>
  715. </if>
  716. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  717. and stat_date = #{yesterdayStartHourTemp}
  718. </if>
  719. <if test="hour != null and hour != ''">
  720. and `stat_hour` &lt;= #{hour}
  721. </if>
  722. group by promoter_id
  723. ) t2 on t1.promoterId = t2.promoterId
  724. order by t1.orderNum desc
  725. </select>
  726. <select id="getPromoterRankRatioListBytedance" resultType="com.alibaba.fastjson.JSONObject">
  727. select
  728. t1.*,
  729. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  730. from (
  731. select
  732. author_short_id as 'promoterId',
  733. author_account as 'promoterNickName',
  734. count(order_id) as 'orderNum',
  735. sum(case when flow_point != 'REFUND' then 1 else 0 end) as 'validOrderNUm',
  736. round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id),4) as 'validRadio'
  737. from ruixuan.bytedance_order_list
  738. where author_short_id is not null
  739. <if test='promoterIds != null and promoterIds.size() > 0'>
  740. AND author_short_id IN
  741. <foreach collection="promoterIds" item="item" separator=","
  742. open="(" close=")">
  743. #{item}
  744. </foreach>
  745. </if>
  746. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  747. and pay_success_time &gt;= #{nowStartHourTemp}
  748. </if>
  749. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  750. and pay_success_time &lt;= #{nowEndHourTemp}
  751. </if>
  752. <if test="hour != null and hour != ''">
  753. and pay_success_time_hour &lt;= #{hour}
  754. </if>
  755. group by author_short_id
  756. ) t1
  757. left join (
  758. select
  759. author_short_id as 'promoterId',
  760. count(order_id) as 'orderNum'
  761. from ruixuan.bytedance_order_list
  762. where 1=1
  763. <if test='promoterIds != null and promoterIds.size() > 0'>
  764. AND author_short_id IN
  765. <foreach collection="promoterIds" item="item" separator=","
  766. open="(" close=")">
  767. #{item}
  768. </foreach>
  769. </if>
  770. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  771. and pay_success_time &gt;= #{yesterdayStartHourTemp}
  772. </if>
  773. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  774. and pay_success_time &lt;= #{yesterdayEndHourTemp}
  775. </if>
  776. <if test="hour != null and hour != ''">
  777. and pay_success_time_hour &lt;= #{hour}
  778. </if>
  779. group by author_short_id
  780. ) t2 on t1.promoterId = t2.promoterId
  781. order by t1.orderNum desc
  782. </select>
  783. <select id="getPromoterRatioList" resultType="com.alibaba.fastjson.JSONObject">
  784. select * from (
  785. select
  786. t1.promoter_id as 'promoterId',
  787. t1.promoter_nick_name as 'promoterNickName',
  788. count(oid) as 'orderNum',
  789. tt.promoter_url as 'promoterUrl',
  790. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  791. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  792. from kuaishou_supply_chain t1
  793. left join kuaishou_promoter tt on t1.promoter_id = tt.promoter_id
  794. where 1= 1
  795. <if test="start != null and start != ''">
  796. and stat_date &gt;= #{start}
  797. </if>
  798. <if test="end != null and end != ''">
  799. and stat_date &lt;= #{end}
  800. </if>
  801. group by t1.promoter_id) t
  802. order by t.orderNum desc
  803. </select>
  804. <select id="getPromoterRatioListBytedance" resultType="com.alibaba.fastjson.JSONObject">
  805. select * from (
  806. select
  807. author_short_id as 'promoterId',
  808. author_account as 'promoterNickName',
  809. count(order_id) as 'orderNum',
  810. sum(case when flow_point != 'REFUND' then 1 else 0 end) as 'validOrderNUm',
  811. round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id),4) as 'validRadio'
  812. from ruixuan.bytedance_order_list
  813. where author_short_id is not null
  814. <if test="start != null and start != ''">
  815. and pay_success_time &gt;= #{start}
  816. </if>
  817. <if test="end != null and end != ''">
  818. and pay_success_time &lt;= #{end}
  819. </if>
  820. group by author_short_id) t
  821. order by t.orderNum desc
  822. </select>
  823. <select id="exportPromoterTotal" resultType="com.alibaba.fastjson.JSONObject">
  824. select t.*,
  825. IFNULL(ROUND(((t.orderNum-t3.orderNum)/t3.orderNum)*100,2),0) as 'orderNumRoi'
  826. from (
  827. select
  828. promoter_id as 'promoterId',
  829. promoter_nick_name as 'promoterNickName',
  830. count(oid) as 'orderNum',
  831. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  832. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  833. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  834. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  835. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  836. then 1 else 0 end) * 100,2) as 'deliveryRadio',
  837. round(sum(pay_amount) / 100,2) as 'payAmount',
  838. round(sum(case when order_status != 80 then pay_amount else 0 end) / 100 , 2 ) as 'validPayAmount',
  839. round(sum(case when order_status != 80 then regimental_promotion_amount else 0 end) / 100, 2) as
  840. 'regimentalPromotionAmount'
  841. from kuaishou_supply_chain
  842. where stat_hour &lt;= #{hour}
  843. <if test="start != null and start != ''">
  844. and stat_date &gt;= #{start}
  845. </if>
  846. <if test="end != null and end != ''">
  847. and stat_date &lt;= #{end}
  848. </if>
  849. <if test="promoterId != null and promoterId != ''">
  850. and promoter_id = #{promoterId}
  851. </if>
  852. <if test="promoterNickName != null and promoterNickName != ''">
  853. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  854. </if>
  855. <if test="itemId != null and itemId != ''">
  856. and item_id = #{itemId}
  857. </if>
  858. <if test="itemTitle != null and itemTitle != ''">
  859. and item_title like concat(concat('%',#{itemTitle}),'%')
  860. </if>
  861. group by promoter_id) t
  862. left join (
  863. select promoter_id as 'promoterId',
  864. count(oid) as 'orderNum'
  865. from kuaishou_supply_chain
  866. where stat_hour &lt;= #{hour}
  867. <if test="lastTimeStart != null and lastTimeStart != ''">
  868. and stat_date &gt;= #{lastTimeStart}
  869. </if>
  870. <if test="lastTimeEnd != null and lastTimeEnd != ''">
  871. and stat_date &lt;= #{lastTimeEnd}
  872. </if>
  873. <if test="promoterId != null and promoterId != ''">
  874. and promoter_id = #{promoterId}
  875. </if>
  876. <if test="promoterNickName != null and promoterNickName != ''">
  877. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  878. </if>
  879. <if test="itemId != null and itemId != ''">
  880. and item_id = #{itemId}
  881. </if>
  882. <if test="itemTitle != null and itemTitle != ''">
  883. and item_title like concat(concat('%',#{itemTitle}),'%')
  884. </if>
  885. group by promoter_id
  886. ) t3 on t.promoterId = t3.promoterId
  887. order by t.orderNum desc
  888. </select>
  889. <select id="exportPromoter" resultType="com.alibaba.fastjson.JSONObject">
  890. select *
  891. from (
  892. select
  893. promoter_id as 'promoterId',
  894. promoter_nick_name as 'promoterNickName',
  895. item_id as 'itemId',
  896. item_title as 'itemTitle',
  897. image_url as 'imageUrl',
  898. count(oid) as 'orderNum',
  899. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  900. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  901. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  902. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  903. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  904. then 1 else 0 end) * 100,2) as 'deliveryRadio'
  905. from kuaishou_supply_chain
  906. where 1= 1
  907. <if test="start != null and start != ''">
  908. and stat_date &gt;= #{start}
  909. </if>
  910. <if test="end != null and end != ''">
  911. and stat_date &lt;= #{end}
  912. </if>
  913. <if test="promoterId != null and promoterId != ''">
  914. and promoter_id = #{promoterId}
  915. </if>
  916. <if test="promoterNickName != null and promoterNickName != ''">
  917. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  918. </if>
  919. <if test="itemId != null and itemId != ''">
  920. and item_id = #{itemId}
  921. </if>
  922. <if test="itemTitle != null and itemTitle != ''">
  923. and item_title like concat(concat('%',#{itemTitle}),'%')
  924. </if>
  925. group by promoter_id,item_id) t
  926. order by t.promoterId,t.orderNum desc
  927. </select>
  928. <select id="exportOrder" resultType="com.alibaba.fastjson.JSONObject">
  929. select *
  930. from (select
  931. t2.user_id as 'userId',
  932. t2.user_name as 'userName',
  933. t1.item_id as 'itemId',
  934. t1.item_title as 'itemTitle',
  935. t1.image_url as 'imageUrl',
  936. count(t1.oid) as 'orderNum',
  937. IFNULL(ROUND(((count(t1.oid)-t6.orderNum)/t6.orderNum)*100,2),0) as 'orderNumRoi',
  938. sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  939. round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid) * 100, 2) as 'validRadio',
  940. sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  941. sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  942. round(sum(case when t1.send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when t1.order_status
  943. != 80 then 1 else 0 end) * 100, 2) as 'deliveryRadio',
  944. round(t1.item_commission_rate / 10,2) as 'itemCommissionRate',
  945. (case
  946. when t4.ccr_value is null or t4.ccr_value = 0
  947. then '0%'
  948. else concat(round(t4.ccr_value / 100, 2), '%')
  949. end
  950. ) as 'ccrValue'
  951. ,
  952. t4.shop_star as 'shopStar',
  953. t4.mall_logistics_score as 'mallLogisticsScore',
  954. t4.shop_score as 'shopScore',
  955. t4.mall_service_score as 'mallServiceScore',
  956. t4.mall_quality_score as 'mallQualityScore',
  957. (
  958. case when t5.is_presale = 1
  959. then '否'
  960. when t5.is_presale = 2
  961. then '是'
  962. else '-'
  963. end
  964. ) as 'isPresale'
  965. from kuaishou_supply_chain t1
  966. left join kuaishou_item_bind_user t2
  967. on t1.item_id = t2.item_id
  968. left join kuaishou_activity_open_item_list t4
  969. on t1.item_id = t4.item_id
  970. left join kuaishou_item_list t5
  971. on t1.item_id = t5.item_id
  972. left join (
  973. select
  974. item_id as 'itemId',
  975. count(oid) as 'orderNum'
  976. from kuaishou_supply_chain
  977. where stat_hour &lt;= #{hour}
  978. <if test="lastTimeStart != null and lastTimeStart != ''">
  979. and stat_date &gt;= #{lastTimeStart}
  980. </if>
  981. <if test="lastTimeEnd != null and lastTimeEnd != ''">
  982. and stat_date &lt;= #{lastTimeEnd}
  983. </if>
  984. <if test="itemId != null and itemId != ''">
  985. and item_id = #{itemId}
  986. </if>
  987. <if test="itemTitle != null and itemTitle != ''">
  988. and item_title like concat(concat('%',#{itemTitle}),'%')
  989. </if>
  990. group by item_id) t6 on t1.item_id = t6.itemId
  991. where t1.stat_hour &lt;= #{hour}
  992. <if test="start != null and start != ''">
  993. and t1.stat_date &gt;= #{start}
  994. </if>
  995. <if test="end != null and end != ''">
  996. and t1.stat_date &lt;= #{end}
  997. </if>
  998. <if test="promoterId != null and promoterId != ''">
  999. and t1.promoter_id = #{promoterId}
  1000. </if>
  1001. <if test="promoterNickName != null and promoterNickName != ''">
  1002. and t1.promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  1003. </if>
  1004. <if test="itemId != null and itemId != ''">
  1005. and t1.item_id = #{itemId}
  1006. </if>
  1007. <if test="itemTitle != null and itemTitle != ''">
  1008. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  1009. </if>
  1010. group by t1.item_id) t
  1011. where 1 = 1
  1012. <if test="userId != null and userId != ''">
  1013. and t.userId = #{userId}
  1014. </if>
  1015. order by t.orderNum desc
  1016. </select>
  1017. <select id="bindUserItemList" resultType="com.alibaba.fastjson.JSONObject">
  1018. select *
  1019. from (select t1.item_id as 'itemId',
  1020. t1.item_title as 'itemTitle',
  1021. t1.reserve_price as 'reservePrice',
  1022. t1.image_url as 'imageUrl',
  1023. t1.activity_id as 'activityId',
  1024. t1.regimental_promotion_rate as 'regimentalPromotionRate',
  1025. t2.user_id as 'userId',
  1026. case when t2.user_id is null then 1 else 2 end as 'status',
  1027. t2.user_name as 'userName',
  1028. t2.create_time as 'bindTime',
  1029. t1.item_commission_rate as 'itemCommissionRate'
  1030. from kuaishou_item_info t1
  1031. left join kuaishou_item_bind_user t2 on t1.item_id = t2.item_id
  1032. where 1 = 1
  1033. <if test="userId != null and userId != ''">
  1034. and t2.user_id = #{userId}
  1035. </if>
  1036. <if test="itemId != null and itemId != ''">
  1037. and t1.item_id = #{itemId}
  1038. </if>
  1039. <if test="itemTitle != null and itemTitle != ''">
  1040. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  1041. </if>
  1042. <if test="activityId != null and activityId != ''">
  1043. and t1.activity_id = #{activityId}
  1044. </if>
  1045. order by t1.create_time desc) t
  1046. where 1 = 1
  1047. <if test="status != null and status != ''">
  1048. and t.status = #{status}
  1049. </if>
  1050. </select>
  1051. <select id="getSupplyChainUserList" resultType="com.alibaba.fastjson.JSONObject">
  1052. SELECT *
  1053. FROM (SELECT t3.user_id AS 'userId',
  1054. t3.nick_name AS 'nickMame',
  1055. t1.role_name AS 'roleName',
  1056. t3.status,
  1057. t3.create_time
  1058. FROM sys_role t1
  1059. LEFT JOIN sys_user_role t2 ON t1.role_id = t2.role_id
  1060. LEFT JOIN sys_user t3 ON t2.user_id = t3.user_id
  1061. WHERE t1.role_key IN (
  1062. 'association',
  1063. 'associationManager',
  1064. 'bd',
  1065. 'bdManager'
  1066. )
  1067. AND t3.status = 0
  1068. GROUP BY t3.user_id) t
  1069. WHERE t.userId IS NOT NULL
  1070. ORDER BY t.create_time DESC
  1071. </select>
  1072. <select id="adminReportList" resultType="com.alibaba.fastjson.JSONObject">
  1073. select t.*,
  1074. t1.sendSampleCount,
  1075. IFNULL(ROUND(((t.orderNum-t3.orderNum)/t3.orderNum)*100,2),0) as 'orderNumRoi'
  1076. from (select t1.user_id as 'userId',
  1077. t1.user_name as 'userName',
  1078. count(distinct t2.item_id) as 'itemCount',
  1079. count(t2.oid) as 'orderNum',
  1080. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  1081. round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid),4) as 'validRadio',
  1082. sum(case when t2.send_status = 1 then 1 else 0 end) as 'deliveryNum',
  1083. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case when
  1084. t2.order_status != 80
  1085. then 1 else 0 end),4) as 'shippingGreen',
  1086. sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  1087. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  1088. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
  1089. when send_status = 1
  1090. then 1
  1091. else 0 end),
  1092. 4) as 'deliveryRadio',
  1093. sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  1094. sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) as 'payAmount',
  1095. sum(case
  1096. when t2.order_status != 80 then t2.regimental_promotion_amount
  1097. else 0 end) as 'regimentalPromotionAmount',
  1098. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  1099. 'totalRegimentalSettleAmount',
  1100. round( sum(case
  1101. when t2.order_status != 80 then t2.regimental_promotion_amount
  1102. else 0 end) / sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) ,5 ) as 'avgServiceRate'
  1103. from kuaishou_item_bind_user t1
  1104. left join kuaishou_supply_chain t2
  1105. on t1.item_id = t2.item_id
  1106. where t2.stat_hour &lt;= #{hour}
  1107. <if test="start != null and start != ''">
  1108. and t2.stat_date &gt;=#{start}
  1109. </if>
  1110. <if test="end != null and end != ''">
  1111. and t2.stat_date &lt;= #{end}
  1112. </if>
  1113. group by t1.user_id
  1114. ) t left join (
  1115. select item_create_id,count(1) as 'sendSampleCount' from kuaishou_item_collect_samples
  1116. where courier_number_time >= #{startDate}
  1117. and courier_number_time &lt;= #{endDate}
  1118. group by item_create_id
  1119. ) t1 on t.userId = t1.item_create_id
  1120. left join (
  1121. select t1.user_id as 'userId',
  1122. count(t2.oid) as 'orderNum'
  1123. from kuaishou_item_bind_user t1
  1124. left join kuaishou_supply_chain t2
  1125. on t1.item_id = t2.item_id
  1126. where t2.stat_hour &lt;= #{hour}
  1127. <if test="lastTimeStart != null and lastTimeStart != ''">
  1128. and t2.stat_date &gt;= #{lastTimeStart}
  1129. </if>
  1130. <if test="lastTimeEnd != null and lastTimeEnd != ''">
  1131. and t2.stat_date &lt;= #{lastTimeEnd}
  1132. </if>
  1133. group by t1.user_id
  1134. ) t3 on t.userId = t3.userId
  1135. where 1 =1
  1136. <if test="userId != null and userId != ''">
  1137. and t.userId = #{userId}
  1138. </if>
  1139. order by t.orderNum desc
  1140. </select>
  1141. <select id="userItemDetail" resultType="com.alibaba.fastjson.JSONObject">
  1142. SELECT
  1143. *
  1144. FROM
  1145. (
  1146. SELECT
  1147. t1.user_id,
  1148. t1.user_name AS 'userName',
  1149. t2.item_id AS 'itemId',
  1150. t2.item_title AS 'itemTitle',
  1151. t2.image_url AS 'imageUrl',
  1152. t2.reserve_price AS 'reservePrice',
  1153. count(t2.oid) AS 'orderNum',
  1154. sum(
  1155. CASE
  1156. WHEN t2.order_status != 80 THEN 1
  1157. ELSE 0
  1158. END
  1159. ) AS 'validOrderNUm',
  1160. round(
  1161. sum(
  1162. CASE
  1163. WHEN t2.order_status != 80 THEN 1
  1164. ELSE 0
  1165. END
  1166. ) / count(t2.oid),
  1167. 4
  1168. ) AS 'validRadio',
  1169. sum(
  1170. CASE
  1171. WHEN t2.send_status = 1
  1172. THEN 1
  1173. ELSE 0
  1174. END
  1175. ) AS 'deliveryNum',
  1176. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case when
  1177. t2.order_status != 80
  1178. then 1 else 0 end),4) as 'shippingGreen',
  1179. sum(
  1180. CASE
  1181. WHEN t2.send_status = 1
  1182. AND t2.order_status != 80 THEN 1
  1183. ELSE 0
  1184. END
  1185. ) AS 'effDeliveryNum',
  1186. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  1187. round(
  1188. sum(
  1189. CASE
  1190. WHEN t2.send_status = 1
  1191. AND t2.order_status != 80 THEN 1
  1192. ELSE 0
  1193. END
  1194. ) / sum(
  1195. CASE
  1196. WHEN t2.send_status = 1 THEN 1
  1197. ELSE 0
  1198. END
  1199. ),
  1200. 4
  1201. ) AS 'deliveryRadio',
  1202. sum(
  1203. CASE
  1204. WHEN t2.order_status = 80 THEN 1
  1205. ELSE 0
  1206. END
  1207. ) AS 'invalidOrderNUm',
  1208. sum(
  1209. CASE
  1210. WHEN t2.order_status != 80 THEN t2.pay_amount
  1211. ELSE 0
  1212. END
  1213. ) AS 'payAmount',
  1214. t2.regimental_promotion_rate AS 'regimentalPromotionRate',
  1215. sum(
  1216. CASE
  1217. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  1218. ELSE 0
  1219. END
  1220. ) AS 'regimentalPromotionAmount',
  1221. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  1222. 'totalRegimentalSettleAmount',
  1223. t2.item_commission_rate as 'itemCommissionRate',
  1224. (case
  1225. when t3.ccr_value is null or t3.ccr_value = 0
  1226. then '0%'
  1227. else concat(round(t3.ccr_value / 100, 2), '%')
  1228. end
  1229. ) as 'ccrValue',
  1230. (case
  1231. when t3.ccr_value is null or t3.ccr_value = 0
  1232. then 0
  1233. else round(t3.ccr_value / 100 , 2)
  1234. end
  1235. ) as 'ccrInt'
  1236. FROM
  1237. kuaishou_item_bind_user t1
  1238. LEFT JOIN
  1239. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  1240. left join kuaishou_activity_open_item_list t3 on t1.item_id = t3.item_id
  1241. WHERE
  1242. 1 = 1
  1243. <if test="start != null and start != ''">
  1244. and t2.stat_date &gt;= #{start}
  1245. </if>
  1246. <if test="end != null and end != ''">
  1247. and t2.stat_date &lt;= #{end}
  1248. </if>
  1249. <if test="itemId != null and itemId != ''">
  1250. and t1.item_id = #{itemId}
  1251. </if>
  1252. <if test="itemTitle != null and itemTitle != ''">
  1253. and t2.item_title like concat(concat('%',#{itemTitle}),'%')
  1254. </if>
  1255. GROUP BY
  1256. t1.item_id
  1257. ) t
  1258. where 1 = 1
  1259. <if test="userId != null and userId != ''">
  1260. and t.user_id = #{userId}
  1261. </if>
  1262. order by ${fieId} ${sort}
  1263. </select>
  1264. <select id="getTimeIntervalRatio" resultType="com.alibaba.fastjson.JSONObject">
  1265. select
  1266. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio',
  1267. round((t1.orderAmount -t2.orderAmount) / t2.orderAmount , 4) as 'orderAmountRatio'
  1268. from (
  1269. select count(oid) as 'oid',
  1270. sum(order_amount) as 'orderAmount'
  1271. from kuaishou_supply_chain
  1272. where 1= 1
  1273. <if test="thisCycleStartTemp != null and thisCycleStartTemp != ''">
  1274. and stat_date &gt;= #{thisCycleStartTemp}
  1275. </if>
  1276. <if test="thisCycleEndTemp != null and thisCycleEndTemp != ''">
  1277. and stat_date &lt;= #{thisCycleEndTemp}
  1278. </if>
  1279. ) t1
  1280. join (
  1281. select count(oid) as 'oid',
  1282. sum(order_amount) as 'orderAmount'
  1283. from kuaishou_supply_chain
  1284. where 1=1
  1285. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  1286. and stat_date &gt;= #{lastCycleStartTemp}
  1287. </if>
  1288. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  1289. and stat_date &lt;= #{lastCycleEndTemp}
  1290. </if>
  1291. ) t2
  1292. </select>
  1293. <select id="indexStatistics" resultType="com.alibaba.fastjson.JSONObject">
  1294. select stat_date as 'date',
  1295. <if test="type == 'orderNum' ">
  1296. count(t.oid) as 'orderNum'
  1297. </if>
  1298. <if test="type == 'validOrderNum' ">
  1299. sum(case when t.order_status = 80 then 1 else 0 end) as 'validOrderNum'
  1300. </if>
  1301. <if test="type == 'orderAmount' ">
  1302. sum(t.order_amount) as 'orderAmount'
  1303. </if>
  1304. <if test="type == 'baseAmount' ">
  1305. sum(t.base_amount) as 'baseAmount'
  1306. </if>
  1307. <if test="type == 'deliveryNum' ">
  1308. sum(case when t.send_status = 1 and t.order_status != 80 then 1 else 0 end) as 'deliveryNum'
  1309. </if>
  1310. from (select
  1311. oid,
  1312. order_status,
  1313. order_amount,
  1314. base_amount,
  1315. send_status,
  1316. stat_date
  1317. from kuaishou_supply_chain
  1318. where 1 = 1
  1319. <if test="startTemp != null and startTemp != ''">
  1320. and stat_date &gt;= #{startTemp}
  1321. </if>
  1322. <if test="endTemp != null and endTemp != ''">
  1323. and stat_date &lt;= #{endTemp}
  1324. </if>
  1325. ) t
  1326. group by stat_date
  1327. order by stat_date asc
  1328. </select>
  1329. <select id="itemBindSummary" resultType="com.alibaba.fastjson.JSONObject">
  1330. 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'
  1331. FROM kuaishou_item_info t1
  1332. LEFT JOIN kuaishou_item_bind_user t2
  1333. ON t1.item_id = t2.item_id
  1334. WHERE 1 = 1
  1335. </select>
  1336. <select id="userItemTotal" resultType="com.alibaba.fastjson.JSONObject">
  1337. SELECT count(t2.oid) AS 'orderNum',
  1338. sum(
  1339. CASE
  1340. WHEN t2.order_status != 80 THEN 1
  1341. ELSE 0
  1342. END
  1343. ) AS 'validOrderNUm',
  1344. round(
  1345. sum(
  1346. CASE
  1347. WHEN t2.order_status != 80 THEN 1
  1348. ELSE 0
  1349. END
  1350. ) / count(t2.oid),
  1351. 4
  1352. ) AS 'validRadio',
  1353. sum(
  1354. CASE
  1355. WHEN t2.send_status = 1
  1356. THEN 1
  1357. ELSE 0
  1358. END
  1359. ) AS 'deliveryNum',
  1360. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case when
  1361. t2.order_status != 80
  1362. then 1 else 0 end),4) as 'shippingGreen',
  1363. sum(
  1364. CASE
  1365. WHEN t2.send_status = 1
  1366. AND t2.order_status != 80 THEN 1
  1367. ELSE 0
  1368. END
  1369. ) AS 'effDeliveryNum',
  1370. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  1371. round(
  1372. sum(
  1373. CASE
  1374. WHEN t2.send_status = 1
  1375. AND t2.order_status != 80 THEN 1
  1376. ELSE 0
  1377. END
  1378. ) / sum(
  1379. CASE
  1380. WHEN t2.send_status != 80 THEN 1
  1381. ELSE 0
  1382. END
  1383. ),
  1384. 4
  1385. ) AS 'deliveryRadio',
  1386. sum(
  1387. CASE
  1388. WHEN t2.order_status = 80 THEN 1
  1389. ELSE 0
  1390. END
  1391. ) AS 'invalidOrderNUm',
  1392. sum(
  1393. CASE
  1394. WHEN t2.order_status != 80 THEN t2.pay_amount
  1395. ELSE 0
  1396. END
  1397. ) AS 'payAmount',
  1398. sum(
  1399. CASE
  1400. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  1401. ELSE 0
  1402. END
  1403. ) AS 'regimentalPromotionAmount',
  1404. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  1405. 'totalRegimentalSettleAmount'
  1406. FROM kuaishou_item_bind_user t1
  1407. LEFT JOIN
  1408. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  1409. WHERE 1 = 1
  1410. <if test="start != null and start != ''">
  1411. and t2.stat_date &gt;= #{start}
  1412. </if>
  1413. <if test="end != null and end != ''">
  1414. and t2.stat_date &lt;= #{end}
  1415. </if>
  1416. <if test="userId != null and userId != ''">
  1417. and t1.user_id = #{userId}
  1418. </if>
  1419. </select>
  1420. <select id="exportUserItemDetail" resultType="com.alibaba.fastjson.JSONObject">
  1421. SELECT
  1422. *
  1423. FROM
  1424. (
  1425. SELECT
  1426. t1.user_id as 'user_id',
  1427. t1.user_name AS 'userName',
  1428. t2.item_id AS 'itemId',
  1429. t2.item_title AS 'itemTitle',
  1430. t2.image_url AS 'imageUrl',
  1431. round(t2.reserve_price / 100,2) AS 'reservePrice',
  1432. count(t2.oid) AS 'orderNum',
  1433. sum(
  1434. CASE
  1435. WHEN t2.order_status != 80 THEN 1
  1436. ELSE 0
  1437. END
  1438. ) AS 'validOrderNUm',
  1439. round(
  1440. sum(
  1441. CASE
  1442. WHEN t2.order_status != 80 THEN 1
  1443. ELSE 0
  1444. END
  1445. ) / count(t2.oid) * 100,
  1446. 2
  1447. ) AS 'validRadio',
  1448. sum(
  1449. CASE
  1450. WHEN t2.send_status = 1
  1451. AND t2.order_status != 80 THEN 1
  1452. ELSE 0
  1453. END
  1454. ) AS 'deliveryNum',
  1455. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  1456. round(
  1457. sum(
  1458. CASE
  1459. WHEN t2.send_status = 1
  1460. AND t2.order_status != 80 THEN 1
  1461. ELSE 0
  1462. END
  1463. ) / sum(
  1464. CASE
  1465. WHEN t2.order_status != 80 THEN 1
  1466. ELSE 0
  1467. END
  1468. ) * 100,
  1469. 2
  1470. ) AS 'deliveryRadio',
  1471. sum(
  1472. CASE
  1473. WHEN t2.order_status = 80 THEN 1
  1474. ELSE 0
  1475. END
  1476. ) AS 'invalidOrderNUm',
  1477. round( sum(
  1478. CASE
  1479. WHEN t2.order_status != 80 THEN t2.pay_amount
  1480. ELSE 0
  1481. END
  1482. )/ 100,2 )AS 'payAmount',
  1483. concat(round(t2.regimental_promotion_rate / 10 ,2),'%') AS 'regimentalPromotionRate',
  1484. round(
  1485. sum(
  1486. CASE
  1487. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  1488. ELSE 0
  1489. END
  1490. ) / 100 , 2)AS 'regimentalPromotionAmount',
  1491. round(
  1492. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100,2) as
  1493. 'totalRegimentalSettleAmount',
  1494. concat(round(t2.item_commission_rate / 10),'%') as 'itemCommissionRate',
  1495. (case
  1496. when t3.ccr_value is null or t3.ccr_value = 0
  1497. then '0%'
  1498. else concat(round(t3.ccr_value / 100, 2), '%')
  1499. end
  1500. ) as 'ccrValue'
  1501. FROM
  1502. kuaishou_item_bind_user t1
  1503. LEFT JOIN
  1504. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  1505. left join kuaishou_activity_open_item_list t3 on t1.item_id = t3.item_id
  1506. WHERE
  1507. 1 = 1
  1508. <if test="start != null and start != ''">
  1509. and t2.stat_date &gt;= #{start}
  1510. </if>
  1511. <if test="end != null and end != ''">
  1512. and t2.stat_date &lt;= #{end}
  1513. </if>
  1514. <if test="itemId != null and itemId != ''">
  1515. and t1.item_id = #{itemId}
  1516. </if>
  1517. <if test="itemTitle != null and itemTitle != ''">
  1518. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  1519. </if>
  1520. GROUP BY
  1521. t1.item_id
  1522. ) t
  1523. where 1 = 1
  1524. <if test="userId != null and userId != ''">
  1525. and t.user_id = #{userId}
  1526. </if>
  1527. order by t.orderNum desc
  1528. </select>
  1529. <select id="getCookie" resultType="java.lang.String">
  1530. SELECT cookie
  1531. FROM kuaishou_supply_chain_cookie
  1532. WHERE id = #{regId} limit 1
  1533. </select>
  1534. <select id="selectOrderInfo" resultType="com.alibaba.fastjson.JSONObject">
  1535. SELECT t1.*,
  1536. ROUND(((t1.validOrderNUm-t2.validOrderNUm)/t2.validOrderNUm)*100,2) as 'validOrderNUmRoi',
  1537. ROUND(((t1.allNumber-t1.validOrderNUm-t2.inValidOrderNUm)/t2.inValidOrderNUm)*100,2) as 'inValidOrderNUmRoi',
  1538. ROUND(((t1.baseAmount-t2.baseAmount)/t2.baseAmount)*100,2) as 'baseAmountRoi',
  1539. ROUND(((t1.regimentalPromotionAmount-t2.regimentalPromotionAmount)/t2.regimentalPromotionAmount)*100,2) as
  1540. 'regimentalPromotionAmountRoi'
  1541. FROM(
  1542. SELECT
  1543. COUNT(DISTINCT promoter_id) as 'promoterCount',
  1544. COUNT(DISTINCT item_id) as 'itemCount',
  1545. COUNT(oid) as 'allNumber',
  1546. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
  1547. IFNULL(SUM(order_amount), 0) AS 'orderAmount',
  1548. IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
  1549. 'regimentalPromotionAmount',
  1550. IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) as 'baseAmount'
  1551. FROM kuaishou_supply_chain
  1552. WHERE stat_date >= #{startDate}
  1553. AND stat_date &lt;= #{endDate}
  1554. AND stat_hour &lt;= #{hour}
  1555. <if test='promoterIds != null and promoterIds.size() > 0'>
  1556. AND promoter_id in
  1557. <foreach collection="promoterIds" item="item" separator=","
  1558. open="(" close=")">
  1559. #{item}
  1560. </foreach>
  1561. </if>
  1562. )t1
  1563. LEFT JOIN (
  1564. SELECT
  1565. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
  1566. COUNT(oid)-IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) as 'inValidOrderNUm',
  1567. IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) as 'baseAmount',
  1568. IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
  1569. 'regimentalPromotionAmount'
  1570. FROM kuaishou_supply_chain
  1571. WHERE stat_date >= #{lastTimeStart}
  1572. AND stat_date &lt;= #{lastTimeEnd}
  1573. AND stat_hour &lt;= #{hour}
  1574. <if test='promoterIds != null and promoterIds.size() > 0'>
  1575. AND promoter_id in
  1576. <foreach collection="promoterIds" item="item" separator=","
  1577. open="(" close=")">
  1578. #{item}
  1579. </foreach>
  1580. </if>
  1581. )t2 on 1=1
  1582. </select>
  1583. <select id="selectOrderInfoBytedance" resultType="com.alibaba.fastjson.JSONObject">
  1584. SELECT t1.*,
  1585. ROUND(((t1.validOrderNUm-t2.validOrderNUm)/t2.validOrderNUm)*100,2) as 'validOrderNUmRoi',
  1586. ROUND(((t1.allNumber-t1.validOrderNUm-t2.inValidOrderNUm)/t2.inValidOrderNUm)*100,2) as 'inValidOrderNUmRoi',
  1587. ROUND(((t1.baseAmount-t2.baseAmount)/t2.baseAmount)*100,2) as 'baseAmountRoi',
  1588. ROUND(((t1.regimentalPromotionAmount-t2.regimentalPromotionAmount)/t2.regimentalPromotionAmount)*100,2) as
  1589. 'regimentalPromotionAmountRoi'
  1590. FROM (
  1591. SELECT
  1592. COUNT(DISTINCT author_short_id) as 'promoterCount',
  1593. COUNT(DISTINCT product_id) as 'itemCount',
  1594. COUNT(order_id) as 'allNumber',
  1595. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
  1596. IFNULL(SUM(total_pay_amount), 0) AS 'orderAmount',
  1597. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END), 0) AS 'baseAmount',
  1598. IFNULL( sum(CASE
  1599. WHEN flow_point != 'REFUND' and colonel_type != 2
  1600. THEN colonel_estimated_commission
  1601. WHEN flow_point != 'REFUND' and colonel_type = 2
  1602. then second_estimated_commission
  1603. ELSE 0 END) * 0.9,0) AS
  1604. 'regimentalPromotionAmount',
  1605. IFNULL( sum(CASE
  1606. WHEN flow_point != 'REFUND' and colonel_type != 2
  1607. THEN second_estimated_commission
  1608. ELSE 0 END) ,0) AS 'secondEstimatedCommission'
  1609. FROM ruixuan.bytedance_order_list
  1610. WHERE pay_success_time >=#{startDate}
  1611. AND pay_success_time &lt;=#{endDate}
  1612. AND pay_success_time_hour &lt;=#{hour}
  1613. <if test='promoterIds != null and promoterIds.size() > 0'>
  1614. AND author_short_id in
  1615. <foreach collection="promoterIds" item="item" separator=","
  1616. open="(" close=")">
  1617. #{item}
  1618. </foreach>
  1619. </if>
  1620. )t1
  1621. LEFT JOIN (
  1622. SELECT
  1623. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
  1624. COUNT(order_id)-IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) as 'inValidOrderNUm',
  1625. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END), 0) AS 'baseAmount',
  1626. IFNULL( sum(CASE
  1627. WHEN flow_point != 'REFUND' and colonel_type != 2
  1628. THEN colonel_estimated_commission
  1629. WHEN flow_point != 'REFUND' and colonel_type = 2
  1630. then second_estimated_commission
  1631. ELSE 0 END) * 0.9,0) AS
  1632. 'regimentalPromotionAmount'
  1633. FROM ruixuan.bytedance_order_list
  1634. WHERE pay_success_time >=#{lastTimeStart}
  1635. AND pay_success_time &lt;=#{lastTimeEnd}
  1636. AND pay_success_time_hour &lt;=#{hour}
  1637. <if test='promoterIds != null and promoterIds.size() > 0'>
  1638. AND author_short_id in
  1639. <foreach collection="promoterIds" item="item" separator=","
  1640. open="(" close=")">
  1641. #{item}
  1642. </foreach>
  1643. </if>
  1644. )t2 on 1 = 1
  1645. </select>
  1646. <select id="selectOrderInfoByItemIds" resultType="com.alibaba.fastjson.JSONObject">
  1647. SELECT t1.*,
  1648. CONCAT(IFNULL(ROUND(t1.sendCount / t1.allNumber * 100, 2),0), '%') as 'sendRate',
  1649. ROUND(((t1.validOrderNUm-t2.validOrderNUm)/t2.validOrderNUm)*100,2) as 'validOrderNUmRoi',
  1650. ROUND(((t1.allNumber-t1.validOrderNUm-t2.inValidOrderNUm)/t2.inValidOrderNUm)*100,2) as 'inValidOrderNUmRoi',
  1651. ROUND(((t1.baseAmount-t2.baseAmount)/t2.baseAmount)*100,2) as 'baseAmountRoi',
  1652. ROUND(((t1.regimentalPromotionAmount-t2.regimentalPromotionAmount)/t2.regimentalPromotionAmount)*100,2) as
  1653. 'regimentalPromotionAmountRoi'
  1654. FROM(
  1655. SELECT
  1656. COUNT(DISTINCT promoter_id) as 'promoterCount',
  1657. COUNT(DISTINCT item_id) as 'itemCount',
  1658. COUNT(oid) as 'allNumber',
  1659. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
  1660. IFNULL(SUM(order_amount), 0) AS 'orderAmount',
  1661. IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
  1662. 'regimentalPromotionAmount',
  1663. IFNULL(sum(base_amount), 0) as 'baseAmount',
  1664. IFNULL(COUNT(CASE WHEN send_status = 1 THEN oid ELSE null END), 0) AS 'sendCount'
  1665. FROM kuaishou_supply_chain
  1666. WHERE stat_date >= #{startDate}
  1667. AND stat_date &lt;= #{endDate}
  1668. AND stat_hour &lt;= #{hour}
  1669. <if test='itemIds != null and itemIds.size() > 0'>
  1670. AND item_id in
  1671. <foreach collection="itemIds" item="item" separator=","
  1672. open="(" close=")">
  1673. #{item}
  1674. </foreach>
  1675. </if>
  1676. )t1
  1677. LEFT JOIN (
  1678. SELECT
  1679. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
  1680. COUNT(oid)-IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) as 'inValidOrderNUm',
  1681. IFNULL(sum(base_amount), 0) as 'baseAmount',
  1682. IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
  1683. 'regimentalPromotionAmount'
  1684. FROM kuaishou_supply_chain
  1685. WHERE stat_date >= #{lastTimeStart}
  1686. AND stat_date &lt;= #{lastTimeEnd}
  1687. AND stat_hour &lt;= #{hour}
  1688. <if test='itemIds != null and itemIds.size() > 0'>
  1689. AND item_id in
  1690. <foreach collection="itemIds" item="item" separator=","
  1691. open="(" close=")">
  1692. #{item}
  1693. </foreach>
  1694. </if>
  1695. )t2 on 1=1
  1696. </select>
  1697. <select id="selectOrderInfoByItemIdsBytedance" resultType="com.alibaba.fastjson.JSONObject">
  1698. SELECT t1.*,
  1699. ROUND(((t1.validOrderNUm-t2.validOrderNUm)/t2.validOrderNUm)*100,2) as 'validOrderNUmRoi',
  1700. ROUND(((t1.allNumber-t1.validOrderNUm-t2.inValidOrderNUm)/t2.inValidOrderNUm)*100,2) as 'inValidOrderNUmRoi',
  1701. ROUND(((t1.baseAmount-t2.baseAmount)/t2.baseAmount)*100,2) as 'baseAmountRoi',
  1702. ROUND(((t1.regimentalPromotionAmount-t2.regimentalPromotionAmount)/t2.regimentalPromotionAmount)*100,2) as
  1703. 'regimentalPromotionAmountRoi'
  1704. from (
  1705. SELECT
  1706. COUNT(DISTINCT author_short_id) as 'promoterCount',
  1707. COUNT(DISTINCT product_id) as 'itemCount',
  1708. COUNT(order_id) as 'allNumber',
  1709. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
  1710. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END)/100, 0) AS 'baseAmount',
  1711. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9 /100,0) AS
  1712. 'regimentalPromotionAmount'
  1713. FROM ruixuan.bytedance_order_list
  1714. WHERE pay_success_time >= #{startDate}
  1715. AND pay_success_time &lt;= #{endDate}
  1716. AND pay_success_time_hour &lt;=#{hour}
  1717. <if test='itemIds != null and itemIds.size() > 0'>
  1718. AND product_id in
  1719. <foreach collection="itemIds" item="item" separator=","
  1720. open="(" close=")">
  1721. #{item}
  1722. </foreach>
  1723. </if>
  1724. )t1
  1725. LEFT JOIN (
  1726. SELECT
  1727. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
  1728. COUNT(order_id)-IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) as 'inValidOrderNUm',
  1729. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END)/100, 0) AS 'baseAmount',
  1730. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9 /100,0) AS
  1731. 'regimentalPromotionAmount'
  1732. FROM ruixuan.bytedance_order_list
  1733. WHERE pay_success_time >= #{lastTimeStart}
  1734. AND pay_success_time &lt;= #{lastTimeEnd}
  1735. AND pay_success_time_hour &lt;=#{hour}
  1736. <if test='itemIds != null and itemIds.size() > 0'>
  1737. AND product_id in
  1738. <foreach collection="itemIds" item="item" separator=","
  1739. open="(" close=")">
  1740. #{item}
  1741. </foreach>
  1742. </if>
  1743. )t2 on 1=1
  1744. </select>
  1745. <select id="selectOrderRate" resultType="com.alibaba.fastjson.JSONObject">
  1746. SELECT
  1747. count(oid) as 'allNumber',
  1748. IFNULL(sum(order_amount),0) AS 'orderAmount'
  1749. FROM kuaishou_supply_chain
  1750. WHERE stat_date >= #{statDate}
  1751. AND stat_date &lt;= #{endDate}
  1752. AND stat_hour &lt;=#{hour}
  1753. <if test='promoterIds != null and promoterIds.size() > 0'>
  1754. AND promoter_id in
  1755. <foreach collection="promoterIds" item="item" separator=","
  1756. open="(" close=")">
  1757. #{item}
  1758. </foreach>
  1759. </if>
  1760. <if test='itemIds != null and itemIds.size() > 0'>
  1761. AND item_id in
  1762. <foreach collection="itemIds" item="item" separator=","
  1763. open="(" close=")">
  1764. #{item}
  1765. </foreach>
  1766. </if>
  1767. </select>
  1768. <select id="selectOrderRateBytedance" resultType="com.alibaba.fastjson.JSONObject">
  1769. SELECT
  1770. count(order_id) as 'allNumber',
  1771. IFNULL(sum(
  1772. CASE
  1773. WHEN flow_point != 'REFUND' THEN total_pay_amount
  1774. ELSE 0
  1775. END
  1776. )/100,0) AS 'orderAmount'
  1777. FROM ruixuan.bytedance_order_list
  1778. WHERE pay_success_time >= #{statDate}
  1779. AND pay_success_time &lt;= #{endDate}
  1780. <if test='hour != null'>
  1781. AND pay_success_time_hour &lt;=#{hour}
  1782. </if>
  1783. <if test='promoterIds != null and promoterIds.size() > 0'>
  1784. AND author_short_id in
  1785. <foreach collection="promoterIds" item="item" separator=","
  1786. open="(" close=")">
  1787. #{item}
  1788. </foreach>
  1789. </if>
  1790. <if test='itemIds != null and itemIds.size() > 0'>
  1791. AND product_id in
  1792. <foreach collection="itemIds" item="item" separator=","
  1793. open="(" close=")">
  1794. #{item}
  1795. </foreach>
  1796. </if>
  1797. </select>
  1798. <select id="getMonthOrderAmount" resultType="com.alibaba.fastjson.JSONObject">
  1799. select t.* ,t2.valid_order_rate as 'validOrderRate',
  1800. t2.valid_gmv_rate as 'validGmvRate'
  1801. from (
  1802. SELECT
  1803. stat_date as 'date',
  1804. DATE_FORMAT(stat_date, '%Y%m%d') as 'dateInt',
  1805. count(1) AS 'orderCount',
  1806. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
  1807. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1808. IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) AS 'validOrderAmount',
  1809. concat( round(IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) / count(1) * 100,2 ),'%') as
  1810. 'validOrderCountRate',
  1811. concat( round(IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END), 0) /IFNULL(SUM(
  1812. order_amount),0) * 100,2 ),'%') as 'validOrderAmountRate',
  1813. IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
  1814. 'regimentalPromotionAmount',
  1815. COUNT(DISTINCT promoter_id) as 'promoterCount'
  1816. FROM kuaishou_supply_chain t1
  1817. WHERE stat_date >= #{startLong}
  1818. AND stat_date &lt;= #{endLong}
  1819. <if test='promoterIds != null and promoterIds.size() > 0'>
  1820. AND promoter_id in
  1821. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1822. #{item}
  1823. </foreach>
  1824. </if>
  1825. GROUP BY stat_date) t left join valid_order_gmv_rate t2
  1826. on t.dateInt = t2.stat_date
  1827. </select>
  1828. <select id="getMonthOrderAmountBytedance" resultType="com.alibaba.fastjson.JSONObject">
  1829. select t.*,t2.valid_order_rate as 'validOrderRate', t2.valid_gmv_rate as 'validGmvRate'
  1830. from(
  1831. SELECT
  1832. DATE_FORMAT(pay_success_time, '%Y-%m-%d') as 'date',
  1833. pay_success_time as 'dateInt',
  1834. count(1) AS 'orderCount',
  1835. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
  1836. IFNULL(SUM( total_pay_amount),0) AS 'orderAmount',
  1837. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END),0) AS 'validOrderAmount',
  1838. concat( round(IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) / count(1) * 100,2 ),'%') as
  1839. 'validOrderCountRate',
  1840. concat( round(IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END), 0) /IFNULL(SUM(
  1841. total_pay_amount),0) * 100,2 ),'%') as 'validOrderAmountRate',
  1842. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9 ,0) AS
  1843. 'regimentalPromotionAmount',
  1844. COUNT(DISTINCT author_short_id) as 'promoterCount'
  1845. FROM ruixuan.bytedance_order_list
  1846. WHERE pay_success_time >= #{startLong}
  1847. AND pay_success_time &lt;= #{endLong}
  1848. <if test='promoterIds != null and promoterIds.size() > 0'>
  1849. AND author_short_id in
  1850. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1851. #{item}
  1852. </foreach>
  1853. </if>
  1854. GROUP BY pay_success_time) t left join ruixuan.bytedance_valid_order_gmv_rate t2
  1855. on t.dateInt = t2.stat_date
  1856. </select>
  1857. <select id="getMonthOrderAmountByItems" resultType="com.alibaba.fastjson.JSONObject">
  1858. select t.*,t2.valid_order_rate as 'validOrderRate',
  1859. t2.valid_gmv_rate as 'validGmvRate'
  1860. from (
  1861. SELECT
  1862. stat_date as 'date',
  1863. DATE_FORMAT(stat_date, '%Y%m%d') as 'dateInt',
  1864. count(1) AS 'orderCount',
  1865. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
  1866. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1867. IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) AS 'validOrderAmount',
  1868. concat( round(IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) / count(1) * 100,2 ),'%') as
  1869. 'validOrderCountRate',
  1870. concat( round(IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END), 0) /IFNULL(SUM(
  1871. order_amount),0) * 100,2 ),'%') as 'validOrderAmountRate',
  1872. IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
  1873. 'regimentalPromotionAmount'
  1874. FROM kuaishou_supply_chain
  1875. WHERE stat_date >= #{IntStart}
  1876. AND stat_date &lt;= #{IntEnd}
  1877. <if test='itemIds != null and itemIds.size() > 0'>
  1878. AND item_id in
  1879. <foreach collection="itemIds" item="item" separator=","
  1880. open="(" close=")">
  1881. #{item}
  1882. </foreach>
  1883. </if>
  1884. GROUP BY stat_date) t left join valid_order_gmv_rate t2
  1885. on t.dateInt = t2.stat_date
  1886. </select>
  1887. <select id="getMonthOrderAmountByItemsBytedance" resultType="com.alibaba.fastjson.JSONObject">
  1888. select t.*, t2.valid_order_rate as 'validOrderRate',
  1889. t2.valid_gmv_rate as 'validGmvRate'
  1890. from (
  1891. SELECT
  1892. DATE_FORMAT(pay_success_time, '%Y-%m-%d') as 'date',
  1893. pay_success_time as 'dateInt',
  1894. count(1) AS 'orderCount',
  1895. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
  1896. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END),0) AS 'orderAmount',
  1897. concat( round(IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) / count(1) * 100,2 ),'%') as
  1898. 'validOrderCountRate',
  1899. concat( round(IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END), 0) /IFNULL(SUM(
  1900. total_pay_amount),0) * 100,2 ),'%') as 'validOrderAmountRate',
  1901. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
  1902. 'regimentalPromotionAmount'
  1903. FROM ruixuan.bytedance_order_list
  1904. WHERE pay_success_time >= #{startLong}
  1905. AND pay_success_time &lt;= #{endLong}
  1906. <if test='itemIds != null and itemIds.size() > 0'>
  1907. AND product_id in
  1908. <foreach collection="itemIds" item="item" separator=","
  1909. open="(" close=")">
  1910. #{item}
  1911. </foreach>
  1912. </if>
  1913. GROUP BY pay_success_time) t left join ruixuan.bytedance_valid_order_gmv_rate t2
  1914. on t.dateInt = t2.stat_date
  1915. </select>
  1916. <select id="getMonthOrderAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  1917. SELECT
  1918. t1.orderAmount,
  1919. t1.regimentalPromotionAmount,
  1920. CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
  1921. CONCAT(IFNULL(ROUND(t2.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
  1922. 'regimentalPromotionAmountRate'
  1923. FROM
  1924. (
  1925. SELECT
  1926. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1927. IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount'
  1928. FROM kuaishou_supply_chain t1
  1929. WHERE order_status != 80
  1930. <if test='promoterIds != null and promoterIds.size() > 0'>
  1931. AND promoter_id in
  1932. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1933. #{item}
  1934. </foreach>
  1935. </if>
  1936. AND stat_date >= #{startLong}
  1937. AND stat_date &lt;= #{endLong}) t1
  1938. LEFT JOIN
  1939. (
  1940. SELECT
  1941. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1942. IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount'
  1943. FROM kuaishou_supply_chain t1
  1944. WHERE order_status != 80
  1945. <if test='promoterIds != null and promoterIds.size() > 0'>
  1946. AND promoter_id in
  1947. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1948. #{item}
  1949. </foreach>
  1950. </if>
  1951. AND stat_date >= #{endLong})t2 ON 1=1
  1952. </select>
  1953. <select id="getMonthOrderAmountTotalBytedance" resultType="com.alibaba.fastjson.JSONObject">
  1954. SELECT
  1955. t1.orderAmount,
  1956. t1.regimentalPromotionAmount,
  1957. CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
  1958. CONCAT(IFNULL(ROUND(t2.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
  1959. 'regimentalPromotionAmountRate'
  1960. FROM
  1961. (
  1962. SELECT
  1963. IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
  1964. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
  1965. 'regimentalPromotionAmount'
  1966. FROM ruixuan.bytedance_order_list t1
  1967. WHERE flow_point != 'REFUND'
  1968. <if test='promoterIds != null and promoterIds.size() > 0'>
  1969. AND author_short_id in
  1970. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1971. #{item}
  1972. </foreach>
  1973. </if>
  1974. AND pay_success_time >= #{startLong}
  1975. AND pay_success_time &lt;= #{endLong}) t1
  1976. LEFT JOIN
  1977. (
  1978. SELECT
  1979. IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
  1980. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
  1981. 'regimentalPromotionAmount'
  1982. FROM ruixuan.bytedance_order_list t1
  1983. WHERE flow_point != 'REFUND'
  1984. <if test='promoterIds != null and promoterIds.size() > 0'>
  1985. AND author_short_id in
  1986. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1987. #{item}
  1988. </foreach>
  1989. </if>
  1990. AND pay_success_time >= #{toStartLong}
  1991. AND pay_success_time &lt;= #{endLong})t2 ON 1=1
  1992. </select>
  1993. <select id="getMonthOrderAmountTotalByItems" resultType="com.alibaba.fastjson.JSONObject">
  1994. SELECT
  1995. t1.orderAmount,
  1996. t1.regimentalPromotionAmount,
  1997. t1.orderCount,
  1998. CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
  1999. CONCAT(IFNULL(ROUND(t2.orderCount/t1.orderCount*100,2),0),'%') as 'orderCountRate',
  2000. CONCAT(IFNULL(ROUND(t2.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
  2001. 'regimentalPromotionAmountRate'
  2002. FROM
  2003. (
  2004. SELECT
  2005. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  2006. IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount',
  2007. COUNT(oid) as 'orderCount'
  2008. FROM kuaishou_supply_chain t1
  2009. WHERE order_status != 80
  2010. <if test='itemIds != null and itemIds.size() > 0'>
  2011. AND item_id in
  2012. <foreach collection="itemIds" item="item" separator=","
  2013. open="(" close=")">
  2014. #{item}
  2015. </foreach>
  2016. </if>
  2017. AND stat_date >= #{IntStart}
  2018. AND stat_date &lt;= #{IntEnd}
  2019. )t1
  2020. LEFT JOIN
  2021. (
  2022. SELECT
  2023. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  2024. IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount',
  2025. COUNT(oid) as 'orderCount'
  2026. FROM kuaishou_supply_chain t1
  2027. WHERE order_status != 80
  2028. <if test='itemIds != null and itemIds.size() > 0'>
  2029. AND item_id in
  2030. <foreach collection="itemIds" item="item" separator=","
  2031. open="(" close=")">
  2032. #{item}
  2033. </foreach>
  2034. </if>
  2035. AND stat_date = #{IntEnd}
  2036. )t2 ON 1=1
  2037. </select>
  2038. <select id="getMonthOrderAmountTotalByItemsBytedance" resultType="com.alibaba.fastjson.JSONObject">
  2039. SELECT
  2040. t1.orderAmount,
  2041. t1.regimentalPromotionAmount,
  2042. t1.orderCount,
  2043. CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
  2044. CONCAT(IFNULL(ROUND(t2.orderCount/t1.orderCount*100,2),0),'%') as 'orderCountRate',
  2045. CONCAT(IFNULL(ROUND(t2.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
  2046. 'regimentalPromotionAmountRate'
  2047. FROM
  2048. (
  2049. SELECT
  2050. IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
  2051. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
  2052. 'regimentalPromotionAmount',
  2053. COUNT(order_id) as 'orderCount'
  2054. FROM ruixuan.bytedance_order_list t1
  2055. WHERE flow_point != 'REFUND'
  2056. <if test='itemIds != null and itemIds.size() > 0'>
  2057. AND product_id in
  2058. <foreach collection="itemIds" item="item" separator=","
  2059. open="(" close=")">
  2060. #{item}
  2061. </foreach>
  2062. </if>
  2063. AND pay_success_time >= #{IntStart}
  2064. AND pay_success_time &lt;= #{IntEnd}
  2065. )t1
  2066. LEFT JOIN
  2067. (
  2068. SELECT
  2069. IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
  2070. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
  2071. 'regimentalPromotionAmount',
  2072. COUNT(order_id) as 'orderCount'
  2073. FROM ruixuan.bytedance_order_list t1
  2074. WHERE flow_point != 'REFUND'
  2075. <if test='itemIds != null and itemIds.size() > 0'>
  2076. AND product_id in
  2077. <foreach collection="itemIds" item="item" separator=","
  2078. open="(" close=")">
  2079. #{item}
  2080. </foreach>
  2081. </if>
  2082. AND pay_success_time >= #{IntStart}
  2083. AND pay_success_time &lt;= #{IntEnd}
  2084. )t2 ON 1=1
  2085. </select>
  2086. <select id="bdReportList" resultType="com.alibaba.fastjson.JSONObject">
  2087. select
  2088. t1.collectSampleId,
  2089. t1.collectSampleName,
  2090. t2.promoterCount,
  2091. t3.sampleCount,
  2092. round(t3.sampleCount / t2.promoterCount * 100, 2) as 'sampleRate',
  2093. t2.promoterCount - t3.sampleCount as 'notSampleCount',
  2094. t1.orderNum,
  2095. t1.validOrderNum,
  2096. t1.validOrderRate,
  2097. t1.orderAmount,
  2098. t1.regimentalPromotionAmount,
  2099. t1.totalRegimentalSettleAmount,
  2100. t4.sendTotalCount,
  2101. t4.sendPromoterCount,
  2102. t4.sendItemCount,
  2103. t1.voucherOrderNum,
  2104. t1.voucherValidOrderNum,
  2105. t1.voucherOrderAmount,
  2106. t1.voucherRegimentalPromotionAmount,
  2107. t1.voucherTotalRegimentalSettleAmount,
  2108. IFNULL(t5.promoters_count,'-') as 'promotersCount'
  2109. from (
  2110. select collect_sample_id as 'collectSampleId',
  2111. collect_sample_name as 'collectSampleName',
  2112. sum(order_num) as 'orderNum',
  2113. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_num ELSE 0 END), 0) AS 'voucherOrderNum',
  2114. sum(valid_order_num) as 'validOrderNum',
  2115. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN valid_order_num ELSE 0 END), 0) AS 'voucherValidOrderNum',
  2116. round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
  2117. sum(order_amount) as 'orderAmount',
  2118. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_amount ELSE 0 END), 0) AS 'voucherOrderAmount',
  2119. sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
  2120. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN regimental_promotion_amount ELSE 0 END), 0)
  2121. AS'voucherRegimentalPromotionAmount',
  2122. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount',
  2123. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN total_regimental_settle_amount ELSE 0 END), 0) AS
  2124. 'voucherTotalRegimentalSettleAmount'
  2125. from promoter_item_order_count1
  2126. where 1 = 1
  2127. <if test="start != null and start != ''">
  2128. and stat_date &gt;= #{start}
  2129. </if>
  2130. <if test="end != null and end != ''">
  2131. and stat_date &lt;= #{end}
  2132. </if>
  2133. <if test="collectSampleId != null and collectSampleId != ''">
  2134. and collect_sample_id = #{collectSampleId}
  2135. </if>
  2136. group by collect_sample_id) t1
  2137. left join (
  2138. select user_id as 'userId',
  2139. count(distinct promoter_id) as 'promoterCount'
  2140. from kuaishou_promoter
  2141. group by user_id) t2
  2142. on t1.collectSampleId = t2.userId
  2143. left join (
  2144. select collect_sample_id as 'collectSampleId',
  2145. count(distinct promoter_id) as 'sampleCount'
  2146. from kuaishou_item_collect_samples
  2147. where collect_sample_status > 2
  2148. group by collect_sample_id) t3
  2149. on t2.userId = t3.collectSampleId
  2150. left join (
  2151. select collect_sample_id as 'collectSampleId',
  2152. count(1) as 'sendTotalCount',
  2153. count(distinct promoter_id) as 'sendPromoterCount',
  2154. count(distinct item_id) as 'sendItemCount'
  2155. from kuaishou_item_collect_samples
  2156. where collect_sample_status > 2
  2157. <if test="collectSampleId != null and collectSampleId != ''">
  2158. and collect_sample_id = #{collectSampleId}
  2159. </if>
  2160. <if test="start != null and start != ''">
  2161. and create_time &gt;= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
  2162. %H:%i:%s')
  2163. </if>
  2164. <if test="end != null and end != ''">
  2165. and create_time &lt;= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
  2166. </if>
  2167. group by collect_sample_id
  2168. ) t4
  2169. on t1.collectSampleId = t4.collectSampleId
  2170. left join (
  2171. select user_id,promoters_count
  2172. from user_promoters_count
  2173. where media_id = 2
  2174. ) t5
  2175. on t1.collectSampleId = t5.user_id
  2176. order by t1.orderNum desc
  2177. </select>
  2178. <select id="bdDetailList" resultType="com.alibaba.fastjson.JSONObject">
  2179. select
  2180. t1.promoterId,
  2181. t1.promoterName,
  2182. t1.promoterUrl,
  2183. t2.sampleCount,
  2184. t1.orderNum,
  2185. t1.validOrderNum,
  2186. t1.validOrderRate,
  2187. t1.orderAmount,
  2188. t1.regimentalPromotionAmount,
  2189. t1.totalRegimentalSettleAmount
  2190. from (
  2191. select promoter_id as 'promoterId',
  2192. promoter_name as 'promoterName',
  2193. promoter_url as 'promoterUrl',
  2194. sum(order_num) as 'orderNum',
  2195. sum(valid_order_num) as 'validOrderNum',
  2196. round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
  2197. sum(order_amount) as 'orderAmount',
  2198. sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
  2199. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
  2200. from promoter_item_order_count1
  2201. where 1 = 1
  2202. <if test="start != null and start != ''">
  2203. and stat_date &gt;= #{start}
  2204. </if>
  2205. <if test="end != null and end != ''">
  2206. and stat_date &lt;= #{end}
  2207. </if>
  2208. <if test="collectSampleId != null and collectSampleId != ''">
  2209. and collect_sample_id = #{collectSampleId}
  2210. </if>
  2211. group by promoter_id) t1
  2212. left join (
  2213. select promoter_id as 'promoterId',
  2214. count(distinct item_id) as 'sampleCount'
  2215. from kuaishou_item_collect_samples
  2216. where collect_sample_status > 2
  2217. <if test="collectSampleId != null and collectSampleId != ''">
  2218. and collect_sample_id = #{collectSampleId}
  2219. </if>
  2220. group by promoter_id) t2
  2221. on t1.promoterId = t2.promoterId
  2222. order by ${fieId} ${sort}
  2223. </select>
  2224. <select id="bdTotal" resultType="com.alibaba.fastjson.JSONObject">
  2225. select
  2226. t2.sampleCount,
  2227. t1.orderNum,
  2228. t1.validOrderNum,
  2229. t1.validOrderRate,
  2230. t1.orderAmount,
  2231. t1.regimentalPromotionAmount,
  2232. t1.totalRegimentalSettleAmount
  2233. from (
  2234. select
  2235. sum(order_num) as 'orderNum',
  2236. sum(valid_order_num) as 'validOrderNum',
  2237. round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
  2238. sum(order_amount) as 'orderAmount',
  2239. sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
  2240. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
  2241. from promoter_item_order_count1
  2242. where 1 = 1
  2243. <if test="start != null and start != ''">
  2244. and stat_date &gt;= #{start}
  2245. </if>
  2246. <if test="end != null and end != ''">
  2247. and stat_date &lt;= #{end}
  2248. </if>
  2249. <if test="collectSampleId != null and collectSampleId != ''">
  2250. and collect_sample_id = #{collectSampleId}
  2251. </if>
  2252. ) t1
  2253. join (
  2254. select
  2255. count(distinct item_id) as 'sampleCount'
  2256. from kuaishou_item_collect_samples
  2257. where collect_sample_status > 2
  2258. <if test="collectSampleId != null and collectSampleId != ''">
  2259. and collect_sample_id = #{collectSampleId}
  2260. </if>
  2261. ) t2
  2262. </select>
  2263. <select id="exportBdDetail" resultType="com.alibaba.fastjson.JSONObject">
  2264. select
  2265. t1.promoterId,
  2266. t1.promoterName,
  2267. t1.promoterUrl,
  2268. t2.sampleCount,
  2269. t1.orderNum,
  2270. t1.validOrderNum,
  2271. t1.validOrderRate,
  2272. t1.orderAmount,
  2273. t1.regimentalPromotionAmount,
  2274. t1.totalRegimentalSettleAmount
  2275. from (
  2276. select promoter_id as 'promoterId',
  2277. promoter_name as 'promoterName',
  2278. promoter_url as 'promoterUrl',
  2279. sum(order_num) as 'orderNum',
  2280. sum(valid_order_num) as 'validOrderNum',
  2281. round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
  2282. sum(order_amount) as 'orderAmount',
  2283. sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
  2284. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
  2285. from promoter_item_order_count1
  2286. where 1 = 1
  2287. <if test="start != null and start != ''">
  2288. and stat_date &gt;= #{start}
  2289. </if>
  2290. <if test="end != null and end != ''">
  2291. and stat_date &lt;= #{end}
  2292. </if>
  2293. <if test="collectSampleId != null and collectSampleId != ''">
  2294. and collect_sample_id = #{collectSampleId}
  2295. </if>
  2296. group by promoter_id) t1
  2297. left join (
  2298. select promoter_id as 'promoterId',
  2299. count(distinct item_id) as 'sampleCount'
  2300. from kuaishou_item_collect_samples
  2301. where collect_sample_status > 2
  2302. <if test="collectSampleId != null and collectSampleId != ''">
  2303. and collect_sample_id = #{collectSampleId}
  2304. </if>
  2305. group by promoter_id) t2
  2306. on t1.promoterId = t2.promoterId
  2307. order by t1.orderNum desc
  2308. </select>
  2309. <select id="getUserList" resultType="com.alibaba.fastjson.JSONObject">
  2310. select promoter_id as 'promoterId', group_concat(user_name) as 'userName'
  2311. from kuaishou_promoter where promoter_id in
  2312. <foreach collection="map.values" item="v" separator="," open="(" close=")">
  2313. ${v}
  2314. </foreach>
  2315. GROUP BY promoter_id
  2316. </select>
  2317. <select id="getUserName" resultType="java.lang.String" parameterType="java.lang.Long">
  2318. SELECT group_concat(user_name) AS 'userName'
  2319. FROM kuaishou_promoter
  2320. WHERE promoter_id = #{promoterId}
  2321. </select>
  2322. <select id="exportBdReportList" resultType="com.alibaba.fastjson.JSONObject">
  2323. select
  2324. t1.collectSampleId,
  2325. t1.collectSampleName,
  2326. t2.promoterCount,
  2327. t3.sampleCount,
  2328. round(t3.sampleCount / t2.promoterCount * 100, 2) as 'sampleRate',
  2329. t2.promoterCount - t3.sampleCount as 'notSampleCount',
  2330. t1.orderNum,
  2331. t1.validOrderNum,
  2332. t1.validOrderRate,
  2333. round(t1.orderAmount / 100,2) as 'orderAmount',
  2334. round(t1.regimentalPromotionAmount / 100 ,2 ) as 'regimentalPromotionAmount',
  2335. round(t1.totalRegimentalSettleAmount / 100 , 2) as 'totalRegimentalSettleAmount',
  2336. t4.sendTotalCount,
  2337. t4.sendPromoterCount,
  2338. t4.sendItemCount,
  2339. t1.voucherOrderNum,
  2340. t1.voucherValidOrderNum,
  2341. round(t1.voucherOrderAmount / 100 ,2) as 'voucherOrderAmount',
  2342. round(t1.voucherRegimentalPromotionAmount / 100 ,2) as 'voucherRegimentalPromotionAmount',
  2343. round( t1.voucherTotalRegimentalSettleAmount / 100 , 2) as 'voucherTotalRegimentalSettleAmount'
  2344. from (
  2345. select collect_sample_id as 'collectSampleId',
  2346. collect_sample_name as 'collectSampleName',
  2347. sum(order_num) as 'orderNum',
  2348. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_num ELSE 0 END), 0) AS 'voucherOrderNum',
  2349. sum(valid_order_num) as 'validOrderNum',
  2350. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN valid_order_num ELSE 0 END), 0) AS 'voucherValidOrderNum',
  2351. round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
  2352. sum(order_amount) as 'orderAmount',
  2353. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_amount ELSE 0 END), 0) AS 'voucherOrderAmount',
  2354. sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
  2355. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN regimental_promotion_amount ELSE 0 END), 0)
  2356. AS'voucherRegimentalPromotionAmount',
  2357. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount',
  2358. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN total_regimental_settle_amount ELSE 0 END), 0) AS
  2359. 'voucherTotalRegimentalSettleAmount'
  2360. from promoter_item_order_count1
  2361. where 1 = 1
  2362. <if test="start != null and start != ''">
  2363. and stat_date &gt;= #{start}
  2364. </if>
  2365. <if test="end != null and end != ''">
  2366. and stat_date &lt;= #{end}
  2367. </if>
  2368. <if test="collectSampleId != null and collectSampleId != ''">
  2369. and collect_sample_id = #{collectSampleId}
  2370. </if>
  2371. group by collect_sample_id) t1
  2372. left join (
  2373. select user_id as 'userId',
  2374. count(distinct promoter_id) as 'promoterCount'
  2375. from kuaishou_promoter
  2376. group by user_id) t2
  2377. on t1.collectSampleId = t2.userId
  2378. left join (
  2379. select collect_sample_id as 'collectSampleId',
  2380. count(distinct promoter_id) as 'sampleCount'
  2381. from kuaishou_item_collect_samples
  2382. where collect_sample_status > 2
  2383. group by collect_sample_id) t3
  2384. on t2.userId = t3.collectSampleId
  2385. left join (
  2386. select collect_sample_id as 'collectSampleId',
  2387. count(1) as 'sendTotalCount',
  2388. count(distinct promoter_id) as 'sendPromoterCount',
  2389. count(distinct item_id) as 'sendItemCount'
  2390. from kuaishou_item_collect_samples
  2391. where collect_sample_status > 2
  2392. <if test="collectSampleId != null and collectSampleId != ''">
  2393. and collect_sample_id = #{collectSampleId}
  2394. </if>
  2395. <if test="start != null and start != ''">
  2396. and create_time &gt;= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
  2397. %H:%i:%s')
  2398. </if>
  2399. <if test="end != null and end != ''">
  2400. and create_time &lt;= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
  2401. </if>
  2402. group by collect_sample_id
  2403. ) t4
  2404. on t1.collectSampleId = t4.collectSampleId
  2405. order by t1.orderNum desc
  2406. </select>
  2407. <select id="exportAdminReportList" resultType="com.alibaba.fastjson.JSONObject">
  2408. select t.*,
  2409. t1.sendSampleCount,
  2410. IFNULL(ROUND(((t.orderNum-t3.orderNum)/t3.orderNum)*100,2),0) as 'orderNumRoi'
  2411. from (select t1.user_id as 'userId',
  2412. t1.user_name as 'userName',
  2413. count(distinct t2.item_id) as 'itemCount',
  2414. count(t2.oid) as 'orderNum',
  2415. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  2416. round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100,2) as 'validRadio',
  2417. sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  2418. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  2419. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
  2420. when t2.order_status != 80
  2421. then 1
  2422. else 0 end) * 100,
  2423. 2) as 'deliveryRadio',
  2424. sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  2425. round(sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) / 100 , 2) as 'payAmount',
  2426. round(sum(case
  2427. when t2.order_status != 80 then t2.regimental_promotion_amount
  2428. else 0 end) / 100, 2 )as 'regimentalPromotionAmount',
  2429. round(sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100 , 2) as
  2430. 'totalRegimentalSettleAmount',
  2431. round( sum(case
  2432. when t2.order_status != 80 then t2.regimental_promotion_amount
  2433. else 0 end) / sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) * 100 ,2) as 'avgServiceRate'
  2434. from kuaishou_item_bind_user t1
  2435. left join kuaishou_supply_chain t2
  2436. on t1.item_id = t2.item_id
  2437. where t2.stat_hour &lt;= #{hour}
  2438. <if test="startDate != null and startDate != ''">
  2439. and t2.stat_date &gt;= DATE_FORMAT(#{startDate},'%Y%m%d')
  2440. </if>
  2441. <if test="endDate != null and endDate != ''">
  2442. and t2.stat_date &lt;= DATE_FORMAT(#{endDate},'%Y%m%d')
  2443. </if>
  2444. group by t1.user_id) t left join (
  2445. select item_create_id,count(1) as 'sendSampleCount' from kuaishou_item_collect_samples
  2446. where courier_number_time >= #{startDate}
  2447. and courier_number_time &lt;= #{endDate}
  2448. group by item_create_id
  2449. ) t1 on t.userId = t1.item_create_id
  2450. left join (
  2451. select t1.user_id as 'userId',
  2452. count(t2.oid) as 'orderNum'
  2453. from kuaishou_item_bind_user t1
  2454. left join kuaishou_supply_chain t2
  2455. on t1.item_id = t2.item_id
  2456. where t2.stat_hour &lt;= #{hour}
  2457. <if test="lastTimeStart != null and lastTimeStart != ''">
  2458. and t2.stat_date &gt;= #{lastTimeStart}
  2459. </if>
  2460. <if test="lastTimeEnd != null and lastTimeEnd != ''">
  2461. and t2.stat_date &lt;= #{lastTimeEnd}
  2462. </if>
  2463. group by t1.user_id
  2464. ) t3 on t.userId = t3.userId
  2465. where 1 =1
  2466. <if test="userId != null and userId != ''">
  2467. and t.userId = #{userId}
  2468. </if>
  2469. order by t.orderNum desc
  2470. </select>
  2471. <select id="getSupplyChainCourtshipUserList" resultType="com.alibaba.fastjson.JSONObject">
  2472. SELECT t3.user_id AS 'userId', t3.nick_name AS 'nickMame', t1.role_name AS 'roleName', t3.status
  2473. FROM sys_role t1
  2474. LEFT JOIN sys_user_role t2 ON t1.role_id = t2.role_id
  2475. LEFT JOIN sys_user t3 ON t2.user_id = t3.user_id
  2476. WHERE t1.role_key IN (
  2477. 'courtship',
  2478. 'courtshipManager'
  2479. )
  2480. AND t3.status = 0
  2481. GROUP BY t3.user_id
  2482. ORDER BY t3.create_time ASC
  2483. </select>
  2484. <select id="adminReportListByBind" resultType="com.alibaba.fastjson.JSONObject">
  2485. select * from (
  2486. select t1.user_id as 'userId',
  2487. t1.user_name as 'userName',
  2488. count(distinct t1.item_id) as 'itemCount',
  2489. count(t2.oid) as 'orderNum',
  2490. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  2491. round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid), 4) as 'validRadio',
  2492. sum(case when t2.send_status = 1 then 1 else 0 end) as 'deliveryNum',
  2493. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  2494. then 1 else 0 end),4) as 'shippingGreen',
  2495. sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  2496. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  2497. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
  2498. when t2.send_status = 1
  2499. then 1
  2500. else 0 end),
  2501. 4) as 'deliveryRadio',
  2502. sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  2503. sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) as 'payAmount',
  2504. sum(case
  2505. when t2.order_status != 80 then t2.regimental_promotion_amount
  2506. else 0 end) as 'regimentalPromotionAmount',
  2507. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  2508. 'totalRegimentalSettleAmount',
  2509. round( sum(case
  2510. when t2.order_status != 80 then t2.regimental_promotion_amount
  2511. else 0 end) / sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) ,5) as 'avgServiceRate'
  2512. from kuaishou_item_list t1
  2513. left join (select item_id,
  2514. oid,
  2515. order_status,
  2516. send_status,
  2517. pay_amount,
  2518. regimental_promotion_amount,
  2519. total_regimental_settle_amount
  2520. from kuaishou_supply_chain
  2521. where stat_date &gt;= DATE_FORMAT(#{startDate},'%Y%m%d') ) t2
  2522. on t1.item_id = t2.item_id
  2523. where t1.create_time >= #{startDate}
  2524. and t1.create_time &lt;= #{endDate}
  2525. <if test="userId != null and userId != ''">
  2526. and t1.user_id = #{userId}
  2527. </if>
  2528. group by t1.user_id ) t left join (
  2529. select t1.user_id,count(distinct courier_number) as 'sendSampleCount' from kuaishou_item_list t1 left join
  2530. kuaishou_item_collect_samples t2
  2531. on t1.item_id = t2.item_id
  2532. where t1.create_time >= #{startDate}
  2533. and t1.create_time &lt;= #{endDate}
  2534. and t2.courier_number_time >= #{startDate}
  2535. group by t1.user_id
  2536. ) t2 on t.userId = t2.user_id order by t.orderNum desc
  2537. </select>
  2538. <select id="exportAdminReportListByBind" resultType="com.alibaba.fastjson.JSONObject">
  2539. select * from (
  2540. select t1.user_id as 'userId',
  2541. t1.user_name as 'userName',
  2542. count(distinct t1.item_id) as 'itemCount',
  2543. count(t2.oid) as 'orderNum',
  2544. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  2545. round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100,2) as 'validRadio',
  2546. sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  2547. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  2548. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
  2549. when t2.order_status != 80
  2550. then 1
  2551. else 0 end) * 100,
  2552. 2) as 'deliveryRadio',
  2553. sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  2554. round(sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) / 100 , 2) as 'payAmount',
  2555. round(sum(case
  2556. when t2.order_status != 80 then t2.regimental_promotion_amount
  2557. else 0 end) / 100, 2 )as 'regimentalPromotionAmount',
  2558. round(sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100 , 2) as
  2559. 'totalRegimentalSettleAmount',
  2560. round( sum(case
  2561. when t2.order_status != 80 then t2.regimental_promotion_amount
  2562. else 0 end) / sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) * 100 ,2) as 'avgServiceRate'
  2563. from kuaishou_item_list t1
  2564. left join (select item_id,
  2565. oid,
  2566. order_status,
  2567. send_status,
  2568. pay_amount,
  2569. regimental_promotion_amount,
  2570. total_regimental_settle_amount
  2571. from kuaishou_supply_chain
  2572. where stat_date &gt;= DATE_FORMAT(#{startDate},'%Y%m%d') ) t2
  2573. on t1.item_id = t2.item_id
  2574. where t1.create_time >= #{startDate}
  2575. and t1.create_time &lt;= #{endDate}
  2576. <if test="userId != null and userId != ''">
  2577. and t1.userId = #{userId}
  2578. </if>
  2579. group by t1.user_id ) t left join (
  2580. select t1.user_id,count(distinct courier_number) as 'sendSampleCount' from kuaishou_item_list t1 left join
  2581. kuaishou_item_collect_samples t2
  2582. on t1.item_id = t2.item_id
  2583. where t1.create_time >= #{startDate}
  2584. and t1.create_time &lt;= #{endDate}
  2585. and t2.courier_number_time >= #{startDate}
  2586. group by t1.user_id
  2587. ) t2 on t.userId = t2.user_id order by t.orderNum desc;
  2588. </select>
  2589. <select id="bdReportListV2" resultType="com.alibaba.fastjson.JSONObject">
  2590. select t.*,
  2591. tt.promoterCount,
  2592. ttt.sampleCount,
  2593. tttt.sendTotalCount,
  2594. tttt.sendPromoterCount,
  2595. tttt.sendItemCount,
  2596. IFNULL( ttttt.promoters_count,'-') as 'promotersCount',
  2597. concat(round(ttt.sampleCount / tt.promoterCount * 100, 2), '%') as 'sampleRate',
  2598. tt.promoterCount - ttt.sampleCount as 'notSampleCount'
  2599. from (
  2600. select t1.user_id as 'collectSampleId',
  2601. t1.user_name as 'collectSampleName',
  2602. sum(t2.orderNum) as 'orderNum',
  2603. sum(t2.validOrderNum) as 'validOrderNum',
  2604. concat(round( sum(t2.validOrderNum) / sum(t2.orderNum) * 100,
  2605. 2),
  2606. '%') as 'validOrderRate',
  2607. round(sum(t2.orderAmount) / 100, 2) as 'orderAmount',
  2608. round(sum(t2.regimentalPromotionAmount) / 100, 2) as 'regimentalPromotionAmount',
  2609. round(sum(t2.totalRegimentalSettleAmount) / 100, 2) as 'totalRegimentalSettleAmount'
  2610. from promoter_bind_channel_date t1
  2611. left join (select promoter_id as 'promoter_id',
  2612. stat_date as 'stat_date',
  2613. count(oid) as 'orderNum',
  2614. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNum',
  2615. sum(order_amount) as 'orderAmount',
  2616. sum(
  2617. CASE
  2618. WHEN order_status != 80 THEN regimental_promotion_amount
  2619. ELSE 0
  2620. END
  2621. ) AS 'regimentalPromotionAmount',
  2622. sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
  2623. 'totalRegimentalSettleAmount'
  2624. from kuaishou_supply_chain
  2625. where stat_date &gt;= #{start}
  2626. and stat_date &lt;= #{end}
  2627. group by promoter_id, stat_date) t2
  2628. on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
  2629. where 1 = 1
  2630. and t1.media_id = 2
  2631. <if test="start != null and start != ''">
  2632. and t1.stat_date &gt;= #{start}
  2633. </if>
  2634. <if test="end != null and end != ''">
  2635. and t1.stat_date &lt;= #{end}
  2636. </if>
  2637. <if test="collectSampleId != null and collectSampleId != ''">
  2638. and t1.user_id = #{collectSampleId}
  2639. </if>
  2640. group by t1.user_id) t
  2641. left join (select user_id,
  2642. count(distinct promoter_id) as 'promoterCount'
  2643. from kuaishou_promoter
  2644. group by user_id) tt on t.collectSampleId = tt.user_id
  2645. left join (select collect_sample_id as 'user_id',
  2646. count(distinct promoter_id) as 'sampleCount'
  2647. from kuaishou_item_collect_samples
  2648. where collect_sample_status > 2
  2649. group by collect_sample_id) ttt on t.collectSampleId = ttt.user_id
  2650. left join (select collect_sample_id as 'user_id',
  2651. count(1) as 'sendTotalCount',
  2652. count(distinct promoter_id) as 'sendPromoterCount',
  2653. count(distinct item_id) as 'sendItemCount'
  2654. from kuaishou_item_collect_samples
  2655. where collect_sample_status > 2
  2656. <if test="collectSampleId != null and collectSampleId != ''">
  2657. and collect_sample_id = #{collectSampleId}
  2658. </if>
  2659. <if test="start != null and start != ''">
  2660. and create_time &gt;= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
  2661. %H:%i:%s')
  2662. </if>
  2663. <if test="end != null and end != ''">
  2664. and create_time &lt;= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
  2665. </if>
  2666. group by collect_sample_id) tttt on t.collectSampleId = tttt.user_id
  2667. left join (select user_id, promoters_count
  2668. from user_promoters_count
  2669. where media_id = 2) ttttt
  2670. on t.collectSampleId = ttttt.user_id
  2671. where t.orderNum > 0
  2672. order by t.orderNum desc
  2673. </select>
  2674. <select id="bdTotalV2" resultType="com.alibaba.fastjson.JSONObject">
  2675. select t.*,tt.sampleCount
  2676. from (select t1.user_id as 'collectSampleId',
  2677. t1.user_name as 'collectSampleName',
  2678. count(t2.oid) as 'orderNum',
  2679. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNum',
  2680. concat(round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100, 2), '%') as
  2681. 'validOrderRate',
  2682. round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
  2683. round(
  2684. sum(
  2685. CASE
  2686. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  2687. ELSE 0
  2688. END
  2689. ) / 100 , 2) AS 'regimentalPromotionAmount',
  2690. round(sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100 , 2) as
  2691. 'totalRegimentalSettleAmount'
  2692. from promoter_bind_channel_date t1
  2693. left join kuaishou_supply_chain t2
  2694. on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
  2695. where 1 = 1
  2696. <if test="start != null and start != '' ">
  2697. and t1.stat_date &gt;= #{start}
  2698. </if>
  2699. <if test="end != null and end != ''">
  2700. and t1.stat_date &lt;= #{end}
  2701. </if>
  2702. <if test="collectSampleId != null and collectSampleId != ''">
  2703. and t1.user_id = #{collectSampleId}
  2704. </if>
  2705. group by t1.user_id) t
  2706. join (select count(distinct item_id) as 'sampleCount'
  2707. from kuaishou_item_collect_samples
  2708. where collect_sample_status > 2
  2709. and collect_sample_id = #{collectSampleId} ) tt
  2710. </select>
  2711. <select id="bdDetailListV2" resultType="com.alibaba.fastjson.JSONObject">
  2712. select t.*, tt.sampleCount
  2713. from (select t1.promoter_id as 'promoterId',
  2714. t1.promoter_name as 'promoterName',
  2715. t1.promoter_url as 'promoterUrl',
  2716. count(t2.oid) as 'orderNum',
  2717. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNum',
  2718. concat(round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100, 2), '%') as
  2719. 'validOrderRate',
  2720. round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
  2721. round( sum(
  2722. CASE
  2723. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  2724. ELSE 0
  2725. END
  2726. ) / 100 , 2) AS 'regimentalPromotionAmount',
  2727. round(sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100 , 2)as
  2728. 'totalRegimentalSettleAmount'
  2729. from promoter_bind_channel_date t1
  2730. left join kuaishou_supply_chain t2
  2731. on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
  2732. where 1 = 1
  2733. <if test="start != null and start != '' ">
  2734. and t1.stat_date &gt;= #{start}
  2735. </if>
  2736. <if test="end != null and end != ''">
  2737. and t1.stat_date &lt;= #{end}
  2738. </if>
  2739. <if test="collectSampleId != null and collectSampleId != ''">
  2740. and t1.user_id = #{collectSampleId}
  2741. </if>
  2742. group by t1.promoter_id) t
  2743. left join (select promoter_id,
  2744. count(distinct item_id) as 'sampleCount'
  2745. from kuaishou_item_collect_samples
  2746. where collect_sample_status > 2
  2747. and collect_sample_id = #{collectSampleId}
  2748. group by promoter_id) tt on t.promoterId = tt.promoter_id
  2749. where t.orderNum > 0
  2750. order by ${fieId} ${sort}
  2751. </select>
  2752. <select id="bdReportListV2ByBind" resultType="com.alibaba.fastjson.JSONObject">
  2753. select t.*,
  2754. tt.promoterCount,
  2755. ttt.sampleCount,
  2756. tttt.sendTotalCount,
  2757. tttt.sendPromoterCount,
  2758. tttt.sendItemCount,
  2759. IFNULL(ttttt.promoters_count, '-') as 'promotersCount'
  2760. from (select t1.user_id as 'collectSampleId',
  2761. t1.user_name as 'collectSampleName',
  2762. count(t2.oid) as 'orderNum',
  2763. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNum',
  2764. concat(round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100, 2), '%') as
  2765. 'validOrderRate',
  2766. round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
  2767. round(sum(t2.regimental_promotion_amount) / 100, 2) as 'regimentalPromotionAmount',
  2768. round(sum(t2.total_regimental_settle_amount) / 100, 2) as 'totalRegimentalSettleAmount'
  2769. from kuaishou_promoter t1
  2770. left join(select *
  2771. from kuaishou_supply_chain
  2772. where stat_date &gt;= #{bindStartDate}) t2
  2773. on t1.promoter_id = t2.promoter_id
  2774. where 1 = 1
  2775. <if test="bindStartDate != null and bindStartDate != '' ">
  2776. and t1.create_time &gt;= str_to_date(concat(date_format(#{bindStartDate}, '%Y-%m-%d'), '00:00:01'),
  2777. '%Y-%m-%d %H:%i:%s')
  2778. </if>
  2779. <if test="bindEndDate != null and bindEndDate != '' ">
  2780. and t1.create_time &lt;= str_to_date(concat(date_format(#{bindEndDate}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d
  2781. %H:%i:%s')
  2782. </if>
  2783. <if test="collectSampleId != null and collectSampleId != '' ">
  2784. and t1.user_id = #{collectSampleId}
  2785. </if>
  2786. group by t1.user_id) t
  2787. left join (select user_id,
  2788. count(distinct promoter_id) as 'promoterCount'
  2789. from kuaishou_promoter
  2790. where 1 = 1
  2791. <if test="collectSampleId != null and collectSampleId != '' ">
  2792. and user_id = #{collectSampleId}
  2793. </if>
  2794. group by user_id) tt on t.collectSampleId = tt.user_id
  2795. left join (select collect_sample_id as 'user_id',
  2796. count(distinct promoter_id) as 'sampleCount'
  2797. from kuaishou_item_collect_samples
  2798. where collect_sample_status > 2
  2799. <if test="collectSampleId != null and collectSampleId != '' ">
  2800. and collect_sample_id = #{collectSampleId}
  2801. </if>
  2802. group by collect_sample_id) ttt on t.collectSampleId = ttt.user_id
  2803. left join (select collect_sample_id as 'user_id',
  2804. count(1) as 'sendTotalCount',
  2805. count(distinct promoter_id) as 'sendPromoterCount',
  2806. count(distinct item_id) as 'sendItemCount'
  2807. from kuaishou_item_collect_samples
  2808. where collect_sample_status > 2
  2809. <if test="collectSampleId != null and collectSampleId != '' ">
  2810. and collect_sample_id = #{collectSampleId}
  2811. </if>
  2812. <if test="bindStartDate != null and bindStartDate != '' ">
  2813. and create_time &gt;= str_to_date(concat(date_format(#{bindStartDate}, '%Y-%m-%d'), '00:00:01'),
  2814. '%Y-%m-%d %H:%i:%s')
  2815. </if>
  2816. <if test="bindEndDate != null and bindEndDate != '' ">
  2817. and create_time &lt;= str_to_date(concat(date_format(#{bindEndDate}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d
  2818. %H:%i:%s')
  2819. </if>
  2820. group by collect_sample_id) tttt on t.collectSampleId = tttt.user_id
  2821. left join (select user_id, promoters_count
  2822. from user_promoters_count
  2823. where media_id = 2
  2824. <if test="collectSampleId != null and collectSampleId != '' ">
  2825. and user_id = #{collectSampleId}
  2826. </if>
  2827. ) ttttt
  2828. on t.collectSampleId = ttttt.user_id
  2829. order by t.orderNum desc
  2830. </select>
  2831. <select id="exportBindOrder" resultType="com.alibaba.fastjson.JSONObject">
  2832. select *, (case
  2833. when t4.ccr_value is null or t4.ccr_value = 0
  2834. then '0%'
  2835. else concat(round(t4.ccr_value / 100, 2), '%')
  2836. end
  2837. ) as 'ccrValue',
  2838. t4.shop_star as 'shopStar',
  2839. t4.mall_logistics_score as 'mallLogisticsScore',
  2840. t4.shop_score as 'shopScore',
  2841. t4.mall_service_score as 'mallServiceScore',
  2842. t4.mall_quality_score as 'mallQualityScore',
  2843. (
  2844. case when t5.is_presale = 1
  2845. then '否'
  2846. when t5.is_presale = 2
  2847. then '是'
  2848. else '-'
  2849. end
  2850. ) as 'isPresale'
  2851. from (select item_id as 'itemId', item_title as 'itemTitle', user_id as 'userId', user_name as 'userName'
  2852. from kuaishou_item_list
  2853. where
  2854. create_time &gt;= str_to_date(concat(#{bindStartDate},' 00:00:01'),'%Y-%m-%d
  2855. %H:%i:%s')
  2856. and
  2857. create_time &lt;= str_to_date(concat(#{bindEndDate},' 23:59:59'),'%Y-%m-%d
  2858. %H:%i:%s')
  2859. ) t1
  2860. left join
  2861. (select item_id as 'itemId',
  2862. image_url as 'imageUrl',
  2863. count(oid) as 'orderNum',
  2864. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  2865. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100, 2) as 'validRadio',
  2866. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  2867. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  2868. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status
  2869. != 80 then 1 else 0 end) * 100, 2) as 'deliveryRadio',
  2870. round(item_commission_rate / 10,2) as 'itemCommissionRate'
  2871. from kuaishou_supply_chain
  2872. where stat_date &gt;= #{start}
  2873. group by item_id) t2 on t1.itemId = t2.itemId
  2874. left join kuaishou_activity_open_item_list t4
  2875. on t1.itemId = t4.item_id
  2876. left join kuaishou_item_list t5
  2877. on t1.itemId = t5.item_id
  2878. where 1 = 1
  2879. <if test="itemId != null and itemId != ''">
  2880. and t1.item_id = #{itemId}
  2881. </if>
  2882. <if test="itemTitle != null and itemTitle != ''">
  2883. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  2884. </if>
  2885. <if test="userId != null and userId != ''">
  2886. and t1.userId = #{userId}
  2887. </if>
  2888. order by t2.orderNum desc
  2889. </select>
  2890. <insert id="replaceKuaishouActivityInfo">
  2891. replace into kuaishou_activity_info(
  2892. activity_id,
  2893. regimental_id,
  2894. activity_title,
  2895. activity_type,
  2896. activity_begin_time,
  2897. activity_end_time,
  2898. activity_status,
  2899. apply_item_count,
  2900. wait_audit_item_count,
  2901. audit_pass_item_count
  2902. )
  2903. values
  2904. <foreach collection="list" item="add" separator=",">
  2905. (
  2906. #{add.activityId},
  2907. #{add.regimentalId},
  2908. #{add.activityTitle},
  2909. #{add.activityType},
  2910. #{add.activityBeginTime},
  2911. #{add.activityEndTime},
  2912. #{add.activityStatus},
  2913. #{add.applyItemCount},
  2914. #{add.waitAuditItemCount},
  2915. #{add.auditPassItemCount}
  2916. )
  2917. </foreach>
  2918. </insert>
  2919. <insert id="replaceMgsKuaishouActivityInfo">
  2920. replace into miaogousi.kuaishou_activity_info(
  2921. activity_id,
  2922. regimental_id,
  2923. activity_title,
  2924. activity_type,
  2925. activity_begin_time,
  2926. activity_end_time,
  2927. activity_status,
  2928. apply_item_count,
  2929. wait_audit_item_count,
  2930. audit_pass_item_count
  2931. )
  2932. values
  2933. <foreach collection="list" item="add" separator=",">
  2934. (
  2935. #{add.activityId},
  2936. #{add.regimentalId},
  2937. #{add.activityTitle},
  2938. #{add.activityType},
  2939. #{add.activityBeginTime},
  2940. #{add.activityEndTime},
  2941. #{add.activityStatus},
  2942. #{add.applyItemCount},
  2943. #{add.waitAuditItemCount},
  2944. #{add.auditPassItemCount}
  2945. )
  2946. </foreach>
  2947. </insert>
  2948. <insert id="replaceRocketKuaishouActivityInfo">
  2949. replace into rocket.kuaishou_activity_info(
  2950. activity_id,
  2951. regimental_id,
  2952. activity_title,
  2953. activity_type,
  2954. activity_begin_time,
  2955. activity_end_time,
  2956. activity_status,
  2957. apply_item_count,
  2958. wait_audit_item_count,
  2959. audit_pass_item_count
  2960. )
  2961. values
  2962. <foreach collection="list" item="add" separator=",">
  2963. (
  2964. #{add.activityId},
  2965. #{add.regimentalId},
  2966. #{add.activityTitle},
  2967. #{add.activityType},
  2968. #{add.activityBeginTime},
  2969. #{add.activityEndTime},
  2970. #{add.activityStatus},
  2971. #{add.applyItemCount},
  2972. #{add.waitAuditItemCount},
  2973. #{add.auditPassItemCount}
  2974. )
  2975. </foreach>
  2976. </insert>
  2977. <insert id="replaceYufuKuaishouActivityInfo">
  2978. replace into yufu.kuaishou_activity_info(
  2979. activity_id,
  2980. regimental_id,
  2981. activity_title,
  2982. activity_type,
  2983. activity_begin_time,
  2984. activity_end_time,
  2985. activity_status,
  2986. apply_item_count,
  2987. wait_audit_item_count,
  2988. audit_pass_item_count
  2989. )
  2990. values
  2991. <foreach collection="list" item="add" separator=",">
  2992. (
  2993. #{add.activityId},
  2994. #{add.regimentalId},
  2995. #{add.activityTitle},
  2996. #{add.activityType},
  2997. #{add.activityBeginTime},
  2998. #{add.activityEndTime},
  2999. #{add.activityStatus},
  3000. #{add.applyItemCount},
  3001. #{add.waitAuditItemCount},
  3002. #{add.auditPassItemCount}
  3003. )
  3004. </foreach>
  3005. </insert>
  3006. <insert id="replaceYuxiuKuaishouActivityInfo">
  3007. replace into yuxiu.kuaishou_activity_info(
  3008. activity_id,
  3009. regimental_id,
  3010. activity_title,
  3011. activity_type,
  3012. activity_begin_time,
  3013. activity_end_time,
  3014. activity_status,
  3015. apply_item_count,
  3016. wait_audit_item_count,
  3017. audit_pass_item_count
  3018. )
  3019. values
  3020. <foreach collection="list" item="add" separator=",">
  3021. (
  3022. #{add.activityId},
  3023. #{add.regimentalId},
  3024. #{add.activityTitle},
  3025. #{add.activityType},
  3026. #{add.activityBeginTime},
  3027. #{add.activityEndTime},
  3028. #{add.activityStatus},
  3029. #{add.applyItemCount},
  3030. #{add.waitAuditItemCount},
  3031. #{add.auditPassItemCount}
  3032. )
  3033. </foreach>
  3034. </insert>
  3035. <insert id="replaceZhishuiKuaishouActivityInfo">
  3036. replace into zhishui.kuaishou_activity_info(
  3037. activity_id,
  3038. regimental_id,
  3039. activity_title,
  3040. activity_type,
  3041. activity_begin_time,
  3042. activity_end_time,
  3043. activity_status,
  3044. apply_item_count,
  3045. wait_audit_item_count,
  3046. audit_pass_item_count
  3047. )
  3048. values
  3049. <foreach collection="list" item="add" separator=",">
  3050. (
  3051. #{add.activityId},
  3052. #{add.regimentalId},
  3053. #{add.activityTitle},
  3054. #{add.activityType},
  3055. #{add.activityBeginTime},
  3056. #{add.activityEndTime},
  3057. #{add.activityStatus},
  3058. #{add.applyItemCount},
  3059. #{add.waitAuditItemCount},
  3060. #{add.auditPassItemCount}
  3061. )
  3062. </foreach>
  3063. </insert>
  3064. <update id="updateKuaishouSupplyChain">
  3065. update ruixuan.kuaishou_supply_chain set send_status = 1
  3066. where oid in
  3067. <foreach collection="list" item="id" separator=","
  3068. open="(" close=")">
  3069. #{id}
  3070. </foreach>
  3071. </update>
  3072. <update id="updateMgsKuaishouSupplyChain">
  3073. update miaogousi.kuaishou_supply_chain set send_status = 1
  3074. where oid in
  3075. <foreach collection="list" item="id" separator=","
  3076. open="(" close=")">
  3077. #{id}
  3078. </foreach>
  3079. </update>
  3080. <update id="updateRocketKuaishouSupplyChain">
  3081. update rocket.kuaishou_supply_chain set send_status = 1
  3082. where oid in
  3083. <foreach collection="list" item="id" separator=","
  3084. open="(" close=")">
  3085. #{id}
  3086. </foreach>
  3087. </update>
  3088. <update id="updateYufuKuaishouSupplyChain">
  3089. update yufu.kuaishou_supply_chain set send_status = 1
  3090. where oid in
  3091. <foreach collection="list" item="id" separator=","
  3092. open="(" close=")">
  3093. #{id}
  3094. </foreach>
  3095. </update>
  3096. <update id="updateYuxiuKuaishouSupplyChain">
  3097. update yuxiu.kuaishou_supply_chain set send_status = 1
  3098. where oid in
  3099. <foreach collection="list" item="id" separator=","
  3100. open="(" close=")">
  3101. #{id}
  3102. </foreach>
  3103. </update>
  3104. <update id="updateZhishuiKuaishouSupplyChain">
  3105. update zhishui.kuaishou_supply_chain set send_status = 1
  3106. where oid in
  3107. <foreach collection="list" item="id" separator=","
  3108. open="(" close=")">
  3109. #{id}
  3110. </foreach>
  3111. </update>
  3112. <update id="updateRuiXuanOrderRegimentalSettleAmount">
  3113. UPDATE ruixuan.kuaishou_supply_chain
  3114. SET order_status = #{cpsOrderStatus},
  3115. <choose>
  3116. <when test='cpsOrderStatus == 60 '>
  3117. total_regimental_settle_amount = regimental_promotion_amount
  3118. </when>
  3119. <otherwise>
  3120. send_status = 1
  3121. </otherwise>
  3122. </choose>
  3123. WHERE oid = #{oid}
  3124. </update>
  3125. <update id="updateMgsOrderRegimentalSettleAmount">
  3126. UPDATE miaogousi.kuaishou_supply_chain
  3127. SET order_status = #{cpsOrderStatus},
  3128. <choose>
  3129. <when test='cpsOrderStatus == 60 '>
  3130. total_regimental_settle_amount = regimental_promotion_amount
  3131. </when>
  3132. <otherwise>
  3133. send_status = 1
  3134. </otherwise>
  3135. </choose>
  3136. WHERE oid = #{oid}
  3137. </update>
  3138. <update id="updateRocketOrderRegimentalSettleAmount">
  3139. UPDATE rocket.kuaishou_supply_chain
  3140. SET order_status = #{cpsOrderStatus},
  3141. <choose>
  3142. <when test='cpsOrderStatus == 60 '>
  3143. total_regimental_settle_amount = regimental_promotion_amount
  3144. </when>
  3145. <otherwise>
  3146. send_status = 1
  3147. </otherwise>
  3148. </choose>
  3149. WHERE oid = #{oid}
  3150. </update>
  3151. <update id="updateRocketOrderRegimentalSettleAmountCS">
  3152. UPDATE rocket.kuaishou_supply_chain_ceshi
  3153. SET order_status = #{cpsOrderStatus},
  3154. <choose>
  3155. <when test='cpsOrderStatus == 60 '>
  3156. total_regimental_settle_amount = regimental_promotion_amount
  3157. </when>
  3158. <otherwise>
  3159. send_status = 1
  3160. </otherwise>
  3161. </choose>
  3162. WHERE oid = #{oid}
  3163. </update>
  3164. <update id="updateYufuOrderRegimentalSettleAmount">
  3165. UPDATE yufu.kuaishou_supply_chain
  3166. SET order_status = #{cpsOrderStatus},
  3167. <choose>
  3168. <when test='cpsOrderStatus == 60 '>
  3169. total_regimental_settle_amount = regimental_promotion_amount
  3170. </when>
  3171. <otherwise>
  3172. send_status = 1
  3173. </otherwise>
  3174. </choose>
  3175. WHERE oid = #{oid}
  3176. </update>
  3177. <update id="updateYuxiuOrderRegimentalSettleAmount">
  3178. UPDATE yuxiu.kuaishou_supply_chain
  3179. SET order_status = #{cpsOrderStatus},
  3180. <choose>
  3181. <when test='cpsOrderStatus == 60 '>
  3182. total_regimental_settle_amount = regimental_promotion_amount
  3183. </when>
  3184. <otherwise>
  3185. send_status = 1
  3186. </otherwise>
  3187. </choose>
  3188. WHERE oid = #{oid}
  3189. </update>
  3190. <update id="updateZhishuiOrderRegimentalSettleAmount">
  3191. UPDATE zhishui.kuaishou_supply_chain
  3192. SET order_status = #{cpsOrderStatus},
  3193. <choose>
  3194. <when test='cpsOrderStatus == 60 '>
  3195. total_regimental_settle_amount = regimental_promotion_amount
  3196. </when>
  3197. <otherwise>
  3198. send_status = 1
  3199. </otherwise>
  3200. </choose>
  3201. WHERE oid = #{oid}
  3202. </update>
  3203. <update id="updateRuixuanOrder">
  3204. UPDATE ruixuan.kuaishou_supply_chain
  3205. SET order_status = #{cpsOrderStatus}
  3206. WHERE oid = #{oid}
  3207. </update>
  3208. <update id="updateMgsOrder">
  3209. UPDATE miaogousi.kuaishou_supply_chain
  3210. SET order_status = #{cpsOrderStatus}
  3211. WHERE oid = #{oid}
  3212. </update>
  3213. <update id="updateRocketOrder">
  3214. UPDATE rocket.kuaishou_supply_chain
  3215. SET order_status = #{cpsOrderStatus}
  3216. WHERE oid = #{oid}
  3217. </update>
  3218. <update id="updateYufuOrder">
  3219. UPDATE yufu.kuaishou_supply_chain
  3220. SET order_status = #{cpsOrderStatus}
  3221. WHERE oid = #{oid}
  3222. </update>
  3223. <update id="updateYuXiuOrder">
  3224. UPDATE yuxiu.kuaishou_supply_chain
  3225. SET order_status = #{cpsOrderStatus}
  3226. WHERE oid = #{oid}
  3227. </update>
  3228. <update id="updateZhishuiOrder">
  3229. UPDATE zhishui.kuaishou_supply_chain
  3230. SET order_status = #{cpsOrderStatus}
  3231. WHERE oid = #{oid}
  3232. </update>
  3233. <select id="getBytedanceOrderHourDataList" resultType="com.alibaba.fastjson.JSONObject">
  3234. 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'
  3235. FROM ruixuan.bytedance_order_list
  3236. WHERE pay_success_time = #{date}
  3237. GROUP BY pay_success_time_hour
  3238. ORDER BY pay_success_time_hour
  3239. </select>
  3240. <select id="getKuaishouOrderHourDataList" resultType="com.alibaba.fastjson.JSONObject">
  3241. 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'
  3242. FROM kuaishou_supply_chain
  3243. WHERE stat_date = #{date}
  3244. GROUP BY stat_hour
  3245. ORDER BY stat_hour
  3246. </select>
  3247. <select id="exportItemDetail" resultType="com.alibaba.fastjson.JSONObject">
  3248. select t.*,tt.userName
  3249. from (
  3250. select
  3251. promoter_nick_name as 'promoterNickName',
  3252. promoter_id as 'promoterId',
  3253. count(oid) as 'orderNum',
  3254. round(sum(case when order_status != 80 then pay_amount else 0 end)/100,2 )as 'payAmount',
  3255. round(regimental_promotion_rate / 10 ,2) as 'regimentalPromotionRate',
  3256. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  3257. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  3258. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  3259. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  3260. then 1 else 0 end) * 100 ,2) as 'shippingGreen',
  3261. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  3262. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  3263. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when send_status = 1
  3264. then 1 else 0 end) *100,2) as 'deliveryRadio'
  3265. from kuaishou_supply_chain
  3266. where 1= 1
  3267. <if test="itemId != null and itemId != ''">
  3268. and item_id = #{itemId}
  3269. </if>
  3270. <if test="start != null and start != ''">
  3271. and stat_date &gt;= #{start}
  3272. </if>
  3273. <if test="end != null and end != ''">
  3274. and stat_date &lt;= #{end}
  3275. </if>
  3276. <if test="promoterId != null and promoterId != ''">
  3277. and promoter_id = #{promoterId}
  3278. </if>
  3279. <if test="promoterNickName != null and promoterNickName != ''">
  3280. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  3281. </if>
  3282. group by promoter_id) t left join (select promoter_id,group_concat(user_name) as 'userName',user_id as 'userId'
  3283. from
  3284. kuaishou_promoter group by promoter_id) tt
  3285. on t.promoterId = tt.promoter_id
  3286. where 1 =1
  3287. <if test="userId != null and userId != ''">
  3288. and tt.userId = #{userId}
  3289. </if>
  3290. order by t.orderNum desc
  3291. </select>
  3292. <select id="getKsChannelGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
  3293. select stat_hour as 'time',
  3294. <if test="hourType == 1 ">
  3295. round(sum(pay_amount) / 100, 2) as 'charge'
  3296. </if>
  3297. <if test="hourType == 2 ">
  3298. count(1) as 'charge'
  3299. </if>
  3300. from kuaishou_supply_chain
  3301. where stat_date = #{date}
  3302. <if test='userList != null and userList.size() > 0'>
  3303. and promoter_id in (
  3304. select promoter_id
  3305. from kuaishou_promoter where
  3306. 1 = 1
  3307. and user_id in
  3308. <foreach collection="userList" item="item" separator=","
  3309. open="(" close=")">
  3310. #{item}
  3311. </foreach>
  3312. group by promoter_id
  3313. )
  3314. </if>
  3315. group by stat_hour
  3316. order by stat_hour asc;
  3317. </select>
  3318. <select id="getKsChannelGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
  3319. SELECT
  3320. t1.time,
  3321. ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
  3322. FROM
  3323. (
  3324. select stat_hour as 'time',
  3325. <if test="hourType == 1 ">
  3326. round(sum(pay_amount) / 100, 2) as 'charge'
  3327. </if>
  3328. <if test="hourType == 2 ">
  3329. count(1) as 'charge'
  3330. </if>
  3331. from kuaishou_supply_chain
  3332. where stat_date = #{date}
  3333. <if test='userList != null and userList.size() > 0'>
  3334. and promoter_id in (
  3335. select promoter_id
  3336. from kuaishou_promoter where
  3337. 1 = 1
  3338. and user_id in
  3339. <foreach collection="userList" item="item" separator=","
  3340. open="(" close=")">
  3341. #{item}
  3342. </foreach>
  3343. group by promoter_id
  3344. )
  3345. </if>
  3346. group by stat_hour
  3347. ) t1
  3348. LEFT JOIN
  3349. (select stat_hour as 'time',
  3350. <if test="hourType == 1 ">
  3351. round(sum(pay_amount) / 100, 2) as 'charge'
  3352. </if>
  3353. <if test="hourType == 2 ">
  3354. count(1) as 'charge'
  3355. </if>
  3356. from kuaishou_supply_chain
  3357. where stat_date = DATE_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
  3358. <if test='userList != null and userList.size() > 0'>
  3359. and promoter_id in (
  3360. select promoter_id
  3361. from kuaishou_promoter where
  3362. 1 = 1
  3363. and user_id in
  3364. <foreach collection="userList" item="item" separator=","
  3365. open="(" close=")">
  3366. #{item}
  3367. </foreach>
  3368. group by promoter_id
  3369. )
  3370. </if>
  3371. group by stat_hour
  3372. ) t2 ON t1.time =t2.time
  3373. ORDER BY `time`
  3374. </select>
  3375. <select id="getKsCourtshipGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
  3376. select stat_hour as 'time',
  3377. <if test="hourType == 1 ">
  3378. round(sum(pay_amount) / 100, 2) as 'charge'
  3379. </if>
  3380. <if test="hourType == 2 ">
  3381. count(1) as 'charge'
  3382. </if>
  3383. from kuaishou_supply_chain
  3384. where stat_date = #{date}
  3385. <if test='userList != null and userList.size() > 0'>
  3386. and item_id in (
  3387. select item_id
  3388. from kuaishou_item_list where
  3389. 1 = 1
  3390. and user_id in
  3391. <foreach collection="userList" item="item" separator=","
  3392. open="(" close=")">
  3393. #{item}
  3394. </foreach>
  3395. group by item_id
  3396. )
  3397. </if>
  3398. group by stat_hour
  3399. order by stat_hour asc;
  3400. </select>
  3401. <select id="getKsCourtshipGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
  3402. SELECT
  3403. t1.time,
  3404. ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
  3405. FROM
  3406. ( select stat_hour as 'time',
  3407. <if test="hourType == 1 ">
  3408. round(sum(pay_amount) / 100, 2) as 'charge'
  3409. </if>
  3410. <if test="hourType == 2 ">
  3411. count(1) as 'charge'
  3412. </if>
  3413. from kuaishou_supply_chain
  3414. where stat_date = #{date}
  3415. <if test='userList != null and userList.size() > 0'>
  3416. and item_id in (
  3417. select item_id
  3418. from kuaishou_item_list where
  3419. 1 = 1
  3420. and user_id in
  3421. <foreach collection="userList" item="item" separator=","
  3422. open="(" close=")">
  3423. #{item}
  3424. </foreach>
  3425. group by item_id
  3426. )
  3427. </if>
  3428. group by stat_hour
  3429. ) t1
  3430. LEFT JOIN
  3431. (
  3432. select stat_hour as 'time',
  3433. <if test="hourType == 1 ">
  3434. round(sum(pay_amount) / 100, 2) as 'charge'
  3435. </if>
  3436. <if test="hourType == 2 ">
  3437. count(1) as 'charge'
  3438. </if>
  3439. from kuaishou_supply_chain
  3440. where stat_date = DATE_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
  3441. <if test='userList != null and userList.size() > 0'>
  3442. and item_id in (
  3443. select item_id
  3444. from kuaishou_item_list where
  3445. 1 = 1
  3446. and user_id in
  3447. <foreach collection="userList" item="item" separator=","
  3448. open="(" close=")">
  3449. #{item}
  3450. </foreach>
  3451. group by item_id
  3452. )
  3453. </if>
  3454. group by stat_hour
  3455. ) t2 ON t1.time =t2.time
  3456. ORDER BY `time`
  3457. </select>
  3458. <select id="getBytedanceChannelGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
  3459. select pay_success_time_hour as 'time',
  3460. <if test="hourType == 1 ">
  3461. round(sum(total_pay_amount) / 100, 2) as 'charge'
  3462. </if>
  3463. <if test="hourType == 2 ">
  3464. count(1) as 'charge'
  3465. </if>
  3466. from ruixuan.bytedance_order_list where pay_success_time = #{date}
  3467. <if test='userList != null and userList.size() > 0'>
  3468. and author_short_id in(
  3469. select promoter_id
  3470. from kuaishou_promoter where
  3471. 1 = 1
  3472. and user_id in
  3473. <foreach collection="userList" item="item" separator=","
  3474. open="(" close=")">
  3475. #{item}
  3476. </foreach>
  3477. group by promoter_id
  3478. )
  3479. </if>
  3480. group by pay_success_time_hour
  3481. order by pay_success_time_hour asc;
  3482. </select>
  3483. <select id="getBytedanceChannelGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
  3484. SELECT
  3485. t1.time,
  3486. ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
  3487. FROM
  3488. (
  3489. select pay_success_time_hour as 'time',
  3490. <if test="hourType == 1 ">
  3491. round(sum(total_pay_amount) / 100, 2) as 'charge'
  3492. </if>
  3493. <if test="hourType == 2 ">
  3494. count(1) as 'charge'
  3495. </if>
  3496. from ruixuan.bytedance_order_list where pay_success_time = #{date}
  3497. <if test='userList != null and userList.size() > 0'>
  3498. and author_short_id in(
  3499. select promoter_id
  3500. from kuaishou_promoter where
  3501. 1 = 1
  3502. and user_id in
  3503. <foreach collection="userList" item="item" separator=","
  3504. open="(" close=")">
  3505. #{item}
  3506. </foreach>
  3507. group by promoter_id
  3508. )
  3509. </if>
  3510. group by pay_success_time_hour
  3511. ) t1
  3512. LEFT JOIN
  3513. (
  3514. select pay_success_time_hour as 'time',
  3515. <if test="hourType == 1 ">
  3516. round(sum(total_pay_amount) / 100, 2) as 'charge'
  3517. </if>
  3518. <if test="hourType == 2 ">
  3519. count(1) as 'charge'
  3520. </if>
  3521. from ruixuan.bytedance_order_list
  3522. where pay_success_time = DATE_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
  3523. <if test='userList != null and userList.size() > 0'>
  3524. and author_short_id in(
  3525. select promoter_id
  3526. from kuaishou_promoter where
  3527. 1 = 1
  3528. and user_id in
  3529. <foreach collection="userList" item="item" separator=","
  3530. open="(" close=")">
  3531. #{item}
  3532. </foreach>
  3533. group by promoter_id
  3534. )
  3535. </if>
  3536. group by pay_success_time_hour
  3537. ) t2 ON t1.time =t2.time
  3538. ORDER BY `time`
  3539. </select>
  3540. <select id="getBytedanceCourtshipGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
  3541. select pay_success_time_hour as 'time',
  3542. <if test="hourType == 1 ">
  3543. round(sum(total_pay_amount) / 100, 2) as 'charge'
  3544. </if>
  3545. <if test="hourType == 2 ">
  3546. count(1) as 'charge'
  3547. </if>
  3548. from ruixuan.bytedance_order_list where pay_success_time = #{date}
  3549. <if test='userList != null and userList.size() > 0'>
  3550. and product_id in(
  3551. select item_id
  3552. from kuaishou_item_list where
  3553. 1 = 1
  3554. and user_id in
  3555. <foreach collection="userList" item="item" separator=","
  3556. open="(" close=")">
  3557. #{item}
  3558. </foreach>
  3559. group by item_id
  3560. )
  3561. </if>
  3562. group by pay_success_time_hour
  3563. order by pay_success_time_hour asc;
  3564. </select>
  3565. <select id="getBytedanceCourtshipGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
  3566. SELECT
  3567. t1.time,
  3568. ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
  3569. FROM
  3570. (
  3571. select pay_success_time_hour as 'time',
  3572. <if test="hourType == 1 ">
  3573. round(sum(total_pay_amount) / 100, 2) as 'charge'
  3574. </if>
  3575. <if test="hourType == 2 ">
  3576. count(1) as 'charge'
  3577. </if>
  3578. from ruixuan.bytedance_order_list where pay_success_time = #{date}
  3579. <if test='userList != null and userList.size() > 0'>
  3580. and product_id in(
  3581. select item_id
  3582. from kuaishou_item_list where
  3583. 1 = 1
  3584. and user_id in
  3585. <foreach collection="userList" item="item" separator=","
  3586. open="(" close=")">
  3587. #{item}
  3588. </foreach>
  3589. group by item_id
  3590. )
  3591. </if>
  3592. group by pay_success_time_hour
  3593. ) t1
  3594. LEFT JOIN
  3595. (
  3596. select pay_success_time_hour as 'time',
  3597. <if test="hourType == 1 ">
  3598. round(sum(total_pay_amount) / 100, 2) as 'charge'
  3599. </if>
  3600. <if test="hourType == 2 ">
  3601. count(1) as 'charge'
  3602. </if>
  3603. from ruixuan.bytedance_order_list
  3604. where pay_success_time = DATE_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
  3605. <if test='userList != null and userList.size() > 0'>
  3606. and product_id in(
  3607. select item_id
  3608. from kuaishou_item_list where
  3609. 1 = 1
  3610. and user_id in
  3611. <foreach collection="userList" item="item" separator=","
  3612. open="(" close=")">
  3613. #{item}
  3614. </foreach>
  3615. group by item_id
  3616. )
  3617. </if>
  3618. group by pay_success_time_hour
  3619. ) t2 ON t1.time =t2.time
  3620. ORDER BY `time`
  3621. </select>
  3622. <insert id="replaceKuaiShouActivityOpenItemList">
  3623. replace into kuaishou_activity_open_item_list(
  3624. item_id,
  3625. item_category_name,
  3626. item_price,
  3627. pre_activity_id,
  3628. item_leaf_category_id,
  3629. item_commission_rate,
  3630. investment_promotion_rate,
  3631. shop_id
  3632. )
  3633. values
  3634. <foreach collection="list" item="li" separator=",">
  3635. (
  3636. #{li.itemId},
  3637. #{li.itemCategoryName},
  3638. #{li.itemPrice},
  3639. #{li.preActivityId},
  3640. #{li.itemLeafCategoryId},
  3641. #{li.itemCommissionRate},
  3642. #{li.investmentPromotionRate},
  3643. #{li.shopId}
  3644. )
  3645. </foreach>
  3646. </insert>
  3647. <insert id="replaceMgsKuaiShouActivityOpenItemList">
  3648. replace into miaogousi.kuaishou_activity_open_item_list(
  3649. item_id,
  3650. item_category_name,
  3651. item_price,
  3652. pre_activity_id,
  3653. item_leaf_category_id,
  3654. item_commission_rate,
  3655. investment_promotion_rate,
  3656. shop_id
  3657. )
  3658. values
  3659. <foreach collection="list" item="li" separator=",">
  3660. (
  3661. #{li.itemId},
  3662. #{li.itemCategoryName},
  3663. #{li.itemPrice},
  3664. #{li.preActivityId},
  3665. #{li.itemLeafCategoryId},
  3666. #{li.itemCommissionRate},
  3667. #{li.investmentPromotionRate},
  3668. #{li.shopId}
  3669. )
  3670. </foreach>
  3671. </insert>
  3672. <insert id="replaceRocketKuaiShouActivityOpenItemList">
  3673. replace into rocket.kuaishou_activity_open_item_list(
  3674. item_id,
  3675. item_category_name,
  3676. item_price,
  3677. pre_activity_id,
  3678. item_leaf_category_id,
  3679. item_commission_rate,
  3680. investment_promotion_rate,
  3681. shop_id
  3682. )
  3683. values
  3684. <foreach collection="list" item="li" separator=",">
  3685. (
  3686. #{li.itemId},
  3687. #{li.itemCategoryName},
  3688. #{li.itemPrice},
  3689. #{li.preActivityId},
  3690. #{li.itemLeafCategoryId},
  3691. #{li.itemCommissionRate},
  3692. #{li.investmentPromotionRate},
  3693. #{li.shopId}
  3694. )
  3695. </foreach>
  3696. </insert>
  3697. <insert id="replaceYufuKuaiShouActivityOpenItemList">
  3698. replace into yufu.kuaishou_activity_open_item_list(
  3699. item_id,
  3700. item_category_name,
  3701. item_price,
  3702. pre_activity_id,
  3703. item_leaf_category_id,
  3704. item_commission_rate,
  3705. investment_promotion_rate,
  3706. shop_id
  3707. )
  3708. values
  3709. <foreach collection="list" item="li" separator=",">
  3710. (
  3711. #{li.itemId},
  3712. #{li.itemCategoryName},
  3713. #{li.itemPrice},
  3714. #{li.preActivityId},
  3715. #{li.itemLeafCategoryId},
  3716. #{li.itemCommissionRate},
  3717. #{li.investmentPromotionRate},
  3718. #{li.shopId}
  3719. )
  3720. </foreach>
  3721. </insert>
  3722. <insert id="replaceYuxiuKuaiShouActivityOpenItemList">
  3723. replace into yuxiu.kuaishou_activity_open_item_list(
  3724. item_id,
  3725. item_category_name,
  3726. item_price,
  3727. pre_activity_id,
  3728. item_leaf_category_id,
  3729. item_commission_rate,
  3730. investment_promotion_rate,
  3731. shop_id
  3732. )
  3733. values
  3734. <foreach collection="list" item="li" separator=",">
  3735. (
  3736. #{li.itemId},
  3737. #{li.itemCategoryName},
  3738. #{li.itemPrice},
  3739. #{li.preActivityId},
  3740. #{li.itemLeafCategoryId},
  3741. #{li.itemCommissionRate},
  3742. #{li.investmentPromotionRate},
  3743. #{li.shopId}
  3744. )
  3745. </foreach>
  3746. </insert>
  3747. <insert id="replaceZhishuiKuaiShouActivityOpenItemList">
  3748. replace into zhishui.kuaishou_activity_open_item_list(
  3749. item_id,
  3750. item_category_name,
  3751. item_price,
  3752. pre_activity_id,
  3753. item_leaf_category_id,
  3754. item_commission_rate,
  3755. investment_promotion_rate,
  3756. shop_id
  3757. )
  3758. values
  3759. <foreach collection="list" item="li" separator=",">
  3760. (
  3761. #{li.itemId},
  3762. #{li.itemCategoryName},
  3763. #{li.itemPrice},
  3764. #{li.preActivityId},
  3765. #{li.itemLeafCategoryId},
  3766. #{li.itemCommissionRate},
  3767. #{li.investmentPromotionRate},
  3768. #{li.shopId}
  3769. )
  3770. </foreach>
  3771. </insert>
  3772. <select id="getKuaishouActivityInfoList" resultType="Long">
  3773. SELECT DISTINCT activity_id
  3774. FROM kuaishou_activity_info
  3775. WHERE activity_status = 2
  3776. OR activity_status = 3
  3777. </select>
  3778. <select id="getMgsKuaishouActivityInfoList" resultType="Long">
  3779. SELECT DISTINCT activity_id
  3780. FROM miaogousi.kuaishou_activity_info
  3781. WHERE activity_status = 2
  3782. OR activity_status = 3
  3783. </select>
  3784. <select id="getRocketKuaishouActivityInfoList" resultType="Long">
  3785. SELECT DISTINCT activity_id
  3786. FROM rocket.kuaishou_activity_info
  3787. WHERE activity_status = 2
  3788. OR activity_status = 3
  3789. </select>
  3790. <select id="getYufuKuaishouActivityInfoList" resultType="Long">
  3791. SELECT DISTINCT activity_id
  3792. FROM yufu.kuaishou_activity_info
  3793. WHERE activity_status = 2
  3794. OR activity_status = 3
  3795. </select>
  3796. <select id="getYuxiuKuaishouActivityInfoList" resultType="Long">
  3797. SELECT DISTINCT activity_id
  3798. FROM yuxiu.kuaishou_activity_info
  3799. WHERE activity_status = 2
  3800. OR activity_status = 3
  3801. </select>
  3802. <select id="getZhishuiKuaishouActivityInfoList" resultType="Long">
  3803. SELECT DISTINCT activity_id
  3804. FROM zhishui.kuaishou_activity_info
  3805. WHERE activity_status = 2
  3806. OR activity_status = 3
  3807. </select>
  3808. <select id="getPromoterId" resultType="com.alibaba.fastjson.JSONObject" parameterType="java.lang.Long">
  3809. SELECT tag, proportion
  3810. FROM promoter_tag
  3811. WHERE promoter_id = #{promoterId}
  3812. ORDER BY tag_oid_num DESC limit 5
  3813. </select>
  3814. <select id="shopList" resultType="com.alibaba.fastjson.JSONObject">
  3815. SELECT t2.shopTitle as 'sellerName',t1.* from (
  3816. select seller_id as 'sellerId',
  3817. sum(case when order_status = 60 then 1 else 0 end) as 'settledOrderNUm',
  3818. round(sum(case when order_status = 60 then 1 else 0 end) / count(oid) * 100,
  3819. 2) as 'settledOrderRate',
  3820. count(oid) as 'orderNum',
  3821. round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
  3822. 2) as 'payAmount',
  3823. round(regimental_promotion_rate / 10, 2) as 'regimentalPromotionRate',
  3824. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  3825. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,
  3826. 2) as 'validRadio',
  3827. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  3828. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
  3829. when order_status != 80
  3830. then 1
  3831. else 0 end) * 100,
  3832. 2) as 'shippingGreen',
  3833. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  3834. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  3835. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
  3836. when send_status = 1
  3837. then 1
  3838. else 0 end) * 100,
  3839. 2) as 'deliveryRadio'
  3840. from kuaishou_supply_chain t1 LEFT JOIN kuaishou_activity_open_item_list t2 on t1.item_id = t2.item_id
  3841. where 1 = 1
  3842. <if test="start != null and start != ''">
  3843. and stat_date &gt;= #{start}
  3844. </if>
  3845. <if test="end != null and end != ''">
  3846. and stat_date &lt;= #{end}
  3847. </if>
  3848. <if test="sellerId != null and sellerId != ''">
  3849. and seller_id = #{sellerId}
  3850. </if>
  3851. <if test='itemIds != null and itemIds.size() > 0'>
  3852. and item_id in
  3853. <foreach collection="itemIds" item="item" separator=","
  3854. open="(" close=")">
  3855. #{item}
  3856. </foreach>
  3857. </if>
  3858. group by seller_id ) t1
  3859. left join(select shop_id as 'shopId', shop_title as 'shopTitle' from kuaishou_activity_open_item_list GROUP BY
  3860. shop_id)t2
  3861. on t1.sellerId = t2.shopId
  3862. order by ${fieId} ${sort}
  3863. </select>
  3864. <select id="shopDetail" resultType="com.alibaba.fastjson.JSONObject">
  3865. SELECT t1.*,
  3866. (case
  3867. when t2.ccr_value is null or t2.ccr_value = 0
  3868. then '0%'
  3869. else concat(round(t2.ccr_value / 100, 2), '%')
  3870. end
  3871. ) as 'ccrValue',
  3872. (case
  3873. when t2.ccr_value is null or t2.ccr_value = 0
  3874. then 0
  3875. else round(t2.ccr_value / 100 , 2)
  3876. end
  3877. ) as 'ccrInt',
  3878. t3.userName
  3879. from (
  3880. select item_id as 'itemId',
  3881. item_title as 'itemTitle',
  3882. image_url as 'imageUrl',
  3883. round(reserve_price / 100 , 2) as 'reservePrice',
  3884. count(oid) as 'orderNum',
  3885. round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
  3886. 2) as 'payAmount',
  3887. round(regimental_promotion_rate / 10, 2) as 'regimentalPromotionRate',
  3888. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  3889. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,
  3890. 2) as 'validRadio',
  3891. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  3892. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
  3893. when order_status != 80
  3894. then 1
  3895. else 0 end) * 100,
  3896. 2) as 'shippingGreen',
  3897. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  3898. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  3899. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
  3900. when send_status = 1
  3901. then 1
  3902. else 0 end) * 100,
  3903. 2) as 'deliveryRadio'
  3904. from kuaishou_supply_chain
  3905. where 1 = 1
  3906. <if test="start != null and start != ''">
  3907. and stat_date &gt;= #{start}
  3908. </if>
  3909. <if test="end != null and end != ''">
  3910. and stat_date &lt;= #{end}
  3911. </if>
  3912. <if test="sellerId != null and sellerId != ''">
  3913. and seller_id = #{sellerId}
  3914. </if>
  3915. <if test="itemId != null and itemId != ''">
  3916. and item_id = #{itemId}
  3917. </if>
  3918. <if test="itemTitle != null and itemTitle != ''">
  3919. and item_title like concat(concat('%',#{itemTitle}),'%')
  3920. </if>
  3921. <if test='itemIds != null and itemIds.size() > 0'>
  3922. and item_id in
  3923. <foreach collection="itemIds" item="item" separator=","
  3924. open="(" close=")">
  3925. #{item}
  3926. </foreach>
  3927. </if>
  3928. group by item_id) t1 left join kuaishou_activity_open_item_list t2
  3929. on t1.itemId = t2.item_id
  3930. LEFT JOIN (select item_id as 'itemId',user_name as 'userName' from kuaishou_item_list WHERE media_id = 2 group
  3931. by item_id) t3
  3932. on t1.itemId = t3.itemId
  3933. order by t1.orderNum desc
  3934. </select>
  3935. <select id="getItemIdsByUserId" resultType="java.lang.Long" parameterType="java.lang.Long">
  3936. SELECT item_id
  3937. FROM kuaishou_item_list
  3938. WHERE user_id = #{userId}
  3939. GROUP BY item_id
  3940. </select>
  3941. <select id="getItemIdsByDeptId" resultType="java.lang.Long" parameterType="java.lang.Long">
  3942. SELECT item_id
  3943. FROM kuaishou_item_list
  3944. WHERE user_id IN (SELECT sys_user.user_id
  3945. FROM sys_user
  3946. WHERE dept_id = #{deptId})
  3947. GROUP BY item_id
  3948. </select>
  3949. <update id="updateKuaiShouActivityOpenItemList">
  3950. UPDATE ruixuan.kuaishou_activity_open_item_list
  3951. SET shop_star = #{shopStar},
  3952. mall_logistics_score = #{mallLogisticsScore},
  3953. shop_score = #{shopScore},
  3954. mall_service_score = #{mallServiceScore},
  3955. mall_quality_score = #{mallQualityScore},
  3956. base_order_status = #{baseOrderStatus},
  3957. ccr_value = #{ccrValue},
  3958. shop_title = #{shopTitle},
  3959. store_score = #{storeScore}
  3960. where item_id = #{itemId}
  3961. </update>
  3962. <update id="updateMgsKuaiShouActivityOpenItemList">
  3963. UPDATE miaogousi.kuaishou_activity_open_item_list
  3964. SET shop_star = #{shopStar},
  3965. mall_logistics_score = #{mallLogisticsScore},
  3966. shop_score = #{shopScore},
  3967. mall_service_score = #{mallServiceScore},
  3968. mall_quality_score = #{mallQualityScore},
  3969. base_order_status = #{baseOrderStatus},
  3970. ccr_value = #{ccrValue},
  3971. shop_title = #{shopTitle},
  3972. store_score = #{storeScore}
  3973. where item_id = #{itemId}
  3974. </update>
  3975. <update id="updateRocketKuaiShouActivityOpenItemList">
  3976. update rocket.kuaishou_activity_open_item_list
  3977. set shop_star = #{shopStar},
  3978. mall_logistics_score = #{mallLogisticsScore},
  3979. shop_score = #{shopScore},
  3980. mall_service_score = #{mallServiceScore},
  3981. mall_quality_score = #{mallQualityScore},
  3982. base_order_status = #{baseOrderStatus},
  3983. ccr_value = #{ccrValue},
  3984. shop_title = #{shopTitle},
  3985. store_score = #{storeScore}
  3986. where item_id = #{itemId}
  3987. </update>
  3988. <update id="updateYufuKuaiShouActivityOpenItemList">
  3989. UPDATE yufu.kuaishou_activity_open_item_list
  3990. SET shop_star = #{shopStar},
  3991. mall_logistics_score = #{mallLogisticsScore},
  3992. shop_score = #{shopScore},
  3993. mall_service_score = #{mallServiceScore},
  3994. mall_quality_score = #{mallQualityScore},
  3995. base_order_status = #{baseOrderStatus},
  3996. ccr_value = #{ccrValue},
  3997. shop_title = #{shopTitle},
  3998. store_score = #{storeScore}
  3999. where item_id = #{itemId}
  4000. </update>
  4001. <update id="updateYuxiuKuaiShouActivityOpenItemList">
  4002. UPDATE yuxiu.kuaishou_activity_open_item_list
  4003. SET shop_star = #{shopStar},
  4004. mall_logistics_score = #{mallLogisticsScore},
  4005. shop_score = #{shopScore},
  4006. mall_service_score = #{mallServiceScore},
  4007. mall_quality_score = #{mallQualityScore},
  4008. base_order_status = #{baseOrderStatus},
  4009. ccr_value = #{ccrValue},
  4010. shop_title = #{shopTitle},
  4011. store_score = #{storeScore}
  4012. where item_id = #{itemId}
  4013. </update>
  4014. <update id="updateZhishuiKuaiShouActivityOpenItemList">
  4015. UPDATE zhishui.kuaishou_activity_open_item_list
  4016. SET shop_star = #{shopStar},
  4017. mall_logistics_score = #{mallLogisticsScore},
  4018. shop_score = #{shopScore},
  4019. mall_service_score = #{mallServiceScore},
  4020. mall_quality_score = #{mallQualityScore},
  4021. base_order_status = #{baseOrderStatus},
  4022. ccr_value = #{ccrValue},
  4023. shop_title = #{shopTitle},
  4024. store_score = #{storeScore}
  4025. where item_id = #{itemId}
  4026. </update>
  4027. <insert id="replaceOne">
  4028. replace into
  4029. <choose>
  4030. <when test='ownership == null '>
  4031. kuaishou_supply_chain_ceshi
  4032. </when>
  4033. <otherwise>
  4034. ${ownership}.kuaishou_supply_chain_ceshi
  4035. </otherwise>
  4036. </choose>
  4037. (
  4038. regimental_id,
  4039. oid,
  4040. item_id,
  4041. item_title,
  4042. reserve_price,
  4043. image_url,
  4044. order_status,
  4045. order_create_time,
  4046. send_status,
  4047. settlement_biz_type,
  4048. settlement_biz_type_desc,
  4049. send_time,
  4050. recv_time,
  4051. seller_id,
  4052. promoter_id,
  4053. promoter_nick_name,
  4054. activity_id,
  4055. order_amount,
  4056. pay_amount,
  4057. regimental_promotion_rate,
  4058. share_rate,
  4059. base_amount,
  4060. service_amount,
  4061. regimental_promotion_amount,
  4062. total_regimental_settle_amount,
  4063. stat_date,
  4064. stat_hour,
  4065. item_commission_rate,
  4066. second_activity_user_id,
  4067. second_activity_id,
  4068. seller_nick_name,
  4069. sku_id,
  4070. num,
  4071. expend_regimental_settle_amount,
  4072. expend_estimate_settle_amount,
  4073. expend_regimental_promotion_rate,
  4074. excitation_income,
  4075. service_income,
  4076. fund_type,
  4077. second_service_amount,
  4078. promoter_commission_rate
  4079. )
  4080. value
  4081. (
  4082. #{supplyChain.regimentalId},
  4083. #{supplyChain.oid},
  4084. #{supplyChain.itemId},
  4085. #{supplyChain.itemTitle},
  4086. #{supplyChain.reservePrice},
  4087. #{supplyChain.imageUrl},
  4088. #{supplyChain.orderStatus},
  4089. #{supplyChain.orderCreateTime},
  4090. #{supplyChain.sendStatus},
  4091. #{supplyChain.settlementBizType},
  4092. #{supplyChain.settlementBizTypeDesc},
  4093. #{supplyChain.sendTime},
  4094. #{supplyChain.recvTime},
  4095. #{supplyChain.sellerId},
  4096. #{supplyChain.promoterId},
  4097. #{supplyChain.promoterNickName},
  4098. #{supplyChain.activityId},
  4099. #{supplyChain.orderAmount},
  4100. #{supplyChain.payAmount},
  4101. #{supplyChain.regimentalPromotionRate},
  4102. #{supplyChain.shareRate},
  4103. #{supplyChain.baseAmount},
  4104. #{supplyChain.serviceAmount},
  4105. #{supplyChain.regimentalPromotionAmount},
  4106. #{supplyChain.totalRegimentalSettleAmount},
  4107. #{supplyChain.statDate},
  4108. #{supplyChain.statHour},
  4109. #{supplyChain.itemCommissionRate},
  4110. #{supplyChain.secondActivityUserId},
  4111. #{supplyChain.secondActivityId},
  4112. #{supplyChain.sellerNickName},
  4113. #{supplyChain.skuId},
  4114. #{supplyChain.num},
  4115. #{supplyChain.expendRegimentalSettleAmount},
  4116. #{supplyChain.expendEstimateSettleAmount},
  4117. #{supplyChain.expendRegimentalPromotionRate},
  4118. #{supplyChain.excitationIncome},
  4119. #{supplyChain.serviceIncome},
  4120. #{supplyChain.fundType},
  4121. #{supplyChain.secondServiceAmount},
  4122. #{supplyChain.promoterCommissionRate}
  4123. )
  4124. </insert>
  4125. <insert id="replaceBatchOrder">
  4126. replace into
  4127. <choose>
  4128. <when test='ownership == null '>
  4129. kuaishou_supply_chain_ceshi
  4130. </when>
  4131. <otherwise>
  4132. ${ownership}.kuaishou_supply_chain_ceshi
  4133. </otherwise>
  4134. </choose>
  4135. (
  4136. regimental_id,
  4137. oid,
  4138. item_id,
  4139. item_title,
  4140. reserve_price,
  4141. image_url,
  4142. order_status,
  4143. order_create_time,
  4144. send_status,
  4145. settlement_biz_type,
  4146. settlement_biz_type_desc,
  4147. send_time,
  4148. recv_time,
  4149. seller_id,
  4150. promoter_id,
  4151. promoter_nick_name,
  4152. activity_id,
  4153. order_amount,
  4154. pay_amount,
  4155. regimental_promotion_rate,
  4156. share_rate,
  4157. base_amount,
  4158. service_amount,
  4159. regimental_promotion_amount,
  4160. total_regimental_settle_amount,
  4161. stat_date,
  4162. stat_hour,
  4163. item_commission_rate,
  4164. second_activity_user_id,
  4165. second_activity_id,
  4166. seller_nick_name,
  4167. sku_id,
  4168. num,
  4169. expend_regimental_settle_amount,
  4170. expend_estimate_settle_amount,
  4171. expend_regimental_promotion_rate,
  4172. excitation_income,
  4173. service_income,
  4174. fund_type,
  4175. second_service_amount,
  4176. promoter_commission_rate
  4177. )
  4178. values
  4179. <foreach collection="supplyChainList" item="supplyChain" separator=",">
  4180. (
  4181. #{supplyChain.regimentalId},
  4182. #{supplyChain.oid},
  4183. #{supplyChain.itemId},
  4184. #{supplyChain.itemTitle},
  4185. #{supplyChain.reservePrice},
  4186. #{supplyChain.imageUrl},
  4187. #{supplyChain.orderStatus},
  4188. #{supplyChain.orderCreateTime},
  4189. #{supplyChain.sendStatus},
  4190. #{supplyChain.settlementBizType},
  4191. #{supplyChain.settlementBizTypeDesc},
  4192. #{supplyChain.sendTime},
  4193. #{supplyChain.recvTime},
  4194. #{supplyChain.sellerId},
  4195. #{supplyChain.promoterId},
  4196. #{supplyChain.promoterNickName},
  4197. #{supplyChain.activityId},
  4198. #{supplyChain.orderAmount},
  4199. #{supplyChain.payAmount},
  4200. #{supplyChain.regimentalPromotionRate},
  4201. #{supplyChain.shareRate},
  4202. #{supplyChain.baseAmount},
  4203. #{supplyChain.serviceAmount},
  4204. #{supplyChain.regimentalPromotionAmount},
  4205. #{supplyChain.totalRegimentalSettleAmount},
  4206. #{supplyChain.statDate},
  4207. #{supplyChain.statHour},
  4208. #{supplyChain.itemCommissionRate},
  4209. #{supplyChain.secondActivityUserId},
  4210. #{supplyChain.secondActivityId},
  4211. #{supplyChain.sellerNickName},
  4212. #{supplyChain.skuId},
  4213. #{supplyChain.num},
  4214. #{supplyChain.expendRegimentalSettleAmount},
  4215. #{supplyChain.expendEstimateSettleAmount},
  4216. #{supplyChain.expendRegimentalPromotionRate},
  4217. #{supplyChain.excitationIncome},
  4218. #{supplyChain.serviceIncome},
  4219. #{supplyChain.fundType},
  4220. #{supplyChain.secondServiceAmount},
  4221. #{supplyChain.promoterCommissionRate}
  4222. )
  4223. </foreach>
  4224. </insert>
  4225. </mapper>