SupplyChainMapper.xml 155 KB

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