SupplyChainMapper.xml 108 KB

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