SupplyChainMapper.xml 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  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
  8. kuaishou_item_bind_user(item_id,user_id,user_name)
  9. value
  10. (#{itemId},#{userId},#{nikeName})
  11. </insert>
  12. <delete id="unbindUser" parameterType="java.lang.Long">
  13. delete from kuaishou_item_bind_user where item_id = #{itemId}
  14. </delete>
  15. <select id="getOrderList" resultType="com.alibaba.fastjson.JSONObject">
  16. select *
  17. from (
  18. select promoter_id as 'promoterId',
  19. promoter_nick_name as 'promoterNickName',
  20. count(oid) as 'orderNum',
  21. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  22. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  23. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  24. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  25. then 1 else 0 end),4) as 'deliveryRadio'
  26. from kuaishou_supply_chain
  27. where 1= 1
  28. <if test="start != null and start != ''">
  29. and order_create_time &gt;= #{start}
  30. </if>
  31. <if test="end != null and end != ''">
  32. and order_create_time &lt;= #{end}
  33. </if>
  34. <if test="promoterId != null and promoterId != ''">
  35. and promoter_id = #{promoterId}
  36. </if>
  37. <if test="promoterNickName != null and promoterNickName != ''">
  38. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  39. </if>
  40. group by promoter_id) t
  41. order by t.orderNum desc
  42. </select>
  43. <select id="getTopOrders" resultType="com.alibaba.fastjson.JSONObject">
  44. select *
  45. from
  46. (select item_id as 'itemId',
  47. item_title as 'itemTitle',
  48. image_url as 'imageUrl',
  49. count(oid) as 'orderNum'
  50. from kuaishou_supply_chain
  51. where promoter_id = #{promoterId}
  52. <if test="start != null and start != ''">
  53. and order_create_time &gt;= #{start}
  54. </if>
  55. <if test="end != null and end != ''">
  56. and order_create_time &lt;= #{end}
  57. </if>
  58. group by item_id) t
  59. order by t.orderNum desc limit 3
  60. </select>
  61. <select id="anchorOrderDetail" resultType="com.alibaba.fastjson.JSONObject">
  62. select *
  63. from (select
  64. item_title as 'itemTitle',
  65. item_id as 'itemId',
  66. reserve_price as 'reservePrice',
  67. image_url 'imageUrl',
  68. count(oid) as 'orderNum',
  69. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  70. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  71. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  72. regimental_promotion_rate as 'regimentalPromotionRate',
  73. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  74. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  75. then 1 else 0 end),4) as 'deliveryRadio'
  76. from kuaishou_supply_chain
  77. where 1= 1
  78. <if test="promoterId != null and promoterId != ''">
  79. and promoter_id = #{promoterId}
  80. </if>
  81. <if test="start != null and start != ''">
  82. and order_create_time &gt;= #{start}
  83. </if>
  84. <if test="end != null and end != ''">
  85. and order_create_time &lt;= #{end}
  86. </if>
  87. <if test="itemId != null and itemId != ''">
  88. and item_id = #{itemId}
  89. </if>
  90. <if test="itemTitle != null and itemTitle != ''">
  91. and item_title like concat(concat('%',#{itemTitle}),'%')
  92. </if>
  93. group by item_id) t
  94. order by t.orderNum desc
  95. </select>
  96. <select id="orderStatistics" resultType="com.alibaba.fastjson.JSONObject">
  97. select FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') as 'date',
  98. count(t.oid) as 'orderNum'
  99. from (select oid,
  100. order_create_time
  101. from kuaishou_supply_chain
  102. where 1 = 1
  103. <if test="promoterId != null and promoterId != ''">
  104. and promoter_id = #{promoterId}
  105. </if>
  106. <if test="start != null and start != ''">
  107. and order_create_time &gt;= #{start}
  108. </if>
  109. <if test="end != null and end != ''">
  110. and order_create_time &lt;= #{end}
  111. </if>
  112. ) t
  113. group by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d')
  114. order by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') asc
  115. </select>
  116. <select id="itemList" resultType="com.alibaba.fastjson.JSONObject">
  117. select *
  118. from (
  119. select
  120. item_id as 'itemId',
  121. reserve_price as 'reservePrice',
  122. item_title as 'itemTitle',
  123. image_url as 'imageUrl',
  124. count(oid) as 'orderNum',
  125. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  126. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  127. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  128. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  129. then 1 else 0 end),4) as 'deliveryRadio'
  130. from kuaishou_supply_chain
  131. where 1= 1
  132. <if test="start != null and start != ''">
  133. and order_create_time &gt;= #{start}
  134. </if>
  135. <if test="end != null and end != ''">
  136. and order_create_time &lt;= #{end}
  137. </if>
  138. <if test="itemId != null and itemId != ''">
  139. and item_id = #{itemId}
  140. </if>
  141. <if test="itemTitle != null and itemTitle != ''">
  142. and item_title like concat(concat('%',#{itemTitle}),'%')
  143. </if>
  144. group by item_id) t
  145. order by ${fieId} ${sort}
  146. </select>
  147. <select id="getTopPromoterByItemId" resultType="com.alibaba.fastjson.JSONObject">
  148. select
  149. *
  150. from
  151. (select promoter_id as 'promoterId',
  152. promoter_nick_name as 'promoterNickName',
  153. count(oid) as 'orderNum'
  154. from kuaishou_supply_chain
  155. where item_id = #{itemId}
  156. <if test="start != null and start != ''">
  157. and order_create_time &gt;= #{start}
  158. </if>
  159. <if test="end != null and end != ''">
  160. and order_create_time &lt;= #{end}
  161. </if>
  162. group by promoter_id) t
  163. order by t.orderNum desc limit 3
  164. </select>
  165. <select id="itemDetail" resultType="com.alibaba.fastjson.JSONObject">
  166. select *
  167. from (
  168. select
  169. promoter_nick_name as 'promoterNickName',
  170. promoter_id as 'promoterId',
  171. count(oid) as 'orderNum',
  172. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  173. regimental_promotion_rate as 'regimentalPromotionRate',
  174. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  175. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  176. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  177. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  178. then 1 else 0 end),4) as 'deliveryRadio'
  179. from kuaishou_supply_chain
  180. where 1= 1
  181. <if test="itemId != null and itemId != ''">
  182. and item_id = #{itemId}
  183. </if>
  184. <if test="start != null and start != ''">
  185. and order_create_time &gt;= #{start}
  186. </if>
  187. <if test="end != null and end != ''">
  188. and order_create_time &lt;= #{end}
  189. </if>
  190. <if test="promoterId != null and promoterId != ''">
  191. and promoter_id = #{promoterId}
  192. </if>
  193. <if test="promoterNickName != null and promoterNickName != ''">
  194. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  195. </if>
  196. group by promoter_id) t
  197. order by t.orderNum desc
  198. </select>
  199. <select id="itemServiceCharge" resultType="com.alibaba.fastjson.JSONObject">
  200. select *
  201. from (
  202. select
  203. item_id as 'itemId',
  204. item_title as 'itemTitle',
  205. image_url as 'imageUrl',
  206. count(oid) as 'orderNum',
  207. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  208. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  209. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  210. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  211. then 1 else 0 end),4) as 'deliveryRadio',
  212. sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  213. regimental_promotion_rate as 'regimentalPromotionRate',
  214. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  215. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount'
  216. from kuaishou_supply_chain
  217. where 1= 1
  218. <if test="start != null and start != ''">
  219. and order_create_time &gt;= #{start}
  220. </if>
  221. <if test="end != null and end != ''">
  222. and order_create_time &lt;= #{end}
  223. </if>
  224. <if test="itemId != null and itemId != ''">
  225. and item_id = #{itemId}
  226. </if>
  227. <if test="itemTitle != null and itemTitle != ''">
  228. and item_title like concat(concat('%',#{itemTitle}),'%')
  229. </if>
  230. group by item_id) t
  231. order by t.orderNum desc
  232. </select>
  233. <select id="getOrderTotal" resultType="com.alibaba.fastjson.JSONObject">
  234. select
  235. count(oid) as 'orderNum',
  236. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  237. sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm'
  238. from kuaishou_supply_chain
  239. where 1= 1
  240. <if test="start != null and start != ''">
  241. and order_create_time &gt;= #{start}
  242. </if>
  243. <if test="end != null and end != ''">
  244. and order_create_time &lt;= #{end}
  245. </if>
  246. </select>
  247. <select id="getOrderTotalRatio" resultType="java.lang.Double">
  248. select
  249. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio'
  250. from (select count(oid) as 'oid'
  251. from kuaishou_supply_chain
  252. where 1= 1
  253. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  254. and order_create_time &gt;= #{nowStartHourTemp}
  255. </if>
  256. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  257. and order_create_time &lt;= #{nowEndHourTemp}
  258. </if>
  259. ) t1
  260. join (select count(oid) as 'oid'
  261. from kuaishou_supply_chain
  262. where 1=1
  263. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  264. and order_create_time &gt;= #{yesterdayStartHourTemp}
  265. </if>
  266. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  267. and order_create_time &lt;= #{yesterdayEndHourTemp}
  268. </if>
  269. ) t2
  270. </select>
  271. <select id="getAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  272. select
  273. sum(order_amount) as 'orderAmount',
  274. sum(base_amount) as 'baseAmount',
  275. sum(regimental_promotion_amount) as 'regimentalPromotionAmount'
  276. from kuaishou_supply_chain
  277. where 1= 1
  278. <if test="start != null and start != ''">
  279. and order_create_time &gt;= #{start}
  280. </if>
  281. <if test="end != null and end != ''">
  282. and order_create_time &lt;= #{end}
  283. </if>
  284. </select>
  285. <select id="getAmountTotalRatio" resultType="java.lang.Double">
  286. select
  287. round((t1.payAmount -t2.payAmount) / t2.payAmount , 4) as 'amountTotalRatio'
  288. from (select sum(pay_amount) as 'payAmount'
  289. from kuaishou_supply_chain
  290. where 1= 1
  291. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  292. and order_create_time &gt;= #{nowStartHourTemp}
  293. </if>
  294. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  295. and order_create_time &lt;= #{nowEndHourTemp}
  296. </if>
  297. ) t1
  298. join (select sum(pay_amount) as 'payAmount'
  299. from kuaishou_supply_chain
  300. where 1=1
  301. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  302. and order_create_time &gt;= #{yesterdayStartHourTemp}
  303. </if>
  304. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  305. and order_create_time &lt;= #{yesterdayEndHourTemp}
  306. </if>
  307. ) t2
  308. </select>
  309. <select id="getServiceAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  310. select
  311. count(distinct promoter_id) as 'promoterNum',
  312. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  313. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  314. as 'deliveryRadio'
  315. from kuaishou_supply_chain
  316. where 1= 1
  317. <if test="start != null and start != ''">
  318. and order_create_time &gt;= #{start}
  319. </if>
  320. <if test="end != null and end != ''">
  321. and order_create_time &lt;= #{end}
  322. </if>
  323. </select>
  324. <select id="getOrderRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  325. select
  326. t1.*,
  327. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  328. from (select
  329. item_id as 'itemId',
  330. item_title as 'itemTitle',
  331. image_url as 'imageUrl',
  332. count(oid) as 'orderNum',
  333. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  334. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  335. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  336. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  337. as 'deliveryRadio'
  338. from kuaishou_supply_chain
  339. where 1= 1
  340. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  341. and order_create_time &gt;= #{nowStartHourTemp}
  342. </if>
  343. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  344. and order_create_time &lt;= #{nowEndHourTemp}
  345. </if>
  346. group by item_id
  347. ) t1
  348. left join (select
  349. item_id as 'itemId',
  350. count(oid) as 'orderNum'
  351. from kuaishou_supply_chain
  352. where 1=1
  353. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  354. and order_create_time &gt;= #{yesterdayStartHourTemp}
  355. </if>
  356. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  357. and order_create_time &lt;= #{yesterdayEndHourTemp}
  358. </if>
  359. group by item_id
  360. ) t2 on t1.itemId = t2.itemId
  361. order by t1.orderNum desc
  362. </select>
  363. <select id="getOrderRankList" resultType="com.alibaba.fastjson.JSONObject">
  364. select * from (
  365. 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 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  373. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  374. then 1 else 0 end),4) as 'deliveryRadio'
  375. from kuaishou_supply_chain
  376. where 1= 1
  377. <if test="start != null and start != ''">
  378. and order_create_time &gt;= #{start}
  379. </if>
  380. <if test="end != null and end != ''">
  381. and order_create_time &lt;= #{end}
  382. </if>
  383. group by item_id) t
  384. order by t.orderNum desc
  385. </select>
  386. <select id="getPromoterRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  387. select
  388. t1.*,
  389. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  390. from (
  391. select
  392. promoter_id as 'promoterId',
  393. promoter_nick_name as 'promoterNickName',
  394. count(oid) as 'orderNum',
  395. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  396. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  397. from kuaishou_supply_chain
  398. where 1= 1
  399. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  400. and order_create_time &gt;= #{nowStartHourTemp}
  401. </if>
  402. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  403. and order_create_time &lt;= #{nowEndHourTemp}
  404. </if>
  405. group by promoter_id
  406. ) t1
  407. left join (select
  408. promoter_id as 'promoterId',
  409. count(oid) as 'orderNum'
  410. from kuaishou_supply_chain
  411. where 1=1
  412. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  413. and order_create_time &gt;= #{yesterdayStartHourTemp}
  414. </if>
  415. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  416. and order_create_time &lt;= #{yesterdayEndHourTemp}
  417. </if>
  418. group by promoter_id
  419. ) t2 on t1.promoterId = t2.promoterId
  420. order by t1.orderNum desc
  421. </select>
  422. <select id="getPromoterRatioList" resultType="com.alibaba.fastjson.JSONObject">
  423. select * from (
  424. select
  425. promoter_id as 'promoterId',
  426. promoter_nick_name as 'promoterNickName',
  427. count(oid) as 'orderNum',
  428. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  429. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  430. from kuaishou_supply_chain
  431. where 1= 1
  432. <if test="start != null and start != ''">
  433. and order_create_time &gt;= #{start}
  434. </if>
  435. <if test="end != null and end != ''">
  436. and order_create_time &lt;= #{end}
  437. </if>
  438. group by promoter_id) t
  439. order by t.orderNum desc
  440. </select>
  441. <select id="exportPromoterTotal" resultType="com.alibaba.fastjson.JSONObject">
  442. select *
  443. from (
  444. select
  445. promoter_id as 'promoterId',
  446. promoter_nick_name as 'promoterNickName',
  447. count(oid) as 'orderNum',
  448. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  449. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  450. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  451. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  452. then 1 else 0 end) * 100,2) as 'deliveryRadio'
  453. from kuaishou_supply_chain
  454. where 1= 1
  455. <if test="start != null and start != ''">
  456. and order_create_time &gt;= #{start}
  457. </if>
  458. <if test="end != null and end != ''">
  459. and order_create_time &lt;= #{end}
  460. </if>
  461. <if test="promoterId != null and promoterId != ''">
  462. and promoter_id = #{promoterId}
  463. </if>
  464. <if test="promoterNickName != null and promoterNickName != ''">
  465. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  466. </if>
  467. <if test="itemId != null and itemId != ''">
  468. and item_id = #{itemId}
  469. </if>
  470. <if test="itemTitle != null and itemTitle != ''">
  471. and item_title like concat(concat('%',#{itemTitle}),'%')
  472. </if>
  473. group by promoter_id) t
  474. order by t.orderNum desc
  475. </select>
  476. <select id="exportPromoter" resultType="com.alibaba.fastjson.JSONObject">
  477. select *
  478. from (
  479. select
  480. promoter_id as 'promoterId',
  481. promoter_nick_name as 'promoterNickName',
  482. item_id as 'itemId',
  483. item_title as 'itemTitle',
  484. image_url as 'imageUrl',
  485. count(oid) as 'orderNum',
  486. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  487. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  488. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  489. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  490. then 1 else 0 end) * 100,2) as 'deliveryRadio'
  491. from kuaishou_supply_chain
  492. where 1= 1
  493. <if test="start != null and start != ''">
  494. and order_create_time &gt;= #{start}
  495. </if>
  496. <if test="end != null and end != ''">
  497. and order_create_time &lt;= #{end}
  498. </if>
  499. <if test="promoterId != null and promoterId != ''">
  500. and promoter_id = #{promoterId}
  501. </if>
  502. <if test="promoterNickName != null and promoterNickName != ''">
  503. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  504. </if>
  505. <if test="itemId != null and itemId != ''">
  506. and item_id = #{itemId}
  507. </if>
  508. <if test="itemTitle != null and itemTitle != ''">
  509. and item_title like concat(concat('%',#{itemTitle}),'%')
  510. </if>
  511. group by promoter_id,item_id) t
  512. order by t.promoterId,t.orderNum desc
  513. </select>
  514. <select id="exportOrder" resultType="com.alibaba.fastjson.JSONObject">
  515. select *
  516. from (
  517. select
  518. item_id as 'itemId',
  519. item_title as 'itemTitle',
  520. image_url as 'imageUrl',
  521. promoter_id as 'promoterId',
  522. promoter_nick_name as 'promoterNickName',
  523. count(oid) as 'orderNum',
  524. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  525. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  526. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  527. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  528. then 1 else 0 end) * 100,2) as 'deliveryRadio'
  529. from kuaishou_supply_chain
  530. where 1= 1
  531. <if test="start != null and start != ''">
  532. and order_create_time &gt;= #{start}
  533. </if>
  534. <if test="end != null and end != ''">
  535. and order_create_time &lt;= #{end}
  536. </if>
  537. <if test="promoterId != null and promoterId != ''">
  538. and promoter_id = #{promoterId}
  539. </if>
  540. <if test="promoterNickName != null and promoterNickName != ''">
  541. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  542. </if>
  543. <if test="itemId != null and itemId != ''">
  544. and item_id = #{itemId}
  545. </if>
  546. <if test="itemTitle != null and itemTitle != ''">
  547. and item_title like concat(concat('%',#{itemTitle}),'%')
  548. </if>
  549. group by item_id,promoter_id) t
  550. order by t.itemId,t.orderNum desc
  551. </select>
  552. <select id="bindUserItemList" resultType="com.alibaba.fastjson.JSONObject">
  553. select *
  554. from (select t1.item_id as 'itemId',
  555. t1.item_title as 'itemTitle',
  556. t1.reserve_price as 'reservePrice',
  557. t1.image_url as 'imageUrl',
  558. t1.activity_id as 'activityId',
  559. t1.regimental_promotion_rate as 'regimentalPromotionRate',
  560. t2.user_id as 'userId',
  561. case when t2.user_id is null then 1 else 2 end as 'status',
  562. t2.user_name as 'userName',
  563. t2.create_time as 'bindTime'
  564. from kuaishou_item_info t1
  565. left join kuaishou_item_bind_user t2 on t1.item_id = t2.item_id
  566. where 1 = 1
  567. <if test="userId != null and userId != ''">
  568. and t2.user_id = #{userId}
  569. </if>
  570. <if test="itemId != null and itemId != ''">
  571. and t1.item_id = #{itemId}
  572. </if>
  573. <if test="itemTitle != null and itemTitle != ''">
  574. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  575. </if>
  576. <if test="activityId != null and activityId != ''">
  577. and t1.activity_id = #{activityId}
  578. </if>
  579. order by t1.create_time desc) t
  580. where 1 = 1
  581. <if test="status != null and status != ''">
  582. and t.status = #{status}
  583. </if>
  584. </select>
  585. <select id="getSupplyChainUserList" resultType="com.alibaba.fastjson.JSONObject">
  586. select t3.user_id as 'userId',
  587. t3.nick_name as 'nickMame',
  588. t1.role_name as 'roleName',
  589. t3.status
  590. from sys_role t1
  591. left join sys_user_role t2 on t1.role_id = t2.role_id
  592. left join sys_user t3 on t2.user_id = t3.user_id
  593. where t1.role_key in (
  594. 'supplyChain',
  595. 'commodityManagement',
  596. 'supplyChainAdmin'
  597. ) order by t3.create_time asc
  598. </select>
  599. <select id="adminReportList" resultType="com.alibaba.fastjson.JSONObject">
  600. select *
  601. from (select t1.user_id as 'userId',
  602. t1.user_name as 'userName',
  603. count(distinct t2.item_id) as 'itemCount',
  604. count(t2.oid) as 'orderNum',
  605. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  606. round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid),4) as 'validRadio',
  607. sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  608. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
  609. when t2.order_status != 80
  610. then 1
  611. else 0 end),
  612. 4) as 'deliveryRadio',
  613. sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  614. sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) as 'payAmount',
  615. sum(case
  616. when t2.order_status != 80 then t2.regimental_promotion_amount
  617. else 0 end) as 'regimentalPromotionAmount'
  618. from kuaishou_item_bind_user t1
  619. left join kuaishou_supply_chain t2
  620. on t1.item_id = t2.item_id
  621. where 1= 1
  622. <if test="userId != null and userId != ''">
  623. and t1.user_id = #{userId}
  624. </if>
  625. <if test="start != null and start != ''">
  626. and t2.order_create_time &gt;= #{start}
  627. </if>
  628. <if test="end != null and end != ''">
  629. and t2.order_create_time &lt;= #{end}
  630. </if>
  631. group by t1.user_id) t
  632. order by t.orderNum desc
  633. </select>
  634. <select id="userItemDetail" resultType="com.alibaba.fastjson.JSONObject">
  635. SELECT
  636. *
  637. FROM
  638. (
  639. SELECT
  640. t1.user_id,
  641. t1.user_name AS 'userName',
  642. t2.item_id AS 'itemId',
  643. t2.item_title AS 'itemTitle',
  644. t2.image_url AS 'imageUrl',
  645. t2.reserve_price AS 'reservePrice',
  646. count(t2.oid) AS 'orderNum',
  647. sum(
  648. CASE
  649. WHEN t2.order_status != 80 THEN 1
  650. ELSE 0
  651. END
  652. ) AS 'validOrderNUm',
  653. round(
  654. sum(
  655. CASE
  656. WHEN t2.order_status != 80 THEN 1
  657. ELSE 0
  658. END
  659. ) / count(t2.oid),
  660. 4
  661. ) AS 'validRadio',
  662. sum(
  663. CASE
  664. WHEN t2.send_status = 1
  665. AND t2.order_status != 80 THEN 1
  666. ELSE 0
  667. END
  668. ) AS 'deliveryNum',
  669. round(
  670. sum(
  671. CASE
  672. WHEN t2.send_status = 1
  673. AND t2.order_status != 80 THEN 1
  674. ELSE 0
  675. END
  676. ) / sum(
  677. CASE
  678. WHEN t2.order_status != 80 THEN 1
  679. ELSE 0
  680. END
  681. ),
  682. 4
  683. ) AS 'deliveryRadio',
  684. sum(
  685. CASE
  686. WHEN t2.order_status = 80 THEN 1
  687. ELSE 0
  688. END
  689. ) AS 'invalidOrderNUm',
  690. sum(
  691. CASE
  692. WHEN t2.order_status != 80 THEN t2.pay_amount
  693. ELSE 0
  694. END
  695. ) AS 'payAmount',
  696. t2.regimental_promotion_rate AS 'regimentalPromotionRate',
  697. sum(
  698. CASE
  699. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  700. ELSE 0
  701. END
  702. ) AS 'regimentalPromotionAmount'
  703. FROM
  704. kuaishou_item_bind_user t1
  705. LEFT JOIN
  706. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  707. WHERE
  708. 1 = 1
  709. <if test="start != null and start != ''">
  710. and t2.order_create_time &gt;= #{start}
  711. </if>
  712. <if test="end != null and end != ''">
  713. and t2.order_create_time &lt;= #{end}
  714. </if>
  715. <if test="itemId != null and itemId != ''">
  716. and t1.item_id = #{itemId}
  717. </if>
  718. <if test="itemTitle != null and itemTitle != ''">
  719. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  720. </if>
  721. GROUP BY
  722. t1.item_id
  723. ) t
  724. where 1 = 1
  725. <if test="userId != null and userId != ''">
  726. and t.user_id = #{userId}
  727. </if>
  728. order by ${fieId} ${sort}
  729. </select>
  730. <select id="getTimeIntervalRatio" resultType="com.alibaba.fastjson.JSONObject">
  731. select
  732. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio',
  733. round((t1.orderAmount -t2.orderAmount) / t2.orderAmount , 4) as 'orderAmountRatio'
  734. from (
  735. select count(oid) as 'oid',
  736. sum(order_amount) as 'orderAmount'
  737. from kuaishou_supply_chain
  738. where 1= 1
  739. <if test="thisCycleStartTemp != null and thisCycleStartTemp != ''">
  740. and order_create_time &gt;= #{thisCycleStartTemp}
  741. </if>
  742. <if test="thisCycleEndTemp != null and thisCycleEndTemp != ''">
  743. and order_create_time &lt;= #{thisCycleEndTemp}
  744. </if>
  745. ) t1
  746. join (
  747. select count(oid) as 'oid',
  748. sum(order_amount) as 'orderAmount'
  749. from kuaishou_supply_chain
  750. where 1=1
  751. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  752. and order_create_time &gt;= #{lastCycleStartTemp}
  753. </if>
  754. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  755. and order_create_time &lt;= #{lastCycleEndTemp}
  756. </if>
  757. ) t2
  758. </select>
  759. <select id="indexStatistics" resultType="com.alibaba.fastjson.JSONObject">
  760. select FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') as 'date',
  761. <if test="type == 'orderNum' ">
  762. count(t.oid) as 'orderNum'
  763. </if>
  764. <if test="type == 'validOrderNum' ">
  765. sum(case when t.order_status = 80 then 1 else 0 end) as 'validOrderNum'
  766. </if>
  767. <if test="type == 'orderAmount' ">
  768. sum(t.order_amount) as 'orderAmount'
  769. </if>
  770. <if test="type == 'baseAmount' ">
  771. sum(t.base_amount) as 'baseAmount'
  772. </if>
  773. <if test="type == 'deliveryNum' ">
  774. sum(case when t.send_status = 1 and t.order_status != 80 then 1 else 0 end) as 'deliveryNum'
  775. </if>
  776. from (select
  777. oid,
  778. order_status,
  779. order_amount,
  780. base_amount,
  781. send_status,
  782. order_create_time
  783. from kuaishou_supply_chain
  784. where 1 = 1
  785. <if test="startTemp != null and startTemp != ''">
  786. and order_create_time &gt;= #{startTemp}
  787. </if>
  788. <if test="endTemp != null and endTemp != ''">
  789. and order_create_time &lt;= #{endTemp}
  790. </if>
  791. ) t
  792. group by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d')
  793. order by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') asc
  794. </select>
  795. <select id="itemBindSummary" resultType="com.alibaba.fastjson.JSONObject">
  796. select count(t1.item_id) as 'itemTotal',
  797. sum(case when t2.item_id is not null then 1 else 0 end) as 'claimCount',
  798. sum(case when t2.item_id is null then 1 else 0 end) as 'unClaimCount'
  799. from kuaishou_item_info t1
  800. left join kuaishou_item_bind_user t2
  801. on t1.item_id = t2.item_id
  802. where 1=1
  803. </select>
  804. </mapper>