SupplyChainMapper.xml 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260
  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(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  25. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  26. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  27. then 1 else 0 end),4) as 'deliveryRadio'
  28. from kuaishou_supply_chain
  29. where 1= 1
  30. <if test="start != null and start != ''">
  31. and order_create_time &gt;= #{start}
  32. </if>
  33. <if test="end != null and end != ''">
  34. and order_create_time &lt;= #{end}
  35. </if>
  36. <if test="promoterId != null and promoterId != ''">
  37. and promoter_id = #{promoterId}
  38. </if>
  39. <if test="promoterNickName != null and promoterNickName != ''">
  40. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  41. </if>
  42. group by promoter_id) t
  43. order by t.orderNum desc
  44. </select>
  45. <select id="getTopOrders" resultType="com.alibaba.fastjson.JSONObject">
  46. select *
  47. from
  48. (select item_id as 'itemId',
  49. item_title as 'itemTitle',
  50. image_url as 'imageUrl',
  51. count(oid) as 'orderNum'
  52. from kuaishou_supply_chain
  53. where promoter_id = #{promoterId}
  54. <if test="start != null and start != ''">
  55. and order_create_time &gt;= #{start}
  56. </if>
  57. <if test="end != null and end != ''">
  58. and order_create_time &lt;= #{end}
  59. </if>
  60. group by item_id) t
  61. order by t.orderNum desc limit 3
  62. </select>
  63. <select id="anchorOrderDetail" resultType="com.alibaba.fastjson.JSONObject">
  64. select *
  65. from (select
  66. item_title as 'itemTitle',
  67. item_id as 'itemId',
  68. reserve_price as 'reservePrice',
  69. image_url 'imageUrl',
  70. count(oid) as 'orderNum',
  71. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  72. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  73. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  74. regimental_promotion_rate as 'regimentalPromotionRate',
  75. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  76. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  77. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  78. then 1 else 0 end),4) as 'deliveryRadio'
  79. from kuaishou_supply_chain
  80. where 1= 1
  81. <if test="promoterId != null and promoterId != ''">
  82. and promoter_id = #{promoterId}
  83. </if>
  84. <if test="start != null and start != ''">
  85. and order_create_time &gt;= #{start}
  86. </if>
  87. <if test="end != null and end != ''">
  88. and order_create_time &lt;= #{end}
  89. </if>
  90. <if test="itemId != null and itemId != ''">
  91. and item_id = #{itemId}
  92. </if>
  93. <if test="itemTitle != null and itemTitle != ''">
  94. and item_title like concat(concat('%',#{itemTitle}),'%')
  95. </if>
  96. group by item_id) t
  97. order by t.orderNum desc
  98. </select>
  99. <select id="orderStatistics" resultType="com.alibaba.fastjson.JSONObject">
  100. select FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') as 'date',
  101. count(t.oid) as 'orderNum'
  102. from (select oid,
  103. order_create_time
  104. from kuaishou_supply_chain
  105. where 1 = 1
  106. <if test="promoterId != null and promoterId != ''">
  107. and promoter_id = #{promoterId}
  108. </if>
  109. <if test="start != null and start != ''">
  110. and order_create_time &gt;= #{start}
  111. </if>
  112. <if test="end != null and end != ''">
  113. and order_create_time &lt;= #{end}
  114. </if>
  115. ) t
  116. group by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d')
  117. order by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') asc
  118. </select>
  119. <select id="itemList" resultType="com.alibaba.fastjson.JSONObject">
  120. select *
  121. from (select t2.user_id as 'userId',
  122. t2.user_name as 'userName',
  123. t1.item_id as 'itemId',
  124. t1.reserve_price as 'reservePrice',
  125. t1.item_title as 'itemTitle',
  126. t1.image_url as 'imageUrl',
  127. count(t1.oid) as 'orderNum',
  128. sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  129. round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid), 4) as 'validRadio',
  130. sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  131. sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  132. round(sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) / sum(case when
  133. t1.order_status != 80 then 1 else 0 end), 4) as 'deliveryRadio',
  134. t1.item_commission_rate as 'itemCommissionRate'
  135. from kuaishou_supply_chain t1
  136. left join kuaishou_item_bind_user t2
  137. on t1.item_id = t2.item_id
  138. where 1 = 1
  139. <if test="start != null and start != ''">
  140. and t1.order_create_time &gt;= #{start}
  141. </if>
  142. <if test="end != null and end != ''">
  143. and t1.order_create_time &lt;= #{end}
  144. </if>
  145. <if test="itemId != null and itemId != ''">
  146. and t1.item_id = #{itemId}
  147. </if>
  148. <if test="itemTitle != null and itemTitle != ''">
  149. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  150. </if>
  151. group by t1.item_id) t
  152. where 1 = 1
  153. <if test="userId != null and userId != ''">
  154. and t.userId = #{userId}
  155. </if>
  156. order by ${fieId} ${sort}
  157. </select>
  158. <select id="getTopPromoterByItemId" resultType="com.alibaba.fastjson.JSONObject">
  159. select
  160. *
  161. from
  162. (select promoter_id as 'promoterId',
  163. promoter_nick_name as 'promoterNickName',
  164. count(oid) as 'orderNum'
  165. from kuaishou_supply_chain
  166. where item_id = #{itemId}
  167. <if test="start != null and start != ''">
  168. and order_create_time &gt;= #{start}
  169. </if>
  170. <if test="end != null and end != ''">
  171. and order_create_time &lt;= #{end}
  172. </if>
  173. group by promoter_id) t
  174. order by t.orderNum desc limit 3
  175. </select>
  176. <select id="itemDetail" resultType="com.alibaba.fastjson.JSONObject">
  177. select *
  178. from (
  179. select
  180. promoter_nick_name as 'promoterNickName',
  181. promoter_id as 'promoterId',
  182. count(oid) as 'orderNum',
  183. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  184. regimental_promotion_rate as 'regimentalPromotionRate',
  185. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  186. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  187. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  188. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  189. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  190. then 1 else 0 end),4) as 'deliveryRadio'
  191. from kuaishou_supply_chain
  192. where 1= 1
  193. <if test="itemId != null and itemId != ''">
  194. and item_id = #{itemId}
  195. </if>
  196. <if test="start != null and start != ''">
  197. and order_create_time &gt;= #{start}
  198. </if>
  199. <if test="end != null and end != ''">
  200. and order_create_time &lt;= #{end}
  201. </if>
  202. <if test="promoterId != null and promoterId != ''">
  203. and promoter_id = #{promoterId}
  204. </if>
  205. <if test="promoterNickName != null and promoterNickName != ''">
  206. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  207. </if>
  208. group by promoter_id) t
  209. order by t.orderNum desc
  210. </select>
  211. <select id="itemServiceCharge" resultType="com.alibaba.fastjson.JSONObject">
  212. select *
  213. from (
  214. select
  215. item_id as 'itemId',
  216. item_title as 'itemTitle',
  217. image_url as 'imageUrl',
  218. count(oid) as 'orderNum',
  219. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  220. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  221. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  222. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  223. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  224. then 1 else 0 end),4) as 'deliveryRadio',
  225. sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  226. regimental_promotion_rate as 'regimentalPromotionRate',
  227. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  228. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount',
  229. sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
  230. 'totalRegimentalSettleAmount',
  231. item_commission_rate as 'itemCommissionRate'
  232. from kuaishou_supply_chain
  233. where 1= 1
  234. <if test="start != null and start != ''">
  235. and order_create_time &gt;= #{start}
  236. </if>
  237. <if test="end != null and end != ''">
  238. and order_create_time &lt;= #{end}
  239. </if>
  240. <if test="itemId != null and itemId != ''">
  241. and item_id = #{itemId}
  242. </if>
  243. <if test="itemTitle != null and itemTitle != ''">
  244. and item_title like concat(concat('%',#{itemTitle}),'%')
  245. </if>
  246. group by item_id) t
  247. order by t.orderNum desc
  248. </select>
  249. <select id="getOrderTotal" resultType="com.alibaba.fastjson.JSONObject">
  250. select
  251. count(oid) as 'orderNum',
  252. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  253. sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm'
  254. from kuaishou_supply_chain
  255. where 1= 1
  256. <if test="start != null and start != ''">
  257. and order_create_time &gt;= #{start}
  258. </if>
  259. <if test="end != null and end != ''">
  260. and order_create_time &lt;= #{end}
  261. </if>
  262. </select>
  263. <select id="getOrderTotalRatio" resultType="java.lang.Double">
  264. select
  265. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio'
  266. from (select count(oid) as 'oid'
  267. from kuaishou_supply_chain
  268. where 1= 1
  269. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  270. and order_create_time &gt;= #{nowStartHourTemp}
  271. </if>
  272. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  273. and order_create_time &lt;= #{nowEndHourTemp}
  274. </if>
  275. ) t1
  276. join (select count(oid) as 'oid'
  277. from kuaishou_supply_chain
  278. where 1=1
  279. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  280. and order_create_time &gt;= #{yesterdayStartHourTemp}
  281. </if>
  282. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  283. and order_create_time &lt;= #{yesterdayEndHourTemp}
  284. </if>
  285. ) t2
  286. </select>
  287. <select id="getAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  288. select
  289. sum(order_amount) as 'orderAmount',
  290. sum(base_amount) as 'baseAmount',
  291. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount',
  292. sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
  293. 'totalRegimentalSettleAmount'
  294. from kuaishou_supply_chain
  295. where 1= 1
  296. <if test="start != null and start != ''">
  297. and order_create_time &gt;= #{start}
  298. </if>
  299. <if test="end != null and end != ''">
  300. and order_create_time &lt;= #{end}
  301. </if>
  302. </select>
  303. <select id="getAmountTotalRatio" resultType="java.lang.Double">
  304. select
  305. round((t1.payAmount -t2.payAmount) / t2.payAmount , 4) as 'amountTotalRatio'
  306. from (select sum(pay_amount) as 'payAmount'
  307. from kuaishou_supply_chain
  308. where 1= 1
  309. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  310. and order_create_time &gt;= #{nowStartHourTemp}
  311. </if>
  312. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  313. and order_create_time &lt;= #{nowEndHourTemp}
  314. </if>
  315. ) t1
  316. join (select sum(pay_amount) as 'payAmount'
  317. from kuaishou_supply_chain
  318. where 1=1
  319. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  320. and order_create_time &gt;= #{yesterdayStartHourTemp}
  321. </if>
  322. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  323. and order_create_time &lt;= #{yesterdayEndHourTemp}
  324. </if>
  325. ) t2
  326. </select>
  327. <select id="getServiceAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  328. select
  329. count(distinct promoter_id) as 'promoterNum',
  330. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  331. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  332. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  333. as 'deliveryRadio'
  334. from kuaishou_supply_chain
  335. where 1= 1
  336. <if test="start != null and start != ''">
  337. and order_create_time &gt;= #{start}
  338. </if>
  339. <if test="end != null and end != ''">
  340. and order_create_time &lt;= #{end}
  341. </if>
  342. </select>
  343. <select id="getOrderRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  344. select
  345. t1.*,
  346. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  347. from (select
  348. item_id as 'itemId',
  349. item_title as 'itemTitle',
  350. image_url as 'imageUrl',
  351. count(oid) as 'orderNum',
  352. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  353. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  354. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  355. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  356. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  357. as 'deliveryRadio'
  358. from kuaishou_supply_chain
  359. where 1= 1
  360. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  361. and order_create_time &gt;= #{nowStartHourTemp}
  362. </if>
  363. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  364. and order_create_time &lt;= #{nowEndHourTemp}
  365. </if>
  366. group by item_id
  367. ) t1
  368. left join (select
  369. item_id as 'itemId',
  370. count(oid) as 'orderNum'
  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. group by item_id
  380. ) t2 on t1.itemId = t2.itemId
  381. order by t1.orderNum desc
  382. </select>
  383. <select id="getOrderRankList" resultType="com.alibaba.fastjson.JSONObject">
  384. select * from (
  385. select
  386. item_id as 'itemId',
  387. item_title as 'itemTitle',
  388. image_url as 'imageUrl',
  389. count(oid) as 'orderNum',
  390. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  391. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  392. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  393. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  394. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  395. then 1 else 0 end),4) as 'deliveryRadio'
  396. from kuaishou_supply_chain
  397. where 1= 1
  398. <if test="start != null and start != ''">
  399. and order_create_time &gt;= #{start}
  400. </if>
  401. <if test="end != null and end != ''">
  402. and order_create_time &lt;= #{end}
  403. </if>
  404. group by item_id) t
  405. order by t.orderNum desc
  406. </select>
  407. <select id="getPromoterRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  408. select
  409. t1.*,
  410. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  411. from (
  412. select
  413. promoter_id as 'promoterId',
  414. promoter_nick_name as 'promoterNickName',
  415. count(oid) as 'orderNum',
  416. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  417. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  418. from kuaishou_supply_chain
  419. where 1= 1
  420. <if test='promoterIds != null and promoterIds.size() > 0'>
  421. AND promoter_id IN
  422. <foreach collection="promoterIds" item="item" separator=","
  423. open="(" close=")">
  424. #{item}
  425. </foreach>
  426. </if>
  427. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  428. and order_create_time &gt;= #{nowStartHourTemp}
  429. </if>
  430. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  431. and order_create_time &lt;= #{nowEndHourTemp}
  432. </if>
  433. group by promoter_id
  434. ) t1
  435. left join (select
  436. promoter_id as 'promoterId',
  437. count(oid) as 'orderNum'
  438. from kuaishou_supply_chain
  439. where 1=1
  440. <if test='promoterIds != null and promoterIds.size() > 0'>
  441. AND promoter_id IN
  442. <foreach collection="promoterIds" item="item" separator=","
  443. open="(" close=")">
  444. #{item}
  445. </foreach>
  446. </if>
  447. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  448. and order_create_time &gt;= #{yesterdayStartHourTemp}
  449. </if>
  450. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  451. and order_create_time &lt;= #{yesterdayEndHourTemp}
  452. </if>
  453. group by promoter_id
  454. ) t2 on t1.promoterId = t2.promoterId
  455. order by t1.orderNum desc
  456. </select>
  457. <select id="getPromoterRatioList" resultType="com.alibaba.fastjson.JSONObject">
  458. select * from (
  459. select
  460. promoter_id as 'promoterId',
  461. promoter_nick_name as 'promoterNickName',
  462. count(oid) as 'orderNum',
  463. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  464. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  465. from kuaishou_supply_chain
  466. where 1= 1
  467. <if test="start != null and start != ''">
  468. and order_create_time &gt;= #{start}
  469. </if>
  470. <if test="end != null and end != ''">
  471. and order_create_time &lt;= #{end}
  472. </if>
  473. group by promoter_id) t
  474. order by t.orderNum desc
  475. </select>
  476. <select id="exportPromoterTotal" resultType="com.alibaba.fastjson.JSONObject">
  477. select *
  478. from (
  479. select
  480. promoter_id as 'promoterId',
  481. promoter_nick_name as 'promoterNickName',
  482. count(oid) as 'orderNum',
  483. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  484. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  485. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  486. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  487. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  488. then 1 else 0 end) * 100,2) as 'deliveryRadio'
  489. from kuaishou_supply_chain
  490. where 1= 1
  491. <if test="start != null and start != ''">
  492. and order_create_time &gt;= #{start}
  493. </if>
  494. <if test="end != null and end != ''">
  495. and order_create_time &lt;= #{end}
  496. </if>
  497. <if test="promoterId != null and promoterId != ''">
  498. and promoter_id = #{promoterId}
  499. </if>
  500. <if test="promoterNickName != null and promoterNickName != ''">
  501. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  502. </if>
  503. <if test="itemId != null and itemId != ''">
  504. and item_id = #{itemId}
  505. </if>
  506. <if test="itemTitle != null and itemTitle != ''">
  507. and item_title like concat(concat('%',#{itemTitle}),'%')
  508. </if>
  509. group by promoter_id) t
  510. order by t.orderNum desc
  511. </select>
  512. <select id="exportPromoter" resultType="com.alibaba.fastjson.JSONObject">
  513. select *
  514. from (
  515. select
  516. promoter_id as 'promoterId',
  517. promoter_nick_name as 'promoterNickName',
  518. item_id as 'itemId',
  519. item_title as 'itemTitle',
  520. image_url as 'imageUrl',
  521. count(oid) as 'orderNum',
  522. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  523. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  524. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  525. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  526. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  527. then 1 else 0 end) * 100,2) as 'deliveryRadio'
  528. from kuaishou_supply_chain
  529. where 1= 1
  530. <if test="start != null and start != ''">
  531. and order_create_time &gt;= #{start}
  532. </if>
  533. <if test="end != null and end != ''">
  534. and order_create_time &lt;= #{end}
  535. </if>
  536. <if test="promoterId != null and promoterId != ''">
  537. and promoter_id = #{promoterId}
  538. </if>
  539. <if test="promoterNickName != null and promoterNickName != ''">
  540. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  541. </if>
  542. <if test="itemId != null and itemId != ''">
  543. and item_id = #{itemId}
  544. </if>
  545. <if test="itemTitle != null and itemTitle != ''">
  546. and item_title like concat(concat('%',#{itemTitle}),'%')
  547. </if>
  548. group by promoter_id,item_id) t
  549. order by t.promoterId,t.orderNum desc
  550. </select>
  551. <select id="exportOrder" resultType="com.alibaba.fastjson.JSONObject">
  552. select *
  553. from (select
  554. t2.user_id as 'userId',
  555. t2.user_name as 'userName',
  556. t1.item_id as 'itemId',
  557. t1.item_title as 'itemTitle',
  558. t1.image_url as 'imageUrl',
  559. count(t1.oid) as 'orderNum',
  560. sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  561. round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid) * 100, 2) as 'validRadio',
  562. sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  563. sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  564. round(sum(case when t1.send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when t1.order_status
  565. != 80 then 1 else 0 end) * 100, 2) as 'deliveryRadio',
  566. round(t1.item_commission_rate / 10,2) as 'itemCommissionRate'
  567. from kuaishou_supply_chain t1
  568. left join kuaishou_item_bind_user t2
  569. on t1.item_id = t2.item_id
  570. where 1 = 1
  571. <if test="start != null and start != ''">
  572. and t1.order_create_time &gt;= #{start}
  573. </if>
  574. <if test="end != null and end != ''">
  575. and t1.order_create_time &lt;= #{end}
  576. </if>
  577. <if test="promoterId != null and promoterId != ''">
  578. and t1.promoter_id = #{promoterId}
  579. </if>
  580. <if test="promoterNickName != null and promoterNickName != ''">
  581. and t1.promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  582. </if>
  583. <if test="itemId != null and itemId != ''">
  584. and t1.item_id = #{itemId}
  585. </if>
  586. <if test="itemTitle != null and itemTitle != ''">
  587. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  588. </if>
  589. group by t1.item_id) t
  590. where 1 = 1
  591. <if test="userId != null and userId != ''">
  592. and t.userId = #{userId}
  593. </if>
  594. order by t.orderNum desc
  595. </select>
  596. <select id="bindUserItemList" resultType="com.alibaba.fastjson.JSONObject">
  597. select *
  598. from (select t1.item_id as 'itemId',
  599. t1.item_title as 'itemTitle',
  600. t1.reserve_price as 'reservePrice',
  601. t1.image_url as 'imageUrl',
  602. t1.activity_id as 'activityId',
  603. t1.regimental_promotion_rate as 'regimentalPromotionRate',
  604. t2.user_id as 'userId',
  605. case when t2.user_id is null then 1 else 2 end as 'status',
  606. t2.user_name as 'userName',
  607. t2.create_time as 'bindTime',
  608. t1.item_commission_rate as 'itemCommissionRate'
  609. from kuaishou_item_info t1
  610. left join kuaishou_item_bind_user t2 on t1.item_id = t2.item_id
  611. where 1 = 1
  612. <if test="userId != null and userId != ''">
  613. and t2.user_id = #{userId}
  614. </if>
  615. <if test="itemId != null and itemId != ''">
  616. and t1.item_id = #{itemId}
  617. </if>
  618. <if test="itemTitle != null and itemTitle != ''">
  619. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  620. </if>
  621. <if test="activityId != null and activityId != ''">
  622. and t1.activity_id = #{activityId}
  623. </if>
  624. order by t1.create_time desc) t
  625. where 1 = 1
  626. <if test="status != null and status != ''">
  627. and t.status = #{status}
  628. </if>
  629. </select>
  630. <select id="getSupplyChainUserList" resultType="com.alibaba.fastjson.JSONObject">
  631. select t3.user_id as 'userId', t3.nick_name as 'nickMame', t1.role_name as 'roleName', t3.status
  632. from sys_role t1
  633. left join sys_user_role t2 on t1.role_id = t2.role_id
  634. left join sys_user t3 on t2.user_id = t3.user_id
  635. where t1.role_key in (
  636. 'supplyChainAdmin',
  637. 'associationManager',
  638. 'bd',
  639. 'bdManager',
  640. 'association',
  641. 'courtshipManager',
  642. 'courtship'
  643. )
  644. group by t3.user_id
  645. order by t3.create_time asc
  646. </select>
  647. <select id="adminReportList" resultType="com.alibaba.fastjson.JSONObject">
  648. select *
  649. from (select t1.user_id as 'userId',
  650. t1.user_name as 'userName',
  651. count(distinct t2.item_id) as 'itemCount',
  652. count(t2.oid) as 'orderNum',
  653. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  654. round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid),4) as 'validRadio',
  655. sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  656. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  657. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
  658. when t2.order_status != 80
  659. then 1
  660. else 0 end),
  661. 4) as 'deliveryRadio',
  662. sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  663. sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) as 'payAmount',
  664. sum(case
  665. when t2.order_status != 80 then t2.regimental_promotion_amount
  666. else 0 end) as 'regimentalPromotionAmount',
  667. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  668. 'totalRegimentalSettleAmount'
  669. from kuaishou_item_bind_user t1
  670. left join kuaishou_supply_chain t2
  671. on t1.item_id = t2.item_id
  672. where 1= 1
  673. <if test="start != null and start != ''">
  674. and t2.order_create_time &gt;= #{start}
  675. </if>
  676. <if test="end != null and end != ''">
  677. and t2.order_create_time &lt;= #{end}
  678. </if>
  679. group by t1.user_id) t
  680. where 1 =1
  681. <if test="userId != null and userId != ''">
  682. and t.userId = #{userId}
  683. </if>
  684. order by t.orderNum desc
  685. </select>
  686. <select id="userItemDetail" resultType="com.alibaba.fastjson.JSONObject">
  687. SELECT
  688. *
  689. FROM
  690. (
  691. SELECT
  692. t1.user_id,
  693. t1.user_name AS 'userName',
  694. t2.item_id AS 'itemId',
  695. t2.item_title AS 'itemTitle',
  696. t2.image_url AS 'imageUrl',
  697. t2.reserve_price AS 'reservePrice',
  698. count(t2.oid) AS 'orderNum',
  699. sum(
  700. CASE
  701. WHEN t2.order_status != 80 THEN 1
  702. ELSE 0
  703. END
  704. ) AS 'validOrderNUm',
  705. round(
  706. sum(
  707. CASE
  708. WHEN t2.order_status != 80 THEN 1
  709. ELSE 0
  710. END
  711. ) / count(t2.oid),
  712. 4
  713. ) AS 'validRadio',
  714. sum(
  715. CASE
  716. WHEN t2.send_status = 1
  717. AND t2.order_status != 80 THEN 1
  718. ELSE 0
  719. END
  720. ) AS 'deliveryNum',
  721. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  722. round(
  723. sum(
  724. CASE
  725. WHEN t2.send_status = 1
  726. AND t2.order_status != 80 THEN 1
  727. ELSE 0
  728. END
  729. ) / sum(
  730. CASE
  731. WHEN t2.order_status != 80 THEN 1
  732. ELSE 0
  733. END
  734. ),
  735. 4
  736. ) AS 'deliveryRadio',
  737. sum(
  738. CASE
  739. WHEN t2.order_status = 80 THEN 1
  740. ELSE 0
  741. END
  742. ) AS 'invalidOrderNUm',
  743. sum(
  744. CASE
  745. WHEN t2.order_status != 80 THEN t2.pay_amount
  746. ELSE 0
  747. END
  748. ) AS 'payAmount',
  749. t2.regimental_promotion_rate AS 'regimentalPromotionRate',
  750. sum(
  751. CASE
  752. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  753. ELSE 0
  754. END
  755. ) AS 'regimentalPromotionAmount',
  756. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  757. 'totalRegimentalSettleAmount',
  758. t2.item_commission_rate as 'itemCommissionRate'
  759. FROM
  760. kuaishou_item_bind_user t1
  761. LEFT JOIN
  762. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  763. WHERE
  764. 1 = 1
  765. <if test="start != null and start != ''">
  766. and t2.order_create_time &gt;= #{start}
  767. </if>
  768. <if test="end != null and end != ''">
  769. and t2.order_create_time &lt;= #{end}
  770. </if>
  771. <if test="itemId != null and itemId != ''">
  772. and t1.item_id = #{itemId}
  773. </if>
  774. <if test="itemTitle != null and itemTitle != ''">
  775. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  776. </if>
  777. GROUP BY
  778. t1.item_id
  779. ) t
  780. where 1 = 1
  781. <if test="userId != null and userId != ''">
  782. and t.user_id = #{userId}
  783. </if>
  784. order by ${fieId} ${sort}
  785. </select>
  786. <select id="getTimeIntervalRatio" resultType="com.alibaba.fastjson.JSONObject">
  787. select
  788. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio',
  789. round((t1.orderAmount -t2.orderAmount) / t2.orderAmount , 4) as 'orderAmountRatio'
  790. from (
  791. select count(oid) as 'oid',
  792. sum(order_amount) as 'orderAmount'
  793. from kuaishou_supply_chain
  794. where 1= 1
  795. <if test="thisCycleStartTemp != null and thisCycleStartTemp != ''">
  796. and order_create_time &gt;= #{thisCycleStartTemp}
  797. </if>
  798. <if test="thisCycleEndTemp != null and thisCycleEndTemp != ''">
  799. and order_create_time &lt;= #{thisCycleEndTemp}
  800. </if>
  801. ) t1
  802. join (
  803. select count(oid) as 'oid',
  804. sum(order_amount) as 'orderAmount'
  805. from kuaishou_supply_chain
  806. where 1=1
  807. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  808. and order_create_time &gt;= #{lastCycleStartTemp}
  809. </if>
  810. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  811. and order_create_time &lt;= #{lastCycleEndTemp}
  812. </if>
  813. ) t2
  814. </select>
  815. <select id="indexStatistics" resultType="com.alibaba.fastjson.JSONObject">
  816. select FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') as 'date',
  817. <if test="type == 'orderNum' ">
  818. count(t.oid) as 'orderNum'
  819. </if>
  820. <if test="type == 'validOrderNum' ">
  821. sum(case when t.order_status = 80 then 1 else 0 end) as 'validOrderNum'
  822. </if>
  823. <if test="type == 'orderAmount' ">
  824. sum(t.order_amount) as 'orderAmount'
  825. </if>
  826. <if test="type == 'baseAmount' ">
  827. sum(t.base_amount) as 'baseAmount'
  828. </if>
  829. <if test="type == 'deliveryNum' ">
  830. sum(case when t.send_status = 1 and t.order_status != 80 then 1 else 0 end) as 'deliveryNum'
  831. </if>
  832. from (select
  833. oid,
  834. order_status,
  835. order_amount,
  836. base_amount,
  837. send_status,
  838. order_create_time
  839. from kuaishou_supply_chain
  840. where 1 = 1
  841. <if test="startTemp != null and startTemp != ''">
  842. and order_create_time &gt;= #{startTemp}
  843. </if>
  844. <if test="endTemp != null and endTemp != ''">
  845. and order_create_time &lt;= #{endTemp}
  846. </if>
  847. ) t
  848. group by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d')
  849. order by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') asc
  850. </select>
  851. <select id="itemBindSummary" resultType="com.alibaba.fastjson.JSONObject">
  852. 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'
  853. from kuaishou_item_info t1
  854. left join kuaishou_item_bind_user t2
  855. on t1.item_id = t2.item_id
  856. where 1 = 1
  857. </select>
  858. <select id="userItemTotal" resultType="com.alibaba.fastjson.JSONObject">
  859. SELECT count(t2.oid) AS 'orderNum',
  860. sum(
  861. CASE
  862. WHEN t2.order_status != 80 THEN 1
  863. ELSE 0
  864. END
  865. ) AS 'validOrderNUm',
  866. round(
  867. sum(
  868. CASE
  869. WHEN t2.order_status != 80 THEN 1
  870. ELSE 0
  871. END
  872. ) / count(t2.oid),
  873. 4
  874. ) AS 'validRadio',
  875. sum(
  876. CASE
  877. WHEN t2.send_status = 1
  878. AND t2.order_status != 80 THEN 1
  879. ELSE 0
  880. END
  881. ) AS 'deliveryNum',
  882. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  883. round(
  884. sum(
  885. CASE
  886. WHEN t2.send_status = 1
  887. AND t2.order_status != 80 THEN 1
  888. ELSE 0
  889. END
  890. ) / sum(
  891. CASE
  892. WHEN t2.order_status != 80 THEN 1
  893. ELSE 0
  894. END
  895. ),
  896. 4
  897. ) AS 'deliveryRadio',
  898. sum(
  899. CASE
  900. WHEN t2.order_status = 80 THEN 1
  901. ELSE 0
  902. END
  903. ) AS 'invalidOrderNUm',
  904. sum(
  905. CASE
  906. WHEN t2.order_status != 80 THEN t2.pay_amount
  907. ELSE 0
  908. END
  909. ) AS 'payAmount',
  910. sum(
  911. CASE
  912. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  913. ELSE 0
  914. END
  915. ) AS 'regimentalPromotionAmount',
  916. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  917. 'totalRegimentalSettleAmount'
  918. FROM kuaishou_item_bind_user t1
  919. LEFT JOIN
  920. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  921. WHERE 1 = 1
  922. <if test="start != null and start != ''">
  923. and t2.order_create_time &gt;= #{start}
  924. </if>
  925. <if test="end != null and end != ''">
  926. and t2.order_create_time &lt;= #{end}
  927. </if>
  928. <if test="userId != null and userId != ''">
  929. and t1.user_id = #{userId}
  930. </if>
  931. </select>
  932. <select id="exportUserItemDetail" resultType="com.alibaba.fastjson.JSONObject">
  933. SELECT
  934. *
  935. FROM
  936. (
  937. SELECT
  938. t1.user_id as 'user_id',
  939. t1.user_name AS 'userName',
  940. t2.item_id AS 'itemId',
  941. t2.item_title AS 'itemTitle',
  942. t2.image_url AS 'imageUrl',
  943. round(t2.reserve_price / 100,2) AS 'reservePrice',
  944. count(t2.oid) AS 'orderNum',
  945. sum(
  946. CASE
  947. WHEN t2.order_status != 80 THEN 1
  948. ELSE 0
  949. END
  950. ) AS 'validOrderNUm',
  951. round(
  952. sum(
  953. CASE
  954. WHEN t2.order_status != 80 THEN 1
  955. ELSE 0
  956. END
  957. ) / count(t2.oid) * 100,
  958. 2
  959. ) AS 'validRadio',
  960. sum(
  961. CASE
  962. WHEN t2.send_status = 1
  963. AND t2.order_status != 80 THEN 1
  964. ELSE 0
  965. END
  966. ) AS 'deliveryNum',
  967. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  968. round(
  969. sum(
  970. CASE
  971. WHEN t2.send_status = 1
  972. AND t2.order_status != 80 THEN 1
  973. ELSE 0
  974. END
  975. ) / sum(
  976. CASE
  977. WHEN t2.order_status != 80 THEN 1
  978. ELSE 0
  979. END
  980. ) * 100,
  981. 2
  982. ) AS 'deliveryRadio',
  983. sum(
  984. CASE
  985. WHEN t2.order_status = 80 THEN 1
  986. ELSE 0
  987. END
  988. ) AS 'invalidOrderNUm',
  989. round( sum(
  990. CASE
  991. WHEN t2.order_status != 80 THEN t2.pay_amount
  992. ELSE 0
  993. END
  994. )/ 100,2 )AS 'payAmount',
  995. concat(round(t2.regimental_promotion_rate / 10 ,2),'%') AS 'regimentalPromotionRate',
  996. round(
  997. sum(
  998. CASE
  999. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  1000. ELSE 0
  1001. END
  1002. ) / 100 , 2)AS 'regimentalPromotionAmount',
  1003. round(
  1004. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100,2) as
  1005. 'totalRegimentalSettleAmount',
  1006. concat(round(t2.item_commission_rate / 10),'%') as 'itemCommissionRate'
  1007. FROM
  1008. kuaishou_item_bind_user t1
  1009. LEFT JOIN
  1010. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  1011. WHERE
  1012. 1 = 1
  1013. <if test="start != null and start != ''">
  1014. and t2.order_create_time &gt;= #{start}
  1015. </if>
  1016. <if test="end != null and end != ''">
  1017. and t2.order_create_time &lt;= #{end}
  1018. </if>
  1019. <if test="itemId != null and itemId != ''">
  1020. and t1.item_id = #{itemId}
  1021. </if>
  1022. <if test="itemTitle != null and itemTitle != ''">
  1023. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  1024. </if>
  1025. GROUP BY
  1026. t1.item_id
  1027. ) t
  1028. where 1 = 1
  1029. <if test="userId != null and userId != ''">
  1030. and t.user_id = #{userId}
  1031. </if>
  1032. order by t.orderNum desc
  1033. </select>
  1034. <select id="getCookie" resultType="java.lang.String">
  1035. select cookie
  1036. from ruixuan.kuaishou_supply_chain_cookie limit 1
  1037. </select>
  1038. <select id="selectOrderInfo" resultType="com.alibaba.fastjson.JSONObject">
  1039. SELECT COUNT(oid) as 'allNumber', IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS
  1040. 'validOrderNUm', IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END), 0) AS 'orderAmount',
  1041. IFNULL(
  1042. SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),
  1043. 0) AS 'regimentalPromotionAmount', IFNULL(sum(base_amount), 0) as 'baseAmount'
  1044. FROM kuaishou_supply_chain
  1045. WHERE stat_date >= #{startDate}
  1046. AND stat_date &lt;= #{endDate}
  1047. <if test='promoterIds != null and promoterIds.size() > 0'>
  1048. AND promoter_id in
  1049. <foreach collection="promoterIds" item="item" separator=","
  1050. open="(" close=")">
  1051. #{item}
  1052. </foreach>
  1053. </if>
  1054. </select>
  1055. <select id="selectOrderInfoByItemIds" resultType="com.alibaba.fastjson.JSONObject">
  1056. SELECT t.*,
  1057. CONCAT(IFNULL(ROUND(sendCount / allNumber * 100, 2),0), '%') as 'sendRate'
  1058. FROM (SELECT COUNT(oid) as 'allNumber',
  1059. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS
  1060. 'validOrderNUm',
  1061. IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END), 0) AS 'orderAmount',
  1062. IFNULL(
  1063. SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),
  1064. 0) AS 'regimentalPromotionAmount',
  1065. IFNULL(sum(base_amount), 0) as 'baseAmount',
  1066. IFNULL(COUNT(CASE WHEN send_status = 1 THEN oid ELSE null END), 0) AS 'sendCount'
  1067. FROM kuaishou_supply_chain
  1068. WHERE stat_date >= #{startDate}
  1069. AND stat_date &lt;= #{endDate}
  1070. <if test='itemIds != null and itemIds.size() > 0'>
  1071. AND item_id in
  1072. <foreach collection="itemIds" item="item" separator=","
  1073. open="(" close=")">
  1074. #{item}
  1075. </foreach>
  1076. </if>
  1077. ) t
  1078. </select>
  1079. <select id="selectOrderRate" resultType="com.alibaba.fastjson.JSONObject">
  1080. SELECT
  1081. count(oid) as 'allNumber',
  1082. sum(
  1083. CASE
  1084. WHEN order_status != 80 THEN order_amount
  1085. ELSE 0
  1086. END
  1087. ) AS 'orderAmount'
  1088. FROM kuaishou_supply_chain
  1089. WHERE stat_date >= #{statDate}
  1090. AND stat_date &lt;= #{endDate}
  1091. <if test='promoterIds != null and promoterIds.size() > 0'>
  1092. AND promoter_id in
  1093. <foreach collection="promoterIds" item="item" separator=","
  1094. open="(" close=")">
  1095. #{item}
  1096. </foreach>
  1097. </if>
  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. </select>
  1106. <select id="getMonthOrderAmount" resultType="com.alibaba.fastjson.JSONObject">
  1107. SELECT
  1108. FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') as 'date',
  1109. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1110. IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount',
  1111. IFNULL(promoterCount,0) AS 'promoterCount'
  1112. FROM kuaishou_supply_chain t1
  1113. LEFT JOIN (
  1114. SELECT count(promoter_id) as 'promoterCount', DATE_FORMAT(create_time, '%Y-%m-%d') as 'date'
  1115. FROM kuaishou_promoter
  1116. WHERE user_id = #{userId}
  1117. AND DATE_FORMAT(create_time, '%Y-%m-%d') >= #{start}
  1118. AND DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{end}
  1119. GROUP BY DATE_FORMAT(create_time, '%Y-%m-%d')
  1120. ) t2 ON t1.FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') = t2.date
  1121. WHERE order_status != 80
  1122. <if test='promoterIds != null and promoterIds.size() > 0'>
  1123. AND promoter_id in
  1124. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1125. #{item}
  1126. </foreach>
  1127. </if>
  1128. AND order_create_time >= #{startLong}
  1129. AND order_create_time &lt;= #{endLong}
  1130. GROUP BY FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d')
  1131. </select>
  1132. <select id="getMonthOrderAmountByItems" resultType="com.alibaba.fastjson.JSONObject">
  1133. SELECT
  1134. FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') as 'date',
  1135. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1136. IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount',
  1137. count(oid) AS 'orderCount'
  1138. FROM kuaishou_supply_chain
  1139. WHERE order_status != 80
  1140. <if test='itemIds != null and itemIds.size() > 0'>
  1141. AND item_id in
  1142. <foreach collection="itemIds" item="item" separator=","
  1143. open="(" close=")">
  1144. #{item}
  1145. </foreach>
  1146. </if>
  1147. AND order_create_time >= #{startLong}
  1148. AND order_create_time &lt;= #{endLong}
  1149. GROUP BY FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d')
  1150. </select>
  1151. <select id="getMonthOrderAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  1152. SELECT
  1153. t1.orderAmount,
  1154. t1.totalRegimentalSettleAmount,
  1155. CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
  1156. CONCAT(IFNULL(ROUND(t2.totalRegimentalSettleAmount/t1.totalRegimentalSettleAmount*100,2),0),'%') as
  1157. 'totalRegimentalSettleAmountRate'
  1158. FROM
  1159. (
  1160. SELECT
  1161. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1162. IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount'
  1163. FROM kuaishou_supply_chain t1
  1164. WHERE order_status != 80
  1165. <if test='promoterIds != null and promoterIds.size() > 0'>
  1166. AND promoter_id in
  1167. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1168. #{item}
  1169. </foreach>
  1170. </if>
  1171. AND order_create_time >= #{startLong}
  1172. AND order_create_time &lt;= #{endLong}) t1
  1173. LEFT JOIN
  1174. (
  1175. SELECT
  1176. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1177. IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount'
  1178. FROM kuaishou_supply_chain t1
  1179. WHERE order_status != 80
  1180. <if test='promoterIds != null and promoterIds.size() > 0'>
  1181. AND promoter_id in
  1182. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1183. #{item}
  1184. </foreach>
  1185. </if>
  1186. AND order_create_time >= #{toStartLong}
  1187. AND order_create_time &lt;= #{endLong})t2 ON 1=1
  1188. </select>
  1189. <select id="getMonthOrderAmountTotalByItems" resultType="com.alibaba.fastjson.JSONObject">
  1190. SELECT
  1191. t1.orderAmount,
  1192. t1.totalRegimentalSettleAmount,
  1193. t1.orderCount,
  1194. CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
  1195. CONCAT(IFNULL(ROUND(t2.orderCount/t1.orderCount*100,2),0),'%') as 'orderCountRate',
  1196. CONCAT(IFNULL(ROUND(t2.totalRegimentalSettleAmount/t1.totalRegimentalSettleAmount*100,2),0),'%') as
  1197. 'totalRegimentalSettleAmountRate'
  1198. FROM
  1199. (
  1200. SELECT
  1201. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1202. IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount',
  1203. COUNT(oid) as 'orderCount'
  1204. FROM kuaishou_supply_chain t1
  1205. WHERE order_status != 80
  1206. <if test='itemIds != null and itemIds.size() > 0'>
  1207. AND item_id in
  1208. <foreach collection="itemIds" item="item" separator=","
  1209. open="(" close=")">
  1210. #{item}
  1211. </foreach>
  1212. </if>
  1213. AND order_create_time >= #{startLong}
  1214. AND order_create_time &lt;= #{endLong}
  1215. )t1
  1216. LEFT JOIN
  1217. (
  1218. SELECT
  1219. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1220. IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount',
  1221. COUNT(oid) as 'orderCount'
  1222. FROM kuaishou_supply_chain t1
  1223. WHERE order_status != 80
  1224. <if test='itemIds != null and itemIds.size() > 0'>
  1225. AND item_id in
  1226. <foreach collection="itemIds" item="item" separator=","
  1227. open="(" close=")">
  1228. #{item}
  1229. </foreach>
  1230. </if>
  1231. AND order_create_time >= #{toStartLong}
  1232. AND order_create_time &lt;= #{endLong}
  1233. )t2 ON 1=1
  1234. </select>
  1235. </mapper>