SupplyChainMapper.xml 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893
  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. <delete id="unbindUser" parameterType="java.lang.Long">
  12. delete
  13. from kuaishou_item_bind_user
  14. where item_id = #{itemId}
  15. </delete>
  16. <select id="getOrderList" resultType="com.alibaba.fastjson.JSONObject">
  17. select *
  18. from (
  19. select promoter_id as 'promoterId',
  20. promoter_nick_name as 'promoterNickName',
  21. count(oid) as 'orderNum',
  22. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  23. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  24. sum(pay_amount) as 'payAmount',
  25. sum(case when order_status != 80 then pay_amount else 0 end) as 'validPayAmount',
  26. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  27. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  28. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  29. then 1 else 0 end),4) as 'deliveryRadio',
  30. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount'
  31. from kuaishou_supply_chain
  32. where 1= 1
  33. <if test="start != null and start != ''">
  34. and order_create_time &gt;= #{start}
  35. </if>
  36. <if test="end != null and end != ''">
  37. and order_create_time &lt;= #{end}
  38. </if>
  39. <if test="promoterId != null and promoterId != ''">
  40. and promoter_id = #{promoterId}
  41. </if>
  42. <if test="promoterNickName != null and promoterNickName != ''">
  43. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  44. </if>
  45. group by promoter_id) t
  46. order by t.orderNum desc
  47. </select>
  48. <select id="getTopOrders" resultType="com.alibaba.fastjson.JSONObject">
  49. select *
  50. from
  51. (select item_id as 'itemId',
  52. item_title as 'itemTitle',
  53. image_url as 'imageUrl',
  54. count(oid) as 'orderNum'
  55. from kuaishou_supply_chain
  56. where promoter_id = #{promoterId}
  57. <if test="start != null and start != ''">
  58. and order_create_time &gt;= #{start}
  59. </if>
  60. <if test="end != null and end != ''">
  61. and order_create_time &lt;= #{end}
  62. </if>
  63. group by item_id) t
  64. order by t.orderNum desc limit 3
  65. </select>
  66. <select id="anchorOrderDetail" resultType="com.alibaba.fastjson.JSONObject">
  67. select t.*,
  68. t2.status,
  69. (
  70. case
  71. when t3.activity_item_status = 1 then '待审核'
  72. when t3.activity_item_status = 2 then '已上架'
  73. when t3.activity_item_status = 3 then '审核拒绝'
  74. when t3.activity_item_status = 4 then '活动失效'
  75. when t3.activity_item_status = 5 then '商品下架'
  76. else ''
  77. end
  78. ) as 'activityItemStatus'
  79. from (select
  80. item_title as 'itemTitle',
  81. item_id as 'itemId',
  82. reserve_price as 'reservePrice',
  83. image_url 'imageUrl',
  84. count(oid) as 'orderNum',
  85. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  86. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  87. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  88. regimental_promotion_rate as 'regimentalPromotionRate',
  89. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  90. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  91. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  92. then 1 else 0 end),4) as 'deliveryRadio'
  93. from kuaishou_supply_chain
  94. where 1= 1
  95. <if test="promoterId != null and promoterId != ''">
  96. and promoter_id = #{promoterId}
  97. </if>
  98. <if test="start != null and start != ''">
  99. and order_create_time &gt;= #{start}
  100. </if>
  101. <if test="end != null and end != ''">
  102. and order_create_time &lt;= #{end}
  103. </if>
  104. <if test="itemId != null and itemId != ''">
  105. and item_id = #{itemId}
  106. </if>
  107. <if test="itemTitle != null and itemTitle != ''">
  108. and item_title like concat(concat('%',#{itemTitle}),'%')
  109. </if>
  110. group by item_id) t left join ( select item_id as 'itemId', collect_sample_status as 'status' from
  111. kuaishou_item_collect_samples where promoter_id = #{promoterId}) t2
  112. on t.itemId = t2.itemId
  113. left join kuaishou_item_list t3
  114. on t.itemId = t3.item_id
  115. order by t.orderNum desc
  116. </select>
  117. <select id="orderStatistics" resultType="com.alibaba.fastjson.JSONObject">
  118. select FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') as 'date',
  119. count(t.oid) as 'orderNum'
  120. from (select oid,
  121. order_create_time
  122. from kuaishou_supply_chain
  123. where 1 = 1
  124. <if test="promoterId != null and promoterId != ''">
  125. and promoter_id = #{promoterId}
  126. </if>
  127. <if test="start != null and start != ''">
  128. and order_create_time &gt;= #{start}
  129. </if>
  130. <if test="end != null and end != ''">
  131. and order_create_time &lt;= #{end}
  132. </if>
  133. ) t
  134. group by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d')
  135. order by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') asc
  136. </select>
  137. <select id="itemList" resultType="com.alibaba.fastjson.JSONObject">
  138. select *
  139. from (select t2.user_id as 'userId',
  140. t2.user_name as 'userName',
  141. t1.item_id as 'itemId',
  142. t1.reserve_price as 'reservePrice',
  143. t1.item_title as 'itemTitle',
  144. t1.image_url as 'imageUrl',
  145. count(t1.oid) as 'orderNum',
  146. sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  147. round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid), 4) as 'validRadio',
  148. sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  149. sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  150. round(sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) / sum(case when
  151. t1.order_status != 80 then 1 else 0 end), 4) as 'deliveryRadio',
  152. t1.item_commission_rate as 'itemCommissionRate'
  153. from kuaishou_supply_chain t1
  154. left join kuaishou_item_bind_user t2
  155. on t1.item_id = t2.item_id
  156. where 1 = 1
  157. <if test="start != null and start != ''">
  158. and t1.order_create_time &gt;= #{start}
  159. </if>
  160. <if test="end != null and end != ''">
  161. and t1.order_create_time &lt;= #{end}
  162. </if>
  163. <if test="itemId != null and itemId != ''">
  164. and t1.item_id = #{itemId}
  165. </if>
  166. <if test="itemTitle != null and itemTitle != ''">
  167. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  168. </if>
  169. group by t1.item_id) t
  170. where 1 = 1
  171. <if test="userId != null and userId != ''">
  172. and t.userId = #{userId}
  173. </if>
  174. order by ${fieId} ${sort}
  175. </select>
  176. <select id="getTopPromoterByItemId" resultType="com.alibaba.fastjson.JSONObject">
  177. select
  178. *
  179. from
  180. (select promoter_id as 'promoterId',
  181. promoter_nick_name as 'promoterNickName',
  182. count(oid) as 'orderNum'
  183. from kuaishou_supply_chain
  184. where item_id = #{itemId}
  185. <if test="start != null and start != ''">
  186. and order_create_time &gt;= #{start}
  187. </if>
  188. <if test="end != null and end != ''">
  189. and order_create_time &lt;= #{end}
  190. </if>
  191. group by promoter_id) t
  192. order by t.orderNum desc limit 3
  193. </select>
  194. <select id="itemDetail" resultType="com.alibaba.fastjson.JSONObject">
  195. select *
  196. from (
  197. select
  198. promoter_nick_name as 'promoterNickName',
  199. promoter_id as 'promoterId',
  200. count(oid) as 'orderNum',
  201. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  202. regimental_promotion_rate as 'regimentalPromotionRate',
  203. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  204. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  205. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  206. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  207. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  208. then 1 else 0 end),4) as 'deliveryRadio'
  209. from kuaishou_supply_chain
  210. where 1= 1
  211. <if test="itemId != null and itemId != ''">
  212. and item_id = #{itemId}
  213. </if>
  214. <if test="start != null and start != ''">
  215. and order_create_time &gt;= #{start}
  216. </if>
  217. <if test="end != null and end != ''">
  218. and order_create_time &lt;= #{end}
  219. </if>
  220. <if test="promoterId != null and promoterId != ''">
  221. and promoter_id = #{promoterId}
  222. </if>
  223. <if test="promoterNickName != null and promoterNickName != ''">
  224. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  225. </if>
  226. group by promoter_id) t
  227. order by t.orderNum desc
  228. </select>
  229. <select id="itemServiceCharge" resultType="com.alibaba.fastjson.JSONObject">
  230. select *
  231. from (
  232. select
  233. item_id as 'itemId',
  234. item_title as 'itemTitle',
  235. image_url as 'imageUrl',
  236. count(oid) as 'orderNum',
  237. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  238. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  239. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  240. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  241. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  242. then 1 else 0 end),4) as 'deliveryRadio',
  243. sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  244. regimental_promotion_rate as 'regimentalPromotionRate',
  245. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  246. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount',
  247. sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
  248. 'totalRegimentalSettleAmount',
  249. item_commission_rate as 'itemCommissionRate'
  250. from kuaishou_supply_chain
  251. where 1= 1
  252. <if test="start != null and start != ''">
  253. and order_create_time &gt;= #{start}
  254. </if>
  255. <if test="end != null and end != ''">
  256. and order_create_time &lt;= #{end}
  257. </if>
  258. <if test="itemId != null and itemId != ''">
  259. and item_id = #{itemId}
  260. </if>
  261. <if test="itemTitle != null and itemTitle != ''">
  262. and item_title like concat(concat('%',#{itemTitle}),'%')
  263. </if>
  264. group by item_id) t
  265. order by t.orderNum desc
  266. </select>
  267. <select id="getOrderTotal" resultType="com.alibaba.fastjson.JSONObject">
  268. select
  269. count(oid) as 'orderNum',
  270. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  271. sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm'
  272. from kuaishou_supply_chain
  273. where 1= 1
  274. <if test="start != null and start != ''">
  275. and order_create_time &gt;= #{start}
  276. </if>
  277. <if test="end != null and end != ''">
  278. and order_create_time &lt;= #{end}
  279. </if>
  280. </select>
  281. <select id="getOrderTotalRatio" resultType="java.lang.Double">
  282. select
  283. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio'
  284. from (select count(oid) as 'oid'
  285. from kuaishou_supply_chain
  286. where 1= 1
  287. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  288. and order_create_time &gt;= #{nowStartHourTemp}
  289. </if>
  290. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  291. and order_create_time &lt;= #{nowEndHourTemp}
  292. </if>
  293. ) t1
  294. join (select count(oid) as 'oid'
  295. from kuaishou_supply_chain
  296. where 1=1
  297. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  298. and order_create_time &gt;= #{yesterdayStartHourTemp}
  299. </if>
  300. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  301. and order_create_time &lt;= #{yesterdayEndHourTemp}
  302. </if>
  303. ) t2
  304. </select>
  305. <select id="getAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  306. select
  307. sum(order_amount) as 'orderAmount',
  308. sum(base_amount) as 'baseAmount',
  309. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount',
  310. sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
  311. 'totalRegimentalSettleAmount'
  312. from kuaishou_supply_chain
  313. where 1= 1
  314. <if test="start != null and start != ''">
  315. and order_create_time &gt;= #{start}
  316. </if>
  317. <if test="end != null and end != ''">
  318. and order_create_time &lt;= #{end}
  319. </if>
  320. </select>
  321. <select id="getAmountTotalRatio" resultType="java.lang.Double">
  322. select
  323. round((t1.payAmount -t2.payAmount) / t2.payAmount , 4) as 'amountTotalRatio'
  324. from (select sum(pay_amount) as 'payAmount'
  325. from kuaishou_supply_chain
  326. where 1= 1
  327. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  328. and order_create_time &gt;= #{nowStartHourTemp}
  329. </if>
  330. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  331. and order_create_time &lt;= #{nowEndHourTemp}
  332. </if>
  333. ) t1
  334. join (select sum(pay_amount) as 'payAmount'
  335. from kuaishou_supply_chain
  336. where 1=1
  337. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  338. and order_create_time &gt;= #{yesterdayStartHourTemp}
  339. </if>
  340. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  341. and order_create_time &lt;= #{yesterdayEndHourTemp}
  342. </if>
  343. ) t2
  344. </select>
  345. <select id="getServiceAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  346. select
  347. count(distinct promoter_id) as 'promoterNum',
  348. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  349. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  350. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  351. as 'deliveryRadio'
  352. from kuaishou_supply_chain
  353. where 1= 1
  354. <if test="start != null and start != ''">
  355. and order_create_time &gt;= #{start}
  356. </if>
  357. <if test="end != null and end != ''">
  358. and order_create_time &lt;= #{end}
  359. </if>
  360. </select>
  361. <select id="getOrderRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  362. select
  363. t1.*,
  364. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  365. from (select
  366. item_id as 'itemId',
  367. item_title as 'itemTitle',
  368. image_url as 'imageUrl',
  369. count(oid) as 'orderNum',
  370. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  371. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  372. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  373. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  374. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  375. as 'deliveryRadio'
  376. from kuaishou_supply_chain
  377. where 1= 1
  378. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  379. and order_create_time &gt;= #{nowStartHourTemp}
  380. </if>
  381. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  382. and order_create_time &lt;= #{nowEndHourTemp}
  383. </if>
  384. group by item_id
  385. ) t1
  386. left join (select
  387. item_id as 'itemId',
  388. count(oid) as 'orderNum'
  389. from kuaishou_supply_chain
  390. where 1=1
  391. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  392. and order_create_time &gt;= #{yesterdayStartHourTemp}
  393. </if>
  394. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  395. and order_create_time &lt;= #{yesterdayEndHourTemp}
  396. </if>
  397. group by item_id
  398. ) t2 on t1.itemId = t2.itemId
  399. order by t1.orderNum desc
  400. </select>
  401. <select id="getOrderRankList" resultType="com.alibaba.fastjson.JSONObject">
  402. select * from (
  403. select
  404. item_id as 'itemId',
  405. item_title as 'itemTitle',
  406. image_url as 'imageUrl',
  407. count(oid) as 'orderNum',
  408. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  409. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  410. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  411. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  412. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  413. then 1 else 0 end),4) as 'deliveryRadio'
  414. from kuaishou_supply_chain
  415. where 1= 1
  416. <if test="start != null and start != ''">
  417. and order_create_time &gt;= #{start}
  418. </if>
  419. <if test="end != null and end != ''">
  420. and order_create_time &lt;= #{end}
  421. </if>
  422. group by item_id) t
  423. order by t.orderNum desc
  424. </select>
  425. <select id="getPromoterRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  426. select
  427. t1.*,
  428. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  429. from (
  430. select
  431. promoter_id as 'promoterId',
  432. promoter_nick_name as 'promoterNickName',
  433. count(oid) as 'orderNum',
  434. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  435. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  436. from kuaishou_supply_chain
  437. where 1= 1
  438. <if test='promoterIds != null and promoterIds.size() > 0'>
  439. AND promoter_id IN
  440. <foreach collection="promoterIds" item="item" separator=","
  441. open="(" close=")">
  442. #{item}
  443. </foreach>
  444. </if>
  445. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  446. and order_create_time &gt;= #{nowStartHourTemp}
  447. </if>
  448. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  449. and order_create_time &lt;= #{nowEndHourTemp}
  450. </if>
  451. group by promoter_id
  452. ) t1
  453. left join (select
  454. promoter_id as 'promoterId',
  455. count(oid) as 'orderNum'
  456. from kuaishou_supply_chain
  457. where 1=1
  458. <if test='promoterIds != null and promoterIds.size() > 0'>
  459. AND promoter_id IN
  460. <foreach collection="promoterIds" item="item" separator=","
  461. open="(" close=")">
  462. #{item}
  463. </foreach>
  464. </if>
  465. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  466. and order_create_time &gt;= #{yesterdayStartHourTemp}
  467. </if>
  468. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  469. and order_create_time &lt;= #{yesterdayEndHourTemp}
  470. </if>
  471. group by promoter_id
  472. ) t2 on t1.promoterId = t2.promoterId
  473. order by t1.orderNum desc
  474. </select>
  475. <select id="getPromoterRatioList" resultType="com.alibaba.fastjson.JSONObject">
  476. select * from (
  477. select
  478. promoter_id as 'promoterId',
  479. promoter_nick_name as 'promoterNickName',
  480. count(oid) as 'orderNum',
  481. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  482. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  483. from kuaishou_supply_chain
  484. where 1= 1
  485. <if test="start != null and start != ''">
  486. and order_create_time &gt;= #{start}
  487. </if>
  488. <if test="end != null and end != ''">
  489. and order_create_time &lt;= #{end}
  490. </if>
  491. group by promoter_id) t
  492. order by t.orderNum desc
  493. </select>
  494. <select id="exportPromoterTotal" resultType="com.alibaba.fastjson.JSONObject">
  495. select *
  496. from (
  497. select
  498. promoter_id as 'promoterId',
  499. promoter_nick_name as 'promoterNickName',
  500. count(oid) as 'orderNum',
  501. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  502. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  503. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  504. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  505. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  506. then 1 else 0 end) * 100,2) as 'deliveryRadio',
  507. round(sum(pay_amount) / 100,2) as 'payAmount',
  508. round(sum(case when order_status != 80 then pay_amount else 0 end) / 100 , 2 ) as 'validPayAmount',
  509. round(sum(case when order_status != 80 then regimental_promotion_amount else 0 end) / 100, 2) as
  510. 'regimentalPromotionAmount'
  511. from kuaishou_supply_chain
  512. where 1= 1
  513. <if test="start != null and start != ''">
  514. and order_create_time &gt;= #{start}
  515. </if>
  516. <if test="end != null and end != ''">
  517. and order_create_time &lt;= #{end}
  518. </if>
  519. <if test="promoterId != null and promoterId != ''">
  520. and promoter_id = #{promoterId}
  521. </if>
  522. <if test="promoterNickName != null and promoterNickName != ''">
  523. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  524. </if>
  525. <if test="itemId != null and itemId != ''">
  526. and item_id = #{itemId}
  527. </if>
  528. <if test="itemTitle != null and itemTitle != ''">
  529. and item_title like concat(concat('%',#{itemTitle}),'%')
  530. </if>
  531. group by promoter_id) t
  532. order by t.orderNum desc
  533. </select>
  534. <select id="exportPromoter" resultType="com.alibaba.fastjson.JSONObject">
  535. select *
  536. from (
  537. select
  538. promoter_id as 'promoterId',
  539. promoter_nick_name as 'promoterNickName',
  540. item_id as 'itemId',
  541. item_title as 'itemTitle',
  542. image_url as 'imageUrl',
  543. count(oid) as 'orderNum',
  544. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  545. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  546. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  547. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  548. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  549. then 1 else 0 end) * 100,2) as 'deliveryRadio'
  550. from kuaishou_supply_chain
  551. where 1= 1
  552. <if test="start != null and start != ''">
  553. and order_create_time &gt;= #{start}
  554. </if>
  555. <if test="end != null and end != ''">
  556. and order_create_time &lt;= #{end}
  557. </if>
  558. <if test="promoterId != null and promoterId != ''">
  559. and promoter_id = #{promoterId}
  560. </if>
  561. <if test="promoterNickName != null and promoterNickName != ''">
  562. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  563. </if>
  564. <if test="itemId != null and itemId != ''">
  565. and item_id = #{itemId}
  566. </if>
  567. <if test="itemTitle != null and itemTitle != ''">
  568. and item_title like concat(concat('%',#{itemTitle}),'%')
  569. </if>
  570. group by promoter_id,item_id) t
  571. order by t.promoterId,t.orderNum desc
  572. </select>
  573. <select id="exportOrder" resultType="com.alibaba.fastjson.JSONObject">
  574. select *
  575. from (select
  576. t2.user_id as 'userId',
  577. t2.user_name as 'userName',
  578. t1.item_id as 'itemId',
  579. t1.item_title as 'itemTitle',
  580. t1.image_url as 'imageUrl',
  581. count(t1.oid) as 'orderNum',
  582. sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  583. round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid) * 100, 2) as 'validRadio',
  584. sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  585. sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  586. round(sum(case when t1.send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when t1.order_status
  587. != 80 then 1 else 0 end) * 100, 2) as 'deliveryRadio',
  588. round(t1.item_commission_rate / 10,2) as 'itemCommissionRate'
  589. from kuaishou_supply_chain t1
  590. left join kuaishou_item_bind_user t2
  591. on t1.item_id = t2.item_id
  592. where 1 = 1
  593. <if test="start != null and start != ''">
  594. and t1.order_create_time &gt;= #{start}
  595. </if>
  596. <if test="end != null and end != ''">
  597. and t1.order_create_time &lt;= #{end}
  598. </if>
  599. <if test="promoterId != null and promoterId != ''">
  600. and t1.promoter_id = #{promoterId}
  601. </if>
  602. <if test="promoterNickName != null and promoterNickName != ''">
  603. and t1.promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  604. </if>
  605. <if test="itemId != null and itemId != ''">
  606. and t1.item_id = #{itemId}
  607. </if>
  608. <if test="itemTitle != null and itemTitle != ''">
  609. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  610. </if>
  611. group by t1.item_id) t
  612. where 1 = 1
  613. <if test="userId != null and userId != ''">
  614. and t.userId = #{userId}
  615. </if>
  616. order by t.orderNum desc
  617. </select>
  618. <select id="bindUserItemList" resultType="com.alibaba.fastjson.JSONObject">
  619. select *
  620. from (select t1.item_id as 'itemId',
  621. t1.item_title as 'itemTitle',
  622. t1.reserve_price as 'reservePrice',
  623. t1.image_url as 'imageUrl',
  624. t1.activity_id as 'activityId',
  625. t1.regimental_promotion_rate as 'regimentalPromotionRate',
  626. t2.user_id as 'userId',
  627. case when t2.user_id is null then 1 else 2 end as 'status',
  628. t2.user_name as 'userName',
  629. t2.create_time as 'bindTime',
  630. t1.item_commission_rate as 'itemCommissionRate'
  631. from kuaishou_item_info t1
  632. left join kuaishou_item_bind_user t2 on t1.item_id = t2.item_id
  633. where 1 = 1
  634. <if test="userId != null and userId != ''">
  635. and t2.user_id = #{userId}
  636. </if>
  637. <if test="itemId != null and itemId != ''">
  638. and t1.item_id = #{itemId}
  639. </if>
  640. <if test="itemTitle != null and itemTitle != ''">
  641. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  642. </if>
  643. <if test="activityId != null and activityId != ''">
  644. and t1.activity_id = #{activityId}
  645. </if>
  646. order by t1.create_time desc) t
  647. where 1 = 1
  648. <if test="status != null and status != ''">
  649. and t.status = #{status}
  650. </if>
  651. </select>
  652. <select id="getSupplyChainUserList" resultType="com.alibaba.fastjson.JSONObject">
  653. select t3.user_id as 'userId', t3.nick_name as 'nickMame', t1.role_name as 'roleName', t3.status
  654. from sys_role t1
  655. left join sys_user_role t2 on t1.role_id = t2.role_id
  656. left join sys_user t3 on t2.user_id = t3.user_id
  657. where t1.role_key in (
  658. 'association',
  659. 'associationManager',
  660. 'bd',
  661. 'bdManager'
  662. )
  663. group by t3.user_id
  664. order by t3.create_time asc
  665. </select>
  666. <select id="adminReportList" resultType="com.alibaba.fastjson.JSONObject">
  667. select *
  668. from (select t1.user_id as 'userId',
  669. t1.user_name as 'userName',
  670. count(distinct t2.item_id) as 'itemCount',
  671. count(t2.oid) as 'orderNum',
  672. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  673. round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid),4) as 'validRadio',
  674. sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  675. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  676. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
  677. when t2.order_status != 80
  678. then 1
  679. else 0 end),
  680. 4) as 'deliveryRadio',
  681. sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  682. sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) as 'payAmount',
  683. sum(case
  684. when t2.order_status != 80 then t2.regimental_promotion_amount
  685. else 0 end) as 'regimentalPromotionAmount',
  686. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  687. 'totalRegimentalSettleAmount'
  688. from kuaishou_item_bind_user t1
  689. left join kuaishou_supply_chain t2
  690. on t1.item_id = t2.item_id
  691. where 1= 1
  692. <if test="start != null and start != ''">
  693. and t2.order_create_time &gt;= #{start}
  694. </if>
  695. <if test="end != null and end != ''">
  696. and t2.order_create_time &lt;= #{end}
  697. </if>
  698. group by t1.user_id) t left join (
  699. select item_create_id,count(1) as 'sendSampleCount' from kuaishou_item_collect_samples
  700. where courier_number_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  701. and courier_number_time &lt;= from_unixtime(#{end}/1000,'%Y-%m-%d %H:%i:%s')
  702. group by item_create_id
  703. ) t1 on t.userId = t1.item_create_id
  704. where 1 =1
  705. <if test="userId != null and userId != ''">
  706. and t.userId = #{userId}
  707. </if>
  708. order by t.orderNum desc
  709. </select>
  710. <select id="userItemDetail" resultType="com.alibaba.fastjson.JSONObject">
  711. SELECT
  712. *
  713. FROM
  714. (
  715. SELECT
  716. t1.user_id,
  717. t1.user_name AS 'userName',
  718. t2.item_id AS 'itemId',
  719. t2.item_title AS 'itemTitle',
  720. t2.image_url AS 'imageUrl',
  721. t2.reserve_price AS 'reservePrice',
  722. count(t2.oid) AS 'orderNum',
  723. sum(
  724. CASE
  725. WHEN t2.order_status != 80 THEN 1
  726. ELSE 0
  727. END
  728. ) AS 'validOrderNUm',
  729. round(
  730. sum(
  731. CASE
  732. WHEN t2.order_status != 80 THEN 1
  733. ELSE 0
  734. END
  735. ) / count(t2.oid),
  736. 4
  737. ) AS 'validRadio',
  738. sum(
  739. CASE
  740. WHEN t2.send_status = 1
  741. AND t2.order_status != 80 THEN 1
  742. ELSE 0
  743. END
  744. ) AS 'deliveryNum',
  745. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  746. round(
  747. sum(
  748. CASE
  749. WHEN t2.send_status = 1
  750. AND t2.order_status != 80 THEN 1
  751. ELSE 0
  752. END
  753. ) / sum(
  754. CASE
  755. WHEN t2.order_status != 80 THEN 1
  756. ELSE 0
  757. END
  758. ),
  759. 4
  760. ) AS 'deliveryRadio',
  761. sum(
  762. CASE
  763. WHEN t2.order_status = 80 THEN 1
  764. ELSE 0
  765. END
  766. ) AS 'invalidOrderNUm',
  767. sum(
  768. CASE
  769. WHEN t2.order_status != 80 THEN t2.pay_amount
  770. ELSE 0
  771. END
  772. ) AS 'payAmount',
  773. t2.regimental_promotion_rate AS 'regimentalPromotionRate',
  774. sum(
  775. CASE
  776. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  777. ELSE 0
  778. END
  779. ) AS 'regimentalPromotionAmount',
  780. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  781. 'totalRegimentalSettleAmount',
  782. t2.item_commission_rate as 'itemCommissionRate'
  783. FROM
  784. kuaishou_item_bind_user t1
  785. LEFT JOIN
  786. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  787. WHERE
  788. 1 = 1
  789. <if test="start != null and start != ''">
  790. and t2.order_create_time &gt;= #{start}
  791. </if>
  792. <if test="end != null and end != ''">
  793. and t2.order_create_time &lt;= #{end}
  794. </if>
  795. <if test="itemId != null and itemId != ''">
  796. and t1.item_id = #{itemId}
  797. </if>
  798. <if test="itemTitle != null and itemTitle != ''">
  799. and t2.item_title like concat(concat('%',#{itemTitle}),'%')
  800. </if>
  801. GROUP BY
  802. t1.item_id
  803. ) t
  804. where 1 = 1
  805. <if test="userId != null and userId != ''">
  806. and t.user_id = #{userId}
  807. </if>
  808. order by ${fieId} ${sort}
  809. </select>
  810. <select id="getTimeIntervalRatio" resultType="com.alibaba.fastjson.JSONObject">
  811. select
  812. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio',
  813. round((t1.orderAmount -t2.orderAmount) / t2.orderAmount , 4) as 'orderAmountRatio'
  814. from (
  815. select count(oid) as 'oid',
  816. sum(order_amount) as 'orderAmount'
  817. from kuaishou_supply_chain
  818. where 1= 1
  819. <if test="thisCycleStartTemp != null and thisCycleStartTemp != ''">
  820. and order_create_time &gt;= #{thisCycleStartTemp}
  821. </if>
  822. <if test="thisCycleEndTemp != null and thisCycleEndTemp != ''">
  823. and order_create_time &lt;= #{thisCycleEndTemp}
  824. </if>
  825. ) t1
  826. join (
  827. select count(oid) as 'oid',
  828. sum(order_amount) as 'orderAmount'
  829. from kuaishou_supply_chain
  830. where 1=1
  831. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  832. and order_create_time &gt;= #{lastCycleStartTemp}
  833. </if>
  834. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  835. and order_create_time &lt;= #{lastCycleEndTemp}
  836. </if>
  837. ) t2
  838. </select>
  839. <select id="indexStatistics" resultType="com.alibaba.fastjson.JSONObject">
  840. select FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') as 'date',
  841. <if test="type == 'orderNum' ">
  842. count(t.oid) as 'orderNum'
  843. </if>
  844. <if test="type == 'validOrderNum' ">
  845. sum(case when t.order_status = 80 then 1 else 0 end) as 'validOrderNum'
  846. </if>
  847. <if test="type == 'orderAmount' ">
  848. sum(t.order_amount) as 'orderAmount'
  849. </if>
  850. <if test="type == 'baseAmount' ">
  851. sum(t.base_amount) as 'baseAmount'
  852. </if>
  853. <if test="type == 'deliveryNum' ">
  854. sum(case when t.send_status = 1 and t.order_status != 80 then 1 else 0 end) as 'deliveryNum'
  855. </if>
  856. from (select
  857. oid,
  858. order_status,
  859. order_amount,
  860. base_amount,
  861. send_status,
  862. order_create_time
  863. from kuaishou_supply_chain
  864. where 1 = 1
  865. <if test="startTemp != null and startTemp != ''">
  866. and order_create_time &gt;= #{startTemp}
  867. </if>
  868. <if test="endTemp != null and endTemp != ''">
  869. and order_create_time &lt;= #{endTemp}
  870. </if>
  871. ) t
  872. group by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d')
  873. order by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') asc
  874. </select>
  875. <select id="itemBindSummary" resultType="com.alibaba.fastjson.JSONObject">
  876. 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'
  877. from kuaishou_item_info t1
  878. left join kuaishou_item_bind_user t2
  879. on t1.item_id = t2.item_id
  880. where 1 = 1
  881. </select>
  882. <select id="userItemTotal" resultType="com.alibaba.fastjson.JSONObject">
  883. SELECT count(t2.oid) AS 'orderNum',
  884. sum(
  885. CASE
  886. WHEN t2.order_status != 80 THEN 1
  887. ELSE 0
  888. END
  889. ) AS 'validOrderNUm',
  890. round(
  891. sum(
  892. CASE
  893. WHEN t2.order_status != 80 THEN 1
  894. ELSE 0
  895. END
  896. ) / count(t2.oid),
  897. 4
  898. ) AS 'validRadio',
  899. sum(
  900. CASE
  901. WHEN t2.send_status = 1
  902. AND t2.order_status != 80 THEN 1
  903. ELSE 0
  904. END
  905. ) AS 'deliveryNum',
  906. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  907. round(
  908. sum(
  909. CASE
  910. WHEN t2.send_status = 1
  911. AND t2.order_status != 80 THEN 1
  912. ELSE 0
  913. END
  914. ) / sum(
  915. CASE
  916. WHEN t2.order_status != 80 THEN 1
  917. ELSE 0
  918. END
  919. ),
  920. 4
  921. ) AS 'deliveryRadio',
  922. sum(
  923. CASE
  924. WHEN t2.order_status = 80 THEN 1
  925. ELSE 0
  926. END
  927. ) AS 'invalidOrderNUm',
  928. sum(
  929. CASE
  930. WHEN t2.order_status != 80 THEN t2.pay_amount
  931. ELSE 0
  932. END
  933. ) AS 'payAmount',
  934. sum(
  935. CASE
  936. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  937. ELSE 0
  938. END
  939. ) AS 'regimentalPromotionAmount',
  940. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  941. 'totalRegimentalSettleAmount'
  942. FROM kuaishou_item_bind_user t1
  943. LEFT JOIN
  944. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  945. WHERE 1 = 1
  946. <if test="start != null and start != ''">
  947. and t2.order_create_time &gt;= #{start}
  948. </if>
  949. <if test="end != null and end != ''">
  950. and t2.order_create_time &lt;= #{end}
  951. </if>
  952. <if test="userId != null and userId != ''">
  953. and t1.user_id = #{userId}
  954. </if>
  955. </select>
  956. <select id="exportUserItemDetail" resultType="com.alibaba.fastjson.JSONObject">
  957. SELECT
  958. *
  959. FROM
  960. (
  961. SELECT
  962. t1.user_id as 'user_id',
  963. t1.user_name AS 'userName',
  964. t2.item_id AS 'itemId',
  965. t2.item_title AS 'itemTitle',
  966. t2.image_url AS 'imageUrl',
  967. round(t2.reserve_price / 100,2) AS 'reservePrice',
  968. count(t2.oid) AS 'orderNum',
  969. sum(
  970. CASE
  971. WHEN t2.order_status != 80 THEN 1
  972. ELSE 0
  973. END
  974. ) AS 'validOrderNUm',
  975. round(
  976. sum(
  977. CASE
  978. WHEN t2.order_status != 80 THEN 1
  979. ELSE 0
  980. END
  981. ) / count(t2.oid) * 100,
  982. 2
  983. ) AS 'validRadio',
  984. sum(
  985. CASE
  986. WHEN t2.send_status = 1
  987. AND t2.order_status != 80 THEN 1
  988. ELSE 0
  989. END
  990. ) AS 'deliveryNum',
  991. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  992. round(
  993. sum(
  994. CASE
  995. WHEN t2.send_status = 1
  996. AND t2.order_status != 80 THEN 1
  997. ELSE 0
  998. END
  999. ) / sum(
  1000. CASE
  1001. WHEN t2.order_status != 80 THEN 1
  1002. ELSE 0
  1003. END
  1004. ) * 100,
  1005. 2
  1006. ) AS 'deliveryRadio',
  1007. sum(
  1008. CASE
  1009. WHEN t2.order_status = 80 THEN 1
  1010. ELSE 0
  1011. END
  1012. ) AS 'invalidOrderNUm',
  1013. round( sum(
  1014. CASE
  1015. WHEN t2.order_status != 80 THEN t2.pay_amount
  1016. ELSE 0
  1017. END
  1018. )/ 100,2 )AS 'payAmount',
  1019. concat(round(t2.regimental_promotion_rate / 10 ,2),'%') AS 'regimentalPromotionRate',
  1020. round(
  1021. sum(
  1022. CASE
  1023. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  1024. ELSE 0
  1025. END
  1026. ) / 100 , 2)AS 'regimentalPromotionAmount',
  1027. round(
  1028. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100,2) as
  1029. 'totalRegimentalSettleAmount',
  1030. concat(round(t2.item_commission_rate / 10),'%') as 'itemCommissionRate'
  1031. FROM
  1032. kuaishou_item_bind_user t1
  1033. LEFT JOIN
  1034. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  1035. WHERE
  1036. 1 = 1
  1037. <if test="start != null and start != ''">
  1038. and t2.order_create_time &gt;= #{start}
  1039. </if>
  1040. <if test="end != null and end != ''">
  1041. and t2.order_create_time &lt;= #{end}
  1042. </if>
  1043. <if test="itemId != null and itemId != ''">
  1044. and t1.item_id = #{itemId}
  1045. </if>
  1046. <if test="itemTitle != null and itemTitle != ''">
  1047. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  1048. </if>
  1049. GROUP BY
  1050. t1.item_id
  1051. ) t
  1052. where 1 = 1
  1053. <if test="userId != null and userId != ''">
  1054. and t.user_id = #{userId}
  1055. </if>
  1056. order by t.orderNum desc
  1057. </select>
  1058. <select id="getCookie" resultType="java.lang.String">
  1059. select cookie
  1060. from ruixuan.kuaishou_supply_chain_cookie where id = #{regId} limit 1
  1061. </select>
  1062. <select id="selectOrderInfo" resultType="com.alibaba.fastjson.JSONObject">
  1063. SELECT
  1064. COUNT(DISTINCT promoter_id) as 'promoterCount',
  1065. COUNT(oid) as 'allNumber',
  1066. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
  1067. IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END), 0) AS 'orderAmount',
  1068. IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
  1069. 'regimentalPromotionAmount',
  1070. IFNULL(sum(base_amount), 0) as 'baseAmount'
  1071. FROM kuaishou_supply_chain
  1072. WHERE stat_date >= #{startDate}
  1073. AND stat_date &lt;= #{endDate}
  1074. <if test='promoterIds != null and promoterIds.size() > 0'>
  1075. AND promoter_id in
  1076. <foreach collection="promoterIds" item="item" separator=","
  1077. open="(" close=")">
  1078. #{item}
  1079. </foreach>
  1080. </if>
  1081. </select>
  1082. <select id="selectOrderInfoByItemIds" resultType="com.alibaba.fastjson.JSONObject">
  1083. SELECT t.*,
  1084. CONCAT(IFNULL(ROUND(sendCount / allNumber * 100, 2),0), '%') as 'sendRate'
  1085. FROM (
  1086. SELECT
  1087. COUNT(DISTINCT promoter_id) as 'promoterCount',
  1088. COUNT(oid) as 'allNumber',
  1089. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderNUm',
  1090. IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END), 0) AS 'orderAmount',
  1091. IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
  1092. 'regimentalPromotionAmount',
  1093. IFNULL(sum(base_amount), 0) as 'baseAmount',
  1094. IFNULL(COUNT(CASE WHEN send_status = 1 THEN oid ELSE null END), 0) AS 'sendCount'
  1095. FROM kuaishou_supply_chain
  1096. WHERE stat_date >= #{startDate}
  1097. AND stat_date &lt;= #{endDate}
  1098. <if test='itemIds != null and itemIds.size() > 0'>
  1099. AND item_id in
  1100. <foreach collection="itemIds" item="item" separator=","
  1101. open="(" close=")">
  1102. #{item}
  1103. </foreach>
  1104. </if>
  1105. ) t
  1106. </select>
  1107. <select id="selectOrderRate" resultType="com.alibaba.fastjson.JSONObject">
  1108. SELECT
  1109. count(oid) as 'allNumber',
  1110. IFNULL(sum(
  1111. CASE
  1112. WHEN order_status != 80 THEN order_amount
  1113. ELSE 0
  1114. END
  1115. ),0) AS 'orderAmount'
  1116. FROM kuaishou_supply_chain
  1117. WHERE order_create_time >= #{statDate}
  1118. AND order_create_time &lt;= #{endDate}
  1119. <if test='promoterIds != null and promoterIds.size() > 0'>
  1120. AND promoter_id in
  1121. <foreach collection="promoterIds" item="item" separator=","
  1122. open="(" close=")">
  1123. #{item}
  1124. </foreach>
  1125. </if>
  1126. <if test='itemIds != null and itemIds.size() > 0'>
  1127. AND item_id in
  1128. <foreach collection="itemIds" item="item" separator=","
  1129. open="(" close=")">
  1130. #{item}
  1131. </foreach>
  1132. </if>
  1133. </select>
  1134. <select id="getMonthOrderAmount" resultType="com.alibaba.fastjson.JSONObject">
  1135. SELECT
  1136. FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') as 'date',
  1137. count(1) AS 'orderCount',
  1138. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
  1139. IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) AS 'orderAmount',
  1140. IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
  1141. 'regimentalPromotionAmount',
  1142. COUNT(DISTINCT promoter_id) as 'promoterCount'
  1143. FROM kuaishou_supply_chain t1
  1144. WHERE order_create_time >= #{startLong}
  1145. AND order_create_time &lt;= #{endLong}
  1146. <if test='promoterIds != null and promoterIds.size() > 0'>
  1147. AND promoter_id in
  1148. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1149. #{item}
  1150. </foreach>
  1151. </if>
  1152. GROUP BY FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d')
  1153. </select>
  1154. <select id="getMonthOrderAmountByItems" resultType="com.alibaba.fastjson.JSONObject">
  1155. SELECT
  1156. FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') as 'date',
  1157. count(1) AS 'orderCount',
  1158. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS 'validOrderCount',
  1159. IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END),0) AS 'orderAmount',
  1160. IFNULL(SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),0) AS
  1161. 'regimentalPromotionAmount'
  1162. FROM kuaishou_supply_chain
  1163. WHERE order_create_time >= #{startLong}
  1164. AND order_create_time &lt;= #{endLong}
  1165. <if test='itemIds != null and itemIds.size() > 0'>
  1166. AND item_id in
  1167. <foreach collection="itemIds" item="item" separator=","
  1168. open="(" close=")">
  1169. #{item}
  1170. </foreach>
  1171. </if>
  1172. GROUP BY FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d')
  1173. </select>
  1174. <select id="getMonthOrderAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  1175. SELECT
  1176. t1.orderAmount,
  1177. t1.regimentalPromotionAmount,
  1178. CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
  1179. CONCAT(IFNULL(ROUND(t2.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
  1180. 'regimentalPromotionAmountRate'
  1181. FROM
  1182. (
  1183. SELECT
  1184. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1185. IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount'
  1186. FROM kuaishou_supply_chain t1
  1187. WHERE order_status != 80
  1188. <if test='promoterIds != null and promoterIds.size() > 0'>
  1189. AND promoter_id in
  1190. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1191. #{item}
  1192. </foreach>
  1193. </if>
  1194. AND order_create_time >= #{startLong}
  1195. AND order_create_time &lt;= #{endLong}) t1
  1196. LEFT JOIN
  1197. (
  1198. SELECT
  1199. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1200. IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount'
  1201. FROM kuaishou_supply_chain t1
  1202. WHERE order_status != 80
  1203. <if test='promoterIds != null and promoterIds.size() > 0'>
  1204. AND promoter_id in
  1205. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1206. #{item}
  1207. </foreach>
  1208. </if>
  1209. AND order_create_time >= #{toStartLong}
  1210. AND order_create_time &lt;= #{endLong})t2 ON 1=1
  1211. </select>
  1212. <select id="getMonthOrderAmountTotalByItems" resultType="com.alibaba.fastjson.JSONObject">
  1213. SELECT
  1214. t1.orderAmount,
  1215. t1.regimentalPromotionAmount,
  1216. t1.orderCount,
  1217. CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
  1218. CONCAT(IFNULL(ROUND(t2.orderCount/t1.orderCount*100,2),0),'%') as 'orderCountRate',
  1219. CONCAT(IFNULL(ROUND(t2.regimentalPromotionAmount/t1.regimentalPromotionAmount*100,2),0),'%') as
  1220. 'regimentalPromotionAmountRate'
  1221. FROM
  1222. (
  1223. SELECT
  1224. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1225. IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount',
  1226. COUNT(oid) as 'orderCount'
  1227. FROM kuaishou_supply_chain t1
  1228. WHERE order_status != 80
  1229. <if test='itemIds != null and itemIds.size() > 0'>
  1230. AND item_id in
  1231. <foreach collection="itemIds" item="item" separator=","
  1232. open="(" close=")">
  1233. #{item}
  1234. </foreach>
  1235. </if>
  1236. AND order_create_time >= #{startLong}
  1237. AND order_create_time &lt;= #{endLong}
  1238. )t1
  1239. LEFT JOIN
  1240. (
  1241. SELECT
  1242. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1243. IFNULL(SUM(regimental_promotion_amount),0) AS 'regimentalPromotionAmount',
  1244. COUNT(oid) as 'orderCount'
  1245. FROM kuaishou_supply_chain t1
  1246. WHERE order_status != 80
  1247. <if test='itemIds != null and itemIds.size() > 0'>
  1248. AND item_id in
  1249. <foreach collection="itemIds" item="item" separator=","
  1250. open="(" close=")">
  1251. #{item}
  1252. </foreach>
  1253. </if>
  1254. AND order_create_time >= #{toStartLong}
  1255. AND order_create_time &lt;= #{endLong}
  1256. )t2 ON 1=1
  1257. </select>
  1258. <select id="bdReportList" resultType="com.alibaba.fastjson.JSONObject">
  1259. select
  1260. t1.collectSampleId,
  1261. t1.collectSampleName,
  1262. t2.promoterCount,
  1263. t3.sampleCount,
  1264. round(t3.sampleCount / t2.promoterCount * 100, 2) as 'sampleRate',
  1265. t2.promoterCount - t3.sampleCount as 'notSampleCount',
  1266. t1.orderNum,
  1267. t1.validOrderNum,
  1268. t1.validOrderRate,
  1269. t1.orderAmount,
  1270. t1.regimentalPromotionAmount,
  1271. t1.totalRegimentalSettleAmount,
  1272. t4.sendTotalCount,
  1273. t4.sendPromoterCount,
  1274. t4.sendItemCount,
  1275. t1.voucherOrderNum,
  1276. t1.voucherValidOrderNum,
  1277. t1.voucherOrderAmount,
  1278. t1.voucherRegimentalPromotionAmount,
  1279. t1.voucherTotalRegimentalSettleAmount,
  1280. IFNULL(t5.promoters_count,'-') as 'promotersCount'
  1281. from (
  1282. select collect_sample_id as 'collectSampleId',
  1283. collect_sample_name as 'collectSampleName',
  1284. sum(order_num) as 'orderNum',
  1285. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_num ELSE 0 END), 0) AS 'voucherOrderNum',
  1286. sum(valid_order_num) as 'validOrderNum',
  1287. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN valid_order_num ELSE 0 END), 0) AS 'voucherValidOrderNum',
  1288. round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
  1289. sum(order_amount) as 'orderAmount',
  1290. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_amount ELSE 0 END), 0) AS 'voucherOrderAmount',
  1291. sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
  1292. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN regimental_promotion_amount ELSE 0 END), 0)
  1293. AS'voucherRegimentalPromotionAmount',
  1294. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount',
  1295. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN total_regimental_settle_amount ELSE 0 END), 0) AS
  1296. 'voucherTotalRegimentalSettleAmount'
  1297. from ruixuan.canal_management
  1298. where 1 = 1
  1299. <if test="start != null and start != ''">
  1300. and stat_date &gt;= #{start}
  1301. </if>
  1302. <if test="end != null and end != ''">
  1303. and stat_date &lt;= #{end}
  1304. </if>
  1305. <if test="collectSampleId != null and collectSampleId != ''">
  1306. and collect_sample_id = #{collectSampleId}
  1307. </if>
  1308. group by collect_sample_id) t1
  1309. left join (
  1310. select user_id as 'userId',
  1311. count(distinct promoter_id) as 'promoterCount'
  1312. from kuaishou_promoter
  1313. group by user_id) t2
  1314. on t1.collectSampleId = t2.userId
  1315. left join (
  1316. select collect_sample_id as 'collectSampleId',
  1317. count(distinct promoter_id) as 'sampleCount'
  1318. from kuaishou_item_collect_samples
  1319. where collect_sample_status > 2
  1320. group by collect_sample_id) t3
  1321. on t2.userId = t3.collectSampleId
  1322. left join (
  1323. select collect_sample_id as 'collectSampleId',
  1324. count(1) as 'sendTotalCount',
  1325. count(distinct promoter_id) as 'sendPromoterCount',
  1326. count(distinct item_id) as 'sendItemCount'
  1327. from kuaishou_item_collect_samples
  1328. where collect_sample_status > 2
  1329. <if test="collectSampleId != null and collectSampleId != ''">
  1330. and collect_sample_id = #{collectSampleId}
  1331. </if>
  1332. <if test="start != null and start != ''">
  1333. and create_time &gt;= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
  1334. %H:%i:%s')
  1335. </if>
  1336. <if test="end != null and end != ''">
  1337. and create_time &lt;= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
  1338. </if>
  1339. group by collect_sample_id
  1340. ) t4
  1341. on t1.collectSampleId = t4.collectSampleId
  1342. left join (
  1343. select user_id,promoters_count
  1344. from user_promoters_count
  1345. where media_id = 2
  1346. ) t5
  1347. on t1.collectSampleId = t5.user_id
  1348. order by t1.orderNum desc
  1349. </select>
  1350. <select id="bdDetailList" resultType="com.alibaba.fastjson.JSONObject">
  1351. select
  1352. t1.promoterId,
  1353. t1.promoterName,
  1354. t1.promoterUrl,
  1355. t2.sampleCount,
  1356. t1.orderNum,
  1357. t1.validOrderNum,
  1358. t1.validOrderRate,
  1359. t1.orderAmount,
  1360. t1.regimentalPromotionAmount,
  1361. t1.totalRegimentalSettleAmount
  1362. from (
  1363. select promoter_id as 'promoterId',
  1364. promoter_name as 'promoterName',
  1365. promoter_url as 'promoterUrl',
  1366. sum(order_num) as 'orderNum',
  1367. sum(valid_order_num) as 'validOrderNum',
  1368. round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
  1369. sum(order_amount) as 'orderAmount',
  1370. sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
  1371. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
  1372. from ruixuan.canal_management
  1373. where 1 = 1
  1374. <if test="start != null and start != ''">
  1375. and stat_date &gt;= #{start}
  1376. </if>
  1377. <if test="end != null and end != ''">
  1378. and stat_date &lt;= #{end}
  1379. </if>
  1380. <if test="collectSampleId != null and collectSampleId != ''">
  1381. and collect_sample_id = #{collectSampleId}
  1382. </if>
  1383. group by promoter_id) t1
  1384. left join (
  1385. select promoter_id as 'promoterId',
  1386. count(distinct item_id) as 'sampleCount'
  1387. from kuaishou_item_collect_samples
  1388. where collect_sample_status > 2
  1389. <if test="collectSampleId != null and collectSampleId != ''">
  1390. and collect_sample_id = #{collectSampleId}
  1391. </if>
  1392. group by promoter_id) t2
  1393. on t1.promoterId = t2.promoterId
  1394. order by ${fieId} ${sort}
  1395. </select>
  1396. <select id="bdTotal" resultType="com.alibaba.fastjson.JSONObject">
  1397. select
  1398. t2.sampleCount,
  1399. t1.orderNum,
  1400. t1.validOrderNum,
  1401. t1.validOrderRate,
  1402. t1.orderAmount,
  1403. t1.regimentalPromotionAmount,
  1404. t1.totalRegimentalSettleAmount
  1405. from (
  1406. select
  1407. sum(order_num) as 'orderNum',
  1408. sum(valid_order_num) as 'validOrderNum',
  1409. round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
  1410. sum(order_amount) as 'orderAmount',
  1411. sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
  1412. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
  1413. from ruixuan.canal_management
  1414. where 1 = 1
  1415. <if test="start != null and start != ''">
  1416. and stat_date &gt;= #{start}
  1417. </if>
  1418. <if test="end != null and end != ''">
  1419. and stat_date &lt;= #{end}
  1420. </if>
  1421. <if test="collectSampleId != null and collectSampleId != ''">
  1422. and collect_sample_id = #{collectSampleId}
  1423. </if>
  1424. ) t1
  1425. join (
  1426. select
  1427. count(distinct item_id) as 'sampleCount'
  1428. from kuaishou_item_collect_samples
  1429. where collect_sample_status > 2
  1430. <if test="collectSampleId != null and collectSampleId != ''">
  1431. and collect_sample_id = #{collectSampleId}
  1432. </if>
  1433. ) t2
  1434. </select>
  1435. <select id="exportBdDetail" resultType="com.alibaba.fastjson.JSONObject">
  1436. select
  1437. t1.promoterId,
  1438. t1.promoterName,
  1439. t1.promoterUrl,
  1440. t2.sampleCount,
  1441. t1.orderNum,
  1442. t1.validOrderNum,
  1443. t1.validOrderRate,
  1444. t1.orderAmount,
  1445. t1.regimentalPromotionAmount,
  1446. t1.totalRegimentalSettleAmount
  1447. from (
  1448. select promoter_id as 'promoterId',
  1449. promoter_name as 'promoterName',
  1450. promoter_url as 'promoterUrl',
  1451. sum(order_num) as 'orderNum',
  1452. sum(valid_order_num) as 'validOrderNum',
  1453. round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
  1454. sum(order_amount) as 'orderAmount',
  1455. sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
  1456. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount'
  1457. from ruixuan.canal_management
  1458. where 1 = 1
  1459. <if test="start != null and start != ''">
  1460. and stat_date &gt;= #{start}
  1461. </if>
  1462. <if test="end != null and end != ''">
  1463. and stat_date &lt;= #{end}
  1464. </if>
  1465. <if test="collectSampleId != null and collectSampleId != ''">
  1466. and collect_sample_id = #{collectSampleId}
  1467. </if>
  1468. group by promoter_id) t1
  1469. left join (
  1470. select promoter_id as 'promoterId',
  1471. count(distinct item_id) as 'sampleCount'
  1472. from kuaishou_item_collect_samples
  1473. where collect_sample_status > 2
  1474. <if test="collectSampleId != null and collectSampleId != ''">
  1475. and collect_sample_id = #{collectSampleId}
  1476. </if>
  1477. group by promoter_id) t2
  1478. on t1.promoterId = t2.promoterId
  1479. order by t1.orderNum desc
  1480. </select>
  1481. <select id="getUserList" resultType="com.alibaba.fastjson.JSONObject">
  1482. select promoter_id as 'promoterId', group_concat(user_name) as 'userName'
  1483. from kuaishou_promoter where promoter_id in
  1484. <foreach collection="map.values" item="v" separator="," open="(" close=")">
  1485. ${v}
  1486. </foreach>
  1487. GROUP BY promoter_id
  1488. </select>
  1489. <select id="getUserName" resultType="java.lang.String" parameterType="java.lang.Long">
  1490. select
  1491. group_concat(user_name) as 'userName'
  1492. from kuaishou_promoter
  1493. where promoter_id = #{promoterId}
  1494. </select>
  1495. <select id="exportBdReportList" resultType="com.alibaba.fastjson.JSONObject">
  1496. select
  1497. t1.collectSampleId,
  1498. t1.collectSampleName,
  1499. t2.promoterCount,
  1500. t3.sampleCount,
  1501. round(t3.sampleCount / t2.promoterCount * 100, 2) as 'sampleRate',
  1502. t2.promoterCount - t3.sampleCount as 'notSampleCount',
  1503. t1.orderNum,
  1504. t1.validOrderNum,
  1505. t1.validOrderRate,
  1506. round(t1.orderAmount / 100,2) as 'orderAmount',
  1507. round(t1.regimentalPromotionAmount / 100 ,2 ) as 'regimentalPromotionAmount',
  1508. round(t1.totalRegimentalSettleAmount / 100 , 2) as 'totalRegimentalSettleAmount',
  1509. t4.sendTotalCount,
  1510. t4.sendPromoterCount,
  1511. t4.sendItemCount,
  1512. t1.voucherOrderNum,
  1513. t1.voucherValidOrderNum,
  1514. round(t1.voucherOrderAmount / 100 ,2) as 'voucherOrderAmount',
  1515. round(t1.voucherRegimentalPromotionAmount / 100 ,2) as 'voucherRegimentalPromotionAmount',
  1516. round( t1.voucherTotalRegimentalSettleAmount / 100 , 2) as 'voucherTotalRegimentalSettleAmount'
  1517. from (
  1518. select collect_sample_id as 'collectSampleId',
  1519. collect_sample_name as 'collectSampleName',
  1520. sum(order_num) as 'orderNum',
  1521. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_num ELSE 0 END), 0) AS 'voucherOrderNum',
  1522. sum(valid_order_num) as 'validOrderNum',
  1523. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN valid_order_num ELSE 0 END), 0) AS 'voucherValidOrderNum',
  1524. round(sum(valid_order_num) / sum(order_num) * 100, 2) as 'validOrderRate',
  1525. sum(order_amount) as 'orderAmount',
  1526. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN order_amount ELSE 0 END), 0) AS 'voucherOrderAmount',
  1527. sum(regimental_promotion_amount) as 'regimentalPromotionAmount',
  1528. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN regimental_promotion_amount ELSE 0 END), 0)
  1529. AS'voucherRegimentalPromotionAmount',
  1530. sum(total_regimental_settle_amount) as 'totalRegimentalSettleAmount',
  1531. IFNULL(SUM(CASE WHEN sample_voucher_status = 2 THEN total_regimental_settle_amount ELSE 0 END), 0) AS
  1532. 'voucherTotalRegimentalSettleAmount'
  1533. from ruixuan.canal_management
  1534. where 1 = 1
  1535. <if test="start != null and start != ''">
  1536. and stat_date &gt;= #{start}
  1537. </if>
  1538. <if test="end != null and end != ''">
  1539. and stat_date &lt;= #{end}
  1540. </if>
  1541. <if test="collectSampleId != null and collectSampleId != ''">
  1542. and collect_sample_id = #{collectSampleId}
  1543. </if>
  1544. group by collect_sample_id) t1
  1545. left join (
  1546. select user_id as 'userId',
  1547. count(distinct promoter_id) as 'promoterCount'
  1548. from kuaishou_promoter
  1549. group by user_id) t2
  1550. on t1.collectSampleId = t2.userId
  1551. left join (
  1552. select collect_sample_id as 'collectSampleId',
  1553. count(distinct promoter_id) as 'sampleCount'
  1554. from kuaishou_item_collect_samples
  1555. where collect_sample_status > 2
  1556. group by collect_sample_id) t3
  1557. on t2.userId = t3.collectSampleId
  1558. left join (
  1559. select collect_sample_id as 'collectSampleId',
  1560. count(1) as 'sendTotalCount',
  1561. count(distinct promoter_id) as 'sendPromoterCount',
  1562. count(distinct item_id) as 'sendItemCount'
  1563. from kuaishou_item_collect_samples
  1564. where collect_sample_status > 2
  1565. <if test="collectSampleId != null and collectSampleId != ''">
  1566. and collect_sample_id = #{collectSampleId}
  1567. </if>
  1568. <if test="start != null and start != ''">
  1569. and create_time &gt;= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
  1570. %H:%i:%s')
  1571. </if>
  1572. <if test="end != null and end != ''">
  1573. and create_time &lt;= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
  1574. </if>
  1575. group by collect_sample_id
  1576. ) t4
  1577. on t1.collectSampleId = t4.collectSampleId
  1578. order by t1.orderNum desc
  1579. </select>
  1580. <select id="exportAdminReportList" resultType="com.alibaba.fastjson.JSONObject">
  1581. select *
  1582. from (select t1.user_id as 'userId',
  1583. t1.user_name as 'userName',
  1584. count(distinct t2.item_id) as 'itemCount',
  1585. count(t2.oid) as 'orderNum',
  1586. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  1587. round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100,2) as 'validRadio',
  1588. sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  1589. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  1590. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
  1591. when t2.order_status != 80
  1592. then 1
  1593. else 0 end) * 100,
  1594. 2) as 'deliveryRadio',
  1595. sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  1596. round(sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) / 100 , 2) as 'payAmount',
  1597. round(sum(case
  1598. when t2.order_status != 80 then t2.regimental_promotion_amount
  1599. else 0 end) / 100, 2 )as 'regimentalPromotionAmount',
  1600. round(sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100 , 2) as
  1601. 'totalRegimentalSettleAmount'
  1602. from kuaishou_item_bind_user t1
  1603. left join kuaishou_supply_chain t2
  1604. on t1.item_id = t2.item_id
  1605. where 1= 1
  1606. <if test="start != null and start != ''">
  1607. and t2.order_create_time &gt;= #{start}
  1608. </if>
  1609. <if test="end != null and end != ''">
  1610. and t2.order_create_time &lt;= #{end}
  1611. </if>
  1612. group by t1.user_id) t left join (
  1613. select item_create_id,count(1) as 'sendSampleCount' from kuaishou_item_collect_samples
  1614. where courier_number_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  1615. and courier_number_time &lt;= from_unixtime(#{end}/1000,'%Y-%m-%d %H:%i:%s')
  1616. group by item_create_id
  1617. ) t1 on t.userId = t1.item_create_id
  1618. where 1 =1
  1619. <if test="userId != null and userId != ''">
  1620. and t.userId = #{userId}
  1621. </if>
  1622. order by t.orderNum desc
  1623. </select>
  1624. <select id="getSupplyChainCourtshipUserList" resultType="com.alibaba.fastjson.JSONObject">
  1625. select t3.user_id as 'userId', t3.nick_name as 'nickMame', t1.role_name as 'roleName', t3.status
  1626. from sys_role t1
  1627. left join sys_user_role t2 on t1.role_id = t2.role_id
  1628. left join sys_user t3 on t2.user_id = t3.user_id
  1629. where t1.role_key in (
  1630. 'courtship',
  1631. 'courtshipManager'
  1632. )
  1633. group by t3.user_id
  1634. order by t3.create_time asc
  1635. </select>
  1636. <select id="adminReportListByBind" resultType="com.alibaba.fastjson.JSONObject">
  1637. select * from (
  1638. select t1.user_id as 'userId',
  1639. t1.user_name as 'userName',
  1640. count(distinct t1.item_id) as 'itemCount',
  1641. count(t2.oid) as 'orderNum',
  1642. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  1643. round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid), 4) as 'validRadio',
  1644. sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  1645. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  1646. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
  1647. when t2.order_status != 80
  1648. then 1
  1649. else 0 end),
  1650. 4) as 'deliveryRadio',
  1651. sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  1652. sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) as 'payAmount',
  1653. sum(case
  1654. when t2.order_status != 80 then t2.regimental_promotion_amount
  1655. else 0 end) as 'regimentalPromotionAmount',
  1656. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  1657. 'totalRegimentalSettleAmount'
  1658. from kuaishou_item_list t1
  1659. left join (select item_id,
  1660. oid,
  1661. order_status,
  1662. send_status,
  1663. pay_amount,
  1664. regimental_promotion_amount,
  1665. total_regimental_settle_amount
  1666. from kuaishou_supply_chain
  1667. where order_create_time &gt;= #{start}) t2
  1668. on t1.item_id = t2.item_id
  1669. where t1.create_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  1670. and t1.create_time &lt;= from_unixtime(#{end}/1000,'%Y-%m-%d %H:%i:%s')
  1671. <if test="userId != null and userId != ''">
  1672. and t1.userId = #{userId}
  1673. </if>
  1674. group by t1.user_id ) t left join (
  1675. select t1.user_id,count(distinct courier_number) as 'sendSampleCount' from kuaishou_item_list t1 left join
  1676. kuaishou_item_collect_samples t2
  1677. on t1.item_id = t2.item_id
  1678. where t1.create_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  1679. and t1.create_time &lt;= from_unixtime(#{end}/1000,'%Y-%m-%d %H:%i:%s')
  1680. and t2.courier_number_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  1681. group by t1.user_id
  1682. ) t2 on t.userId = t2.user_id order by t.orderNum desc
  1683. </select>
  1684. <select id="exportAdminReportListByBind" resultType="com.alibaba.fastjson.JSONObject">
  1685. select * from (
  1686. select t1.user_id as 'userId',
  1687. t1.user_name as 'userName',
  1688. count(distinct t1.item_id) as 'itemCount',
  1689. count(t2.oid) as 'orderNum',
  1690. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  1691. round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid) * 100,2) as 'validRadio',
  1692. sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  1693. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  1694. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
  1695. when t2.order_status != 80
  1696. then 1
  1697. else 0 end) * 100,
  1698. 2) as 'deliveryRadio',
  1699. sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  1700. round(sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) / 100 , 2) as 'payAmount',
  1701. round(sum(case
  1702. when t2.order_status != 80 then t2.regimental_promotion_amount
  1703. else 0 end) / 100, 2 )as 'regimentalPromotionAmount',
  1704. round(sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100 , 2) as
  1705. 'totalRegimentalSettleAmount'
  1706. from kuaishou_item_list t1
  1707. left join (select item_id,
  1708. oid,
  1709. order_status,
  1710. send_status,
  1711. pay_amount,
  1712. regimental_promotion_amount,
  1713. total_regimental_settle_amount
  1714. from kuaishou_supply_chain
  1715. where order_create_time &gt;= #{start}) t2
  1716. on t1.item_id = t2.item_id
  1717. where t1.create_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  1718. and t1.create_time &lt;= from_unixtime(#{end}/1000,'%Y-%m-%d %H:%i:%s')
  1719. <if test="userId != null and userId != ''">
  1720. and t1.userId = #{userId}
  1721. </if>
  1722. group by t1.user_id ) t left join (
  1723. select t1.user_id,count(distinct courier_number) as 'sendSampleCount' from kuaishou_item_list t1 left join
  1724. kuaishou_item_collect_samples t2
  1725. on t1.item_id = t2.item_id
  1726. where t1.create_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  1727. and t1.create_time &lt;= from_unixtime(#{end}/1000,'%Y-%m-%d %H:%i:%s')
  1728. and t2.courier_number_time >= from_unixtime(#{start}/1000,'%Y-%m-%d %H:%i:%s')
  1729. group by t1.user_id
  1730. ) t2 on t.userId = t2.user_id order by t.orderNum desc;
  1731. </select>
  1732. <select id="bdReportListV2" resultType="com.alibaba.fastjson.JSONObject">
  1733. select t.*,
  1734. tt.promoterCount,
  1735. ttt.sampleCount,
  1736. tttt.sendTotalCount,
  1737. tttt.sendPromoterCount,
  1738. tttt.sendItemCount,
  1739. IFNULL( ttttt.promoters_count,'-') as 'promotersCount',
  1740. round(ttt.sampleCount / tt.promoterCount * 100, 2) as 'sampleRate',
  1741. tt.promoterCount - ttt.sampleCount as 'notSampleCount'
  1742. from (
  1743. select t1.user_id as 'collectSampleId',
  1744. t1.user_name as 'collectSampleName',
  1745. sum(t2.order_num) as 'orderNum',
  1746. sum(t2.valid_order_num) as 'validOrderNum',
  1747. concat(round(sum(t2.valid_order_num) / sum(t2.order_num) * 100, 2), '%') as 'validOrderRate',
  1748. round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
  1749. round(sum(t2.regimental_promotion_amount) / 100, 2) as 'regimentalPromotionAmount',
  1750. round(sum(t2.total_regimental_settle_amount) / 100, 2) as 'totalRegimentalSettleAmount'
  1751. from promoter_bind_channel_date t1
  1752. left join canal_management t2
  1753. on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
  1754. where 1 = 1
  1755. <if test="start != null and start != ''">
  1756. and t1.stat_date &gt;= #{start}
  1757. </if>
  1758. <if test="end != null and end != ''">
  1759. and t1.stat_date &lt;= #{end}
  1760. </if>
  1761. <if test="collectSampleId != null and collectSampleId != ''">
  1762. and t1.user_id = #{collectSampleId}
  1763. </if>
  1764. group by t1.user_id) t
  1765. left join (select user_id,
  1766. count(distinct promoter_id) as 'promoterCount'
  1767. from kuaishou_promoter
  1768. group by user_id) tt on t.collectSampleId = tt.user_id
  1769. left join (select collect_sample_id as 'user_id',
  1770. count(distinct promoter_id) as 'sampleCount'
  1771. from kuaishou_item_collect_samples
  1772. where collect_sample_status > 2
  1773. group by collect_sample_id) ttt on t.collectSampleId = ttt.user_id
  1774. left join (select collect_sample_id as 'user_id',
  1775. count(1) as 'sendTotalCount',
  1776. count(distinct promoter_id) as 'sendPromoterCount',
  1777. count(distinct item_id) as 'sendItemCount'
  1778. from kuaishou_item_collect_samples
  1779. where collect_sample_status > 2
  1780. <if test="collectSampleId != null and collectSampleId != ''">
  1781. and collect_sample_id = #{collectSampleId}
  1782. </if>
  1783. <if test="start != null and start != ''">
  1784. and create_time &gt;= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
  1785. %H:%i:%s')
  1786. </if>
  1787. <if test="end != null and end != ''">
  1788. and create_time &lt;= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
  1789. </if>
  1790. group by collect_sample_id) tttt on t.collectSampleId = tttt.user_id
  1791. left join (select user_id, promoters_count
  1792. from user_promoters_count
  1793. where media_id = 2) ttttt
  1794. on t.collectSampleId = ttttt.user_id
  1795. order by t.orderNum desc
  1796. </select>
  1797. <select id="bdTotalV2" resultType="com.alibaba.fastjson.JSONObject">
  1798. select t.*,tt.sampleCount
  1799. from (select t1.user_id as 'collectSampleId',
  1800. t1.user_name as 'collectSampleName',
  1801. sum(t2.order_num) as 'orderNum',
  1802. sum(t2.valid_order_num) as 'validOrderNum',
  1803. concat(round(sum(t2.valid_order_num) / sum(t2.order_num) * 100, 2), '%') as 'validOrderRate',
  1804. round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
  1805. round(sum(t2.regimental_promotion_amount) / 100, 2) as 'regimentalPromotionAmount',
  1806. round(sum(t2.total_regimental_settle_amount) / 100, 2) as 'totalRegimentalSettleAmount'
  1807. from promoter_bind_channel_date t1
  1808. left join canal_management t2
  1809. on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
  1810. where 1 = 1
  1811. <if test="start != null and start != '' ">
  1812. and t1.stat_date &gt;= #{start}
  1813. </if>
  1814. <if test="end != null and end != ''">
  1815. and t1.stat_date &lt;= #{end}
  1816. </if>
  1817. <if test="collectSampleId != null and collectSampleId != ''">
  1818. and t1.user_id = #{collectSampleId}
  1819. </if>
  1820. group by t1.user_id) t
  1821. join (select count(distinct item_id) as 'sampleCount'
  1822. from kuaishou_item_collect_samples
  1823. where collect_sample_status > 2
  1824. and collect_sample_id = #{collectSampleId} ) tt
  1825. </select>
  1826. <select id="bdDetailListV2" resultType="com.alibaba.fastjson.JSONObject">
  1827. select t.*, tt.sampleCount
  1828. from (select t1.promoter_id as 'promoterId',
  1829. t1.promoter_name as 'promoterName',
  1830. t1.promoter_url as 'promoterUrl',
  1831. sum(t2.order_num) as 'orderNum',
  1832. sum(t2.valid_order_num) as 'validOrderNum',
  1833. concat(round(sum(t2.valid_order_num) / sum(t2.order_num) * 100, 2), '%') as 'validOrderRate',
  1834. round(sum(t2.order_amount) / 100, 2) as 'orderAmount',
  1835. round(sum(t2.regimental_promotion_amount) / 100, 2) as 'regimentalPromotionAmount',
  1836. round(sum(t2.total_regimental_settle_amount) / 100, 2) as 'totalRegimentalSettleAmount'
  1837. from promoter_bind_channel_date t1
  1838. left join canal_management t2
  1839. on t1.promoter_id = t2.promoter_id and t1.stat_date = t2.stat_date
  1840. where 1 = 1
  1841. <if test="start != null and start != '' ">
  1842. and t1.stat_date &gt;= #{start}
  1843. </if>
  1844. <if test="end != null and end != ''">
  1845. and t1.stat_date &lt;= #{end}
  1846. </if>
  1847. <if test="collectSampleId != null and collectSampleId != ''">
  1848. and t1.user_id = #{collectSampleId}
  1849. </if>
  1850. group by t1.promoter_id) t
  1851. left join (select promoter_id,
  1852. count(distinct item_id) as 'sampleCount'
  1853. from kuaishou_item_collect_samples
  1854. where collect_sample_status > 2
  1855. and collect_sample_id = #{collectSampleId}
  1856. group by promoter_id) tt on t.promoterId = tt.promoter_id
  1857. where t.orderNum > 0
  1858. order by ${fieId} ${sort}
  1859. </select>
  1860. </mapper>