SupplyChainMapper.xml 119 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969
  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 *
  34. from (
  35. select promoter_id as 'promoterId',
  36. promoter_nick_name as 'promoterNickName',
  37. count(oid) as 'orderNum',
  38. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  39. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  40. sum(pay_amount) as 'payAmount',
  41. sum(case when order_status != 80 then pay_amount else 0 end) as 'validPayAmount',
  42. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  43. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  44. then 1 else 0 end),4) as 'shippingGreen',
  45. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  46. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  47. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when send_status = 1
  48. then 1 else 0 end),4) as 'deliveryRadio',
  49. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount'
  50. from kuaishou_supply_chain
  51. where 1= 1
  52. <if test="start != null and start != ''">
  53. and order_create_time &gt;= #{start}
  54. </if>
  55. <if test="end != null and end != ''">
  56. and order_create_time &lt;= #{end}
  57. </if>
  58. <if test="promoterId != null and promoterId != ''">
  59. and promoter_id = #{promoterId}
  60. </if>
  61. <if test="promoterNickName != null and promoterNickName != ''">
  62. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  63. </if>
  64. group by promoter_id) t left join (
  65. select promoter_id as 'promoterId',group_concat(user_name) as 'userName' from kuaishou_promoter where media_id =
  66. 2
  67. group by promoter_id
  68. ) t2 on t.promoterId = t2.promoterId
  69. order by t.orderNum desc
  70. </select>
  71. <select id="getTopOrders" resultType="com.alibaba.fastjson.JSONObject">
  72. select *
  73. from
  74. (select item_id as 'itemId',
  75. item_title as 'itemTitle',
  76. image_url as 'imageUrl',
  77. count(oid) as 'orderNum'
  78. from kuaishou_supply_chain
  79. where promoter_id = #{promoterId}
  80. <if test="start != null and start != ''">
  81. and order_create_time &gt;= #{start}
  82. </if>
  83. <if test="end != null and end != ''">
  84. and order_create_time &lt;= #{end}
  85. </if>
  86. group by item_id) t
  87. order by t.orderNum desc limit 3
  88. </select>
  89. <select id="anchorOrderDetail" resultType="com.alibaba.fastjson.JSONObject">
  90. select t.*,
  91. t2.status,
  92. (
  93. case
  94. when t3.activity_item_status = 1 then '待审核'
  95. when t3.activity_item_status = 2 then '已上架'
  96. when t3.activity_item_status = 3 then '审核拒绝'
  97. when t3.activity_item_status = 4 then '活动失效'
  98. when t3.activity_item_status = 5 then '商品下架'
  99. else ''
  100. end
  101. ) as 'activityItemStatus'
  102. from (select
  103. item_title as 'itemTitle',
  104. item_id as 'itemId',
  105. reserve_price as 'reservePrice',
  106. image_url 'imageUrl',
  107. count(oid) as 'orderNum',
  108. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  109. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  110. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  111. regimental_promotion_rate as 'regimentalPromotionRate',
  112. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  113. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  114. then 1 else 0 end),4) as 'shippingGreen',
  115. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  116. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  117. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when send_status = 1
  118. then 1 else 0 end),4) as 'deliveryRadio'
  119. from kuaishou_supply_chain
  120. where 1= 1
  121. <if test="promoterId != null and promoterId != ''">
  122. and promoter_id = #{promoterId}
  123. </if>
  124. <if test="start != null and start != ''">
  125. and order_create_time &gt;= #{start}
  126. </if>
  127. <if test="end != null and end != ''">
  128. and order_create_time &lt;= #{end}
  129. </if>
  130. <if test="itemId != null and itemId != ''">
  131. and item_id = #{itemId}
  132. </if>
  133. <if test="itemTitle != null and itemTitle != ''">
  134. and item_title like concat(concat('%',#{itemTitle}),'%')
  135. </if>
  136. group by item_id) t left join ( select item_id as 'itemId', collect_sample_status as 'status' from
  137. kuaishou_item_collect_samples where promoter_id = #{promoterId}) t2
  138. on t.itemId = t2.itemId
  139. left join kuaishou_item_list t3
  140. on t.itemId = t3.item_id
  141. order by t.orderNum desc
  142. </select>
  143. <select id="orderStatistics" resultType="com.alibaba.fastjson.JSONObject">
  144. select FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') as 'date',
  145. count(t.oid) as 'orderNum'
  146. from (select oid,
  147. order_create_time
  148. from kuaishou_supply_chain
  149. where 1 = 1
  150. <if test="promoterId != null and promoterId != ''">
  151. and promoter_id = #{promoterId}
  152. </if>
  153. <if test="start != null and start != ''">
  154. and order_create_time &gt;= #{start}
  155. </if>
  156. <if test="end != null and end != ''">
  157. and order_create_time &lt;= #{end}
  158. </if>
  159. ) t
  160. group by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d')
  161. order by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') asc
  162. </select>
  163. <select id="itemList" resultType="com.alibaba.fastjson.JSONObject">
  164. select *
  165. from (select t2.user_id as 'userId',
  166. t2.user_name as 'userName',
  167. t1.item_id as 'itemId',
  168. t1.reserve_price as 'reservePrice',
  169. t1.item_title as 'itemTitle',
  170. t1.image_url as 'imageUrl',
  171. count(t1.oid) as 'orderNum',
  172. sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  173. round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid), 4) as 'validRadio',
  174. sum(case when t1.send_status = 1 then 1 else 0 end) as 'deliveryNum',
  175. round(sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) / sum(case when
  176. t1.order_status != 80
  177. then 1 else 0 end),4) as 'shippingGreen',
  178. sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  179. sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  180. round(sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) / sum(case when
  181. send_status = 1 then 1 else 0 end), 4) as 'deliveryRadio',
  182. t1.item_commission_rate as 'itemCommissionRate',
  183. t3.ccr_value as 'ccrValue',
  184. (case
  185. when t3.ccr_value = '-' or t3.ccr_value is null
  186. then 0
  187. else replace( t3.ccr_value,'%','')
  188. end
  189. ) as 'ccrInt'
  190. from kuaishou_supply_chain t1
  191. left join kuaishou_item_bind_user t2
  192. on t1.item_id = t2.item_id
  193. left join kuaishou_item_ccr_info t3
  194. on t1.item_id = t3.item_id
  195. where 1 = 1
  196. <if test="start != null and start != ''">
  197. and t1.order_create_time &gt;= #{start}
  198. </if>
  199. <if test="end != null and end != ''">
  200. and t1.order_create_time &lt;= #{end}
  201. </if>
  202. <if test="itemId != null and itemId != ''">
  203. and t1.item_id = #{itemId}
  204. </if>
  205. <if test="itemTitle != null and itemTitle != ''">
  206. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  207. </if>
  208. group by t1.item_id) t
  209. where 1 = 1
  210. <if test="userId != null and userId != ''">
  211. and t.userId = #{userId}
  212. </if>
  213. order by ${fieId} ${sort}
  214. </select>
  215. <select id="itemBindList" resultType="com.alibaba.fastjson.JSONObject">
  216. select t1.*,t2.*
  217. from (select t.item_id as 'itemId', t.item_title as 'itemTitle', t.user_id as 'userId', t.user_name as
  218. 'userName',
  219. (case
  220. when tt.ccr_value = '-' or tt.ccr_value is null
  221. then 0
  222. else replace(tt.ccr_value, '%', '')
  223. end
  224. ) as 'ccrInt',
  225. tt.ccr_value as 'ccrValue'
  226. from kuaishou_item_list t left join kuaishou_item_ccr_info tt
  227. on t.item_id = tt.item_id
  228. where
  229. t.create_time &gt;= str_to_date(concat(#{bindStartDate},' 00:00:01'),'%Y-%m-%d
  230. %H:%i:%s')
  231. and
  232. t.create_time &lt;= str_to_date(concat(#{bindEndDate},' 23:59:59'),'%Y-%m-%d
  233. %H:%i:%s')
  234. ) t1
  235. left join
  236. (select item_id as 'itemId',
  237. reserve_price as 'reservePrice',
  238. item_title as 'itemTitle',
  239. image_url as 'imageUrl',
  240. count(oid) as 'orderNum',
  241. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  242. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),
  243. 4) as 'validRadio',
  244. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  245. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  246. then 1 else 0 end),4) as 'shippingGreen',
  247. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  248. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  249. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
  250. when
  251. send_status = 1
  252. then 1
  253. else 0 end),
  254. 4) as 'deliveryRadio',
  255. item_commission_rate as 'itemCommissionRate'
  256. from kuaishou_supply_chain
  257. where order_create_time &gt;= #{start}
  258. group by item_id) t2 on t1.itemId = t2.itemId
  259. where 1 = 1
  260. <if test="itemId != null and itemId != ''">
  261. and t1.itemId = #{itemId}
  262. </if>
  263. <if test="itemTitle != null and itemTitle != ''">
  264. and t1.itemTitle like concat(concat('%',#{itemTitle}),'%')
  265. </if>
  266. <if test="userId != null and userId != ''">
  267. and t1.userId = #{userId}
  268. </if>
  269. order by ${fieId} ${sort}
  270. </select>
  271. <select id="getTopPromoterByItemId" resultType="com.alibaba.fastjson.JSONObject">
  272. select
  273. *
  274. from
  275. (select promoter_id as 'promoterId',
  276. promoter_nick_name as 'promoterNickName',
  277. count(oid) as 'orderNum'
  278. from kuaishou_supply_chain
  279. where item_id = #{itemId}
  280. <if test="start != null and start != ''">
  281. and order_create_time &gt;= #{start}
  282. </if>
  283. <if test="end != null and end != ''">
  284. and order_create_time &lt;= #{end}
  285. </if>
  286. group by promoter_id) t
  287. order by t.orderNum desc limit 3
  288. </select>
  289. <select id="itemDetail" resultType="com.alibaba.fastjson.JSONObject">
  290. select t.*,tt.userName
  291. from (
  292. select
  293. promoter_nick_name as 'promoterNickName',
  294. promoter_id as 'promoterId',
  295. count(oid) as 'orderNum',
  296. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  297. regimental_promotion_rate as 'regimentalPromotionRate',
  298. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  299. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  300. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  301. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  302. then 1 else 0 end),4) as 'shippingGreen',
  303. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  304. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  305. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when send_status = 1
  306. then 1 else 0 end),4) as 'deliveryRadio'
  307. from kuaishou_supply_chain
  308. where 1= 1
  309. <if test="itemId != null and itemId != ''">
  310. and item_id = #{itemId}
  311. </if>
  312. <if test="start != null and start != ''">
  313. and order_create_time &gt;= #{start}
  314. </if>
  315. <if test="end != null and end != ''">
  316. and order_create_time &lt;= #{end}
  317. </if>
  318. <if test="promoterId != null and promoterId != ''">
  319. and promoter_id = #{promoterId}
  320. </if>
  321. <if test="promoterNickName != null and promoterNickName != ''">
  322. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  323. </if>
  324. group by promoter_id) t left join (select promoter_id,group_concat(user_name) as 'userName',user_id as 'userId'
  325. from
  326. kuaishou_promoter group by promoter_id) tt
  327. on t.promoterId = tt.promoter_id
  328. where 1 =1
  329. <if test="userId != null and userId != ''">
  330. and tt.userId = #{userId}
  331. </if>
  332. order by t.orderNum desc
  333. </select>
  334. <select id="itemServiceCharge" resultType="com.alibaba.fastjson.JSONObject">
  335. select *
  336. from (
  337. select
  338. item_id as 'itemId',
  339. item_title as 'itemTitle',
  340. image_url as 'imageUrl',
  341. count(oid) as 'orderNum',
  342. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  343. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  344. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  345. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  346. then 1 else 0 end),4) as 'shippingGreen',
  347. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  348. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  349. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when send_status = 1
  350. then 1 else 0 end),4) as 'deliveryRadio',
  351. sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  352. regimental_promotion_rate as 'regimentalPromotionRate',
  353. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  354. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount',
  355. sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
  356. 'totalRegimentalSettleAmount',
  357. item_commission_rate as 'itemCommissionRate'
  358. from kuaishou_supply_chain
  359. where 1= 1
  360. <if test="start != null and start != ''">
  361. and order_create_time &gt;= #{start}
  362. </if>
  363. <if test="end != null and end != ''">
  364. and order_create_time &lt;= #{end}
  365. </if>
  366. <if test="itemId != null and itemId != ''">
  367. and item_id = #{itemId}
  368. </if>
  369. <if test="itemTitle != null and itemTitle != ''">
  370. and item_title like concat(concat('%',#{itemTitle}),'%')
  371. </if>
  372. group by item_id) t
  373. order by t.orderNum desc
  374. </select>
  375. <select id="getOrderTotal" resultType="com.alibaba.fastjson.JSONObject">
  376. select
  377. count(oid) as 'orderNum',
  378. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  379. sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm'
  380. from kuaishou_supply_chain
  381. where 1= 1
  382. <if test="start != null and start != ''">
  383. and order_create_time &gt;= #{start}
  384. </if>
  385. <if test="end != null and end != ''">
  386. and order_create_time &lt;= #{end}
  387. </if>
  388. </select>
  389. <select id="getOrderTotalRatio" resultType="java.lang.Double">
  390. select
  391. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio'
  392. from (select count(oid) as 'oid'
  393. from kuaishou_supply_chain
  394. where 1= 1
  395. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  396. and order_create_time &gt;= #{nowStartHourTemp}
  397. </if>
  398. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  399. and order_create_time &lt;= #{nowEndHourTemp}
  400. </if>
  401. ) t1
  402. join (select count(oid) as 'oid'
  403. from kuaishou_supply_chain
  404. where 1=1
  405. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  406. and order_create_time &gt;= #{yesterdayStartHourTemp}
  407. </if>
  408. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  409. and order_create_time &lt;= #{yesterdayEndHourTemp}
  410. </if>
  411. ) t2
  412. </select>
  413. <select id="getAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  414. select
  415. sum(order_amount) as 'orderAmount',
  416. sum(base_amount) as 'baseAmount',
  417. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount',
  418. sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
  419. 'totalRegimentalSettleAmount'
  420. from kuaishou_supply_chain
  421. where 1= 1
  422. <if test="start != null and start != ''">
  423. and order_create_time &gt;= #{start}
  424. </if>
  425. <if test="end != null and end != ''">
  426. and order_create_time &lt;= #{end}
  427. </if>
  428. </select>
  429. <select id="getAmountTotalRatio" resultType="java.lang.Double">
  430. select
  431. round((t1.payAmount -t2.payAmount) / t2.payAmount , 4) as 'amountTotalRatio'
  432. from (select sum(pay_amount) as 'payAmount'
  433. from kuaishou_supply_chain
  434. where 1= 1
  435. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  436. and order_create_time &gt;= #{nowStartHourTemp}
  437. </if>
  438. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  439. and order_create_time &lt;= #{nowEndHourTemp}
  440. </if>
  441. ) t1
  442. join (select sum(pay_amount) as 'payAmount'
  443. from kuaishou_supply_chain
  444. where 1=1
  445. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  446. and order_create_time &gt;= #{yesterdayStartHourTemp}
  447. </if>
  448. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  449. and order_create_time &lt;= #{yesterdayEndHourTemp}
  450. </if>
  451. ) t2
  452. </select>
  453. <select id="getServiceAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  454. select
  455. count(distinct promoter_id) as 'promoterNum',
  456. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  457. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  458. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  459. as 'deliveryRadio'
  460. from kuaishou_supply_chain
  461. where 1= 1
  462. <if test="start != null and start != ''">
  463. and order_create_time &gt;= #{start}
  464. </if>
  465. <if test="end != null and end != ''">
  466. and order_create_time &lt;= #{end}
  467. </if>
  468. </select>
  469. <select id="getOrderRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  470. select
  471. t1.*,
  472. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  473. from (select
  474. item_id as 'itemId',
  475. item_title as 'itemTitle',
  476. image_url as 'imageUrl',
  477. count(oid) as 'orderNum',
  478. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  479. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  480. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  481. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  482. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  483. as 'deliveryRadio'
  484. from kuaishou_supply_chain
  485. where 1= 1
  486. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  487. and order_create_time &gt;= #{nowStartHourTemp}
  488. </if>
  489. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  490. and order_create_time &lt;= #{nowEndHourTemp}
  491. </if>
  492. group by item_id
  493. ) t1
  494. left join (select
  495. item_id as 'itemId',
  496. count(oid) as 'orderNum'
  497. from kuaishou_supply_chain
  498. where 1=1
  499. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  500. and order_create_time &gt;= #{yesterdayStartHourTemp}
  501. </if>
  502. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  503. and order_create_time &lt;= #{yesterdayEndHourTemp}
  504. </if>
  505. group by item_id
  506. ) t2 on t1.itemId = t2.itemId
  507. order by t1.orderNum desc
  508. </select>
  509. <select id="getOrderRankRatioListBytedance" resultType="com.alibaba.fastjson.JSONObject">
  510. select
  511. t1.*,
  512. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  513. from (
  514. select
  515. product_id as 'itemId',
  516. product_name as 'itemTitle',
  517. product_img as 'imageUrl',
  518. count(order_id) as 'orderNum',
  519. sum(case when flow_point != 'REFUND' then 1 else 0 end) as 'validOrderNUm',
  520. round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id),4) as 'validRadio'
  521. from bytedance_order_list
  522. where 1= 1
  523. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  524. and pay_success_time &gt;= #{nowStartHourTemp}
  525. </if>
  526. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  527. and pay_success_time &lt;= #{nowEndHourTemp}
  528. </if>
  529. group by product_id
  530. ) t1
  531. left join (select
  532. product_id as 'itemId',
  533. count(order_id) as 'orderNum'
  534. from bytedance_order_list
  535. where 1=1
  536. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  537. and pay_success_time &gt;= #{yesterdayStartHourTemp}
  538. </if>
  539. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  540. and pay_success_time &lt;= #{yesterdayEndHourTemp}
  541. </if>
  542. group by product_id
  543. ) t2 on t1.itemId = t2.itemId
  544. order by t1.orderNum desc
  545. </select>
  546. <select id="getOrderRankList" resultType="com.alibaba.fastjson.JSONObject">
  547. select * from (
  548. select
  549. item_id as 'itemId',
  550. item_title as 'itemTitle',
  551. image_url as 'imageUrl',
  552. count(oid) as 'orderNum',
  553. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  554. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  555. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  556. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  557. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  558. then 1 else 0 end),4) as 'deliveryRadio'
  559. from kuaishou_supply_chain
  560. where 1= 1
  561. <if test="start != null and start != ''">
  562. and order_create_time &gt;= #{start}
  563. </if>
  564. <if test="end != null and end != ''">
  565. and order_create_time &lt;= #{end}
  566. </if>
  567. group by item_id) t
  568. order by t.orderNum desc
  569. </select>
  570. <select id="getOrderRankListBytedance" resultType="com.alibaba.fastjson.JSONObject">
  571. select * from (
  572. select
  573. product_id as 'itemId',
  574. product_name as 'itemTitle',
  575. product_img as 'imageUrl',
  576. count(order_id) as 'orderNum',
  577. sum(case when flow_point != 'REFUND' then 1 else 0 end) as 'validOrderNUm',
  578. round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id),4) as 'validRadio'
  579. from bytedance_order_list
  580. where 1= 1
  581. <if test="start != null and start != ''">
  582. and pay_success_time &gt;= #{start}
  583. </if>
  584. <if test="end != null and end != ''">
  585. and pay_success_time &lt;= #{end}
  586. </if>
  587. group by product_id) t
  588. order by t.orderNum desc
  589. </select>
  590. <select id="getPromoterRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  591. select
  592. t1.*,
  593. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  594. from (
  595. select
  596. t.promoter_id as 'promoterId',
  597. t.promoter_nick_name as 'promoterNickName',
  598. tt.promoter_url as 'promoterUrl',
  599. count(oid) as 'orderNum',
  600. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  601. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  602. from kuaishou_supply_chain t
  603. left join kuaishou_promoter tt on t.promoter_id = tt.promoter_id
  604. where 1= 1
  605. <if test='promoterIds != null and promoterIds.size() > 0'>
  606. AND t.promoter_id IN
  607. <foreach collection="promoterIds" item="item" separator=","
  608. open="(" close=")">
  609. #{item}
  610. </foreach>
  611. </if>
  612. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  613. and order_create_time &gt;= #{nowStartHourTemp}
  614. </if>
  615. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  616. and order_create_time &lt;= #{nowEndHourTemp}
  617. </if>
  618. group by t.promoter_id
  619. ) t1
  620. left join (select
  621. promoter_id as 'promoterId',
  622. count(oid) as 'orderNum'
  623. from kuaishou_supply_chain
  624. where 1=1
  625. <if test='promoterIds != null and promoterIds.size() > 0'>
  626. AND promoter_id IN
  627. <foreach collection="promoterIds" item="item" separator=","
  628. open="(" close=")">
  629. #{item}
  630. </foreach>
  631. </if>
  632. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  633. and order_create_time &gt;= #{yesterdayStartHourTemp}
  634. </if>
  635. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  636. and order_create_time &lt;= #{yesterdayEndHourTemp}
  637. </if>
  638. group by promoter_id
  639. ) t2 on t1.promoterId = t2.promoterId
  640. order by t1.orderNum desc
  641. </select>
  642. <select id="getPromoterRankRatioListBytedance" resultType="com.alibaba.fastjson.JSONObject">
  643. select
  644. t1.*,
  645. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  646. from (
  647. select
  648. author_short_id as 'promoterId',
  649. author_account as 'promoterNickName',
  650. count(order_id) as 'orderNum',
  651. sum(case when flow_point != 'REFUND' then 1 else 0 end) as 'validOrderNUm',
  652. round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id),4) as 'validRadio'
  653. from bytedance_order_list
  654. where author_short_id is not null
  655. <if test='promoterIds != null and promoterIds.size() > 0'>
  656. AND author_short_id IN
  657. <foreach collection="promoterIds" item="item" separator=","
  658. open="(" close=")">
  659. #{item}
  660. </foreach>
  661. </if>
  662. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  663. and pay_success_time &gt;= #{nowStartHourTemp}
  664. </if>
  665. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  666. and pay_success_time &lt;= #{nowEndHourTemp}
  667. </if>
  668. group by author_short_id
  669. ) t1
  670. left join (
  671. select
  672. author_short_id as 'promoterId',
  673. count(order_id) as 'orderNum'
  674. from bytedance_order_list
  675. where 1=1
  676. <if test='promoterIds != null and promoterIds.size() > 0'>
  677. AND author_short_id IN
  678. <foreach collection="promoterIds" item="item" separator=","
  679. open="(" close=")">
  680. #{item}
  681. </foreach>
  682. </if>
  683. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  684. and pay_success_time &gt;= #{yesterdayStartHourTemp}
  685. </if>
  686. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  687. and pay_success_time &lt;= #{yesterdayEndHourTemp}
  688. </if>
  689. group by author_short_id
  690. ) t2 on t1.promoterId = t2.promoterId
  691. order by t1.orderNum desc
  692. </select>
  693. <select id="getPromoterRatioList" resultType="com.alibaba.fastjson.JSONObject">
  694. select * from (
  695. select
  696. t1.promoter_id as 'promoterId',
  697. t1.promoter_nick_name as 'promoterNickName',
  698. count(oid) as 'orderNum',
  699. tt.promoter_url as 'promoterUrl',
  700. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  701. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  702. from kuaishou_supply_chain t1
  703. left join kuaishou_promoter tt on t1.promoter_id = tt.promoter_id
  704. where 1= 1
  705. <if test="start != null and start != ''">
  706. and order_create_time &gt;= #{start}
  707. </if>
  708. <if test="end != null and end != ''">
  709. and order_create_time &lt;= #{end}
  710. </if>
  711. group by t1.promoter_id) t
  712. order by t.orderNum desc
  713. </select>
  714. <select id="getPromoterRatioListBytedance" resultType="com.alibaba.fastjson.JSONObject">
  715. select * from (
  716. select
  717. author_short_id as 'promoterId',
  718. author_account as 'promoterNickName',
  719. count(order_id) as 'orderNum',
  720. sum(case when flow_point != 'REFUND' then 1 else 0 end) as 'validOrderNUm',
  721. round(sum(case when flow_point != 'REFUND' then 1 else 0 end) / count(order_id),4) as 'validRadio'
  722. from bytedance_order_list
  723. where author_short_id is not null
  724. <if test="start != null and start != ''">
  725. and pay_success_time &gt;= #{start}
  726. </if>
  727. <if test="end != null and end != ''">
  728. and pay_success_time &lt;= #{end}
  729. </if>
  730. group by author_short_id) t
  731. order by t.orderNum desc
  732. </select>
  733. <select id="exportPromoterTotal" resultType="com.alibaba.fastjson.JSONObject">
  734. select *
  735. from (
  736. select
  737. promoter_id as 'promoterId',
  738. promoter_nick_name as 'promoterNickName',
  739. count(oid) as 'orderNum',
  740. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  741. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  742. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  743. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  744. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  745. then 1 else 0 end) * 100,2) as 'deliveryRadio',
  746. round(sum(pay_amount) / 100,2) as 'payAmount',
  747. round(sum(case when order_status != 80 then pay_amount else 0 end) / 100 , 2 ) as 'validPayAmount',
  748. round(sum(case when order_status != 80 then regimental_promotion_amount else 0 end) / 100, 2) as
  749. 'regimentalPromotionAmount'
  750. from kuaishou_supply_chain
  751. where 1= 1
  752. <if test="start != null and start != ''">
  753. and order_create_time &gt;= #{start}
  754. </if>
  755. <if test="end != null and end != ''">
  756. and order_create_time &lt;= #{end}
  757. </if>
  758. <if test="promoterId != null and promoterId != ''">
  759. and promoter_id = #{promoterId}
  760. </if>
  761. <if test="promoterNickName != null and promoterNickName != ''">
  762. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  763. </if>
  764. <if test="itemId != null and itemId != ''">
  765. and item_id = #{itemId}
  766. </if>
  767. <if test="itemTitle != null and itemTitle != ''">
  768. and item_title like concat(concat('%',#{itemTitle}),'%')
  769. </if>
  770. group by promoter_id) t
  771. order by t.orderNum desc
  772. </select>
  773. <select id="exportPromoter" resultType="com.alibaba.fastjson.JSONObject">
  774. select *
  775. from (
  776. select
  777. promoter_id as 'promoterId',
  778. promoter_nick_name as 'promoterNickName',
  779. item_id as 'itemId',
  780. item_title as 'itemTitle',
  781. image_url as 'imageUrl',
  782. count(oid) as 'orderNum',
  783. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  784. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  785. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  786. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  787. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  788. then 1 else 0 end) * 100,2) as 'deliveryRadio'
  789. from kuaishou_supply_chain
  790. where 1= 1
  791. <if test="start != null and start != ''">
  792. and order_create_time &gt;= #{start}
  793. </if>
  794. <if test="end != null and end != ''">
  795. and order_create_time &lt;= #{end}
  796. </if>
  797. <if test="promoterId != null and promoterId != ''">
  798. and promoter_id = #{promoterId}
  799. </if>
  800. <if test="promoterNickName != null and promoterNickName != ''">
  801. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  802. </if>
  803. <if test="itemId != null and itemId != ''">
  804. and item_id = #{itemId}
  805. </if>
  806. <if test="itemTitle != null and itemTitle != ''">
  807. and item_title like concat(concat('%',#{itemTitle}),'%')
  808. </if>
  809. group by promoter_id,item_id) t
  810. order by t.promoterId,t.orderNum desc
  811. </select>
  812. <select id="exportOrder" resultType="com.alibaba.fastjson.JSONObject">
  813. select *
  814. from (select
  815. t2.user_id as 'userId',
  816. t2.user_name as 'userName',
  817. t1.item_id as 'itemId',
  818. t1.item_title as 'itemTitle',
  819. t1.image_url as 'imageUrl',
  820. count(t1.oid) as 'orderNum',
  821. sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  822. round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid) * 100, 2) as 'validRadio',
  823. sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  824. sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  825. round(sum(case when t1.send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when t1.order_status
  826. != 80 then 1 else 0 end) * 100, 2) as 'deliveryRadio',
  827. round(t1.item_commission_rate / 10,2) as 'itemCommissionRate',
  828. t3.ccr_value as 'ccrValue'
  829. from kuaishou_supply_chain t1
  830. left join kuaishou_item_bind_user t2
  831. on t1.item_id = t2.item_id
  832. left join kuaishou_item_ccr_info t3
  833. on t1.item_id = t3.item_id
  834. where 1 = 1
  835. <if test="start != null and start != ''">
  836. and t1.order_create_time &gt;= #{start}
  837. </if>
  838. <if test="end != null and end != ''">
  839. and t1.order_create_time &lt;= #{end}
  840. </if>
  841. <if test="promoterId != null and promoterId != ''">
  842. and t1.promoter_id = #{promoterId}
  843. </if>
  844. <if test="promoterNickName != null and promoterNickName != ''">
  845. and t1.promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  846. </if>
  847. <if test="itemId != null and itemId != ''">
  848. and t1.item_id = #{itemId}
  849. </if>
  850. <if test="itemTitle != null and itemTitle != ''">
  851. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  852. </if>
  853. group by t1.item_id) t
  854. where 1 = 1
  855. <if test="userId != null and userId != ''">
  856. and t.userId = #{userId}
  857. </if>
  858. order by t.orderNum desc
  859. </select>
  860. <select id="bindUserItemList" resultType="com.alibaba.fastjson.JSONObject">
  861. select *
  862. from (select t1.item_id as 'itemId',
  863. t1.item_title as 'itemTitle',
  864. t1.reserve_price as 'reservePrice',
  865. t1.image_url as 'imageUrl',
  866. t1.activity_id as 'activityId',
  867. t1.regimental_promotion_rate as 'regimentalPromotionRate',
  868. t2.user_id as 'userId',
  869. case when t2.user_id is null then 1 else 2 end as 'status',
  870. t2.user_name as 'userName',
  871. t2.create_time as 'bindTime',
  872. t1.item_commission_rate as 'itemCommissionRate'
  873. from kuaishou_item_info t1
  874. left join kuaishou_item_bind_user t2 on t1.item_id = t2.item_id
  875. where 1 = 1
  876. <if test="userId != null and userId != ''">
  877. and t2.user_id = #{userId}
  878. </if>
  879. <if test="itemId != null and itemId != ''">
  880. and t1.item_id = #{itemId}
  881. </if>
  882. <if test="itemTitle != null and itemTitle != ''">
  883. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  884. </if>
  885. <if test="activityId != null and activityId != ''">
  886. and t1.activity_id = #{activityId}
  887. </if>
  888. order by t1.create_time desc) t
  889. where 1 = 1
  890. <if test="status != null and status != ''">
  891. and t.status = #{status}
  892. </if>
  893. </select>
  894. <select id="getSupplyChainUserList" resultType="com.alibaba.fastjson.JSONObject">
  895. select *
  896. from (select t3.user_id as 'userId',
  897. t3.nick_name as 'nickMame',
  898. t1.role_name as 'roleName',
  899. t3.status,
  900. t3.create_time
  901. from sys_role t1
  902. left join sys_user_role t2 on t1.role_id = t2.role_id
  903. left join sys_user t3 on t2.user_id = t3.user_id
  904. where t1.role_key in (
  905. 'association',
  906. 'associationManager',
  907. 'bd',
  908. 'bdManager'
  909. )
  910. and t3.status = 0
  911. group by t3.user_id) t
  912. where t.userId is not null
  913. order by t.create_time desc
  914. </select>
  915. <select id="adminReportList" resultType="com.alibaba.fastjson.JSONObject">
  916. select *
  917. from (select t1.user_id as 'userId',
  918. t1.user_name as 'userName',
  919. count(distinct t2.item_id) as 'itemCount',
  920. count(t2.oid) as 'orderNum',
  921. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  922. round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid),4) as 'validRadio',
  923. sum(case when t2.send_status = 1 then 1 else 0 end) as 'deliveryNum',
  924. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case when
  925. t2.order_status != 80
  926. then 1 else 0 end),4) as 'shippingGreen',
  927. sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  928. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  929. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
  930. when send_status = 1
  931. then 1
  932. else 0 end),
  933. 4) as 'deliveryRadio',
  934. sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  935. sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) as 'payAmount',
  936. sum(case
  937. when t2.order_status != 80 then t2.regimental_promotion_amount
  938. else 0 end) as 'regimentalPromotionAmount',
  939. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  940. 'totalRegimentalSettleAmount',
  941. round( sum(case
  942. when t2.order_status != 80 then t2.regimental_promotion_amount
  943. else 0 end) / sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) ,5 ) as 'avgServiceRate'
  944. from kuaishou_item_bind_user t1
  945. left join kuaishou_supply_chain t2
  946. on t1.item_id = t2.item_id
  947. where 1= 1
  948. <if test="start != null and start != ''">
  949. and t2.order_create_time &gt;= #{start}
  950. </if>
  951. <if test="end != null and end != ''">
  952. and t2.order_create_time &lt;= #{end}
  953. </if>
  954. group by t1.user_id) t left join (
  955. select item_create_id,count(1) as 'sendSampleCount' from kuaishou_item_collect_samples
  956. where courier_number_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  957. and courier_number_time &lt;= from_unixtime(#{end}/1000,'%Y-%m-%d %H:%i:%s')
  958. group by item_create_id
  959. ) t1 on t.userId = t1.item_create_id
  960. where 1 =1
  961. <if test="userId != null and userId != ''">
  962. and t.userId = #{userId}
  963. </if>
  964. order by t.orderNum desc
  965. </select>
  966. <select id="userItemDetail" resultType="com.alibaba.fastjson.JSONObject">
  967. SELECT
  968. *
  969. FROM
  970. (
  971. SELECT
  972. t1.user_id,
  973. t1.user_name AS 'userName',
  974. t2.item_id AS 'itemId',
  975. t2.item_title AS 'itemTitle',
  976. t2.image_url AS 'imageUrl',
  977. t2.reserve_price AS 'reservePrice',
  978. count(t2.oid) AS 'orderNum',
  979. sum(
  980. CASE
  981. WHEN t2.order_status != 80 THEN 1
  982. ELSE 0
  983. END
  984. ) AS 'validOrderNUm',
  985. round(
  986. sum(
  987. CASE
  988. WHEN t2.order_status != 80 THEN 1
  989. ELSE 0
  990. END
  991. ) / count(t2.oid),
  992. 4
  993. ) AS 'validRadio',
  994. sum(
  995. CASE
  996. WHEN t2.send_status = 1
  997. THEN 1
  998. ELSE 0
  999. END
  1000. ) AS 'deliveryNum',
  1001. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case when
  1002. t2.order_status != 80
  1003. then 1 else 0 end),4) as 'shippingGreen',
  1004. sum(
  1005. CASE
  1006. WHEN t2.send_status = 1
  1007. AND t2.order_status != 80 THEN 1
  1008. ELSE 0
  1009. END
  1010. ) AS 'effDeliveryNum',
  1011. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  1012. round(
  1013. sum(
  1014. CASE
  1015. WHEN t2.send_status = 1
  1016. AND t2.order_status != 80 THEN 1
  1017. ELSE 0
  1018. END
  1019. ) / sum(
  1020. CASE
  1021. WHEN t2.send_status = 1 THEN 1
  1022. ELSE 0
  1023. END
  1024. ),
  1025. 4
  1026. ) AS 'deliveryRadio',
  1027. sum(
  1028. CASE
  1029. WHEN t2.order_status = 80 THEN 1
  1030. ELSE 0
  1031. END
  1032. ) AS 'invalidOrderNUm',
  1033. sum(
  1034. CASE
  1035. WHEN t2.order_status != 80 THEN t2.pay_amount
  1036. ELSE 0
  1037. END
  1038. ) AS 'payAmount',
  1039. t2.regimental_promotion_rate AS 'regimentalPromotionRate',
  1040. sum(
  1041. CASE
  1042. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  1043. ELSE 0
  1044. END
  1045. ) AS 'regimentalPromotionAmount',
  1046. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  1047. 'totalRegimentalSettleAmount',
  1048. t2.item_commission_rate as 'itemCommissionRate',
  1049. t3.ccr_value as 'ccrValue',
  1050. (case
  1051. when t3.ccr_value = '-' or t3.ccr_value is null
  1052. then 0
  1053. else replace(t3.ccr_value,'%','')
  1054. end
  1055. ) as 'ccrInt'
  1056. FROM
  1057. kuaishou_item_bind_user t1
  1058. LEFT JOIN
  1059. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  1060. left join kuaishou_item_ccr_info t3 on t1.item_id = t3.item_id
  1061. WHERE
  1062. 1 = 1
  1063. <if test="start != null and start != ''">
  1064. and t2.order_create_time &gt;= #{start}
  1065. </if>
  1066. <if test="end != null and end != ''">
  1067. and t2.order_create_time &lt;= #{end}
  1068. </if>
  1069. <if test="itemId != null and itemId != ''">
  1070. and t1.item_id = #{itemId}
  1071. </if>
  1072. <if test="itemTitle != null and itemTitle != ''">
  1073. and t2.item_title like concat(concat('%',#{itemTitle}),'%')
  1074. </if>
  1075. GROUP BY
  1076. t1.item_id
  1077. ) t
  1078. where 1 = 1
  1079. <if test="userId != null and userId != ''">
  1080. and t.user_id = #{userId}
  1081. </if>
  1082. order by ${fieId} ${sort}
  1083. </select>
  1084. <select id="getTimeIntervalRatio" resultType="com.alibaba.fastjson.JSONObject">
  1085. select
  1086. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio',
  1087. round((t1.orderAmount -t2.orderAmount) / t2.orderAmount , 4) as 'orderAmountRatio'
  1088. from (
  1089. select count(oid) as 'oid',
  1090. sum(order_amount) as 'orderAmount'
  1091. from kuaishou_supply_chain
  1092. where 1= 1
  1093. <if test="thisCycleStartTemp != null and thisCycleStartTemp != ''">
  1094. and order_create_time &gt;= #{thisCycleStartTemp}
  1095. </if>
  1096. <if test="thisCycleEndTemp != null and thisCycleEndTemp != ''">
  1097. and order_create_time &lt;= #{thisCycleEndTemp}
  1098. </if>
  1099. ) t1
  1100. join (
  1101. select count(oid) as 'oid',
  1102. sum(order_amount) as 'orderAmount'
  1103. from kuaishou_supply_chain
  1104. where 1=1
  1105. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  1106. and order_create_time &gt;= #{lastCycleStartTemp}
  1107. </if>
  1108. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  1109. and order_create_time &lt;= #{lastCycleEndTemp}
  1110. </if>
  1111. ) t2
  1112. </select>
  1113. <select id="indexStatistics" resultType="com.alibaba.fastjson.JSONObject">
  1114. select FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') as 'date',
  1115. <if test="type == 'orderNum' ">
  1116. count(t.oid) as 'orderNum'
  1117. </if>
  1118. <if test="type == 'validOrderNum' ">
  1119. sum(case when t.order_status = 80 then 1 else 0 end) as 'validOrderNum'
  1120. </if>
  1121. <if test="type == 'orderAmount' ">
  1122. sum(t.order_amount) as 'orderAmount'
  1123. </if>
  1124. <if test="type == 'baseAmount' ">
  1125. sum(t.base_amount) as 'baseAmount'
  1126. </if>
  1127. <if test="type == 'deliveryNum' ">
  1128. sum(case when t.send_status = 1 and t.order_status != 80 then 1 else 0 end) as 'deliveryNum'
  1129. </if>
  1130. from (select
  1131. oid,
  1132. order_status,
  1133. order_amount,
  1134. base_amount,
  1135. send_status,
  1136. order_create_time
  1137. from kuaishou_supply_chain
  1138. where 1 = 1
  1139. <if test="startTemp != null and startTemp != ''">
  1140. and order_create_time &gt;= #{startTemp}
  1141. </if>
  1142. <if test="endTemp != null and endTemp != ''">
  1143. and order_create_time &lt;= #{endTemp}
  1144. </if>
  1145. ) t
  1146. group by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d')
  1147. order by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') asc
  1148. </select>
  1149. <select id="itemBindSummary" resultType="com.alibaba.fastjson.JSONObject">
  1150. 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'
  1151. from kuaishou_item_info t1
  1152. left join kuaishou_item_bind_user t2
  1153. on t1.item_id = t2.item_id
  1154. where 1 = 1
  1155. </select>
  1156. <select id="userItemTotal" resultType="com.alibaba.fastjson.JSONObject">
  1157. SELECT count(t2.oid) AS 'orderNum',
  1158. sum(
  1159. CASE
  1160. WHEN t2.order_status != 80 THEN 1
  1161. ELSE 0
  1162. END
  1163. ) AS 'validOrderNUm',
  1164. round(
  1165. sum(
  1166. CASE
  1167. WHEN t2.order_status != 80 THEN 1
  1168. ELSE 0
  1169. END
  1170. ) / count(t2.oid),
  1171. 4
  1172. ) AS 'validRadio',
  1173. sum(
  1174. CASE
  1175. WHEN t2.send_status = 1
  1176. THEN 1
  1177. ELSE 0
  1178. END
  1179. ) AS 'deliveryNum',
  1180. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case when
  1181. t2.order_status != 80
  1182. then 1 else 0 end),4) as 'shippingGreen',
  1183. sum(
  1184. CASE
  1185. WHEN t2.send_status = 1
  1186. AND t2.order_status != 80 THEN 1
  1187. ELSE 0
  1188. END
  1189. ) AS 'effDeliveryNum',
  1190. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  1191. round(
  1192. sum(
  1193. CASE
  1194. WHEN t2.send_status = 1
  1195. AND t2.order_status != 80 THEN 1
  1196. ELSE 0
  1197. END
  1198. ) / sum(
  1199. CASE
  1200. WHEN t2.send_status != 80 THEN 1
  1201. ELSE 0
  1202. END
  1203. ),
  1204. 4
  1205. ) AS 'deliveryRadio',
  1206. sum(
  1207. CASE
  1208. WHEN t2.order_status = 80 THEN 1
  1209. ELSE 0
  1210. END
  1211. ) AS 'invalidOrderNUm',
  1212. sum(
  1213. CASE
  1214. WHEN t2.order_status != 80 THEN t2.pay_amount
  1215. ELSE 0
  1216. END
  1217. ) AS 'payAmount',
  1218. sum(
  1219. CASE
  1220. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  1221. ELSE 0
  1222. END
  1223. ) AS 'regimentalPromotionAmount',
  1224. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  1225. 'totalRegimentalSettleAmount'
  1226. FROM kuaishou_item_bind_user t1
  1227. LEFT JOIN
  1228. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  1229. WHERE 1 = 1
  1230. <if test="start != null and start != ''">
  1231. and t2.order_create_time &gt;= #{start}
  1232. </if>
  1233. <if test="end != null and end != ''">
  1234. and t2.order_create_time &lt;= #{end}
  1235. </if>
  1236. <if test="userId != null and userId != ''">
  1237. and t1.user_id = #{userId}
  1238. </if>
  1239. </select>
  1240. <select id="exportUserItemDetail" resultType="com.alibaba.fastjson.JSONObject">
  1241. SELECT
  1242. *
  1243. FROM
  1244. (
  1245. SELECT
  1246. t1.user_id as 'user_id',
  1247. t1.user_name AS 'userName',
  1248. t2.item_id AS 'itemId',
  1249. t2.item_title AS 'itemTitle',
  1250. t2.image_url AS 'imageUrl',
  1251. round(t2.reserve_price / 100,2) AS 'reservePrice',
  1252. count(t2.oid) AS 'orderNum',
  1253. sum(
  1254. CASE
  1255. WHEN t2.order_status != 80 THEN 1
  1256. ELSE 0
  1257. END
  1258. ) AS 'validOrderNUm',
  1259. round(
  1260. sum(
  1261. CASE
  1262. WHEN t2.order_status != 80 THEN 1
  1263. ELSE 0
  1264. END
  1265. ) / count(t2.oid) * 100,
  1266. 2
  1267. ) AS 'validRadio',
  1268. sum(
  1269. CASE
  1270. WHEN t2.send_status = 1
  1271. AND t2.order_status != 80 THEN 1
  1272. ELSE 0
  1273. END
  1274. ) AS 'deliveryNum',
  1275. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  1276. round(
  1277. sum(
  1278. CASE
  1279. WHEN t2.send_status = 1
  1280. AND t2.order_status != 80 THEN 1
  1281. ELSE 0
  1282. END
  1283. ) / sum(
  1284. CASE
  1285. WHEN t2.order_status != 80 THEN 1
  1286. ELSE 0
  1287. END
  1288. ) * 100,
  1289. 2
  1290. ) AS 'deliveryRadio',
  1291. sum(
  1292. CASE
  1293. WHEN t2.order_status = 80 THEN 1
  1294. ELSE 0
  1295. END
  1296. ) AS 'invalidOrderNUm',
  1297. round( sum(
  1298. CASE
  1299. WHEN t2.order_status != 80 THEN t2.pay_amount
  1300. ELSE 0
  1301. END
  1302. )/ 100,2 )AS 'payAmount',
  1303. concat(round(t2.regimental_promotion_rate / 10 ,2),'%') AS 'regimentalPromotionRate',
  1304. round(
  1305. sum(
  1306. CASE
  1307. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  1308. ELSE 0
  1309. END
  1310. ) / 100 , 2)AS 'regimentalPromotionAmount',
  1311. round(
  1312. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100,2) as
  1313. 'totalRegimentalSettleAmount',
  1314. concat(round(t2.item_commission_rate / 10),'%') as 'itemCommissionRate',
  1315. t3.ccr_value as 'ccrValue'
  1316. FROM
  1317. kuaishou_item_bind_user t1
  1318. LEFT JOIN
  1319. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  1320. left join kuaishou_item_ccr_info t3 on t1.item_id = t3.item_id
  1321. WHERE
  1322. 1 = 1
  1323. <if test="start != null and start != ''">
  1324. and t2.order_create_time &gt;= #{start}
  1325. </if>
  1326. <if test="end != null and end != ''">
  1327. and t2.order_create_time &lt;= #{end}
  1328. </if>
  1329. <if test="itemId != null and itemId != ''">
  1330. and t1.item_id = #{itemId}
  1331. </if>
  1332. <if test="itemTitle != null and itemTitle != ''">
  1333. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  1334. </if>
  1335. GROUP BY
  1336. t1.item_id
  1337. ) t
  1338. where 1 = 1
  1339. <if test="userId != null and userId != ''">
  1340. and t.user_id = #{userId}
  1341. </if>
  1342. order by t.orderNum desc
  1343. </select>
  1344. <select id="getCookie" resultType="java.lang.String">
  1345. select cookie
  1346. from kuaishou_supply_chain_cookie
  1347. where id = #{regId} limit 1
  1348. </select>
  1349. <select id="selectOrderInfo" resultType="com.alibaba.fastjson.JSONObject">
  1350. SELECT
  1351. COUNT(DISTINCT promoter_id) as 'promoterCount',
  1352. COUNT(DISTINCT item_id) as 'itemCount',
  1353. COUNT(oid) as 'allNumber',
  1354. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
  1355. IFNULL(SUM(order_amount), 0) AS 'orderAmount',
  1356. IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
  1357. 'regimentalPromotionAmount',
  1358. IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) as 'baseAmount'
  1359. FROM kuaishou_supply_chain
  1360. WHERE stat_date >= #{startDate}
  1361. AND stat_date &lt;= #{endDate}
  1362. <if test='promoterIds != null and promoterIds.size() > 0'>
  1363. AND promoter_id in
  1364. <foreach collection="promoterIds" item="item" separator=","
  1365. open="(" close=")">
  1366. #{item}
  1367. </foreach>
  1368. </if>
  1369. </select>
  1370. <select id="selectOrderInfoBytedance" resultType="com.alibaba.fastjson.JSONObject">
  1371. SELECT
  1372. COUNT(DISTINCT author_short_id) as 'promoterCount',
  1373. COUNT(DISTINCT product_id) as 'itemCount',
  1374. COUNT(order_id) as 'allNumber',
  1375. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
  1376. IFNULL(SUM(total_pay_amount), 0) AS 'orderAmount',
  1377. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END), 0) AS 'baseAmount',
  1378. IFNULL( sum(CASE
  1379. WHEN flow_point != 'REFUND' and colonel_type != 2
  1380. THEN colonel_estimated_commission
  1381. WHEN flow_point != 'REFUND' and colonel_type = 2
  1382. then second_estimated_commission
  1383. ELSE 0 END) * 0.9,0) AS
  1384. 'regimentalPromotionAmount',
  1385. IFNULL( sum(CASE
  1386. WHEN flow_point != 'REFUND' and colonel_type != 2
  1387. THEN second_estimated_commission
  1388. ELSE 0 END) ,0) AS 'secondEstimatedCommission'
  1389. FROM bytedance_order_list
  1390. WHERE pay_success_time >= #{startDate}
  1391. AND pay_success_time &lt;= #{endDate}
  1392. <if test='promoterIds != null and promoterIds.size() > 0'>
  1393. AND author_short_id in
  1394. <foreach collection="promoterIds" item="item" separator=","
  1395. open="(" close=")">
  1396. #{item}
  1397. </foreach>
  1398. </if>
  1399. </select>
  1400. <select id="selectOrderInfoByItemIds" resultType="com.alibaba.fastjson.JSONObject">
  1401. SELECT t.*,
  1402. CONCAT(IFNULL(ROUND(sendCount / allNumber * 100, 2),0), '%') as 'sendRate'
  1403. FROM (
  1404. SELECT
  1405. COUNT(DISTINCT promoter_id) as 'promoterCount',
  1406. COUNT(DISTINCT item_id) as 'itemCount',
  1407. COUNT(oid) as 'allNumber',
  1408. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
  1409. IFNULL(SUM(order_amount), 0) AS 'orderAmount',
  1410. IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
  1411. 'regimentalPromotionAmount',
  1412. IFNULL(sum(base_amount), 0) as 'baseAmount',
  1413. IFNULL(COUNT(CASE WHEN send_status = 1 THEN oid ELSE null END), 0) AS 'sendCount'
  1414. FROM kuaishou_supply_chain
  1415. WHERE stat_date >= #{startDate}
  1416. AND stat_date &lt;= #{endDate}
  1417. <if test='itemIds != null and itemIds.size() > 0'>
  1418. AND item_id in
  1419. <foreach collection="itemIds" item="item" separator=","
  1420. open="(" close=")">
  1421. #{item}
  1422. </foreach>
  1423. </if>
  1424. ) t
  1425. </select>
  1426. <select id="selectOrderInfoByItemIdsBytedance" resultType="com.alibaba.fastjson.JSONObject">
  1427. SELECT
  1428. COUNT(DISTINCT author_short_id) as 'promoterCount',
  1429. COUNT(DISTINCT product_id) as 'itemCount',
  1430. COUNT(order_id) as 'allNumber',
  1431. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
  1432. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END)/100, 0) AS 'orderAmount',
  1433. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9 /100,0) AS
  1434. 'regimentalPromotionAmount'
  1435. FROM bytedance_order_list
  1436. WHERE pay_success_time >= #{startDate}
  1437. AND pay_success_time &lt;= #{endDate}
  1438. <if test='itemIds != null and itemIds.size() > 0'>
  1439. AND product_id in
  1440. <foreach collection="itemIds" item="item" separator=","
  1441. open="(" close=")">
  1442. #{item}
  1443. </foreach>
  1444. </if>
  1445. </select>
  1446. <select id="selectOrderRate" resultType="com.alibaba.fastjson.JSONObject">
  1447. SELECT
  1448. count(oid) as 'allNumber',
  1449. IFNULL(sum(order_amount),0) AS 'orderAmount'
  1450. FROM kuaishou_supply_chain
  1451. WHERE order_create_time >= #{statDate}
  1452. AND order_create_time &lt;= #{endDate}
  1453. <if test='promoterIds != null and promoterIds.size() > 0'>
  1454. AND promoter_id in
  1455. <foreach collection="promoterIds" item="item" separator=","
  1456. open="(" close=")">
  1457. #{item}
  1458. </foreach>
  1459. </if>
  1460. <if test='itemIds != null and itemIds.size() > 0'>
  1461. AND item_id in
  1462. <foreach collection="itemIds" item="item" separator=","
  1463. open="(" close=")">
  1464. #{item}
  1465. </foreach>
  1466. </if>
  1467. </select>
  1468. <select id="selectOrderRateBytedance" resultType="com.alibaba.fastjson.JSONObject">
  1469. SELECT
  1470. count(order_id) as 'allNumber',
  1471. IFNULL(sum(
  1472. CASE
  1473. WHEN flow_point != 'REFUND' THEN total_pay_amount
  1474. ELSE 0
  1475. END
  1476. )/100,0) AS 'orderAmount'
  1477. FROM bytedance_order_list
  1478. WHERE pay_success_time >= #{statDate}
  1479. AND pay_success_time &lt;= #{endDate}
  1480. <if test='promoterIds != null and promoterIds.size() > 0'>
  1481. AND author_short_id in
  1482. <foreach collection="promoterIds" item="item" separator=","
  1483. open="(" close=")">
  1484. #{item}
  1485. </foreach>
  1486. </if>
  1487. <if test='itemIds != null and itemIds.size() > 0'>
  1488. AND product_id in
  1489. <foreach collection="itemIds" item="item" separator=","
  1490. open="(" close=")">
  1491. #{item}
  1492. </foreach>
  1493. </if>
  1494. </select>
  1495. <select id="getMonthOrderAmount" resultType="com.alibaba.fastjson.JSONObject">
  1496. SELECT
  1497. FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') as 'date',
  1498. count(1) AS 'orderCount',
  1499. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
  1500. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1501. IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) AS 'validOrderAmount',
  1502. IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
  1503. 'regimentalPromotionAmount',
  1504. COUNT(DISTINCT promoter_id) as 'promoterCount'
  1505. FROM kuaishou_supply_chain t1
  1506. WHERE order_create_time >= #{startLong}
  1507. AND order_create_time &lt;= #{endLong}
  1508. <if test='promoterIds != null and promoterIds.size() > 0'>
  1509. AND promoter_id in
  1510. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1511. #{item}
  1512. </foreach>
  1513. </if>
  1514. GROUP BY FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d')
  1515. </select>
  1516. <select id="getMonthOrderAmountBytedance" resultType="com.alibaba.fastjson.JSONObject">
  1517. SELECT
  1518. DATE_FORMAT(pay_success_time, '%Y-%m-%d') as 'date',
  1519. count(1) AS 'orderCount',
  1520. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
  1521. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END),0) AS 'orderAmount',
  1522. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9 ,0) AS
  1523. 'regimentalPromotionAmount',
  1524. COUNT(DISTINCT author_short_id) as 'promoterCount'
  1525. FROM bytedance_order_list
  1526. WHERE pay_success_time >= #{startLong}
  1527. AND pay_success_time &lt;= #{endLong}
  1528. <if test='promoterIds != null and promoterIds.size() > 0'>
  1529. AND author_short_id in
  1530. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1531. #{item}
  1532. </foreach>
  1533. </if>
  1534. GROUP BY pay_success_time
  1535. </select>
  1536. <select id="getMonthOrderAmountByItems" resultType="com.alibaba.fastjson.JSONObject">
  1537. SELECT
  1538. FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') as 'date',
  1539. count(1) AS 'orderCount',
  1540. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
  1541. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1542. IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) AS 'validOrderAmount',
  1543. IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
  1544. 'regimentalPromotionAmount'
  1545. FROM kuaishou_supply_chain
  1546. WHERE order_create_time >= #{startLong}
  1547. AND order_create_time &lt;= #{endLong}
  1548. <if test='itemIds != null and itemIds.size() > 0'>
  1549. AND item_id in
  1550. <foreach collection="itemIds" item="item" separator=","
  1551. open="(" close=")">
  1552. #{item}
  1553. </foreach>
  1554. </if>
  1555. GROUP BY FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d')
  1556. </select>
  1557. <select id="getMonthOrderAmountByItemsBytedance" resultType="com.alibaba.fastjson.JSONObject">
  1558. SELECT
  1559. DATE_FORMAT(pay_success_time, '%Y-%m-%d') as 'date',
  1560. count(1) AS 'orderCount',
  1561. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
  1562. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN total_pay_amount ELSE 0 END),0) AS 'orderAmount',
  1563. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
  1564. 'regimentalPromotionAmount'
  1565. FROM bytedance_order_list
  1566. WHERE pay_success_time >= #{startLong}
  1567. AND pay_success_time &lt;= #{endLong}
  1568. <if test='itemIds != null and itemIds.size() > 0'>
  1569. AND product_id in
  1570. <foreach collection="itemIds" item="item" separator=","
  1571. open="(" close=")">
  1572. #{item}
  1573. </foreach>
  1574. </if>
  1575. GROUP BY pay_success_time
  1576. </select>
  1577. <select id="getMonthOrderAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  1578. SELECT
  1579. t1.orderAmount,
  1580. t1.regimentalPromotionAmount,
  1581. CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
  1582. CONCAT(IFNULL(ROUND(t2.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
  1583. 'regimentalPromotionAmountRate'
  1584. FROM
  1585. (
  1586. SELECT
  1587. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1588. IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount'
  1589. FROM kuaishou_supply_chain t1
  1590. WHERE order_status != 80
  1591. <if test='promoterIds != null and promoterIds.size() > 0'>
  1592. AND promoter_id in
  1593. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1594. #{item}
  1595. </foreach>
  1596. </if>
  1597. AND order_create_time >= #{startLong}
  1598. AND order_create_time &lt;= #{endLong}) t1
  1599. LEFT JOIN
  1600. (
  1601. SELECT
  1602. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1603. IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount'
  1604. FROM kuaishou_supply_chain t1
  1605. WHERE order_status != 80
  1606. <if test='promoterIds != null and promoterIds.size() > 0'>
  1607. AND promoter_id in
  1608. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1609. #{item}
  1610. </foreach>
  1611. </if>
  1612. AND order_create_time >= #{toStartLong}
  1613. AND order_create_time &lt;= #{endLong})t2 ON 1=1
  1614. </select>
  1615. <select id="getMonthOrderAmountTotalBytedance" resultType="com.alibaba.fastjson.JSONObject">
  1616. SELECT
  1617. t1.orderAmount,
  1618. t1.regimentalPromotionAmount,
  1619. CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
  1620. CONCAT(IFNULL(ROUND(t2.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
  1621. 'regimentalPromotionAmountRate'
  1622. FROM
  1623. (
  1624. SELECT
  1625. IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
  1626. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
  1627. 'regimentalPromotionAmount'
  1628. FROM bytedance_order_list t1
  1629. WHERE flow_point != 'REFUND'
  1630. <if test='promoterIds != null and promoterIds.size() > 0'>
  1631. AND author_short_id in
  1632. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1633. #{item}
  1634. </foreach>
  1635. </if>
  1636. AND pay_success_time >= #{startLong}
  1637. AND pay_success_time &lt;= #{endLong}) t1
  1638. LEFT JOIN
  1639. (
  1640. SELECT
  1641. IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
  1642. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
  1643. 'regimentalPromotionAmount'
  1644. FROM bytedance_order_list t1
  1645. WHERE flow_point != 'REFUND'
  1646. <if test='promoterIds != null and promoterIds.size() > 0'>
  1647. AND author_short_id in
  1648. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1649. #{item}
  1650. </foreach>
  1651. </if>
  1652. AND pay_success_time >= #{toStartLong}
  1653. AND pay_success_time &lt;= #{endLong})t2 ON 1=1
  1654. </select>
  1655. <select id="getMonthOrderAmountTotalByItems" resultType="com.alibaba.fastjson.JSONObject">
  1656. SELECT
  1657. t1.orderAmount,
  1658. t1.regimentalPromotionAmount,
  1659. t1.orderCount,
  1660. CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
  1661. CONCAT(IFNULL(ROUND(t2.orderCount/t1.orderCount*100,2),0),'%') as 'orderCountRate',
  1662. CONCAT(IFNULL(ROUND(t2.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
  1663. 'regimentalPromotionAmountRate'
  1664. FROM
  1665. (
  1666. SELECT
  1667. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1668. IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount',
  1669. COUNT(oid) as 'orderCount'
  1670. FROM kuaishou_supply_chain t1
  1671. WHERE order_status != 80
  1672. <if test='itemIds != null and itemIds.size() > 0'>
  1673. AND item_id in
  1674. <foreach collection="itemIds" item="item" separator=","
  1675. open="(" close=")">
  1676. #{item}
  1677. </foreach>
  1678. </if>
  1679. AND order_create_time >= #{startLong}
  1680. AND order_create_time &lt;= #{endLong}
  1681. )t1
  1682. LEFT JOIN
  1683. (
  1684. SELECT
  1685. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1686. IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount',
  1687. COUNT(oid) as 'orderCount'
  1688. FROM kuaishou_supply_chain t1
  1689. WHERE order_status != 80
  1690. <if test='itemIds != null and itemIds.size() > 0'>
  1691. AND item_id in
  1692. <foreach collection="itemIds" item="item" separator=","
  1693. open="(" close=")">
  1694. #{item}
  1695. </foreach>
  1696. </if>
  1697. AND order_create_time >= #{toStartLong}
  1698. AND order_create_time &lt;= #{endLong}
  1699. )t2 ON 1=1
  1700. </select>
  1701. <select id="getMonthOrderAmountTotalByItemsBytedance" resultType="com.alibaba.fastjson.JSONObject">
  1702. SELECT
  1703. t1.orderAmount,
  1704. t1.regimentalPromotionAmount,
  1705. t1.orderCount,
  1706. CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
  1707. CONCAT(IFNULL(ROUND(t2.orderCount/t1.orderCount*100,2),0),'%') as 'orderCountRate',
  1708. CONCAT(IFNULL(ROUND(t2.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
  1709. 'regimentalPromotionAmountRate'
  1710. FROM
  1711. (
  1712. SELECT
  1713. IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
  1714. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
  1715. 'regimentalPromotionAmount',
  1716. COUNT(order_id) as 'orderCount'
  1717. FROM bytedance_order_list t1
  1718. WHERE flow_point != 'REFUND'
  1719. <if test='itemIds != null and itemIds.size() > 0'>
  1720. AND product_id in
  1721. <foreach collection="itemIds" item="item" separator=","
  1722. open="(" close=")">
  1723. #{item}
  1724. </foreach>
  1725. </if>
  1726. AND pay_success_time >= #{IntStart}
  1727. AND pay_success_time &lt;= #{IntEnd}
  1728. )t1
  1729. LEFT JOIN
  1730. (
  1731. SELECT
  1732. IFNULL(SUM(total_pay_amount),0) AS 'orderAmount',
  1733. IFNULL(SUM(CASE WHEN flow_point != 'REFUND' THEN colonel_estimated_commission ELSE 0 END) * 0.9,0) AS
  1734. 'regimentalPromotionAmount',
  1735. COUNT(order_id) as 'orderCount'
  1736. FROM bytedance_order_list t1
  1737. WHERE flow_point != 'REFUND'
  1738. <if test='itemIds != null and itemIds.size() > 0'>
  1739. AND product_id in
  1740. <foreach collection="itemIds" item="item" separator=","
  1741. open="(" close=")">
  1742. #{item}
  1743. </foreach>
  1744. </if>
  1745. AND pay_success_time >= #{IntStart}
  1746. AND pay_success_time &lt;= #{IntEnd}
  1747. )t2 ON 1=1
  1748. </select>
  1749. <select id="bdReportList" resultType="com.alibaba.fastjson.JSONObject">
  1750. select
  1751. t1.collectSampleId,
  1752. t1.collectSampleName,
  1753. t2.promoterCount,
  1754. t3.sampleCount,
  1755. round(t3.sampleCount / t2.promoterCount * 100, 2) as 'sampleRate',
  1756. t2.promoterCount - t3.sampleCount as 'notSampleCount',
  1757. t1.orderNum,
  1758. t1.validOrderNum,
  1759. t1.validOrderRate,
  1760. t1.orderAmount,
  1761. t1.regimentalPromotionAmount,
  1762. t1.totalRegimentalSettleAmount,
  1763. t4.sendTotalCount,
  1764. t4.sendPromoterCount,
  1765. t4.sendItemCount,
  1766. t1.voucherOrderNum,
  1767. t1.voucherValidOrderNum,
  1768. t1.voucherOrderAmount,
  1769. t1.voucherRegimentalPromotionAmount,
  1770. t1.voucherTotalRegimentalSettleAmount,
  1771. IFNULL(t5.promoters_count,'-') as 'promotersCount'
  1772. from (
  1773. select collect_sample_id as 'collectSampleId',
  1774. collect_sample_name as 'collectSampleName',
  1775. sum(order_num) as 'orderNum',
  1776. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_num ELSE 0 END), 0) AS 'voucherOrderNum',
  1777. sum(valid_order_num) as 'validOrderNum',
  1778. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN valid_order_num ELSE 0 END), 0) AS 'voucherValidOrderNum',
  1779. round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
  1780. sum(order_amount) as 'orderAmount',
  1781. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_amount ELSE 0 END), 0) AS 'voucherOrderAmount',
  1782. sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
  1783. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN regimental_promotion_amount ELSE 0 END), 0)
  1784. AS'voucherRegimentalPromotionAmount',
  1785. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount',
  1786. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN total_regimental_settle_amount ELSE 0 END), 0) AS
  1787. 'voucherTotalRegimentalSettleAmount'
  1788. from promoter_item_order_count
  1789. where 1 = 1
  1790. <if test="start != null and start != ''">
  1791. and stat_date &gt;= #{start}
  1792. </if>
  1793. <if test="end != null and end != ''">
  1794. and stat_date &lt;= #{end}
  1795. </if>
  1796. <if test="collectSampleId != null and collectSampleId != ''">
  1797. and collect_sample_id = #{collectSampleId}
  1798. </if>
  1799. group by collect_sample_id) t1
  1800. left join (
  1801. select user_id as 'userId',
  1802. count(distinct promoter_id) as 'promoterCount'
  1803. from kuaishou_promoter
  1804. group by user_id) t2
  1805. on t1.collectSampleId = t2.userId
  1806. left join (
  1807. select collect_sample_id as 'collectSampleId',
  1808. count(distinct promoter_id) as 'sampleCount'
  1809. from kuaishou_item_collect_samples
  1810. where collect_sample_status > 2
  1811. group by collect_sample_id) t3
  1812. on t2.userId = t3.collectSampleId
  1813. left join (
  1814. select collect_sample_id as 'collectSampleId',
  1815. count(1) as 'sendTotalCount',
  1816. count(distinct promoter_id) as 'sendPromoterCount',
  1817. count(distinct item_id) as 'sendItemCount'
  1818. from kuaishou_item_collect_samples
  1819. where collect_sample_status > 2
  1820. <if test="collectSampleId != null and collectSampleId != ''">
  1821. and collect_sample_id = #{collectSampleId}
  1822. </if>
  1823. <if test="start != null and start != ''">
  1824. and create_time &gt;= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
  1825. %H:%i:%s')
  1826. </if>
  1827. <if test="end != null and end != ''">
  1828. and create_time &lt;= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
  1829. </if>
  1830. group by collect_sample_id
  1831. ) t4
  1832. on t1.collectSampleId = t4.collectSampleId
  1833. left join (
  1834. select user_id,promoters_count
  1835. from user_promoters_count
  1836. where media_id = 2
  1837. ) t5
  1838. on t1.collectSampleId = t5.user_id
  1839. order by t1.orderNum desc
  1840. </select>
  1841. <select id="bdDetailList" resultType="com.alibaba.fastjson.JSONObject">
  1842. select
  1843. t1.promoterId,
  1844. t1.promoterName,
  1845. t1.promoterUrl,
  1846. t2.sampleCount,
  1847. t1.orderNum,
  1848. t1.validOrderNum,
  1849. t1.validOrderRate,
  1850. t1.orderAmount,
  1851. t1.regimentalPromotionAmount,
  1852. t1.totalRegimentalSettleAmount
  1853. from (
  1854. select promoter_id as 'promoterId',
  1855. promoter_name as 'promoterName',
  1856. promoter_url as 'promoterUrl',
  1857. sum(order_num) as 'orderNum',
  1858. sum(valid_order_num) as 'validOrderNum',
  1859. round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
  1860. sum(order_amount) as 'orderAmount',
  1861. sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
  1862. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
  1863. from promoter_item_order_count
  1864. where 1 = 1
  1865. <if test="start != null and start != ''">
  1866. and stat_date &gt;= #{start}
  1867. </if>
  1868. <if test="end != null and end != ''">
  1869. and stat_date &lt;= #{end}
  1870. </if>
  1871. <if test="collectSampleId != null and collectSampleId != ''">
  1872. and collect_sample_id = #{collectSampleId}
  1873. </if>
  1874. group by promoter_id) t1
  1875. left join (
  1876. select promoter_id as 'promoterId',
  1877. count(distinct item_id) as 'sampleCount'
  1878. from kuaishou_item_collect_samples
  1879. where collect_sample_status > 2
  1880. <if test="collectSampleId != null and collectSampleId != ''">
  1881. and collect_sample_id = #{collectSampleId}
  1882. </if>
  1883. group by promoter_id) t2
  1884. on t1.promoterId = t2.promoterId
  1885. order by ${fieId} ${sort}
  1886. </select>
  1887. <select id="bdTotal" resultType="com.alibaba.fastjson.JSONObject">
  1888. select
  1889. t2.sampleCount,
  1890. t1.orderNum,
  1891. t1.validOrderNum,
  1892. t1.validOrderRate,
  1893. t1.orderAmount,
  1894. t1.regimentalPromotionAmount,
  1895. t1.totalRegimentalSettleAmount
  1896. from (
  1897. select
  1898. sum(order_num) as 'orderNum',
  1899. sum(valid_order_num) as 'validOrderNum',
  1900. round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
  1901. sum(order_amount) as 'orderAmount',
  1902. sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
  1903. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
  1904. from promoter_item_order_count
  1905. where 1 = 1
  1906. <if test="start != null and start != ''">
  1907. and stat_date &gt;= #{start}
  1908. </if>
  1909. <if test="end != null and end != ''">
  1910. and stat_date &lt;= #{end}
  1911. </if>
  1912. <if test="collectSampleId != null and collectSampleId != ''">
  1913. and collect_sample_id = #{collectSampleId}
  1914. </if>
  1915. ) t1
  1916. join (
  1917. select
  1918. count(distinct item_id) as 'sampleCount'
  1919. from kuaishou_item_collect_samples
  1920. where collect_sample_status > 2
  1921. <if test="collectSampleId != null and collectSampleId != ''">
  1922. and collect_sample_id = #{collectSampleId}
  1923. </if>
  1924. ) t2
  1925. </select>
  1926. <select id="exportBdDetail" resultType="com.alibaba.fastjson.JSONObject">
  1927. select
  1928. t1.promoterId,
  1929. t1.promoterName,
  1930. t1.promoterUrl,
  1931. t2.sampleCount,
  1932. t1.orderNum,
  1933. t1.validOrderNum,
  1934. t1.validOrderRate,
  1935. t1.orderAmount,
  1936. t1.regimentalPromotionAmount,
  1937. t1.totalRegimentalSettleAmount
  1938. from (
  1939. select promoter_id as 'promoterId',
  1940. promoter_name as 'promoterName',
  1941. promoter_url as 'promoterUrl',
  1942. sum(order_num) as 'orderNum',
  1943. sum(valid_order_num) as 'validOrderNum',
  1944. round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
  1945. sum(order_amount) as 'orderAmount',
  1946. sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
  1947. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
  1948. from promoter_item_order_count
  1949. where 1 = 1
  1950. <if test="start != null and start != ''">
  1951. and stat_date &gt;= #{start}
  1952. </if>
  1953. <if test="end != null and end != ''">
  1954. and stat_date &lt;= #{end}
  1955. </if>
  1956. <if test="collectSampleId != null and collectSampleId != ''">
  1957. and collect_sample_id = #{collectSampleId}
  1958. </if>
  1959. group by promoter_id) t1
  1960. left join (
  1961. select promoter_id as 'promoterId',
  1962. count(distinct item_id) as 'sampleCount'
  1963. from kuaishou_item_collect_samples
  1964. where collect_sample_status > 2
  1965. <if test="collectSampleId != null and collectSampleId != ''">
  1966. and collect_sample_id = #{collectSampleId}
  1967. </if>
  1968. group by promoter_id) t2
  1969. on t1.promoterId = t2.promoterId
  1970. order by t1.orderNum desc
  1971. </select>
  1972. <select id="getUserList" resultType="com.alibaba.fastjson.JSONObject">
  1973. select promoter_id as 'promoterId', group_concat(user_name) as 'userName'
  1974. from kuaishou_promoter where promoter_id in
  1975. <foreach collection="map.values" item="v" separator="," open="(" close=")">
  1976. ${v}
  1977. </foreach>
  1978. GROUP BY promoter_id
  1979. </select>
  1980. <select id="getUserName" resultType="java.lang.String" parameterType="java.lang.Long">
  1981. select group_concat(user_name) as 'userName'
  1982. from kuaishou_promoter
  1983. where promoter_id = #{promoterId}
  1984. </select>
  1985. <select id="exportBdReportList" resultType="com.alibaba.fastjson.JSONObject">
  1986. select
  1987. t1.collectSampleId,
  1988. t1.collectSampleName,
  1989. t2.promoterCount,
  1990. t3.sampleCount,
  1991. round(t3.sampleCount / t2.promoterCount * 100, 2) as 'sampleRate',
  1992. t2.promoterCount - t3.sampleCount as 'notSampleCount',
  1993. t1.orderNum,
  1994. t1.validOrderNum,
  1995. t1.validOrderRate,
  1996. round(t1.orderAmount / 100,2) as 'orderAmount',
  1997. round(t1.regimentalPromotionAmount / 100 ,2 ) as 'regimentalPromotionAmount',
  1998. round(t1.totalRegimentalSettleAmount / 100 , 2) as 'totalRegimentalSettleAmount',
  1999. t4.sendTotalCount,
  2000. t4.sendPromoterCount,
  2001. t4.sendItemCount,
  2002. t1.voucherOrderNum,
  2003. t1.voucherValidOrderNum,
  2004. round(t1.voucherOrderAmount / 100 ,2) as 'voucherOrderAmount',
  2005. round(t1.voucherRegimentalPromotionAmount / 100 ,2) as 'voucherRegimentalPromotionAmount',
  2006. round( t1.voucherTotalRegimentalSettleAmount / 100 , 2) as 'voucherTotalRegimentalSettleAmount'
  2007. from (
  2008. select collect_sample_id as 'collectSampleId',
  2009. collect_sample_name as 'collectSampleName',
  2010. sum(order_num) as 'orderNum',
  2011. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_num ELSE 0 END), 0) AS 'voucherOrderNum',
  2012. sum(valid_order_num) as 'validOrderNum',
  2013. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN valid_order_num ELSE 0 END), 0) AS 'voucherValidOrderNum',
  2014. round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
  2015. sum(order_amount) as 'orderAmount',
  2016. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_amount ELSE 0 END), 0) AS 'voucherOrderAmount',
  2017. sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
  2018. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN regimental_promotion_amount ELSE 0 END), 0)
  2019. AS'voucherRegimentalPromotionAmount',
  2020. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount',
  2021. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN total_regimental_settle_amount ELSE 0 END), 0) AS
  2022. 'voucherTotalRegimentalSettleAmount'
  2023. from promoter_item_order_count
  2024. where 1 = 1
  2025. <if test="start != null and start != ''">
  2026. and stat_date &gt;= #{start}
  2027. </if>
  2028. <if test="end != null and end != ''">
  2029. and stat_date &lt;= #{end}
  2030. </if>
  2031. <if test="collectSampleId != null and collectSampleId != ''">
  2032. and collect_sample_id = #{collectSampleId}
  2033. </if>
  2034. group by collect_sample_id) t1
  2035. left join (
  2036. select user_id as 'userId',
  2037. count(distinct promoter_id) as 'promoterCount'
  2038. from kuaishou_promoter
  2039. group by user_id) t2
  2040. on t1.collectSampleId = t2.userId
  2041. left join (
  2042. select collect_sample_id as 'collectSampleId',
  2043. count(distinct promoter_id) as 'sampleCount'
  2044. from kuaishou_item_collect_samples
  2045. where collect_sample_status > 2
  2046. group by collect_sample_id) t3
  2047. on t2.userId = t3.collectSampleId
  2048. left join (
  2049. select collect_sample_id as 'collectSampleId',
  2050. count(1) as 'sendTotalCount',
  2051. count(distinct promoter_id) as 'sendPromoterCount',
  2052. count(distinct item_id) as 'sendItemCount'
  2053. from kuaishou_item_collect_samples
  2054. where collect_sample_status > 2
  2055. <if test="collectSampleId != null and collectSampleId != ''">
  2056. and collect_sample_id = #{collectSampleId}
  2057. </if>
  2058. <if test="start != null and start != ''">
  2059. and create_time &gt;= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
  2060. %H:%i:%s')
  2061. </if>
  2062. <if test="end != null and end != ''">
  2063. and create_time &lt;= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
  2064. </if>
  2065. group by collect_sample_id
  2066. ) t4
  2067. on t1.collectSampleId = t4.collectSampleId
  2068. order by t1.orderNum desc
  2069. </select>
  2070. <select id="exportAdminReportList" resultType="com.alibaba.fastjson.JSONObject">
  2071. select *
  2072. from (select t1.user_id as 'userId',
  2073. t1.user_name as 'userName',
  2074. count(distinct t2.item_id) as 'itemCount',
  2075. count(t2.oid) as 'orderNum',
  2076. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  2077. round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100,2) as 'validRadio',
  2078. sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  2079. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  2080. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
  2081. when t2.order_status != 80
  2082. then 1
  2083. else 0 end) * 100,
  2084. 2) as 'deliveryRadio',
  2085. sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  2086. round(sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) / 100 , 2) as 'payAmount',
  2087. round(sum(case
  2088. when t2.order_status != 80 then t2.regimental_promotion_amount
  2089. else 0 end) / 100, 2 )as 'regimentalPromotionAmount',
  2090. round(sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100 , 2) as
  2091. 'totalRegimentalSettleAmount',
  2092. round( sum(case
  2093. when t2.order_status != 80 then t2.regimental_promotion_amount
  2094. else 0 end) / sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) * 100 ,2) as 'avgServiceRate'
  2095. from kuaishou_item_bind_user t1
  2096. left join kuaishou_supply_chain t2
  2097. on t1.item_id = t2.item_id
  2098. where 1= 1
  2099. <if test="start != null and start != ''">
  2100. and t2.order_create_time &gt;= #{start}
  2101. </if>
  2102. <if test="end != null and end != ''">
  2103. and t2.order_create_time &lt;= #{end}
  2104. </if>
  2105. group by t1.user_id) t left join (
  2106. select item_create_id,count(1) as 'sendSampleCount' from kuaishou_item_collect_samples
  2107. where courier_number_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  2108. and courier_number_time &lt;= from_unixtime(#{end}/1000,'%Y-%m-%d %H:%i:%s')
  2109. group by item_create_id
  2110. ) t1 on t.userId = t1.item_create_id
  2111. where 1 =1
  2112. <if test="userId != null and userId != ''">
  2113. and t.userId = #{userId}
  2114. </if>
  2115. order by t.orderNum desc
  2116. </select>
  2117. <select id="getSupplyChainCourtshipUserList" resultType="com.alibaba.fastjson.JSONObject">
  2118. select t3.user_id as 'userId', t3.nick_name as 'nickMame', t1.role_name as 'roleName', t3.status
  2119. from sys_role t1
  2120. left join sys_user_role t2 on t1.role_id = t2.role_id
  2121. left join sys_user t3 on t2.user_id = t3.user_id
  2122. where t1.role_key in (
  2123. 'courtship',
  2124. 'courtshipManager'
  2125. )
  2126. and t3.status = 0
  2127. group by t3.user_id
  2128. order by t3.create_time asc
  2129. </select>
  2130. <select id="adminReportListByBind" resultType="com.alibaba.fastjson.JSONObject">
  2131. select * from (
  2132. select t1.user_id as 'userId',
  2133. t1.user_name as 'userName',
  2134. count(distinct t1.item_id) as 'itemCount',
  2135. count(t2.oid) as 'orderNum',
  2136. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  2137. round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid), 4) as 'validRadio',
  2138. sum(case when t2.send_status = 1 then 1 else 0 end) as 'deliveryNum',
  2139. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  2140. then 1 else 0 end),4) as 'shippingGreen',
  2141. sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  2142. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  2143. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
  2144. when t2.send_status = 1
  2145. then 1
  2146. else 0 end),
  2147. 4) as 'deliveryRadio',
  2148. sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  2149. sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) as 'payAmount',
  2150. sum(case
  2151. when t2.order_status != 80 then t2.regimental_promotion_amount
  2152. else 0 end) as 'regimentalPromotionAmount',
  2153. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  2154. 'totalRegimentalSettleAmount',
  2155. round( sum(case
  2156. when t2.order_status != 80 then t2.regimental_promotion_amount
  2157. else 0 end) / sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) ,5) as 'avgServiceRate'
  2158. from kuaishou_item_list t1
  2159. left join (select item_id,
  2160. oid,
  2161. order_status,
  2162. send_status,
  2163. pay_amount,
  2164. regimental_promotion_amount,
  2165. total_regimental_settle_amount
  2166. from kuaishou_supply_chain
  2167. where order_create_time &gt;= #{start}) t2
  2168. on t1.item_id = t2.item_id
  2169. where t1.create_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  2170. and t1.create_time &lt;= from_unixtime(#{end}/1000,'%Y-%m-%d %H:%i:%s')
  2171. <if test="userId != null and userId != ''">
  2172. and t1.userId = #{userId}
  2173. </if>
  2174. group by t1.user_id ) t left join (
  2175. select t1.user_id,count(distinct courier_number) as 'sendSampleCount' from kuaishou_item_list t1 left join
  2176. kuaishou_item_collect_samples t2
  2177. on t1.item_id = t2.item_id
  2178. where t1.create_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  2179. and t1.create_time &lt;= from_unixtime(#{end}/1000,'%Y-%m-%d %H:%i:%s')
  2180. and t2.courier_number_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  2181. group by t1.user_id
  2182. ) t2 on t.userId = t2.user_id order by t.orderNum desc
  2183. </select>
  2184. <select id="exportAdminReportListByBind" resultType="com.alibaba.fastjson.JSONObject">
  2185. select * from (
  2186. select t1.user_id as 'userId',
  2187. t1.user_name as 'userName',
  2188. count(distinct t1.item_id) as 'itemCount',
  2189. count(t2.oid) as 'orderNum',
  2190. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  2191. round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100,2) as 'validRadio',
  2192. sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  2193. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  2194. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
  2195. when t2.order_status != 80
  2196. then 1
  2197. else 0 end) * 100,
  2198. 2) as 'deliveryRadio',
  2199. sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  2200. round(sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) / 100 , 2) as 'payAmount',
  2201. round(sum(case
  2202. when t2.order_status != 80 then t2.regimental_promotion_amount
  2203. else 0 end) / 100, 2 )as 'regimentalPromotionAmount',
  2204. round(sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100 , 2) as
  2205. 'totalRegimentalSettleAmount',
  2206. round( sum(case
  2207. when t2.order_status != 80 then t2.regimental_promotion_amount
  2208. else 0 end) / sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) * 100 ,2) as 'avgServiceRate'
  2209. from kuaishou_item_list t1
  2210. left join (select item_id,
  2211. oid,
  2212. order_status,
  2213. send_status,
  2214. pay_amount,
  2215. regimental_promotion_amount,
  2216. total_regimental_settle_amount
  2217. from kuaishou_supply_chain
  2218. where order_create_time &gt;= #{start}) t2
  2219. on t1.item_id = t2.item_id
  2220. where t1.create_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  2221. and t1.create_time &lt;= from_unixtime(#{end}/1000,'%Y-%m-%d %H:%i:%s')
  2222. <if test="userId != null and userId != ''">
  2223. and t1.userId = #{userId}
  2224. </if>
  2225. group by t1.user_id ) t left join (
  2226. select t1.user_id,count(distinct courier_number) as 'sendSampleCount' from kuaishou_item_list t1 left join
  2227. kuaishou_item_collect_samples t2
  2228. on t1.item_id = t2.item_id
  2229. where t1.create_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  2230. and t1.create_time &lt;= from_unixtime(#{end}/1000,'%Y-%m-%d %H:%i:%s')
  2231. and t2.courier_number_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  2232. group by t1.user_id
  2233. ) t2 on t.userId = t2.user_id order by t.orderNum desc;
  2234. </select>
  2235. <select id="bdReportListV2" resultType="com.alibaba.fastjson.JSONObject">
  2236. select t.*,
  2237. tt.promoterCount,
  2238. ttt.sampleCount,
  2239. tttt.sendTotalCount,
  2240. tttt.sendPromoterCount,
  2241. tttt.sendItemCount,
  2242. IFNULL( ttttt.promoters_count,'-') as 'promotersCount',
  2243. concat(round(ttt.sampleCount / tt.promoterCount * 100, 2), '%') as 'sampleRate',
  2244. tt.promoterCount - ttt.sampleCount as 'notSampleCount'
  2245. from (
  2246. select t1.user_id as 'collectSampleId',
  2247. t1.user_name as 'collectSampleName',
  2248. sum(t2.order_num) as 'orderNum',
  2249. sum(t2.valid_order_num) as 'validOrderNum',
  2250. concat(round(sum(t2.valid_order_num) / sum(t2.order_num) * 100, 2), '%') as 'validOrderRate',
  2251. round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
  2252. round(sum(t2.regimental_promotion_amount) / 100, 2) as 'regimentalPromotionAmount',
  2253. round(sum(t2.total_regimental_settle_amount) / 100, 2) as 'totalRegimentalSettleAmount'
  2254. from promoter_bind_channel_date t1
  2255. left join promoter_item_order_count t2
  2256. on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
  2257. where 1 = 1
  2258. and t1.media_id = 2
  2259. <if test="start != null and start != ''">
  2260. and t1.stat_date &gt;= #{start}
  2261. </if>
  2262. <if test="end != null and end != ''">
  2263. and t1.stat_date &lt;= #{end}
  2264. </if>
  2265. <if test="collectSampleId != null and collectSampleId != ''">
  2266. and t1.user_id = #{collectSampleId}
  2267. </if>
  2268. group by t1.user_id) t
  2269. left join (select user_id,
  2270. count(distinct promoter_id) as 'promoterCount'
  2271. from kuaishou_promoter
  2272. group by user_id) tt on t.collectSampleId = tt.user_id
  2273. left join (select collect_sample_id as 'user_id',
  2274. count(distinct promoter_id) as 'sampleCount'
  2275. from kuaishou_item_collect_samples
  2276. where collect_sample_status > 2
  2277. group by collect_sample_id) ttt on t.collectSampleId = ttt.user_id
  2278. left join (select collect_sample_id as 'user_id',
  2279. count(1) as 'sendTotalCount',
  2280. count(distinct promoter_id) as 'sendPromoterCount',
  2281. count(distinct item_id) as 'sendItemCount'
  2282. from kuaishou_item_collect_samples
  2283. where collect_sample_status > 2
  2284. <if test="collectSampleId != null and collectSampleId != ''">
  2285. and collect_sample_id = #{collectSampleId}
  2286. </if>
  2287. <if test="start != null and start != ''">
  2288. and create_time &gt;= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
  2289. %H:%i:%s')
  2290. </if>
  2291. <if test="end != null and end != ''">
  2292. and create_time &lt;= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
  2293. </if>
  2294. group by collect_sample_id) tttt on t.collectSampleId = tttt.user_id
  2295. left join (select user_id, promoters_count
  2296. from user_promoters_count
  2297. where media_id = 2) ttttt
  2298. on t.collectSampleId = ttttt.user_id
  2299. where t.orderNum > 0
  2300. order by t.orderNum desc
  2301. </select>
  2302. <select id="bdTotalV2" resultType="com.alibaba.fastjson.JSONObject">
  2303. select t.*,tt.sampleCount
  2304. from (select t1.user_id as 'collectSampleId',
  2305. t1.user_name as 'collectSampleName',
  2306. sum(t2.order_num) as 'orderNum',
  2307. sum(t2.valid_order_num) as 'validOrderNum',
  2308. concat(round(sum(t2.valid_order_num) / sum(t2.order_num) * 100, 2), '%') as 'validOrderRate',
  2309. round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
  2310. round(sum(t2.regimental_promotion_amount) / 100, 2) as 'regimentalPromotionAmount',
  2311. round(sum(t2.total_regimental_settle_amount) / 100, 2) as 'totalRegimentalSettleAmount'
  2312. from promoter_bind_channel_date t1
  2313. left join promoter_item_order_count t2
  2314. on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
  2315. where 1 = 1
  2316. <if test="start != null and start != '' ">
  2317. and t1.stat_date &gt;= #{start}
  2318. </if>
  2319. <if test="end != null and end != ''">
  2320. and t1.stat_date &lt;= #{end}
  2321. </if>
  2322. <if test="collectSampleId != null and collectSampleId != ''">
  2323. and t1.user_id = #{collectSampleId}
  2324. </if>
  2325. group by t1.user_id) t
  2326. join (select count(distinct item_id) as 'sampleCount'
  2327. from kuaishou_item_collect_samples
  2328. where collect_sample_status > 2
  2329. and collect_sample_id = #{collectSampleId} ) tt
  2330. </select>
  2331. <select id="bdDetailListV2" resultType="com.alibaba.fastjson.JSONObject">
  2332. select t.*, tt.sampleCount
  2333. from (select t1.promoter_id as 'promoterId',
  2334. t1.promoter_name as 'promoterName',
  2335. t1.promoter_url as 'promoterUrl',
  2336. sum(t2.order_num) as 'orderNum',
  2337. sum(t2.valid_order_num) as 'validOrderNum',
  2338. concat(round(sum(t2.valid_order_num) / sum(t2.order_num) * 100, 2), '%') as 'validOrderRate',
  2339. round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
  2340. round(sum(t2.regimental_promotion_amount) / 100, 2) as 'regimentalPromotionAmount',
  2341. round(sum(t2.total_regimental_settle_amount) / 100, 2) as 'totalRegimentalSettleAmount'
  2342. from promoter_bind_channel_date t1
  2343. left join promoter_item_order_count t2
  2344. on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
  2345. where 1 = 1
  2346. <if test="start != null and start != '' ">
  2347. and t1.stat_date &gt;= #{start}
  2348. </if>
  2349. <if test="end != null and end != ''">
  2350. and t1.stat_date &lt;= #{end}
  2351. </if>
  2352. <if test="collectSampleId != null and collectSampleId != ''">
  2353. and t1.user_id = #{collectSampleId}
  2354. </if>
  2355. group by t1.promoter_id) t
  2356. left join (select promoter_id,
  2357. count(distinct item_id) as 'sampleCount'
  2358. from kuaishou_item_collect_samples
  2359. where collect_sample_status > 2
  2360. and collect_sample_id = #{collectSampleId}
  2361. group by promoter_id) tt on t.promoterId = tt.promoter_id
  2362. where t.orderNum > 0
  2363. order by ${fieId} ${sort}
  2364. </select>
  2365. <select id="bdReportListV2ByBind" resultType="com.alibaba.fastjson.JSONObject">
  2366. select t.*,
  2367. tt.promoterCount,
  2368. ttt.sampleCount,
  2369. tttt.sendTotalCount,
  2370. tttt.sendPromoterCount,
  2371. tttt.sendItemCount,
  2372. IFNULL(ttttt.promoters_count, '-') as 'promotersCount'
  2373. from (select t1.user_id as 'collectSampleId',
  2374. t1.user_name as 'collectSampleName',
  2375. sum(t2.order_num) as 'orderNum',
  2376. sum(t2.valid_order_num) as 'validOrderNum',
  2377. concat(round(sum(t2.valid_order_num) / sum(t2.order_num) * 100, 2), '%') as 'validOrderRate',
  2378. round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
  2379. round(sum(t2.regimental_promotion_amount) / 100, 2) as 'regimentalPromotionAmount',
  2380. round(sum(t2.total_regimental_settle_amount) / 100, 2) as 'totalRegimentalSettleAmount'
  2381. from kuaishou_promoter t1
  2382. left join(select *
  2383. from promoter_item_order_count
  2384. where stat_date &gt;= #{bindStartDate}) t2
  2385. on t1.promoter_id = t2.promoter_id
  2386. where 1 = 1
  2387. <if test="bindStartDate != null and bindStartDate != '' ">
  2388. and t1.create_time &gt;= str_to_date(concat(date_format(#{bindStartDate}, '%Y-%m-%d'), '00:00:01'),
  2389. '%Y-%m-%d %H:%i:%s')
  2390. </if>
  2391. <if test="bindEndDate != null and bindEndDate != '' ">
  2392. and t1.create_time &lt;= str_to_date(concat(date_format(#{bindEndDate}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d
  2393. %H:%i:%s')
  2394. </if>
  2395. <if test="collectSampleId != null and collectSampleId != '' ">
  2396. and t1.user_id = #{collectSampleId}
  2397. </if>
  2398. group by t1.user_id) t
  2399. left join (select user_id,
  2400. count(distinct promoter_id) as 'promoterCount'
  2401. from kuaishou_promoter
  2402. where 1 = 1
  2403. <if test="collectSampleId != null and collectSampleId != '' ">
  2404. and user_id = #{collectSampleId}
  2405. </if>
  2406. group by user_id) tt on t.collectSampleId = tt.user_id
  2407. left join (select collect_sample_id as 'user_id',
  2408. count(distinct promoter_id) as 'sampleCount'
  2409. from kuaishou_item_collect_samples
  2410. where collect_sample_status > 2
  2411. <if test="collectSampleId != null and collectSampleId != '' ">
  2412. and collect_sample_id = #{collectSampleId}
  2413. </if>
  2414. group by collect_sample_id) ttt on t.collectSampleId = ttt.user_id
  2415. left join (select collect_sample_id as 'user_id',
  2416. count(1) as 'sendTotalCount',
  2417. count(distinct promoter_id) as 'sendPromoterCount',
  2418. count(distinct item_id) as 'sendItemCount'
  2419. from kuaishou_item_collect_samples
  2420. where collect_sample_status > 2
  2421. <if test="collectSampleId != null and collectSampleId != '' ">
  2422. and collect_sample_id = #{collectSampleId}
  2423. </if>
  2424. <if test="bindStartDate != null and bindStartDate != '' ">
  2425. and create_time &gt;= str_to_date(concat(date_format(#{bindStartDate}, '%Y-%m-%d'), '00:00:01'),
  2426. '%Y-%m-%d %H:%i:%s')
  2427. </if>
  2428. <if test="bindEndDate != null and bindEndDate != '' ">
  2429. and create_time &lt;= str_to_date(concat(date_format(#{bindEndDate}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d
  2430. %H:%i:%s')
  2431. </if>
  2432. group by collect_sample_id) tttt on t.collectSampleId = tttt.user_id
  2433. left join (select user_id, promoters_count
  2434. from user_promoters_count
  2435. where media_id = 2
  2436. <if test="collectSampleId != null and collectSampleId != '' ">
  2437. and user_id = #{collectSampleId}
  2438. </if>
  2439. ) ttttt
  2440. on t.collectSampleId = ttttt.user_id
  2441. order by t.orderNum desc
  2442. </select>
  2443. <select id="exportBindOrder" resultType="com.alibaba.fastjson.JSONObject">
  2444. select *,t3.ccr_value as 'ccrValue'
  2445. from (select item_id as 'itemId', item_title as 'itemTitle', user_id as 'userId', user_name as 'userName'
  2446. from kuaishou_item_list
  2447. where
  2448. create_time &gt;= str_to_date(concat(#{bindStartDate},' 00:00:01'),'%Y-%m-%d
  2449. %H:%i:%s')
  2450. and
  2451. create_time &lt;= str_to_date(concat(#{bindEndDate},' 23:59:59'),'%Y-%m-%d
  2452. %H:%i:%s')
  2453. ) t1
  2454. left join
  2455. (select item_id as 'itemId',
  2456. image_url as 'imageUrl',
  2457. count(oid) as 'orderNum',
  2458. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  2459. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100, 2) as 'validRadio',
  2460. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  2461. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  2462. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status
  2463. != 80 then 1 else 0 end) * 100, 2) as 'deliveryRadio',
  2464. round(item_commission_rate / 10,2) as 'itemCommissionRate'
  2465. from kuaishou_supply_chain
  2466. where order_create_time &gt;= #{start}
  2467. group by item_id) t2 on t1.itemId = t2.itemId
  2468. left join kuaishou_item_ccr_info t3
  2469. on t1.itemId = t3.item_id
  2470. where 1 = 1
  2471. <if test="itemId != null and itemId != ''">
  2472. and t1.item_id = #{itemId}
  2473. </if>
  2474. <if test="itemTitle != null and itemTitle != ''">
  2475. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  2476. </if>
  2477. <if test="userId != null and userId != ''">
  2478. and t1.userId = #{userId}
  2479. </if>
  2480. order by t2.orderNum desc
  2481. </select>
  2482. <insert id="replaceAll">
  2483. replace into kuaishou_supply_chain(
  2484. oid,
  2485. item_id,
  2486. item_title,
  2487. reserve_price,
  2488. image_url,
  2489. order_status,
  2490. order_create_time,
  2491. send_status,
  2492. settlement_biz_type,
  2493. settlement_biz_type_desc,
  2494. send_time,
  2495. recv_time,
  2496. seller_id,
  2497. activity_id,
  2498. order_amount,
  2499. pay_amount,
  2500. regimental_promotion_rate,
  2501. share_rate,
  2502. base_amount,
  2503. service_amount,
  2504. regimental_promotion_amount,
  2505. total_regimental_settle_amount,
  2506. stat_date,
  2507. item_commission_rate,
  2508. promoter_id,
  2509. promoter_nick_name
  2510. )
  2511. values
  2512. <foreach collection="list" item="add" separator=",">
  2513. (
  2514. #{add.oid},
  2515. #{add.itemId},
  2516. #{add.itemTitle},
  2517. #{add.reservePrice},
  2518. #{add.imageUrl},
  2519. #{add.orderStatus},
  2520. #{add.orderCreateTime},
  2521. #{add.sendStatus},
  2522. #{add.settlementBizType},
  2523. #{add.settlementBizTypeDesc},
  2524. #{add.sendTime},
  2525. #{add.recvTime},
  2526. #{add.sellerId},
  2527. #{add.activityId},
  2528. #{add.orderAmount},
  2529. #{add.payAmount},
  2530. #{add.regimentalPromotionRate},
  2531. #{add.shareRate},
  2532. #{add.baseAmount},
  2533. #{add.serviceAmount},
  2534. #{add.regimentalPromotionAmount},
  2535. #{add.totalRegimentalSettleAmount},
  2536. #{add.statDate},
  2537. #{add.itemCommissionRate},
  2538. #{add.promoterId},
  2539. #{add.promoterNickName}
  2540. )
  2541. </foreach>
  2542. </insert>
  2543. <insert id="replaceKuaishouActivityInfo">
  2544. replace into kuaishou_activity_info(
  2545. activity_id,
  2546. regimental_id,
  2547. activity_title,
  2548. activity_type,
  2549. activity_begin_time,
  2550. activity_end_time,
  2551. activity_status,
  2552. apply_item_count,
  2553. wait_audit_item_count,
  2554. audit_pass_item_count
  2555. )
  2556. values
  2557. <foreach collection="list" item="add" separator=",">
  2558. (
  2559. #{add.activityId},
  2560. #{add.regimentalId},
  2561. #{add.activityTitle},
  2562. #{add.activityType},
  2563. #{add.activityBeginTime},
  2564. #{add.activityEndTime},
  2565. #{add.activityStatus},
  2566. #{add.applyItemCount},
  2567. #{add.waitAuditItemCount},
  2568. #{add.auditPassItemCount}
  2569. )
  2570. </foreach>
  2571. </insert>
  2572. <insert id="replaceMgsKuaishouActivityInfo">
  2573. replace into miaogousi.kuaishou_activity_info(
  2574. activity_id,
  2575. regimental_id,
  2576. activity_title,
  2577. activity_type,
  2578. activity_begin_time,
  2579. activity_end_time,
  2580. activity_status,
  2581. apply_item_count,
  2582. wait_audit_item_count,
  2583. audit_pass_item_count
  2584. )
  2585. values
  2586. <foreach collection="list" item="add" separator=",">
  2587. (
  2588. #{add.activityId},
  2589. #{add.regimentalId},
  2590. #{add.activityTitle},
  2591. #{add.activityType},
  2592. #{add.activityBeginTime},
  2593. #{add.activityEndTime},
  2594. #{add.activityStatus},
  2595. #{add.applyItemCount},
  2596. #{add.waitAuditItemCount},
  2597. #{add.auditPassItemCount}
  2598. )
  2599. </foreach>
  2600. </insert>
  2601. <insert id="replaceRocketKuaishouActivityInfo">
  2602. replace into rocket.kuaishou_activity_info(
  2603. activity_id,
  2604. regimental_id,
  2605. activity_title,
  2606. activity_type,
  2607. activity_begin_time,
  2608. activity_end_time,
  2609. activity_status,
  2610. apply_item_count,
  2611. wait_audit_item_count,
  2612. audit_pass_item_count
  2613. )
  2614. values
  2615. <foreach collection="list" item="add" separator=",">
  2616. (
  2617. #{add.activityId},
  2618. #{add.regimentalId},
  2619. #{add.activityTitle},
  2620. #{add.activityType},
  2621. #{add.activityBeginTime},
  2622. #{add.activityEndTime},
  2623. #{add.activityStatus},
  2624. #{add.applyItemCount},
  2625. #{add.waitAuditItemCount},
  2626. #{add.auditPassItemCount}
  2627. )
  2628. </foreach>
  2629. </insert>
  2630. <update id="updateKuaishouSupplyChain">
  2631. update kuaishou_supply_chain set send_status = 1
  2632. where oid in
  2633. <foreach collection="list" item="id" separator=","
  2634. open="(" close=")">
  2635. #{id}
  2636. </foreach>
  2637. </update>
  2638. <update id="updateMgsKuaishouSupplyChain">
  2639. update miaogousi.kuaishou_supply_chain set send_status = 1
  2640. where oid in
  2641. <foreach collection="list" item="id" separator=","
  2642. open="(" close=")">
  2643. #{id}
  2644. </foreach>
  2645. </update>
  2646. <update id="updateRocketKuaishouSupplyChain">
  2647. update rocket.kuaishou_supply_chain set send_status = 1
  2648. where oid in
  2649. <foreach collection="list" item="id" separator=","
  2650. open="(" close=")">
  2651. #{id}
  2652. </foreach>
  2653. </update>
  2654. <select id="getBytedanceOrderHourDataList" resultType="com.alibaba.fastjson.JSONObject">
  2655. 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'
  2656. FROM bytedance_order_list
  2657. WHERE pay_success_time = #{date}
  2658. GROUP BY pay_success_time_hour
  2659. ORDER BY pay_success_time_hour
  2660. </select>
  2661. <select id="getKuaishouOrderHourDataList" resultType="com.alibaba.fastjson.JSONObject">
  2662. 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'
  2663. FROM kuaishou_supply_chain
  2664. where stat_date = #{date}
  2665. GROUP BY stat_hour
  2666. ORDER BY stat_hour
  2667. </select>
  2668. <select id="exportItemDetail" resultType="com.alibaba.fastjson.JSONObject">
  2669. select t.*,tt.userName
  2670. from (
  2671. select
  2672. promoter_nick_name as 'promoterNickName',
  2673. promoter_id as 'promoterId',
  2674. count(oid) as 'orderNum',
  2675. round(sum(case when order_status != 80 then pay_amount else 0 end)/100,2 )as 'payAmount',
  2676. round(regimental_promotion_rate / 10 ,2) as 'regimentalPromotionRate',
  2677. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  2678. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  2679. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  2680. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  2681. then 1 else 0 end) * 100 ,2) as 'shippingGreen',
  2682. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'effDeliveryNum',
  2683. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  2684. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when send_status = 1
  2685. then 1 else 0 end) *100,2) as 'deliveryRadio'
  2686. from kuaishou_supply_chain
  2687. where 1= 1
  2688. <if test="itemId != null and itemId != ''">
  2689. and item_id = #{itemId}
  2690. </if>
  2691. <if test="start != null and start != ''">
  2692. and order_create_time &gt;= #{start}
  2693. </if>
  2694. <if test="end != null and end != ''">
  2695. and order_create_time &lt;= #{end}
  2696. </if>
  2697. <if test="promoterId != null and promoterId != ''">
  2698. and promoter_id = #{promoterId}
  2699. </if>
  2700. <if test="promoterNickName != null and promoterNickName != ''">
  2701. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  2702. </if>
  2703. group by promoter_id) t left join (select promoter_id,group_concat(user_name) as 'userName',user_id as 'userId'
  2704. from
  2705. kuaishou_promoter group by promoter_id) tt
  2706. on t.promoterId = tt.promoter_id
  2707. where 1 =1
  2708. <if test="userId != null and userId != ''">
  2709. and tt.userId = #{userId}
  2710. </if>
  2711. order by t.orderNum desc
  2712. </select>
  2713. <select id="getKsChannelGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
  2714. select stat_hour as 'time',
  2715. round(sum(pay_amount) / 100, 2) as 'charge' from kuaishou_supply_chain
  2716. where stat_date = #{date}
  2717. <if test='userList != null and userList.size() > 0'>
  2718. and promoter_id in (
  2719. select promoter_id
  2720. from kuaishou_promoter where
  2721. 1 = 1
  2722. and user_id in
  2723. <foreach collection="userList" item="item" separator=","
  2724. open="(" close=")">
  2725. #{item}
  2726. </foreach>
  2727. group by promoter_id
  2728. )
  2729. </if>
  2730. group by stat_hour
  2731. order by stat_hour asc;
  2732. </select>
  2733. <select id="getKsCourtshipGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
  2734. select stat_hour as 'time',
  2735. round(sum(pay_amount) / 100, 2) as 'charge'
  2736. from kuaishou_supply_chain
  2737. where stat_date = #{date}
  2738. <if test='userList != null and userList.size() > 0'>
  2739. and item_id in (
  2740. select item_id
  2741. from kuaishou_item_list where
  2742. 1 = 1
  2743. and user_id in
  2744. <foreach collection="userList" item="item" separator=","
  2745. open="(" close=")">
  2746. #{item}
  2747. </foreach>
  2748. group by item_id
  2749. )
  2750. </if>
  2751. group by stat_hour
  2752. order by stat_hour asc;
  2753. </select>
  2754. <select id="getBytedanceChannelGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
  2755. select pay_success_time_hour as 'time',
  2756. round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list where pay_success_time = #{date}
  2757. <if test='userList != null and userList.size() > 0'>
  2758. and author_short_id in(
  2759. select promoter_id
  2760. from kuaishou_promoter where
  2761. 1 = 1
  2762. and user_id in
  2763. <foreach collection="userList" item="item" separator=","
  2764. open="(" close=")">
  2765. #{item}
  2766. </foreach>
  2767. group by promoter_id
  2768. )
  2769. </if>
  2770. group by pay_success_time_hour
  2771. order by pay_success_time_hour asc;
  2772. </select>
  2773. <select id="getBytedanceCourtshipGmvHourByDate" resultType="com.alibaba.fastjson.JSONObject">
  2774. select pay_success_time_hour as 'time',
  2775. round(sum(total_pay_amount) / 100, 2) as 'charge' from bytedance_order_list where pay_success_time = #{date}
  2776. <if test='userList != null and userList.size() > 0'>
  2777. and product_id in(
  2778. select item_id
  2779. from kuaishou_item_list where
  2780. 1 = 1
  2781. and user_id in
  2782. <foreach collection="userList" item="item" separator=","
  2783. open="(" close=")">
  2784. #{item}
  2785. </foreach>
  2786. group by item_id
  2787. )
  2788. </if>
  2789. group by pay_success_time_hour
  2790. order by pay_success_time_hour asc;
  2791. </select>
  2792. <insert id="replaceKuaiShouActivityOpenItemList">
  2793. replace into kuaishou_activity_open_item_list(
  2794. item_id,
  2795. item_category_name,
  2796. item_price,
  2797. pre_activity_id,
  2798. item_leaf_category_id,
  2799. item_commission_rate,
  2800. investment_promotion_rate
  2801. )
  2802. values
  2803. <foreach collection="list" item="li" separator=",">
  2804. (
  2805. #{li.itemId},
  2806. #{li.itemCategoryName},
  2807. #{li.itemPrice},
  2808. #{li.preActivityId},
  2809. #{li.itemLeafCategoryId},
  2810. #{li.itemCommissionRate},
  2811. #{li.investmentPromotionRate}
  2812. )
  2813. </foreach>
  2814. </insert>
  2815. <insert id="replaceMgsKuaiShouActivityOpenItemList">
  2816. replace into miaogousi.kuaishou_activity_open_item_list(
  2817. item_id,
  2818. item_category_name,
  2819. item_price,
  2820. pre_activity_id,
  2821. item_leaf_category_id,
  2822. item_commission_rate,
  2823. investment_promotion_rate
  2824. )
  2825. values
  2826. <foreach collection="list" item="li" separator=",">
  2827. (
  2828. #{li.itemId},
  2829. #{li.itemCategoryName},
  2830. #{li.itemPrice},
  2831. #{li.preActivityId},
  2832. #{li.itemLeafCategoryId},
  2833. #{li.itemCommissionRate},
  2834. #{li.investmentPromotionRate}
  2835. )
  2836. </foreach>
  2837. </insert>
  2838. <insert id="replaceRocketKuaiShouActivityOpenItemList">
  2839. replace into rocket.kuaishou_activity_open_item_list(
  2840. item_id,
  2841. item_category_name,
  2842. item_price,
  2843. pre_activity_id,
  2844. item_leaf_category_id,
  2845. item_commission_rate,
  2846. investment_promotion_rate
  2847. )
  2848. values
  2849. <foreach collection="list" item="li" separator=",">
  2850. (
  2851. #{li.itemId},
  2852. #{li.itemCategoryName},
  2853. #{li.itemPrice},
  2854. #{li.preActivityId},
  2855. #{li.itemLeafCategoryId},
  2856. #{li.itemCommissionRate},
  2857. #{li.investmentPromotionRate}
  2858. )
  2859. </foreach>
  2860. </insert>
  2861. <select id="getKuaishouActivityInfoList" resultType="Long">
  2862. SELECT DISTINCT activity_id
  2863. FROM kuaishou_activity_info
  2864. WHERE activity_status = 2
  2865. OR activity_status = 3
  2866. </select>
  2867. <select id="getMgsKuaishouActivityInfoList" resultType="Long">
  2868. SELECT DISTINCT activity_id
  2869. FROM miaogousi.kuaishou_activity_info
  2870. WHERE activity_status = 2
  2871. OR activity_status = 3
  2872. </select>
  2873. <select id="getRocketKuaishouActivityInfoList" resultType="Long">
  2874. SELECT DISTINCT activity_id
  2875. FROM rocket.kuaishou_activity_info
  2876. WHERE activity_status = 2
  2877. OR activity_status = 3
  2878. </select>
  2879. </mapper>