JiaoYangReportMapper.xml 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  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 where stat_date =
  72. DATE_FORMAT(NOW(),'%Y%m%d') ) tt on t.promoterId = tt.clip_id
  73. left join jy_kuaishou_promoter ttt on t.promoterId = ttt.promoter_id
  74. order by t.orderNum desc
  75. </select>
  76. <select id="promoter" resultType="com.alibaba.fastjson.JSONObject">
  77. select t.*,
  78. tt.head_img as 'headImg',
  79. tt.video_count as 'videoCount',
  80. tt.video_show as 'videoShow',
  81. ttt.type as 'type',
  82. ttt.user_name as 'userName'
  83. from (
  84. select clip_user_id as 'promoterId',
  85. clip_nick_name as 'promoterNickName',
  86. count(oid) as 'orderNum',
  87. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  88. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  89. sum(pay_amount) as 'payAmount',
  90. sum(case when order_status != 80 then pay_amount else 0
  91. end) as 'validPayAmount',
  92. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  93. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  94. round(
  95. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case
  96. when order_status != 80
  97. then 1
  98. else 0 end),
  99. 4) as 'deliveryRadio',
  100. sum(case when order_status != 80 then mcn_promotion_amount else 0 end) as 'regimentalPromotionAmount'
  101. from jy_order_list
  102. where 1 = 1
  103. <if test="start != null and start != '' ">
  104. and stat_date &gt;= #{start}
  105. </if>
  106. <if test="end != null and end != '' ">
  107. and stat_date &lt;= #{end}
  108. </if>
  109. <if test="promoterId != null and promoterId != '' ">
  110. and clip_user_id = #{promoterId}
  111. </if>
  112. <if test="promoterNickName != null and promoterNickName != '' ">
  113. and clip_nick_name like concat(concat('%',#{promoterNickName}),'%')
  114. </if>
  115. <if test='promoterIds != null and promoterIds.size() > 0'>
  116. AND clip_user_id in
  117. <foreach collection="promoterIds" item="item" separator=","
  118. open="(" close=")">
  119. #{item}
  120. </foreach>
  121. </if>
  122. group by clip_user_id) t
  123. left join ( select * from jy_clip_cooperation where stat_date = DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -1
  124. DAY),'%Y%m%d') ) tt on t.promoterId = tt.clip_id
  125. left join jy_kuaishou_promoter ttt on t.promoterId = ttt.promoter_id
  126. where 1 = 1
  127. <if test="type != null and type != '' ">
  128. and ttt.type = #{type}
  129. </if>
  130. order by t.payAmount desc
  131. </select>
  132. <select id="anchorOrderDetail" resultType="com.alibaba.fastjson.JSONObject">
  133. select t.*
  134. from (select
  135. item_title as 'itemTitle',
  136. item_id as 'itemId',
  137. reserve_price as 'reservePrice',
  138. image_url 'imageUrl',
  139. count(oid) as 'orderNum',
  140. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  141. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  142. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  143. regimental_promotion_rate as 'regimentalPromotionRate',
  144. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  145. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  146. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  147. then 1 else 0 end),4) as 'deliveryRadio'
  148. from jy_order_list
  149. where 1= 1
  150. <if test="promoterId != null and promoterId != ''">
  151. and clip_user_id = #{promoterId}
  152. </if>
  153. <if test="start != null and start != ''">
  154. and stat_date &gt;= #{start}
  155. </if>
  156. <if test="end != null and end != ''">
  157. and stat_date &lt;= #{end}
  158. </if>
  159. <if test="itemId != null and itemId != ''">
  160. and item_id = #{itemId}
  161. </if>
  162. <if test="itemTitle != null and itemTitle != ''">
  163. and item_title like concat(concat('%',#{itemTitle}),'%')
  164. </if>
  165. <if test='promoterIds != null and promoterIds.size() > 0'>
  166. AND clip_user_id in
  167. <foreach collection="promoterIds" item="item" separator=","
  168. open="(" close=")">
  169. #{item}
  170. </foreach>
  171. </if>
  172. group by item_id) t
  173. order by t.orderNum desc
  174. </select>
  175. <select id="promoterStatistics" resultType="com.alibaba.fastjson.JSONObject">
  176. select date_format(t.stat_date, '%Y-%m-%d') as 'date',
  177. count(t.oid) as 'orderNum'
  178. from (select oid,
  179. stat_date
  180. from jy_order_list
  181. where 1 = 1
  182. <if test="promoterId != null and promoterId != ''">
  183. and clip_user_id = #{promoterId}
  184. </if>
  185. <if test="start != null and start != ''">
  186. and stat_date &gt;= #{start}
  187. </if>
  188. <if test="end != null and end != ''">
  189. and stat_date &lt;= #{end}
  190. </if>
  191. <if test='promoterIds != null and promoterIds.size() > 0'>
  192. AND clip_user_id in
  193. <foreach collection="promoterIds" item="item" separator=","
  194. open="(" close=")">
  195. #{item}
  196. </foreach>
  197. </if>
  198. ) t
  199. group by t.stat_date
  200. order by t.stat_date asc
  201. </select>
  202. <select id="getClipCooperation" resultType="com.alibaba.fastjson.JSONObject">
  203. select clip_id as 'clipId',
  204. clip_name as 'clipName',
  205. head_img as 'headImg',
  206. fans_num as 'fansNum',
  207. gmv_30d as 'gmv30d',
  208. start_time as 'startTime',
  209. end_time as 'endTime',
  210. (case when status = 1
  211. then '上架'
  212. when status = 3
  213. then '已结束'
  214. when status = 2
  215. then '待确认'
  216. else '-'
  217. end
  218. ) as 'status',
  219. termination_reason as 'terminationReason',
  220. concat(commission_rate_view,'%') as 'commissionRateView',
  221. shop_score as 'shopScore',
  222. clip_gmv_30d as 'clipGmv30d',
  223. auth_item_gmv_30d as 'authItemGmv30d',
  224. video_count as 'videoCount',
  225. video_count as 'videoShow',
  226. stat_date as 'statDate'
  227. from jy_clip_cooperation
  228. where
  229. stat_date = #{date}
  230. <if test="promoterId != null and promoterId != ''">
  231. and clip_id = #{promoterId}
  232. </if>
  233. <if test="promoterName != null and promoterName != ''">
  234. and clip_name like concat(concat('%',#{promoterName}),'%')
  235. </if>
  236. </select>
  237. <select id="getOrderTotal" resultType="com.alibaba.fastjson.JSONObject">
  238. select
  239. count(oid) as 'orderNum',
  240. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  241. sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm'
  242. from jy_order_list
  243. where 1= 1
  244. <if test="start != null and start != ''">
  245. and stat_date &gt;= #{start}
  246. </if>
  247. <if test="end != null and end != ''">
  248. and stat_date &lt;= #{end}
  249. </if>
  250. <if test='promoterIds != null and promoterIds.size() > 0'>
  251. AND clip_user_id in
  252. <foreach collection="promoterIds" item="item" separator=","
  253. open="(" close=")">
  254. #{item}
  255. </foreach>
  256. </if>
  257. </select>
  258. <select id="getOrderTotalRatio" resultType="java.lang.Double">
  259. select
  260. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio'
  261. from (select count(oid) as 'oid'
  262. from jy_order_list
  263. where 1= 1
  264. <if test="nowDate != null and nowDate != ''">
  265. and stat_date = #{nowDate}
  266. </if>
  267. <if test="hour != null and hour != ''">
  268. and stat_hour &lt;= #{hour}
  269. </if>
  270. <if test='promoterIds != null and promoterIds.size() > 0'>
  271. AND clip_user_id in
  272. <foreach collection="promoterIds" item="item" separator=","
  273. open="(" close=")">
  274. #{item}
  275. </foreach>
  276. </if>
  277. ) t1
  278. join (select count(oid) as 'oid'
  279. from jy_order_list
  280. where 1=1
  281. <if test="yesDate != null and yesDate != ''">
  282. and stat_date = #{yesDate}
  283. </if>
  284. <if test="hour != null and hour != ''">
  285. and stat_hour &lt;= #{hour}
  286. </if>
  287. <if test='promoterIds != null and promoterIds.size() > 0'>
  288. AND clip_user_id in
  289. <foreach collection="promoterIds" item="item" separator=","
  290. open="(" close=")">
  291. #{item}
  292. </foreach>
  293. </if>
  294. ) t2
  295. </select>
  296. <select id="getServiceAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  297. select
  298. count(distinct clip_user_id) as 'promoterNum',
  299. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  300. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  301. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  302. as 'deliveryRadio'
  303. from jy_order_list
  304. where 1= 1
  305. <if test="start != null and start != ''">
  306. and stat_date &gt;= #{start}
  307. </if>
  308. <if test="end != null and end != ''">
  309. and stat_date &lt;= #{end}
  310. </if>
  311. <if test='promoterIds != null and promoterIds.size() > 0'>
  312. AND clip_user_id in
  313. <foreach collection="promoterIds" item="item" separator=","
  314. open="(" close=")">
  315. #{item}
  316. </foreach>
  317. </if>
  318. </select>
  319. <select id="getAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  320. select
  321. sum(order_amount) as 'orderAmount',
  322. sum(base_amount) as 'baseAmount',
  323. sum(case when order_status != 80 then mcn_promotion_amount else 0 end) as 'regimentalPromotionAmount',
  324. sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
  325. 'totalRegimentalSettleAmount'
  326. from jy_order_list
  327. where 1= 1
  328. <if test="start != null and start != ''">
  329. and stat_date &gt;= #{start}
  330. </if>
  331. <if test="end != null and end != ''">
  332. and stat_date &lt;= #{end}
  333. </if>
  334. <if test='promoterIds != null and promoterIds.size() > 0'>
  335. AND clip_user_id in
  336. <foreach collection="promoterIds" item="item" separator=","
  337. open="(" close=")">
  338. #{item}
  339. </foreach>
  340. </if>
  341. </select>
  342. <select id="getAmountTotalRatio" resultType="java.lang.Double">
  343. select
  344. round((t1.payAmount -t2.payAmount) / t2.payAmount , 4) as 'amountTotalRatio'
  345. from (select sum(pay_amount) as 'payAmount'
  346. from jy_order_list
  347. where 1= 1
  348. <if test="nowDate != null and nowDate != ''">
  349. and stat_date = #{nowDate}
  350. </if>
  351. <if test="hour != null and hour != ''">
  352. and stat_hour &lt;= #{hour}
  353. </if>
  354. <if test='promoterIds != null and promoterIds.size() > 0'>
  355. AND clip_user_id in
  356. <foreach collection="promoterIds" item="item" separator=","
  357. open="(" close=")">
  358. #{item}
  359. </foreach>
  360. </if>
  361. ) t1
  362. join (select sum(pay_amount) as 'payAmount'
  363. from jy_order_list
  364. where 1=1
  365. <if test="yesDate != null and yesDate != ''">
  366. and stat_date = #{yesDate}
  367. </if>
  368. <if test="hour != null and jhour != ''">
  369. and stat_hour &lt;= #{hour}
  370. </if>
  371. <if test='promoterIds != null and promoterIds.size() > 0'>
  372. AND clip_user_id in
  373. <foreach collection="promoterIds" item="item" separator=","
  374. open="(" close=")">
  375. #{item}
  376. </foreach>
  377. </if>
  378. ) t2
  379. </select>
  380. <select id="getPromoterRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  381. select
  382. t1.*,
  383. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  384. from (
  385. select
  386. clip_user_id as 'promoterId',
  387. clip_nick_name as 'promoterNickName',
  388. count(oid) as 'orderNum',
  389. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  390. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  391. from jy_order_list
  392. where 1= 1
  393. <if test="nowDate != null and nowDate != ''">
  394. and stat_date = #{nowDate}
  395. </if>
  396. <if test="hour != null and hour != ''">
  397. and stat_hour &lt;= #{hour}
  398. </if>
  399. <if test='promoterIds != null and promoterIds.size() > 0'>
  400. AND clip_user_id in
  401. <foreach collection="promoterIds" item="item" separator=","
  402. open="(" close=")">
  403. #{item}
  404. </foreach>
  405. </if>
  406. group by clip_user_id
  407. ) t1
  408. left join (select
  409. clip_user_id as 'promoterId',
  410. count(oid) as 'orderNum'
  411. from jy_order_list
  412. where 1=1
  413. <if test="yesDate != null and yesDate != ''">
  414. and stat_date = #{yesDate}
  415. </if>
  416. <if test="hour != null and hour != ''">
  417. and stat_hour &lt;= #{hour}
  418. </if>
  419. <if test='promoterIds != null and promoterIds.size() > 0'>
  420. AND clip_user_id in
  421. <foreach collection="promoterIds" item="item" separator=","
  422. open="(" close=")">
  423. #{item}
  424. </foreach>
  425. </if>
  426. group by clip_user_id
  427. ) t2 on t1.promoterId = t2.promoterId
  428. order by t1.orderNum desc
  429. </select>
  430. <select id="getPromoterRatioList" resultType="com.alibaba.fastjson.JSONObject">
  431. select * from (
  432. select
  433. clip_user_id as 'promoterId',
  434. clip_nick_name as 'promoterNickName',
  435. count(oid) as 'orderNum',
  436. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  437. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  438. from jy_order_list
  439. where 1= 1
  440. <if test="start != null and start != ''">
  441. and stat_date &gt;= #{start}
  442. </if>
  443. <if test="end != null and end != ''">
  444. and stat_date &lt;= #{end}
  445. </if>
  446. <if test='promoterIds != null and promoterIds.size() > 0'>
  447. AND clip_user_id in
  448. <foreach collection="promoterIds" item="item" separator=","
  449. open="(" close=")">
  450. #{item}
  451. </foreach>
  452. </if>
  453. group by clip_user_id) t
  454. order by t.orderNum desc
  455. </select>
  456. <select id="getOrderRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  457. select
  458. t1.*,
  459. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  460. from (select
  461. item_id as 'itemId',
  462. item_title as 'itemTitle',
  463. image_url as 'imageUrl',
  464. count(oid) as 'orderNum',
  465. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  466. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  467. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  468. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  469. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  470. as 'deliveryRadio'
  471. from jy_order_list
  472. where 1= 1
  473. <if test="nowDate != null and nowDate != ''">
  474. and stat_date = #{nowDate}
  475. </if>
  476. <if test="hour != null and hour != ''">
  477. and stat_hour &lt;= #{hour}
  478. </if>
  479. group by item_id
  480. ) t1
  481. left join (select
  482. item_id as 'itemId',
  483. count(oid) as 'orderNum'
  484. from jy_order_list
  485. where 1=1
  486. <if test="yesDate != null and yesDate != ''">
  487. and stat_date = #{yesDate}
  488. </if>
  489. <if test="hour != null and hour != ''">
  490. and stat_hour &lt;= #{hour}
  491. </if>
  492. group by item_id
  493. ) t2 on t1.itemId = t2.itemId
  494. order by t1.orderNum desc
  495. </select>
  496. <select id="getOrderRankList" resultType="com.alibaba.fastjson.JSONObject">
  497. select * from (
  498. select
  499. item_id as 'itemId',
  500. item_title as 'itemTitle',
  501. image_url as 'imageUrl',
  502. count(oid) as 'orderNum',
  503. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  504. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  505. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  506. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  507. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  508. then 1 else 0 end),4) as 'deliveryRadio'
  509. from jy_order_list
  510. where 1= 1
  511. <if test="start != null and start != ''">
  512. and stat_date &gt;= #{start}
  513. </if>
  514. <if test="end != null and end != ''">
  515. and stat_date &lt;= #{end}
  516. </if>
  517. group by item_id) t
  518. order by t.orderNum desc
  519. </select>
  520. <select id="indexStatistics" resultType="com.alibaba.fastjson.JSONObject">
  521. select date_format(t.stat_date,'%Y-%m-%d') as 'date',
  522. <if test="type == 'orderNum' ">
  523. count(t.oid) as 'orderNum'
  524. </if>
  525. <if test="type == 'validOrderNum' ">
  526. sum(case when t.order_status = 80 then 1 else 0 end) as 'validOrderNum'
  527. </if>
  528. <if test="type == 'orderAmount' ">
  529. sum(t.order_amount) as 'orderAmount'
  530. </if>
  531. <if test="type == 'baseAmount' ">
  532. sum(t.base_amount) as 'baseAmount'
  533. </if>
  534. <if test="type == 'deliveryNum' ">
  535. sum(case when t.send_status = 1 and t.order_status != 80 then 1 else 0 end) as 'deliveryNum'
  536. </if>
  537. from (select
  538. oid,
  539. order_status,
  540. order_amount,
  541. base_amount,
  542. send_status,
  543. stat_date
  544. from jy_order_list
  545. where 1 = 1
  546. <if test="start != null and start != ''">
  547. and stat_date &gt;= #{start}
  548. </if>
  549. <if test="end != null and end != ''">
  550. and stat_date &lt;= #{end}
  551. </if>
  552. <if test='promoterIds != null and promoterIds.size() > 0'>
  553. AND clip_user_id in
  554. <foreach collection="promoterIds" item="item" separator=","
  555. open="(" close=")">
  556. #{item}
  557. </foreach>
  558. </if>
  559. ) t
  560. group by t.stat_date
  561. order by t.stat_date asc
  562. </select>
  563. <select id="getTimeIntervalRatio" resultType="com.alibaba.fastjson.JSONObject">
  564. select
  565. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio',
  566. round((t1.orderAmount -t2.orderAmount) / t2.orderAmount , 4) as 'orderAmountRatio'
  567. from (
  568. select count(oid) as 'oid',
  569. sum(order_amount) as 'orderAmount'
  570. from jy_order_list
  571. where 1= 1
  572. <if test="thisCycleStartTemp != null and thisCycleStartTemp != ''">
  573. and stat_date &gt;= #{thisCycleStartTemp}
  574. </if>
  575. <if test="thisCycleEndTemp != null and thisCycleEndTemp != ''">
  576. and stat_date &lt;= #{thisCycleEndTemp}
  577. </if>
  578. <if test='promoterIds != null and promoterIds.size() > 0'>
  579. AND clip_user_id in
  580. <foreach collection="promoterIds" item="item" separator=","
  581. open="(" close=")">
  582. #{item}
  583. </foreach>
  584. </if>
  585. ) t1
  586. join (
  587. select count(oid) as 'oid',
  588. sum(order_amount) as 'orderAmount'
  589. from jy_order_list
  590. where 1=1
  591. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  592. and stat_date &gt;= #{lastCycleStartTemp}
  593. </if>
  594. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  595. and stat_date &lt;= #{lastCycleEndTemp}
  596. </if>
  597. <if test='promoterIds != null and promoterIds.size() > 0'>
  598. AND clip_user_id in
  599. <foreach collection="promoterIds" item="item" separator=","
  600. open="(" close=")">
  601. #{item}
  602. </foreach>
  603. </if>
  604. ) t2
  605. </select>
  606. <select id="getPromoterIdsByUserIds" resultType="java.lang.Long">
  607. select promoter_id from jy_kuaishou_promoter where
  608. 1 = 1
  609. and user_id in
  610. <foreach collection="userIds" item="userId" separator="," open="(" close=")">
  611. #{userId}
  612. </foreach>
  613. </select>
  614. <select id="dayData" resultType="com.alibaba.fastjson.JSONObject">
  615. select *,
  616. t1.gmv - t2.lastGmv as 'gvmGap',
  617. t1.orderNum - t2.lastOrderNum as 'orderNumGap',
  618. t1.validGmv - t2.lastValidGmv as 'validGmvGap',
  619. t1.validOrderNUm - t2.lastValidOrderNUm as 'validOrderNumGap',
  620. t1.mcnPromotionAmount - t2.lastMcnPromotionAmount as 'mcnPromotionAmountGap',
  621. t1.grossMargin - t2.lastGrossMargin as 'grossMarginGap'
  622. from (select date_format(#{date},'%Y/%m/%d') as 'date',
  623. round(sum(pay_amount) / 100, 2) as 'gmv',
  624. count(oid) as 'orderNum',
  625. round(sum(case when order_status != 80 then pay_amount else 0 end) / 100, 2) as 'validGmv',
  626. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNum',
  627. round(sum(mcn_promotion_amount) / 100, 2) as 'mcnPromotionAmount',
  628. round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'grossMargin'
  629. from jy_order_list t1 left join jy_kuaishou_promoter t2
  630. on t1.clip_user_id = t2.promoter_id
  631. where t1.stat_date = #{date}
  632. and t2.type = 1
  633. ) t1
  634. join (select date_format(#{lastDate} ,'%Y/%m/%d') as 'lastDate',
  635. round(sum(pay_amount) / 100, 2) as 'lastGmv',
  636. count(oid) as 'lastOrderNum',
  637. round(sum(case when order_status != 80 then pay_amount else 0 end) / 100, 2) as 'lastValidGmv',
  638. sum(case when order_status != 80 then 1 else 0 end) as 'lastValidOrderNum',
  639. round(sum(mcn_promotion_amount) / 100, 2) as 'lastMcnPromotionAmount',
  640. round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'lastGrossMargin'
  641. from jy_order_list t1 left join jy_kuaishou_promoter t2
  642. on t1.clip_user_id = t2.promoter_id
  643. where t1.stat_date = #{lastDate}
  644. and t2.type = 1
  645. ) t2
  646. </select>
  647. <select id="monthData" resultType="com.alibaba.fastjson.JSONObject">
  648. select *,
  649. concat(ROUND((t1.gmv - t2.lastGmv) / t2.lastGmv * 100, 2) ,'%') as 'gvmRadio',
  650. concat(ROUND((t1.orderNum - t2.lastOrderNum) / t2.lastOrderNum * 100, 2),'%') as 'orderNumRadio',
  651. concat(ROUND((t1.validGmv - t2.lastValidGmv) / t2.lastValidGmv * 100, 2) ,'%')as 'validGmvRadio',
  652. concat(ROUND((t1.validOrderNUm - t2.lastValidOrderNUm) / t2.lastValidOrderNUm * 100,
  653. 2) ,'%')as 'validOrderNumRadio',
  654. concat(ROUND((t1.mcnPromotionAmount - t2.lastMcnPromotionAmount) / t2.lastMcnPromotionAmount * 100,
  655. 2) ,'%')as 'mcnPromotionAmountRadio',
  656. ROUND((t1.grossMargin - t2.lastGrossMargin) / t2.lastGrossMargin * 100,
  657. 2) as 'grossMarginRadio'
  658. from (select CONCAT(date_format(#{nowMonthEndDate} ,'%Y/%m/%d') , '合计') as 'date',
  659. round(sum(pay_amount) / 100, 2) as 'gmv',
  660. count(oid) as 'orderNum',
  661. round(sum(case when order_status != 80 then pay_amount else 0 end) / 100, 2) as 'validGmv',
  662. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNum',
  663. round(sum(mcn_promotion_amount) / 100, 2) as 'mcnPromotionAmount',
  664. round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'grossMargin'
  665. from jy_order_list t1 left join jy_kuaishou_promoter t2
  666. on t1.clip_user_id = t2.promoter_id
  667. where t1.stat_date >= #{nowMonthStartDate}
  668. and t1.stat_date &lt;= #{nowMonthEndDate}
  669. and t2.type = 1
  670. ) t1
  671. join (select CONCAT(date_format(#{lastMonthEndDate} ,'%Y/%m/%d') , '合计') as 'lastDate',
  672. round(sum(pay_amount) / 100, 2) as 'lastGmv',
  673. count(oid) as 'lastOrderNum',
  674. round(sum(case when order_status != 80 then pay_amount else 0 end) / 100, 2) as 'lastValidGmv',
  675. sum(case when order_status != 80 then 1 else 0 end) as 'lastValidOrderNum',
  676. round(sum(mcn_promotion_amount) / 100, 2) as 'lastMcnPromotionAmount',
  677. round(sum(mcn_promotion_amount) / sum(pay_amount) * 100, 2) as 'lastGrossMargin'
  678. from jy_order_list t1 left join jy_kuaishou_promoter t2
  679. on t1.clip_user_id = t2.promoter_id
  680. where t1.stat_date >= #{lastMonthStartDate}
  681. and t1.stat_date &lt;= #{lastMonthEndDate}
  682. and t2.type = 1
  683. ) t2
  684. </select>
  685. <select id="getTopItem" resultType="com.alibaba.fastjson.JSONObject">
  686. select t1.*,
  687. t2.promotionVolume as 'yesPromotionVolume',
  688. t1.promotionVolume - t2.promotionVolume as 'difference',
  689. round((t1.promotionVolume - t2.promotionVolume) / t2.promotionVolume * 100, 2) as 'increaseInPrice',
  690. (
  691. case when t2.itemId is null
  692. then 1
  693. else 2
  694. end
  695. ) as 'isNew'
  696. from (select clip_id as 'clipId',
  697. clip_name as 'clipName',
  698. item_id as 'itemId',
  699. item_name as 'itemName',
  700. item_img_url as 'itemImgUrl',
  701. item_price as 'itemPrice',
  702. promotion_volume as 'promotionVolume',
  703. promotion_promoter_count as 'promotionPromoterCount'
  704. from jy_clip_top_list
  705. where stat_date = #{date}
  706. <if test="promoterId != null and promoterId != ''">
  707. and clip_id = #{promoterId}
  708. </if>
  709. ) t1
  710. left join (select clip_id as 'clipId',
  711. item_id as 'itemId',
  712. promotion_volume as 'promotionVolume'
  713. from jy_clip_top_list
  714. where stat_date = DATE_FORMAT(DATE_ADD(#{date}, INTERVAL -1 DAY),'%Y%m%d')
  715. <if test="promoterId != null and promoterId != ''">
  716. and clip_id = #{promoterId}
  717. </if>
  718. ) t2
  719. on t1.clipId = t2.clipId and t1.itemId = t2.itemId
  720. order by ${fieId} ${sort}
  721. </select>
  722. <select id="getTopItemUser" resultType="com.alibaba.fastjson.JSONObject">
  723. select id,name from jy_fx_top_item_config
  724. </select>
  725. </mapper>