SupplyChainMapper.xml 104 KB

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