JiaoYangReportMapper.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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.jiaoyang.mapper.JiaoYangReportMapper">
  6. <select id="item" resultType="com.alibaba.fastjson.JSONObject">
  7. select t.* from (
  8. select
  9. t1.item_id as 'itemId',
  10. t1.reserve_price as 'reservePrice',
  11. t1.item_title as 'itemTitle',
  12. t1.image_url as 'imageUrl',
  13. count(t1.oid) as 'orderNum',
  14. sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  15. round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid), 4) as 'validRadio',
  16. sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  17. sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  18. round(sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) / sum(case when
  19. t1.order_status != 80 then 1 else 0 end), 4) as 'deliveryRadio',
  20. t1.commission_rate as 'itemCommissionRate'
  21. from jy_order_list t1
  22. where 1 = 1
  23. <if test="start != null and start != ''">
  24. and t1.stat_date &gt;= #{start}
  25. </if>
  26. <if test="end != null and end != ''">
  27. and t1.stat_date &lt;= #{end}
  28. </if>
  29. <if test="itemId != null and itemId != ''">
  30. and t1.item_id = #{itemId}
  31. </if>
  32. <if test="itemTitle != null and itemTitle != ''">
  33. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  34. </if>
  35. group by t1.item_id) t
  36. order by ${fieId} ${sort}
  37. </select>
  38. <select id="itemDetail" resultType="com.alibaba.fastjson.JSONObject">
  39. select t.*,tt.headImg,ttt.type,ttt.user_name as 'userName'
  40. from (
  41. select
  42. clip_nick_name as 'promoterNickName',
  43. clip_user_id as 'promoterId',
  44. count(oid) as 'orderNum',
  45. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  46. regimental_promotion_rate as 'regimentalPromotionRate',
  47. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  48. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  49. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  50. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  51. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  52. then 1 else 0 end),4) as 'deliveryRadio'
  53. from jy_order_list
  54. where 1= 1
  55. <if test="itemId != null and itemId != ''">
  56. and item_id = #{itemId}
  57. </if>
  58. <if test="start != null and start != ''">
  59. and stat_date &gt;= #{start}
  60. </if>
  61. <if test="end != null and end != ''">
  62. and stat_date &lt;= #{end}
  63. </if>
  64. <if test="promoterId != null and promoterId != ''">
  65. and clip_user_id = #{promoterId}
  66. </if>
  67. <if test="promoterNickName != null and promoterNickName != ''">
  68. and clip_nick_name like concat(concat('%',#{promoterNickName}),'%')
  69. </if>
  70. group by clip_user_id) t
  71. left join (select clip_id,head_img as 'headImg' from jy_clip_cooperation ) tt on t.promoterId = tt.clip_id
  72. left join jy_kuaishou_promoter ttt on t.promoterId = ttt.promoter_id
  73. order by t.orderNum desc
  74. </select>
  75. <select id="promoter" resultType="com.alibaba.fastjson.JSONObject">
  76. select t.*,
  77. tt.head_img as 'headImg',
  78. ttt.type as 'type',
  79. ttt.user_name as 'userName'
  80. from (
  81. select clip_user_id as 'promoterId',
  82. clip_nick_name as 'promoterNickName',
  83. count(oid) as 'orderNum',
  84. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  85. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  86. sum(pay_amount) as 'payAmount',
  87. sum(case when order_status != 80 then pay_amount else 0
  88. end) as 'validPayAmount',
  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(
  92. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
  93. when order_status != 80
  94. then 1
  95. else 0 end),
  96. 4) as 'deliveryRadio',
  97. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount'
  98. from jy_order_list
  99. where 1 = 1
  100. <if test="start != null and start != '' ">
  101. and stat_date &gt;= #{start}
  102. </if>
  103. <if test="end != null and end != '' ">
  104. and stat_date &lt;= #{end}
  105. </if>
  106. <if test="promoterId != null and promoterId != '' ">
  107. and clip_user_id = #{promoterId}
  108. </if>
  109. <if test="promoterNickName != null and promoterNickName != '' ">
  110. and clip_nick_name like concat(concat('%',#{promoterNickName}),'%')
  111. </if>
  112. group by clip_user_id) t
  113. left join jy_clip_cooperation tt on t.promoterId = tt.clip_id
  114. left join jy_kuaishou_promoter ttt on t.promoterId = ttt.promoter_id
  115. where 1 = 1
  116. <if test="type != null and type != '' ">
  117. and ttt.type = #{type}
  118. </if>
  119. order by t.orderNum desc
  120. </select>
  121. <select id="anchorOrderDetail" resultType="com.alibaba.fastjson.JSONObject">
  122. select t.*
  123. from (select
  124. item_title as 'itemTitle',
  125. item_id as 'itemId',
  126. reserve_price as 'reservePrice',
  127. image_url 'imageUrl',
  128. count(oid) as 'orderNum',
  129. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  130. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  131. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  132. regimental_promotion_rate as 'regimentalPromotionRate',
  133. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  134. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  135. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  136. then 1 else 0 end),4) as 'deliveryRadio'
  137. from jy_order_list
  138. where 1= 1
  139. <if test="promoterId != null and promoterId != ''">
  140. and clip_user_id = #{promoterId}
  141. </if>
  142. <if test="start != null and start != ''">
  143. and stat_date &gt;= #{start}
  144. </if>
  145. <if test="end != null and end != ''">
  146. and stat_date &lt;= #{end}
  147. </if>
  148. <if test="itemId != null and itemId != ''">
  149. and item_id = #{itemId}
  150. </if>
  151. <if test="itemTitle != null and itemTitle != ''">
  152. and item_title like concat(concat('%',#{itemTitle}),'%')
  153. </if>
  154. group by item_id) t
  155. order by t.orderNum desc
  156. </select>
  157. <select id="promoterStatistics" resultType="com.alibaba.fastjson.JSONObject">
  158. select date_format(t.stat_date, '%Y-%m-%d') as 'date',
  159. count(t.oid) as 'orderNum'
  160. from (select oid,
  161. stat_date
  162. from jy_order_list
  163. where 1 = 1
  164. <if test="promoterId != null and promoterId != ''">
  165. and clip_user_id = #{promoterId}
  166. </if>
  167. <if test="start != null and start != ''">
  168. and stat_date &gt;= #{start}
  169. </if>
  170. <if test="end != null and end != ''">
  171. and stat_date &lt;= #{end}
  172. </if>
  173. ) t
  174. group by t.stat_date
  175. order by t.stat_date asc
  176. </select>
  177. <select id="getClipCooperation" resultType="com.alibaba.fastjson.JSONObject">
  178. select t1.*,
  179. ifnull(t2.videoCount30d,0) as 'frontVideoCount30d',
  180. ifnull(t1.videoCount30d - t2.videoCount30d,0) as 'groundingCount'
  181. from (select clip_id as 'clipId',
  182. clip_name as 'clipName',
  183. head_img as 'headImg',
  184. fans_num as 'fansNum',
  185. gmv_30d as 'gmv30d',
  186. start_time as 'startTime',
  187. end_time as 'endTime',
  188. (case when status = 1
  189. then '上架'
  190. when status = 3
  191. then '已结束'
  192. when status = 2
  193. then '待确认'
  194. else '-'
  195. end
  196. ) as 'status',
  197. termination_reason as 'terminationReason',
  198. concat(commission_rate_view,'%') as 'commissionRateView',
  199. shop_score as 'shopScore',
  200. clip_gmv_30d as 'clipGmv30d',
  201. auth_item_gmv_30d as 'authItemGmv30d',
  202. video_count_30d as 'videoCount30d',
  203. stat_date as 'statDate'
  204. from jy_clip_cooperation
  205. where stat_date = #{date}) t1
  206. left join (select clip_id as 'clipId',
  207. video_count_30d as 'videoCount30d'
  208. from jy_clip_cooperation
  209. where stat_date = date_format(date_sub(#{date}, interval 1 day), '%Y%m%d')) t2
  210. on t1.clipId = t2.clipId
  211. where 1 = 1
  212. <if test="promoterId != null and promoterId != ''">
  213. and t1.clipId = #{promoterId}
  214. </if>
  215. <if test="promoterName != null and promoterName != ''">
  216. and t1.clipName like concat(concat('%',#{promoterName}),'%')
  217. </if>
  218. </select>
  219. <select id="getOrderTotal" resultType="com.alibaba.fastjson.JSONObject">
  220. select
  221. count(oid) as 'orderNum',
  222. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  223. sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm'
  224. from jy_order_list
  225. where 1= 1
  226. <if test="start != null and start != ''">
  227. and stat_date &gt;= #{start}
  228. </if>
  229. <if test="end != null and end != ''">
  230. and stat_date &lt;= #{end}
  231. </if>
  232. </select>
  233. <select id="getOrderTotalRatio" resultType="java.lang.Double">
  234. select
  235. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio'
  236. from (select count(oid) as 'oid'
  237. from jy_order_list
  238. where 1= 1
  239. <if test="nowDate != null and nowDate != ''">
  240. and stat_date = #{nowDate}
  241. </if>
  242. <if test="hour != null and hour != ''">
  243. and stat_hour &lt;= #{hour}
  244. </if>
  245. ) t1
  246. join (select count(oid) as 'oid'
  247. from jy_order_list
  248. where 1=1
  249. <if test="yesDate != null and yesDate != ''">
  250. and stat_date = #{yesDate}
  251. </if>
  252. <if test="hour != null and hour != ''">
  253. and stat_hour &lt;= #{hour}
  254. </if>
  255. ) t2
  256. </select>
  257. <select id="getServiceAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  258. select
  259. count(distinct clip_user_id) as 'promoterNum',
  260. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  261. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  262. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  263. as 'deliveryRadio'
  264. from jy_order_list
  265. where 1= 1
  266. <if test="start != null and start != ''">
  267. and stat_date &gt;= #{start}
  268. </if>
  269. <if test="end != null and end != ''">
  270. and stat_date &lt;= #{end}
  271. </if>
  272. </select>
  273. <select id="getAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  274. select
  275. sum(order_amount) as 'orderAmount',
  276. sum(base_amount) as 'baseAmount',
  277. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount',
  278. sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
  279. 'totalRegimentalSettleAmount'
  280. from jy_order_list
  281. where 1= 1
  282. <if test="start != null and start != ''">
  283. and stat_date &gt;= #{start}
  284. </if>
  285. <if test="end != null and end != ''">
  286. and stat_date &lt;= #{end}
  287. </if>
  288. </select>
  289. <select id="getAmountTotalRatio" resultType="java.lang.Double">
  290. select
  291. round((t1.payAmount -t2.payAmount) / t2.payAmount , 4) as 'amountTotalRatio'
  292. from (select sum(pay_amount) as 'payAmount'
  293. from jy_order_list
  294. where 1= 1
  295. <if test="nowDate != null and nowDate != ''">
  296. and stat_date = #{nowDate}
  297. </if>
  298. <if test="hour != null and hour != ''">
  299. and stat_hour &lt;= #{hour}
  300. </if>
  301. ) t1
  302. join (select sum(pay_amount) as 'payAmount'
  303. from jy_order_list
  304. where 1=1
  305. <if test="yesDate != null and yesDate != ''">
  306. and stat_date = #{yesDate}
  307. </if>
  308. <if test="hour != null and jhour != ''">
  309. and stat_hour &lt;= #{hour}
  310. </if>
  311. ) t2
  312. </select>
  313. <select id="getPromoterRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  314. select
  315. t1.*,
  316. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  317. from (
  318. select
  319. clip_user_id as 'promoterId',
  320. clip_nick_name as 'promoterNickName',
  321. count(oid) as 'orderNum',
  322. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  323. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  324. from jy_order_list
  325. where 1= 1
  326. <if test="nowDate != null and nowDate != ''">
  327. and stat_date = #{nowDate}
  328. </if>
  329. <if test="hour != null and hour != ''">
  330. and stat_hour &lt;= #{hour}
  331. </if>
  332. group by clip_user_id
  333. ) t1
  334. left join (select
  335. clip_user_id as 'promoterId',
  336. count(oid) as 'orderNum'
  337. from jy_order_list
  338. where 1=1
  339. <if test="yesDate != null and yesDate != ''">
  340. and stat_date = #{yesDate}
  341. </if>
  342. <if test="hour != null and hour != ''">
  343. and stat_hour &lt;= #{hour}
  344. </if>
  345. group by clip_user_id
  346. ) t2 on t1.promoterId = t2.promoterId
  347. order by t1.orderNum desc
  348. </select>
  349. <select id="getPromoterRatioList" resultType="com.alibaba.fastjson.JSONObject">
  350. select * from (
  351. select
  352. clip_user_id as 'promoterId',
  353. clip_nick_name as 'promoterNickName',
  354. count(oid) as 'orderNum',
  355. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  356. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  357. from jy_order_list
  358. where 1= 1
  359. <if test="start != null and start != ''">
  360. and stat_date &gt;= #{start}
  361. </if>
  362. <if test="end != null and end != ''">
  363. and stat_date &lt;= #{end}
  364. </if>
  365. group by clip_user_id) t
  366. order by t.orderNum desc
  367. </select>
  368. <select id="getOrderRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  369. select
  370. t1.*,
  371. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  372. from (select
  373. item_id as 'itemId',
  374. item_title as 'itemTitle',
  375. image_url as 'imageUrl',
  376. count(oid) as 'orderNum',
  377. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  378. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  379. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  380. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  381. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  382. as 'deliveryRadio'
  383. from jy_order_list
  384. where 1= 1
  385. <if test="nowDate != null and nowDate != ''">
  386. and stat_date = #{nowDate}
  387. </if>
  388. <if test="hour != null and hour != ''">
  389. and stat_hour &lt;= #{hour}
  390. </if>
  391. group by item_id
  392. ) t1
  393. left join (select
  394. item_id as 'itemId',
  395. count(oid) as 'orderNum'
  396. from jy_order_list
  397. where 1=1
  398. <if test="yesDate != null and yesDate != ''">
  399. and stat_date = #{yesDate}
  400. </if>
  401. <if test="hour != null and hour != ''">
  402. and stat_hour &lt;= #{hour}
  403. </if>
  404. group by item_id
  405. ) t2 on t1.itemId = t2.itemId
  406. order by t1.orderNum desc
  407. </select>
  408. <select id="getOrderRankList" resultType="com.alibaba.fastjson.JSONObject">
  409. select * from (
  410. select
  411. item_id as 'itemId',
  412. item_title as 'itemTitle',
  413. image_url as 'imageUrl',
  414. count(oid) as 'orderNum',
  415. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  416. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  417. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  418. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  419. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  420. then 1 else 0 end),4) as 'deliveryRadio'
  421. from jy_order_list
  422. where 1= 1
  423. <if test="start != null and start != ''">
  424. and stat_date &gt;= #{start}
  425. </if>
  426. <if test="end != null and end != ''">
  427. and stat_date &lt;= #{end}
  428. </if>
  429. group by item_id) t
  430. order by t.orderNum desc
  431. </select>
  432. <select id="indexStatistics" resultType="com.alibaba.fastjson.JSONObject">
  433. select date_format(t.stat_date,'%Y-%m-%d') as 'date',
  434. <if test="type == 'orderNum' ">
  435. count(t.oid) as 'orderNum'
  436. </if>
  437. <if test="type == 'validOrderNum' ">
  438. sum(case when t.order_status = 80 then 1 else 0 end) as 'validOrderNum'
  439. </if>
  440. <if test="type == 'orderAmount' ">
  441. sum(t.order_amount) as 'orderAmount'
  442. </if>
  443. <if test="type == 'baseAmount' ">
  444. sum(t.base_amount) as 'baseAmount'
  445. </if>
  446. <if test="type == 'deliveryNum' ">
  447. sum(case when t.send_status = 1 and t.order_status != 80 then 1 else 0 end) as 'deliveryNum'
  448. </if>
  449. from (select
  450. oid,
  451. order_status,
  452. order_amount,
  453. base_amount,
  454. send_status,
  455. stat_date
  456. from jy_order_list
  457. where 1 = 1
  458. <if test="start != null and start != ''">
  459. and stat_date &gt;= #{start}
  460. </if>
  461. <if test="end != null and end != ''">
  462. and stat_date &lt;= #{end}
  463. </if>
  464. ) t
  465. group by t.stat_date
  466. order by t.stat_date asc
  467. </select>
  468. <select id="getTimeIntervalRatio" resultType="com.alibaba.fastjson.JSONObject">
  469. select
  470. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio',
  471. round((t1.orderAmount -t2.orderAmount) / t2.orderAmount , 4) as 'orderAmountRatio'
  472. from (
  473. select count(oid) as 'oid',
  474. sum(order_amount) as 'orderAmount'
  475. from jy_order_list
  476. where 1= 1
  477. <if test="thisCycleStartTemp != null and thisCycleStartTemp != ''">
  478. and stat_date &gt;= #{thisCycleStartTemp}
  479. </if>
  480. <if test="thisCycleEndTemp != null and thisCycleEndTemp != ''">
  481. and stat_date &lt;= #{thisCycleEndTemp}
  482. </if>
  483. ) t1
  484. join (
  485. select count(oid) as 'oid',
  486. sum(order_amount) as 'orderAmount'
  487. from jy_order_list
  488. where 1=1
  489. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  490. and stat_date &gt;= #{lastCycleStartTemp}
  491. </if>
  492. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  493. and stat_date &lt;= #{lastCycleEndTemp}
  494. </if>
  495. ) t2
  496. </select>
  497. </mapper>