SupplyChainMapper.xml 106 KB

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