SupplyChainMapper.xml 154 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915
  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(regimental_promotion_amount) as 'regimentalPromotionAmount',
  2615. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
  2616. from kuaishou_supply_chain
  2617. where stat_date &gt;= #{start}
  2618. and stat_date &lt;= #{end}
  2619. group by promoter_id, stat_date) t2
  2620. on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
  2621. where 1 = 1
  2622. and t1.media_id = 2
  2623. <if test="start != null and start != ''">
  2624. and t1.stat_date &gt;= #{start}
  2625. </if>
  2626. <if test="end != null and end != ''">
  2627. and t1.stat_date &lt;= #{end}
  2628. </if>
  2629. <if test="collectSampleId != null and collectSampleId != ''">
  2630. and t1.user_id = #{collectSampleId}
  2631. </if>
  2632. group by t1.user_id) t
  2633. left join (select user_id,
  2634. count(distinct promoter_id) as 'promoterCount'
  2635. from kuaishou_promoter
  2636. group by user_id) tt on t.collectSampleId = tt.user_id
  2637. left join (select collect_sample_id as 'user_id',
  2638. count(distinct promoter_id) as 'sampleCount'
  2639. from kuaishou_item_collect_samples
  2640. where collect_sample_status > 2
  2641. group by collect_sample_id) ttt on t.collectSampleId = ttt.user_id
  2642. left join (select collect_sample_id as 'user_id',
  2643. count(1) as 'sendTotalCount',
  2644. count(distinct promoter_id) as 'sendPromoterCount',
  2645. count(distinct item_id) as 'sendItemCount'
  2646. from kuaishou_item_collect_samples
  2647. where collect_sample_status > 2
  2648. <if test="collectSampleId != null and collectSampleId != ''">
  2649. and collect_sample_id = #{collectSampleId}
  2650. </if>
  2651. <if test="start != null and start != ''">
  2652. and create_time &gt;= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
  2653. %H:%i:%s')
  2654. </if>
  2655. <if test="end != null and end != ''">
  2656. and create_time &lt;= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
  2657. </if>
  2658. group by collect_sample_id) tttt on t.collectSampleId = tttt.user_id
  2659. left join (select user_id, promoters_count
  2660. from user_promoters_count
  2661. where media_id = 2) ttttt
  2662. on t.collectSampleId = ttttt.user_id
  2663. where t.orderNum > 0
  2664. order by t.orderNum desc
  2665. </select>
  2666. <select id="bdTotalV2" resultType="com.alibaba.fastjson.JSONObject">
  2667. select t.*,tt.sampleCount
  2668. from (select t1.user_id as 'collectSampleId',
  2669. t1.user_name as 'collectSampleName',
  2670. count(t2.oid) as 'orderNum',
  2671. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNum',
  2672. concat(round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100, 2), '%') as 'validOrderRate',
  2673. round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
  2674. round(sum(t2.regimental_promotion_amount) / 100, 2) as 'regimentalPromotionAmount',
  2675. round(sum(t2.total_regimental_settle_amount) / 100, 2) as 'totalRegimentalSettleAmount'
  2676. from promoter_bind_channel_date t1
  2677. left join kuaishou_supply_chain t2
  2678. on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
  2679. where 1 = 1
  2680. <if test="start != null and start != '' ">
  2681. and t1.stat_date &gt;= #{start}
  2682. </if>
  2683. <if test="end != null and end != ''">
  2684. and t1.stat_date &lt;= #{end}
  2685. </if>
  2686. <if test="collectSampleId != null and collectSampleId != ''">
  2687. and t1.user_id = #{collectSampleId}
  2688. </if>
  2689. group by t1.user_id) t
  2690. join (select count(distinct item_id) as 'sampleCount'
  2691. from kuaishou_item_collect_samples
  2692. where collect_sample_status > 2
  2693. and collect_sample_id = #{collectSampleId} ) tt
  2694. </select>
  2695. <select id="bdDetailListV2" resultType="com.alibaba.fastjson.JSONObject">
  2696. select t.*, tt.sampleCount
  2697. from (select t1.promoter_id as 'promoterId',
  2698. t1.promoter_name as 'promoterName',
  2699. t1.promoter_url as 'promoterUrl',
  2700. count(t2.oid) as 'orderNum',
  2701. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNum',
  2702. concat(round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100, 2), '%') as 'validOrderRate',
  2703. round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
  2704. round(sum(t2.regimental_promotion_amount) / 100, 2) as 'regimentalPromotionAmount',
  2705. round(sum(t2.total_regimental_settle_amount) / 100, 2) as 'totalRegimentalSettleAmount'
  2706. from promoter_bind_channel_date t1
  2707. left join kuaishou_supply_chain t2
  2708. on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
  2709. where 1 = 1
  2710. <if test="start != null and start != '' ">
  2711. and t1.stat_date &gt;= #{start}
  2712. </if>
  2713. <if test="end != null and end != ''">
  2714. and t1.stat_date &lt;= #{end}
  2715. </if>
  2716. <if test="collectSampleId != null and collectSampleId != ''">
  2717. and t1.user_id = #{collectSampleId}
  2718. </if>
  2719. group by t1.promoter_id) t
  2720. left join (select promoter_id,
  2721. count(distinct item_id) as 'sampleCount'
  2722. from kuaishou_item_collect_samples
  2723. where collect_sample_status > 2
  2724. and collect_sample_id = #{collectSampleId}
  2725. group by promoter_id) tt on t.promoterId = tt.promoter_id
  2726. where t.orderNum > 0
  2727. order by ${fieId} ${sort}
  2728. </select>
  2729. <select id="bdReportListV2ByBind" resultType="com.alibaba.fastjson.JSONObject">
  2730. select t.*,
  2731. tt.promoterCount,
  2732. ttt.sampleCount,
  2733. tttt.sendTotalCount,
  2734. tttt.sendPromoterCount,
  2735. tttt.sendItemCount,
  2736. IFNULL(ttttt.promoters_count, '-') as 'promotersCount'
  2737. from (select t1.user_id as 'collectSampleId',
  2738. t1.user_name as 'collectSampleName',
  2739. count(t2.oid) as 'orderNum',
  2740. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNum',
  2741. concat(round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100, 2), '%') as 'validOrderRate',
  2742. round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
  2743. round(sum(t2.regimental_promotion_amount) / 100, 2) as 'regimentalPromotionAmount',
  2744. round(sum(t2.total_regimental_settle_amount) / 100, 2) as 'totalRegimentalSettleAmount'
  2745. from kuaishou_promoter t1
  2746. left join(select *
  2747. from kuaishou_supply_chain
  2748. where stat_date &gt;= #{bindStartDate}) t2
  2749. on t1.promoter_id = t2.promoter_id
  2750. where 1 = 1
  2751. <if test="bindStartDate != null and bindStartDate != '' ">
  2752. and t1.create_time &gt;= str_to_date(concat(date_format(#{bindStartDate}, '%Y-%m-%d'), '00:00:01'),
  2753. '%Y-%m-%d %H:%i:%s')
  2754. </if>
  2755. <if test="bindEndDate != null and bindEndDate != '' ">
  2756. and t1.create_time &lt;= str_to_date(concat(date_format(#{bindEndDate}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d
  2757. %H:%i:%s')
  2758. </if>
  2759. <if test="collectSampleId != null and collectSampleId != '' ">
  2760. and t1.user_id = #{collectSampleId}
  2761. </if>
  2762. group by t1.user_id) t
  2763. left join (select user_id,
  2764. count(distinct promoter_id) as 'promoterCount'
  2765. from kuaishou_promoter
  2766. where 1 = 1
  2767. <if test="collectSampleId != null and collectSampleId != '' ">
  2768. and user_id = #{collectSampleId}
  2769. </if>
  2770. group by user_id) tt on t.collectSampleId = tt.user_id
  2771. left join (select collect_sample_id as 'user_id',
  2772. count(distinct promoter_id) as 'sampleCount'
  2773. from kuaishou_item_collect_samples
  2774. where collect_sample_status > 2
  2775. <if test="collectSampleId != null and collectSampleId != '' ">
  2776. and collect_sample_id = #{collectSampleId}
  2777. </if>
  2778. group by collect_sample_id) ttt on t.collectSampleId = ttt.user_id
  2779. left join (select collect_sample_id as 'user_id',
  2780. count(1) as 'sendTotalCount',
  2781. count(distinct promoter_id) as 'sendPromoterCount',
  2782. count(distinct item_id) as 'sendItemCount'
  2783. from kuaishou_item_collect_samples
  2784. where collect_sample_status > 2
  2785. <if test="collectSampleId != null and collectSampleId != '' ">
  2786. and collect_sample_id = #{collectSampleId}
  2787. </if>
  2788. <if test="bindStartDate != null and bindStartDate != '' ">
  2789. and create_time &gt;= str_to_date(concat(date_format(#{bindStartDate}, '%Y-%m-%d'), '00:00:01'),
  2790. '%Y-%m-%d %H:%i:%s')
  2791. </if>
  2792. <if test="bindEndDate != null and bindEndDate != '' ">
  2793. and create_time &lt;= str_to_date(concat(date_format(#{bindEndDate}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d
  2794. %H:%i:%s')
  2795. </if>
  2796. group by collect_sample_id) tttt on t.collectSampleId = tttt.user_id
  2797. left join (select user_id, promoters_count
  2798. from user_promoters_count
  2799. where media_id = 2
  2800. <if test="collectSampleId != null and collectSampleId != '' ">
  2801. and user_id = #{collectSampleId}
  2802. </if>
  2803. ) ttttt
  2804. on t.collectSampleId = ttttt.user_id
  2805. order by t.orderNum desc
  2806. </select>
  2807. <select id="exportBindOrder" resultType="com.alibaba.fastjson.JSONObject">
  2808. select *, (case
  2809. when t4.ccr_value is null or t4.ccr_value = 0
  2810. then '0%'
  2811. else concat(round(t4.ccr_value / 100, 2), '%')
  2812. end
  2813. ) as 'ccrValue',
  2814. t4.shop_star as 'shopStar',
  2815. t4.mall_logistics_score as 'mallLogisticsScore',
  2816. t4.shop_score as 'shopScore',
  2817. t4.mall_service_score as 'mallServiceScore',
  2818. t4.mall_quality_score as 'mallQualityScore',
  2819. (
  2820. case when t5.is_presale = 1
  2821. then '否'
  2822. when t5.is_presale = 2
  2823. then '是'
  2824. else '-'
  2825. end
  2826. ) as 'isPresale'
  2827. from (select item_id as 'itemId', item_title as 'itemTitle', user_id as 'userId', user_name as 'userName'
  2828. from kuaishou_item_list
  2829. where
  2830. create_time &gt;= str_to_date(concat(#{bindStartDate},' 00:00:01'),'%Y-%m-%d
  2831. %H:%i:%s')
  2832. and
  2833. create_time &lt;= str_to_date(concat(#{bindEndDate},' 23:59:59'),'%Y-%m-%d
  2834. %H:%i:%s')
  2835. ) t1
  2836. left join
  2837. (select item_id as 'itemId',
  2838. image_url as 'imageUrl',
  2839. count(oid) as 'orderNum',
  2840. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  2841. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100, 2) as 'validRadio',
  2842. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  2843. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  2844. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status
  2845. != 80 then 1 else 0 end) * 100, 2) as 'deliveryRadio',
  2846. round(item_commission_rate / 10,2) as 'itemCommissionRate'
  2847. from kuaishou_supply_chain
  2848. where stat_date &gt;= #{start}
  2849. group by item_id) t2 on t1.itemId = t2.itemId
  2850. left join kuaishou_activity_open_item_list t4
  2851. on t1.itemId = t4.item_id
  2852. left join kuaishou_item_list t5
  2853. on t1.itemId = t5.item_id
  2854. where 1 = 1
  2855. <if test="itemId != null and itemId != ''">
  2856. and t1.item_id = #{itemId}
  2857. </if>
  2858. <if test="itemTitle != null and itemTitle != ''">
  2859. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  2860. </if>
  2861. <if test="userId != null and userId != ''">
  2862. and t1.userId = #{userId}
  2863. </if>
  2864. order by t2.orderNum desc
  2865. </select>
  2866. <insert id="replaceKuaishouActivityInfo">
  2867. replace into kuaishou_activity_info(
  2868. activity_id,
  2869. regimental_id,
  2870. activity_title,
  2871. activity_type,
  2872. activity_begin_time,
  2873. activity_end_time,
  2874. activity_status,
  2875. apply_item_count,
  2876. wait_audit_item_count,
  2877. audit_pass_item_count
  2878. )
  2879. values
  2880. <foreach collection="list" item="add" separator=",">
  2881. (
  2882. #{add.activityId},
  2883. #{add.regimentalId},
  2884. #{add.activityTitle},
  2885. #{add.activityType},
  2886. #{add.activityBeginTime},
  2887. #{add.activityEndTime},
  2888. #{add.activityStatus},
  2889. #{add.applyItemCount},
  2890. #{add.waitAuditItemCount},
  2891. #{add.auditPassItemCount}
  2892. )
  2893. </foreach>
  2894. </insert>
  2895. <insert id="replaceMgsKuaishouActivityInfo">
  2896. replace into miaogousi.kuaishou_activity_info(
  2897. activity_id,
  2898. regimental_id,
  2899. activity_title,
  2900. activity_type,
  2901. activity_begin_time,
  2902. activity_end_time,
  2903. activity_status,
  2904. apply_item_count,
  2905. wait_audit_item_count,
  2906. audit_pass_item_count
  2907. )
  2908. values
  2909. <foreach collection="list" item="add" separator=",">
  2910. (
  2911. #{add.activityId},
  2912. #{add.regimentalId},
  2913. #{add.activityTitle},
  2914. #{add.activityType},
  2915. #{add.activityBeginTime},
  2916. #{add.activityEndTime},
  2917. #{add.activityStatus},
  2918. #{add.applyItemCount},
  2919. #{add.waitAuditItemCount},
  2920. #{add.auditPassItemCount}
  2921. )
  2922. </foreach>
  2923. </insert>
  2924. <insert id="replaceRocketKuaishouActivityInfo">
  2925. replace into rocket.kuaishou_activity_info(
  2926. activity_id,
  2927. regimental_id,
  2928. activity_title,
  2929. activity_type,
  2930. activity_begin_time,
  2931. activity_end_time,
  2932. activity_status,
  2933. apply_item_count,
  2934. wait_audit_item_count,
  2935. audit_pass_item_count
  2936. )
  2937. values
  2938. <foreach collection="list" item="add" separator=",">
  2939. (
  2940. #{add.activityId},
  2941. #{add.regimentalId},
  2942. #{add.activityTitle},
  2943. #{add.activityType},
  2944. #{add.activityBeginTime},
  2945. #{add.activityEndTime},
  2946. #{add.activityStatus},
  2947. #{add.applyItemCount},
  2948. #{add.waitAuditItemCount},
  2949. #{add.auditPassItemCount}
  2950. )
  2951. </foreach>
  2952. </insert>
  2953. <insert id="replaceYufuKuaishouActivityInfo">
  2954. replace into yufu.kuaishou_activity_info(
  2955. activity_id,
  2956. regimental_id,
  2957. activity_title,
  2958. activity_type,
  2959. activity_begin_time,
  2960. activity_end_time,
  2961. activity_status,
  2962. apply_item_count,
  2963. wait_audit_item_count,
  2964. audit_pass_item_count
  2965. )
  2966. values
  2967. <foreach collection="list" item="add" separator=",">
  2968. (
  2969. #{add.activityId},
  2970. #{add.regimentalId},
  2971. #{add.activityTitle},
  2972. #{add.activityType},
  2973. #{add.activityBeginTime},
  2974. #{add.activityEndTime},
  2975. #{add.activityStatus},
  2976. #{add.applyItemCount},
  2977. #{add.waitAuditItemCount},
  2978. #{add.auditPassItemCount}
  2979. )
  2980. </foreach>
  2981. </insert>
  2982. <insert id="replaceYuxiuKuaishouActivityInfo">
  2983. replace into yuxiu.kuaishou_activity_info(
  2984. activity_id,
  2985. regimental_id,
  2986. activity_title,
  2987. activity_type,
  2988. activity_begin_time,
  2989. activity_end_time,
  2990. activity_status,
  2991. apply_item_count,
  2992. wait_audit_item_count,
  2993. audit_pass_item_count
  2994. )
  2995. values
  2996. <foreach collection="list" item="add" separator=",">
  2997. (
  2998. #{add.activityId},
  2999. #{add.regimentalId},
  3000. #{add.activityTitle},
  3001. #{add.activityType},
  3002. #{add.activityBeginTime},
  3003. #{add.activityEndTime},
  3004. #{add.activityStatus},
  3005. #{add.applyItemCount},
  3006. #{add.waitAuditItemCount},
  3007. #{add.auditPassItemCount}
  3008. )
  3009. </foreach>
  3010. </insert>
  3011. <update id="updateKuaishouSupplyChain">
  3012. update ruixuan.kuaishou_supply_chain set send_status = 1
  3013. where oid in
  3014. <foreach collection="list" item="id" separator=","
  3015. open="(" close=")">
  3016. #{id}
  3017. </foreach>
  3018. </update>
  3019. <update id="updateMgsKuaishouSupplyChain">
  3020. update miaogousi.kuaishou_supply_chain set send_status = 1
  3021. where oid in
  3022. <foreach collection="list" item="id" separator=","
  3023. open="(" close=")">
  3024. #{id}
  3025. </foreach>
  3026. </update>
  3027. <update id="updateRocketKuaishouSupplyChain">
  3028. update rocket.kuaishou_supply_chain set send_status = 1
  3029. where oid in
  3030. <foreach collection="list" item="id" separator=","
  3031. open="(" close=")">
  3032. #{id}
  3033. </foreach>
  3034. </update>
  3035. <update id="updateYufuKuaishouSupplyChain">
  3036. update yufu.kuaishou_supply_chain set send_status = 1
  3037. where oid in
  3038. <foreach collection="list" item="id" separator=","
  3039. open="(" close=")">
  3040. #{id}
  3041. </foreach>
  3042. </update>
  3043. <update id="updateYuxiuKuaishouSupplyChain">
  3044. update yuxiu.kuaishou_supply_chain set send_status = 1
  3045. where oid in
  3046. <foreach collection="list" item="id" separator=","
  3047. open="(" close=")">
  3048. #{id}
  3049. </foreach>
  3050. </update>
  3051. <update id="updateRuiXuanOrderRegimentalSettleAmount">
  3052. UPDATE ruixuan.kuaishou_supply_chain
  3053. SET order_status = #{cpsOrderStatus},
  3054. total_regimental_settle_amount = regimental_promotion_amount
  3055. WHERE oid = #{oid}
  3056. </update>
  3057. <update id="updateMgsOrderRegimentalSettleAmount">
  3058. UPDATE miaogousi.kuaishou_supply_chain
  3059. SET order_status = #{cpsOrderStatus},
  3060. total_regimental_settle_amount = regimental_promotion_amount
  3061. WHERE oid = #{oid}
  3062. </update>
  3063. <update id="updateRocketOrderRegimentalSettleAmount">
  3064. UPDATE rocket.kuaishou_supply_chain
  3065. SET order_status = #{cpsOrderStatus},
  3066. total_regimental_settle_amount = regimental_promotion_amount
  3067. WHERE oid = #{oid}
  3068. </update>
  3069. <update id="updateYufuOrderRegimentalSettleAmount">
  3070. UPDATE yufu.kuaishou_supply_chain
  3071. SET order_status = #{cpsOrderStatus},
  3072. total_regimental_settle_amount = regimental_promotion_amount
  3073. WHERE oid = #{oid}
  3074. </update>
  3075. <update id="updateYuxiuOrderRegimentalSettleAmount">
  3076. UPDATE yuxiu.kuaishou_supply_chain
  3077. SET order_status = #{cpsOrderStatus},
  3078. total_regimental_settle_amount = regimental_promotion_amount
  3079. WHERE oid = #{oid}
  3080. </update>
  3081. <update id="updateRuixuanOrder">
  3082. UPDATE ruixuan.kuaishou_supply_chain
  3083. SET order_status = #{cpsOrderStatus}
  3084. WHERE oid = #{oid}
  3085. </update>
  3086. <update id="updateMgsOrder">
  3087. UPDATE miaogousi.kuaishou_supply_chain
  3088. SET order_status = #{cpsOrderStatus}
  3089. WHERE oid = #{oid}
  3090. </update>
  3091. <update id="updateRocketOrder">
  3092. UPDATE rocket.kuaishou_supply_chain
  3093. SET order_status = #{cpsOrderStatus}
  3094. WHERE oid = #{oid}
  3095. </update>
  3096. <update id="updateYufuOrder">
  3097. UPDATE yufu.kuaishou_supply_chain
  3098. SET order_status = #{cpsOrderStatus}
  3099. WHERE oid = #{oid}
  3100. </update>
  3101. <update id="updateYuxiuOrder">
  3102. UPDATE yuxiu.kuaishou_supply_chain
  3103. SET order_status = #{cpsOrderStatus}
  3104. WHERE oid = #{oid}
  3105. </update>
  3106. <select id="getBytedanceOrderHourDataList" resultType="com.alibaba.fastjson.JSONObject">
  3107. 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'
  3108. FROM bytedance_order_list
  3109. WHERE pay_success_time = #{date}
  3110. GROUP BY pay_success_time_hour
  3111. ORDER BY pay_success_time_hour
  3112. </select>
  3113. <select id="getKuaishouOrderHourDataList" resultType="com.alibaba.fastjson.JSONObject">
  3114. 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'
  3115. FROM kuaishou_supply_chain
  3116. WHERE stat_date = #{date}
  3117. GROUP BY stat_hour
  3118. ORDER BY stat_hour
  3119. </select>
  3120. <select id="exportItemDetail" resultType="com.alibaba.fastjson.JSONObject">
  3121. select t.*,tt.userName
  3122. from (
  3123. select
  3124. promoter_nick_name as 'promoterNickName',
  3125. promoter_id as 'promoterId',
  3126. count(oid) as 'orderNum',
  3127. round(sum(case when order_status != 80 then pay_amount else 0 end)/100,2 )as 'payAmount',
  3128. round(regimental_promotion_rate / 10 ,2) as 'regimentalPromotionRate',
  3129. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  3130. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  3131. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  3132. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  3133. then 1 else 0 end) * 100 ,2) as 'shippingGreen',
  3134. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  3135. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  3136. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when send_status = 1
  3137. then 1 else 0 end) *100,2) as 'deliveryRadio'
  3138. from kuaishou_supply_chain
  3139. where 1= 1
  3140. <if test="itemId != null and itemId != ''">
  3141. and item_id = #{itemId}
  3142. </if>
  3143. <if test="start != null and start != ''">
  3144. and stat_date &gt;= #{start}
  3145. </if>
  3146. <if test="end != null and end != ''">
  3147. and stat_date &lt;= #{end}
  3148. </if>
  3149. <if test="promoterId != null and promoterId != ''">
  3150. and promoter_id = #{promoterId}
  3151. </if>
  3152. <if test="promoterNickName != null and promoterNickName != ''">
  3153. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  3154. </if>
  3155. group by promoter_id) t left join (select promoter_id,group_concat(user_name) as 'userName',user_id as 'userId'
  3156. from
  3157. kuaishou_promoter group by promoter_id) tt
  3158. on t.promoterId = tt.promoter_id
  3159. where 1 =1
  3160. <if test="userId != null and userId != ''">
  3161. and tt.userId = #{userId}
  3162. </if>
  3163. order by t.orderNum desc
  3164. </select>
  3165. <select id="getKsChannelGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
  3166. select stat_hour as 'time',
  3167. round(sum(pay_amount) / 100, 2) as 'charge' from kuaishou_supply_chain
  3168. where stat_date = #{date}
  3169. <if test='userList != null and userList.size() > 0'>
  3170. and promoter_id in (
  3171. select promoter_id
  3172. from kuaishou_promoter where
  3173. 1 = 1
  3174. and user_id in
  3175. <foreach collection="userList" item="item" separator=","
  3176. open="(" close=")">
  3177. #{item}
  3178. </foreach>
  3179. group by promoter_id
  3180. )
  3181. </if>
  3182. group by stat_hour
  3183. order by stat_hour asc;
  3184. </select>
  3185. <select id="getKsChannelGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
  3186. SELECT
  3187. t1.time,
  3188. ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
  3189. FROM
  3190. (select stat_hour as 'time',
  3191. round(sum(pay_amount) / 100, 2) as 'charge' from kuaishou_supply_chain
  3192. where stat_date = #{date}
  3193. <if test='userList != null and userList.size() > 0'>
  3194. and promoter_id in (
  3195. select promoter_id
  3196. from kuaishou_promoter where
  3197. 1 = 1
  3198. and user_id in
  3199. <foreach collection="userList" item="item" separator=","
  3200. open="(" close=")">
  3201. #{item}
  3202. </foreach>
  3203. group by promoter_id
  3204. )
  3205. </if>
  3206. group by stat_hour
  3207. ) t1
  3208. LEFT JOIN
  3209. (select stat_hour as 'time',
  3210. round(sum(pay_amount) / 100, 2) as 'charge' from kuaishou_supply_chain
  3211. where stat_date = DATE_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
  3212. <if test='userList != null and userList.size() > 0'>
  3213. and promoter_id in (
  3214. select promoter_id
  3215. from kuaishou_promoter where
  3216. 1 = 1
  3217. and user_id in
  3218. <foreach collection="userList" item="item" separator=","
  3219. open="(" close=")">
  3220. #{item}
  3221. </foreach>
  3222. group by promoter_id
  3223. )
  3224. </if>
  3225. group by stat_hour
  3226. ) t2 ON t1.time =t2.time
  3227. ORDER BY `time`
  3228. </select>
  3229. <select id="getKsCourtshipGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
  3230. select stat_hour as 'time',
  3231. round(sum(pay_amount) / 100, 2) as 'charge'
  3232. from kuaishou_supply_chain
  3233. where stat_date = #{date}
  3234. <if test='userList != null and userList.size() > 0'>
  3235. and item_id in (
  3236. select item_id
  3237. from kuaishou_item_list where
  3238. 1 = 1
  3239. and user_id in
  3240. <foreach collection="userList" item="item" separator=","
  3241. open="(" close=")">
  3242. #{item}
  3243. </foreach>
  3244. group by item_id
  3245. )
  3246. </if>
  3247. group by stat_hour
  3248. order by stat_hour asc;
  3249. </select>
  3250. <select id="getKsCourtshipGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
  3251. SELECT
  3252. t1.time,
  3253. ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
  3254. FROM
  3255. ( select stat_hour as 'time',
  3256. round(sum(pay_amount) / 100, 2) as 'charge'
  3257. from kuaishou_supply_chain
  3258. where stat_date = #{date}
  3259. <if test='userList != null and userList.size() > 0'>
  3260. and item_id in (
  3261. select item_id
  3262. from kuaishou_item_list where
  3263. 1 = 1
  3264. and user_id in
  3265. <foreach collection="userList" item="item" separator=","
  3266. open="(" close=")">
  3267. #{item}
  3268. </foreach>
  3269. group by item_id
  3270. )
  3271. </if>
  3272. group by stat_hour
  3273. ) t1
  3274. LEFT JOIN
  3275. (
  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_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
  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. ) t2 ON t1.time =t2.time
  3295. ORDER BY `time`
  3296. </select>
  3297. <select id="getBytedanceChannelGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
  3298. select pay_success_time_hour as 'time',
  3299. round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list where pay_success_time = #{date}
  3300. <if test='userList != null and userList.size() > 0'>
  3301. and author_short_id in(
  3302. select promoter_id
  3303. from kuaishou_promoter where
  3304. 1 = 1
  3305. and user_id in
  3306. <foreach collection="userList" item="item" separator=","
  3307. open="(" close=")">
  3308. #{item}
  3309. </foreach>
  3310. group by promoter_id
  3311. )
  3312. </if>
  3313. group by pay_success_time_hour
  3314. order by pay_success_time_hour asc;
  3315. </select>
  3316. <select id="getBytedanceChannelGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
  3317. SELECT
  3318. t1.time,
  3319. ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
  3320. FROM
  3321. (
  3322. select pay_success_time_hour as 'time',
  3323. round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list where pay_success_time = #{date}
  3324. <if test='userList != null and userList.size() > 0'>
  3325. and author_short_id in(
  3326. select promoter_id
  3327. from kuaishou_promoter where
  3328. 1 = 1
  3329. and user_id in
  3330. <foreach collection="userList" item="item" separator=","
  3331. open="(" close=")">
  3332. #{item}
  3333. </foreach>
  3334. group by promoter_id
  3335. )
  3336. </if>
  3337. group by pay_success_time_hour
  3338. ) t1
  3339. LEFT JOIN
  3340. (
  3341. select pay_success_time_hour as 'time',
  3342. round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list
  3343. where pay_success_time = DATE_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
  3344. <if test='userList != null and userList.size() > 0'>
  3345. and author_short_id in(
  3346. select promoter_id
  3347. from kuaishou_promoter where
  3348. 1 = 1
  3349. and user_id in
  3350. <foreach collection="userList" item="item" separator=","
  3351. open="(" close=")">
  3352. #{item}
  3353. </foreach>
  3354. group by promoter_id
  3355. )
  3356. </if>
  3357. group by pay_success_time_hour
  3358. ) t2 ON t1.time =t2.time
  3359. ORDER BY `time`
  3360. </select>
  3361. <select id="getBytedanceCourtshipGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
  3362. select pay_success_time_hour as 'time',
  3363. round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list where pay_success_time = #{date}
  3364. <if test='userList != null and userList.size() > 0'>
  3365. and product_id in(
  3366. select item_id
  3367. from kuaishou_item_list where
  3368. 1 = 1
  3369. and user_id in
  3370. <foreach collection="userList" item="item" separator=","
  3371. open="(" close=")">
  3372. #{item}
  3373. </foreach>
  3374. group by item_id
  3375. )
  3376. </if>
  3377. group by pay_success_time_hour
  3378. order by pay_success_time_hour asc;
  3379. </select>
  3380. <select id="getBytedanceCourtshipGmvHourByDateRoi" resultType="com.alibaba.fastjson.JSONObject">
  3381. SELECT
  3382. t1.time,
  3383. ROUND(((t1.charge-t2.charge)/t2.charge)*100,2) as 'roi'
  3384. FROM
  3385. (
  3386. select pay_success_time_hour as 'time',
  3387. round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list where pay_success_time = #{date}
  3388. <if test='userList != null and userList.size() > 0'>
  3389. and product_id in(
  3390. select item_id
  3391. from kuaishou_item_list where
  3392. 1 = 1
  3393. and user_id in
  3394. <foreach collection="userList" item="item" separator=","
  3395. open="(" close=")">
  3396. #{item}
  3397. </foreach>
  3398. group by item_id
  3399. )
  3400. </if>
  3401. group by pay_success_time_hour
  3402. ) t1
  3403. LEFT JOIN
  3404. (
  3405. select pay_success_time_hour as 'time',
  3406. round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list
  3407. where pay_success_time = DATE_FORMAT(DATE_SUB(#{date},INTERVAL 1 day),'%Y%m%d')
  3408. <if test='userList != null and userList.size() > 0'>
  3409. and product_id in(
  3410. select item_id
  3411. from kuaishou_item_list where
  3412. 1 = 1
  3413. and user_id in
  3414. <foreach collection="userList" item="item" separator=","
  3415. open="(" close=")">
  3416. #{item}
  3417. </foreach>
  3418. group by item_id
  3419. )
  3420. </if>
  3421. group by pay_success_time_hour
  3422. ) t2 ON t1.time =t2.time
  3423. ORDER BY `time`
  3424. </select>
  3425. <insert id="replaceKuaiShouActivityOpenItemList">
  3426. replace into kuaishou_activity_open_item_list(
  3427. item_id,
  3428. item_category_name,
  3429. item_price,
  3430. pre_activity_id,
  3431. item_leaf_category_id,
  3432. item_commission_rate,
  3433. investment_promotion_rate
  3434. )
  3435. values
  3436. <foreach collection="list" item="li" separator=",">
  3437. (
  3438. #{li.itemId},
  3439. #{li.itemCategoryName},
  3440. #{li.itemPrice},
  3441. #{li.preActivityId},
  3442. #{li.itemLeafCategoryId},
  3443. #{li.itemCommissionRate},
  3444. #{li.investmentPromotionRate}
  3445. )
  3446. </foreach>
  3447. </insert>
  3448. <insert id="replaceMgsKuaiShouActivityOpenItemList">
  3449. replace into miaogousi.kuaishou_activity_open_item_list(
  3450. item_id,
  3451. item_category_name,
  3452. item_price,
  3453. pre_activity_id,
  3454. item_leaf_category_id,
  3455. item_commission_rate,
  3456. investment_promotion_rate
  3457. )
  3458. values
  3459. <foreach collection="list" item="li" separator=",">
  3460. (
  3461. #{li.itemId},
  3462. #{li.itemCategoryName},
  3463. #{li.itemPrice},
  3464. #{li.preActivityId},
  3465. #{li.itemLeafCategoryId},
  3466. #{li.itemCommissionRate},
  3467. #{li.investmentPromotionRate}
  3468. )
  3469. </foreach>
  3470. </insert>
  3471. <insert id="replaceRocketKuaiShouActivityOpenItemList">
  3472. replace into rocket.kuaishou_activity_open_item_list(
  3473. item_id,
  3474. item_category_name,
  3475. item_price,
  3476. pre_activity_id,
  3477. item_leaf_category_id,
  3478. item_commission_rate,
  3479. investment_promotion_rate
  3480. )
  3481. values
  3482. <foreach collection="list" item="li" separator=",">
  3483. (
  3484. #{li.itemId},
  3485. #{li.itemCategoryName},
  3486. #{li.itemPrice},
  3487. #{li.preActivityId},
  3488. #{li.itemLeafCategoryId},
  3489. #{li.itemCommissionRate},
  3490. #{li.investmentPromotionRate}
  3491. )
  3492. </foreach>
  3493. </insert>
  3494. <insert id="replaceYufuKuaiShouActivityOpenItemList">
  3495. replace into yufu.kuaishou_activity_open_item_list(
  3496. item_id,
  3497. item_category_name,
  3498. item_price,
  3499. pre_activity_id,
  3500. item_leaf_category_id,
  3501. item_commission_rate,
  3502. investment_promotion_rate
  3503. )
  3504. values
  3505. <foreach collection="list" item="li" separator=",">
  3506. (
  3507. #{li.itemId},
  3508. #{li.itemCategoryName},
  3509. #{li.itemPrice},
  3510. #{li.preActivityId},
  3511. #{li.itemLeafCategoryId},
  3512. #{li.itemCommissionRate},
  3513. #{li.investmentPromotionRate}
  3514. )
  3515. </foreach>
  3516. </insert>
  3517. <insert id="replaceYuxiuKuaiShouActivityOpenItemList">
  3518. replace into yuxiu.kuaishou_activity_open_item_list(
  3519. item_id,
  3520. item_category_name,
  3521. item_price,
  3522. pre_activity_id,
  3523. item_leaf_category_id,
  3524. item_commission_rate,
  3525. investment_promotion_rate
  3526. )
  3527. values
  3528. <foreach collection="list" item="li" separator=",">
  3529. (
  3530. #{li.itemId},
  3531. #{li.itemCategoryName},
  3532. #{li.itemPrice},
  3533. #{li.preActivityId},
  3534. #{li.itemLeafCategoryId},
  3535. #{li.itemCommissionRate},
  3536. #{li.investmentPromotionRate}
  3537. )
  3538. </foreach>
  3539. </insert>
  3540. <select id="getKuaishouActivityInfoList" resultType="Long">
  3541. SELECT DISTINCT activity_id
  3542. FROM kuaishou_activity_info
  3543. WHERE activity_status = 2
  3544. OR activity_status = 3
  3545. </select>
  3546. <select id="getMgsKuaishouActivityInfoList" resultType="Long">
  3547. SELECT DISTINCT activity_id
  3548. FROM miaogousi.kuaishou_activity_info
  3549. WHERE activity_status = 2
  3550. OR activity_status = 3
  3551. </select>
  3552. <select id="getRocketKuaishouActivityInfoList" resultType="Long">
  3553. SELECT DISTINCT activity_id
  3554. FROM rocket.kuaishou_activity_info
  3555. WHERE activity_status = 2
  3556. OR activity_status = 3
  3557. </select>
  3558. <select id="getYufuKuaishouActivityInfoList" resultType="Long">
  3559. SELECT DISTINCT activity_id
  3560. FROM yufu.kuaishou_activity_info
  3561. WHERE activity_status = 2
  3562. OR activity_status = 3
  3563. </select>
  3564. <select id="getYuxiuKuaishouActivityInfoList" resultType="Long">
  3565. SELECT DISTINCT activity_id
  3566. FROM yuxiu.kuaishou_activity_info
  3567. WHERE activity_status = 2
  3568. OR activity_status = 3
  3569. </select>
  3570. <select id="getPromoterId" resultType="com.alibaba.fastjson.JSONObject" parameterType="java.lang.Long">
  3571. SELECT tag, proportion
  3572. FROM promoter_tag
  3573. WHERE promoter_id = #{promoterId}
  3574. ORDER BY tag_oid_num DESC limit 5
  3575. </select>
  3576. <select id="shopList" resultType="com.alibaba.fastjson.JSONObject">
  3577. select t2.seller_name as 'sellerName', t1.*
  3578. from (select seller_id as 'sellerId',
  3579. count(oid) as 'orderNum',
  3580. round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
  3581. 2) as 'payAmount',
  3582. round(regimental_promotion_rate / 10, 2) as 'regimentalPromotionRate',
  3583. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  3584. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,
  3585. 2) as 'validRadio',
  3586. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  3587. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
  3588. when order_status != 80
  3589. then 1
  3590. else 0 end) * 100,
  3591. 2) as 'shippingGreen',
  3592. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  3593. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  3594. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
  3595. when send_status = 1
  3596. then 1
  3597. else 0 end) * 100,
  3598. 2) as 'deliveryRadio'
  3599. from kuaishou_supply_chain
  3600. where 1 = 1
  3601. <if test="start != null and start != ''">
  3602. and stat_date &gt;= #{start}
  3603. </if>
  3604. <if test="end != null and end != ''">
  3605. and stat_date &lt;= #{end}
  3606. </if>
  3607. <if test="sellerId != null and sellerId != ''">
  3608. and seller_id = #{sellerId}
  3609. </if>
  3610. <if test='itemIds != null and itemIds.size() > 0'>
  3611. and item_id in
  3612. <foreach collection="itemIds" item="item" separator=","
  3613. open="(" close=")">
  3614. #{item}
  3615. </foreach>
  3616. </if>
  3617. group by seller_id) t1
  3618. left join kuaishou_seller_info t2
  3619. on t1.sellerId = t2.seller_id
  3620. order by ${fieId} ${sort}
  3621. </select>
  3622. <select id="shopDetail" resultType="com.alibaba.fastjson.JSONObject">
  3623. SELECT t1.*,
  3624. (case
  3625. when t2.ccr_value is null or t2.ccr_value = 0
  3626. then '0%'
  3627. else concat(round(t2.ccr_value / 100, 2), '%')
  3628. end
  3629. ) as 'ccrValue',
  3630. (case
  3631. when t2.ccr_value is null or t2.ccr_value = 0
  3632. then 0
  3633. else round(t2.ccr_value / 100 , 2)
  3634. end
  3635. ) as 'ccrInt',
  3636. t3.userName
  3637. from (
  3638. select item_id as 'itemId',
  3639. item_title as 'itemTitle',
  3640. image_url as 'imageUrl',
  3641. round(reserve_price / 100 , 2) as 'reservePrice',
  3642. count(oid) as 'orderNum',
  3643. round(sum(case when order_status != 80 then pay_amount else 0 end) / 100,
  3644. 2) as 'payAmount',
  3645. round(regimental_promotion_rate / 10, 2) as 'regimentalPromotionRate',
  3646. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  3647. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,
  3648. 2) as 'validRadio',
  3649. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  3650. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
  3651. when order_status != 80
  3652. then 1
  3653. else 0 end) * 100,
  3654. 2) as 'shippingGreen',
  3655. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  3656. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  3657. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
  3658. when send_status = 1
  3659. then 1
  3660. else 0 end) * 100,
  3661. 2) as 'deliveryRadio'
  3662. from kuaishou_supply_chain
  3663. where 1 = 1
  3664. <if test="start != null and start != ''">
  3665. and stat_date &gt;= #{start}
  3666. </if>
  3667. <if test="end != null and end != ''">
  3668. and stat_date &lt;= #{end}
  3669. </if>
  3670. <if test="sellerId != null and sellerId != ''">
  3671. and seller_id = #{sellerId}
  3672. </if>
  3673. <if test="itemId != null and itemId != ''">
  3674. and item_id = #{itemId}
  3675. </if>
  3676. <if test="itemTitle != null and itemTitle != ''">
  3677. and item_title like concat(concat('%',#{itemTitle}),'%')
  3678. </if>
  3679. <if test='itemIds != null and itemIds.size() > 0'>
  3680. and item_id in
  3681. <foreach collection="itemIds" item="item" separator=","
  3682. open="(" close=")">
  3683. #{item}
  3684. </foreach>
  3685. </if>
  3686. group by item_id) t1 left join kuaishou_activity_open_item_list t2
  3687. on t1.itemId = t2.item_id
  3688. LEFT JOIN (select item_id as 'itemId',user_name as 'userName' from kuaishou_item_list WHERE media_id = 2 group
  3689. by item_id) t3
  3690. on t1.itemId = t3.itemId
  3691. order by t1.orderNum desc
  3692. </select>
  3693. <select id="getItemIdsByUserId" resultType="java.lang.Long" parameterType="java.lang.Long">
  3694. SELECT item_id
  3695. FROM kuaishou_item_list
  3696. WHERE user_id = #{userId}
  3697. GROUP BY item_id
  3698. </select>
  3699. <select id="getItemIdsByDeptId" resultType="java.lang.Long" parameterType="java.lang.Long">
  3700. SELECT item_id
  3701. FROM kuaishou_item_list
  3702. WHERE user_id IN (SELECT sys_user.user_id
  3703. FROM sys_user
  3704. WHERE dept_id = #{deptId})
  3705. GROUP BY item_id
  3706. </select>
  3707. <update id="updateKuaiShouActivityOpenItemList">
  3708. UPDATE ruixuan.kuaishou_activity_open_item_list
  3709. SET shop_star = #{shopStar},
  3710. mall_logistics_score = #{mallLogisticsScore},
  3711. shop_score = #{shopScore},
  3712. mall_service_score = #{mallServiceScore},
  3713. mall_quality_score = #{mallQualityScore},
  3714. base_order_status = #{baseOrderStatus},
  3715. ccr_value = #{ccrValue},
  3716. store_score = #{storeScore}
  3717. where item_id = #{itemId}
  3718. </update>
  3719. <update id="updateMgsKuaiShouActivityOpenItemList">
  3720. UPDATE miaogousi.kuaishou_activity_open_item_list
  3721. SET shop_star = #{shopStar},
  3722. mall_logistics_score = #{mallLogisticsScore},
  3723. shop_score = #{shopScore},
  3724. mall_service_score = #{mallServiceScore},
  3725. mall_quality_score = #{mallQualityScore},
  3726. base_order_status = #{baseOrderStatus},
  3727. ccr_value = #{ccrValue},
  3728. store_score = #{storeScore}
  3729. where item_id = #{itemId}
  3730. </update>
  3731. <update id="updateRocketKuaiShouActivityOpenItemList">
  3732. update rocket.kuaishou_activity_open_item_list
  3733. set shop_star = #{shopStar},
  3734. mall_logistics_score = #{mallLogisticsScore},
  3735. shop_score = #{shopScore},
  3736. mall_service_score = #{mallServiceScore},
  3737. mall_quality_score = #{mallQualityScore},
  3738. base_order_status = #{baseOrderStatus},
  3739. ccr_value = #{ccrValue},
  3740. store_score = #{storeScore}
  3741. where item_id = #{itemId}
  3742. </update>
  3743. <update id="updateYufuKuaiShouActivityOpenItemList">
  3744. UPDATE yufu.kuaishou_activity_open_item_list
  3745. SET shop_star = #{shopStar},
  3746. mall_logistics_score = #{mallLogisticsScore},
  3747. shop_score = #{shopScore},
  3748. mall_service_score = #{mallServiceScore},
  3749. mall_quality_score = #{mallQualityScore},
  3750. base_order_status = #{baseOrderStatus},
  3751. ccr_value = #{ccrValue},
  3752. store_score = #{storeScore}
  3753. where item_id = #{itemId}
  3754. </update>
  3755. <update id="updateYuXiuOrder">
  3756. UPDATE yuxiu.kuaishou_supply_chain
  3757. SET order_status = #{cpsOrderStatus}
  3758. WHERE oid = #{oid}
  3759. </update>
  3760. <update id="updateYuXiuOrderRegimentalSettleAmount">
  3761. UPDATE yuxiu.kuaishou_supply_chain
  3762. SET order_status = #{cpsOrderStatus},
  3763. total_regimental_settle_amount = regimental_promotion_amount
  3764. WHERE oid = #{oid}
  3765. </update>
  3766. <update id="updateYuxiuKuaiShouActivityOpenItemList">
  3767. UPDATE yuxiu.kuaishou_activity_open_item_list
  3768. SET shop_star = #{shopStar},
  3769. mall_logistics_score = #{mallLogisticsScore},
  3770. shop_score = #{shopScore},
  3771. mall_service_score = #{mallServiceScore},
  3772. mall_quality_score = #{mallQualityScore},
  3773. base_order_status = #{baseOrderStatus},
  3774. ccr_value = #{ccrValue},
  3775. store_score = #{storeScore}
  3776. where item_id = #{itemId}
  3777. </update>
  3778. </mapper>