HomeMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.yonge.cooleshow.biz.dal.dao.HomeDao">
  5. <select id="getUserToDoNum" resultType="com.yonge.cooleshow.biz.dal.vo.res.HomeUserToDoNum">
  6. select
  7. (select count(1) from teacher_auth_entry_record a
  8. left join sys_user u on a.user_id_ = u.id_
  9. where u.del_flag_ =0 and a.teacher_auth_status_ = 'DOING') as entryNum,
  10. (select count(1) from teacher_auth_musician_record a
  11. left join sys_user u on a.user_id_ = u.id_
  12. where u.del_flag_ =0 and a.teacher_auth_status_ = 'DOING') as musicianNum,
  13. (select count(1) from music_sheet_auth_record where audit_state_ = last_audit_state_ and audit_state_ = 'DOING') as musicNum,
  14. (select count(1) from video_lesson_group where audit_status_ = 'DOING') as videoCourseNum,
  15. (select count(1) from teacher_style_video a
  16. left join sys_user u on a.user_id_ = u.id_
  17. where u.del_flag_ =0 and a.del_flag_ = 0 and a.auth_status_ = 'DOING') as styleNum
  18. from dual
  19. </select>
  20. <select id="totalTeacher" resultType="com.yonge.cooleshow.biz.dal.vo.res.HomeTotalTeacher">
  21. select
  22. <if test="timeType != null and timeType == 'MONTH'">
  23. t.sys_day_ymd_ as timeStr,
  24. </if>
  25. <if test="timeType != null and timeType == 'YEAR'">
  26. t.sys_day_ym_ as timeStr,
  27. </if>
  28. sum(a.registerNum) as registerNum,
  29. sum(b.entryNum) as entryNum,
  30. sum(c.liveNum) as liveNum,
  31. sum(d.musicianNum) as musicianNum
  32. from sys_day t
  33. left join (
  34. select
  35. DATE_FORMAT(t.create_time_,'%Y-%m-%d') as timeStr,
  36. count(1) as registerNum
  37. from teacher t
  38. <where>
  39. <if test="param.startTime !=null">
  40. <![CDATA[AND t.create_time_ >= #{param.startTime} ]]>
  41. </if>
  42. <if test="param.endTime !=null">
  43. <![CDATA[AND t.create_time_ < #{param.endTime} ]]>
  44. </if>
  45. </where>
  46. group by DATE_FORMAT(t.create_time_,'%Y-%m-%d')
  47. ) a on t.sys_day_ymd_ = a.timeStr
  48. left join (
  49. select
  50. DATE_FORMAT(t.entry_auth_date_,'%Y-%m-%d') as timeStr,
  51. count(1) as entryNum
  52. from teacher t
  53. <where>
  54. t.entry_flag_ = 1
  55. <if test="param.startTime !=null">
  56. <![CDATA[AND t.entry_auth_date_ >= #{param.startTime} ]]>
  57. </if>
  58. <if test="param.endTime !=null">
  59. <![CDATA[AND t.entry_auth_date_ < #{param.endTime} ]]>
  60. </if>
  61. </where>
  62. group by DATE_FORMAT(t.entry_auth_date_,'%Y-%m-%d')
  63. ) b on t.sys_day_ymd_ = b.timeStr
  64. left join (
  65. select
  66. DATE_FORMAT(t.live_date_,'%Y-%m-%d') as timeStr,
  67. count(1) as liveNum
  68. from teacher t
  69. <where>
  70. <if test="param.startTime !=null">
  71. <![CDATA[AND t.live_date_ >= #{param.startTime} ]]>
  72. </if>
  73. <if test="param.endTime !=null">
  74. <![CDATA[AND t.live_date_ < #{param.endTime} ]]>
  75. </if>
  76. </where>
  77. group by DATE_FORMAT(t.live_date_,'%Y-%m-%d')
  78. ) c on t.sys_day_ymd_ = c.timeStr
  79. left join (
  80. select
  81. DATE_FORMAT(t.musician_date_,'%Y-%m-%d') as timeStr,
  82. count(1) as musicianNum
  83. from teacher t
  84. <where>
  85. t.musician_flag_ = 1
  86. <if test="param.startTime !=null">
  87. <![CDATA[AND t.musician_date_ >= #{param.startTime} ]]>
  88. </if>
  89. <if test="param.endTime !=null">
  90. <![CDATA[AND t.musician_date_ < #{param.endTime} ]]>
  91. </if>
  92. </where>
  93. group by DATE_FORMAT(t.musician_date_,'%Y-%m-%d')
  94. ) d on t.sys_day_ymd_ = d.timeStr
  95. <where>
  96. <if test="param.startTime !=null">
  97. <![CDATA[AND t.sys_day_ >= #{param.startTime} ]]>
  98. </if>
  99. <if test="param.endTime !=null">
  100. <![CDATA[AND t.sys_day_ < #{param.endTime} ]]>
  101. </if>
  102. </where>
  103. <if test="timeType != null and timeType == 'MONTH'">
  104. group by t.sys_day_ymd_
  105. </if>
  106. <if test="timeType != null and timeType == 'YEAR'">
  107. group by t.sys_day_ym_
  108. </if>
  109. order by t.sys_day_
  110. </select>
  111. <select id="totalStudent" resultType="com.yonge.cooleshow.biz.dal.vo.res.HomeTotalStudent">
  112. select
  113. <if test="timeType != null and timeType == 'MONTH'">
  114. t.sys_day_ymd_ as timeStr,
  115. </if>
  116. <if test="timeType != null and timeType == 'YEAR'">
  117. t.sys_day_ym_ as timeStr,
  118. </if>
  119. sum(a.registerNum) as registerNum,
  120. sum(b.vipNum) as vipNum,
  121. sum(b2.svipNum) as svipNum,
  122. sum(c.practiceNum) as practiceNum,
  123. sum(d.videoNum) as videoNum,
  124. sum(e.liveNum) as liveNum,
  125. sum(f.musicNum) as musicNum,
  126. sum(g.shoppingNum) as shoppingNum
  127. ,sum(h.payNum) as payStudentNum
  128. from sys_day t
  129. left join (
  130. select
  131. DATE_FORMAT(t.create_time_,'%Y-%m-%d') as timeStr,
  132. count(1) as registerNum
  133. from student t
  134. <where>
  135. <if test="param.startTime !=null">
  136. <![CDATA[AND t.create_time_ >= #{param.startTime} ]]>
  137. </if>
  138. <if test="param.endTime !=null">
  139. <![CDATA[AND t.create_time_ < #{param.endTime} ]]>
  140. </if>
  141. </where>
  142. group by DATE_FORMAT(t.create_time_,'%Y-%m-%d')
  143. ) a on t.sys_day_ymd_ = a.timeStr
  144. left join (
  145. select
  146. DATE_FORMAT(t.first_vip_time_,'%Y-%m-%d') as timeStr,
  147. count(1) as vipNum
  148. from student_time t
  149. <where>
  150. <if test="param.startTime !=null">
  151. <![CDATA[AND t.first_vip_time_ >= #{param.startTime} ]]>
  152. </if>
  153. <if test="param.endTime !=null">
  154. <![CDATA[AND t.first_vip_time_ < #{param.endTime} ]]>
  155. </if>
  156. </where>
  157. group by DATE_FORMAT(t.first_vip_time_,'%Y-%m-%d')
  158. ) b on t.sys_day_ymd_ = b.timeStr
  159. left join (
  160. select
  161. DATE_FORMAT(t.first_svip_time_,'%Y-%m-%d') as timeStr,
  162. count(1) as svipNum
  163. from student_time t
  164. <where>
  165. <if test="param.startTime !=null">
  166. <![CDATA[AND t.first_svip_time_ >= #{param.startTime} ]]>
  167. </if>
  168. <if test="param.endTime !=null">
  169. <![CDATA[AND t.first_svip_time_ < #{param.endTime} ]]>
  170. </if>
  171. </where>
  172. group by DATE_FORMAT(t.first_svip_time_,'%Y-%m-%d')
  173. ) b2 on t.sys_day_ymd_ = b2.timeStr
  174. left join (
  175. select
  176. DATE_FORMAT(t.first_pay_time_,'%Y-%m-%d') as timeStr,
  177. count(1) as payNum
  178. from student_time t
  179. <where>
  180. <if test="param.startTime !=null">
  181. <![CDATA[AND t.first_pay_time_ >= #{param.startTime} ]]>
  182. </if>
  183. <if test="param.endTime !=null">
  184. <![CDATA[AND t.first_pay_time_ < #{param.endTime} ]]>
  185. </if>
  186. </where>
  187. group by DATE_FORMAT(t.first_pay_time_,'%Y-%m-%d')
  188. ) h on t.sys_day_ymd_ = h.timeStr
  189. left join (
  190. select
  191. DATE_FORMAT(t.first_practice_time_,'%Y-%m-%d') as timeStr,
  192. count(1) as practiceNum
  193. from student_time t
  194. <where>
  195. <if test="param.startTime !=null">
  196. <![CDATA[AND t.first_practice_time_ >= #{param.startTime} ]]>
  197. </if>
  198. <if test="param.endTime !=null">
  199. <![CDATA[AND t.first_practice_time_ < #{param.endTime} ]]>
  200. </if>
  201. </where>
  202. group by DATE_FORMAT(t.first_practice_time_,'%Y-%m-%d')
  203. ) c on t.sys_day_ymd_ = c.timeStr
  204. left join (
  205. select
  206. DATE_FORMAT(t.first_video_time_,'%Y-%m-%d') as timeStr,
  207. count(1) as videoNum
  208. from student_time t
  209. <where>
  210. <if test="param.startTime !=null">
  211. <![CDATA[AND t.first_video_time_ >= #{param.startTime} ]]>
  212. </if>
  213. <if test="param.endTime !=null">
  214. <![CDATA[AND t.first_video_time_ < #{param.endTime} ]]>
  215. </if>
  216. </where>
  217. group by DATE_FORMAT(t.first_video_time_,'%Y-%m-%d')
  218. ) d on t.sys_day_ymd_ = d.timeStr
  219. left join (
  220. select
  221. DATE_FORMAT(t.first_live_time_,'%Y-%m-%d') as timeStr,
  222. count(1) as liveNum
  223. from student_time t
  224. <where>
  225. <if test="param.startTime !=null">
  226. <![CDATA[AND t.first_live_time_ >= #{param.startTime} ]]>
  227. </if>
  228. <if test="param.endTime !=null">
  229. <![CDATA[AND t.first_live_time_ < #{param.endTime} ]]>
  230. </if>
  231. </where>
  232. group by DATE_FORMAT(t.first_live_time_,'%Y-%m-%d')
  233. ) e on t.sys_day_ymd_ = e.timeStr
  234. left join (
  235. select
  236. DATE_FORMAT(t.first_music_time_,'%Y-%m-%d') as timeStr,
  237. count(1) as musicNum
  238. from student_time t
  239. <where>
  240. <if test="param.startTime !=null">
  241. <![CDATA[AND t.first_music_time_ >= #{param.startTime} ]]>
  242. </if>
  243. <if test="param.endTime !=null">
  244. <![CDATA[AND t.first_music_time_ < #{param.endTime} ]]>
  245. </if>
  246. </where>
  247. group by DATE_FORMAT(t.first_music_time_,'%Y-%m-%d')
  248. ) f on t.sys_day_ymd_ = f.timeStr
  249. left join (
  250. select
  251. DATE_FORMAT(t.first_mall_time_,'%Y-%m-%d') as timeStr,
  252. count(1) as shoppingNum
  253. from student_time t
  254. <where>
  255. <if test="param.startTime !=null">
  256. <![CDATA[AND t.first_mall_time_ >= #{param.startTime} ]]>
  257. </if>
  258. <if test="param.endTime !=null">
  259. <![CDATA[AND t.first_mall_time_ < #{param.endTime} ]]>
  260. </if>
  261. </where>
  262. group by DATE_FORMAT(t.first_mall_time_,'%Y-%m-%d')
  263. ) g on t.sys_day_ymd_ = g.timeStr
  264. <where>
  265. <if test="param.startTime !=null">
  266. <![CDATA[AND t.sys_day_ >= #{param.startTime} ]]>
  267. </if>
  268. <if test="param.endTime !=null">
  269. <![CDATA[AND t.sys_day_ < #{param.endTime} ]]>
  270. </if>
  271. </where>
  272. <if test="timeType != null and timeType == 'MONTH'">
  273. group by t.sys_day_ymd_
  274. </if>
  275. <if test="timeType != null and timeType == 'YEAR'">
  276. group by t.sys_day_ym_
  277. </if>
  278. order by t.sys_day_
  279. </select>
  280. <select id="tagTeacher" resultType="com.yonge.cooleshow.biz.dal.vo.TagTotalTeacher">
  281. SELECT
  282. <if test="timeType != null and timeType == 'MONTH'">
  283. DATE_FORMAT(live_date_,'%Y-%m-%d') as timeStr,
  284. </if>
  285. <if test="timeType != null and timeType == 'YEAR'">
  286. DATE_FORMAT(live_date_,'%Y-%m') as timeStr,
  287. </if>
  288. user_id_ ,
  289. 'LIVE' as tagType
  290. FROM
  291. teacher
  292. <where>
  293. <if test="param.startTime !=null">
  294. <![CDATA[AND live_date_ >= #{param.startTime} ]]>
  295. </if>
  296. <if test="param.endTime !=null">
  297. <![CDATA[AND live_date_ < #{param.endTime} ]]>
  298. </if>
  299. </where>
  300. UNION all
  301. SELECT
  302. <if test="timeType != null and timeType == 'MONTH'">
  303. DATE_FORMAT(style_date_,'%Y-%m-%d') as timeStr,
  304. </if>
  305. <if test="timeType != null and timeType == 'YEAR'">
  306. DATE_FORMAT(style_date_,'%Y-%m') as timeStr,
  307. </if>
  308. user_id_ ,
  309. 'STYLE' as tagType
  310. FROM
  311. teacher
  312. <where>
  313. <if test="param.startTime !=null">
  314. <![CDATA[AND style_date_ >= #{param.startTime} ]]>
  315. </if>
  316. <if test="param.endTime !=null">
  317. <![CDATA[AND style_date_ < #{param.endTime} ]]>
  318. </if>
  319. </where>
  320. UNION all
  321. SELECT
  322. <if test="timeType != null and timeType == 'MONTH'">
  323. DATE_FORMAT(music_date_,'%Y-%m-%d') as timeStr,
  324. </if>
  325. <if test="timeType != null and timeType == 'YEAR'">
  326. DATE_FORMAT(music_date_,'%Y-%m') as timeStr,
  327. </if>
  328. user_id_ ,
  329. 'MUSIC' as tagType
  330. FROM
  331. teacher
  332. <where>
  333. <if test="param.startTime !=null">
  334. <![CDATA[AND music_date_ >= #{param.startTime} ]]>
  335. </if>
  336. <if test="param.endTime !=null">
  337. <![CDATA[AND music_date_ < #{param.endTime} ]]>
  338. </if>
  339. </where>
  340. UNION all
  341. SELECT
  342. <if test="timeType != null and timeType == 'MONTH'">
  343. DATE_FORMAT(video_date_,'%Y-%m-%d') as timeStr,
  344. </if>
  345. <if test="timeType != null and timeType == 'YEAR'">
  346. DATE_FORMAT(video_date_,'%Y-%m') as timeStr,
  347. </if>
  348. user_id_ ,
  349. 'VIDEO' as tagType
  350. FROM
  351. teacher
  352. <where>
  353. <if test="param.startTime !=null">
  354. <![CDATA[AND video_date_ >= #{param.startTime} ]]>
  355. </if>
  356. <if test="param.endTime !=null">
  357. <![CDATA[AND video_date_ < #{param.endTime} ]]>
  358. </if>
  359. </where>
  360. </select>
  361. <select id="selectSubjectHome" resultType="com.yonge.cooleshow.biz.dal.vo.SubjectHomeVo">
  362. select
  363. s.id_ as subjectId
  364. ,s.name_ as subjectName
  365. ,a.musicSheetNum as musicSheetNum
  366. ,a.enableMusicSheetNum as enableMusicSheetNum
  367. ,a.enablePlatformMusicSheetNum as enablePlatformMusicSheetNum
  368. ,a.musicPlatformSheetNum as musicPlatformSheetNum
  369. ,a.enableTeacherMusicSheetNum as enableTeacherMusicSheetNum
  370. ,a.musicTeacherSheetNum as musicTeacherSheetNum
  371. ,b.practiceNum as practiceNum
  372. ,c.pianoClassNum as pianoClassNum
  373. ,d.liveNum as liveNum
  374. ,e.videoNum as videoNum
  375. from subject s
  376. left join (
  377. select
  378. ms.music_subject_ ,
  379. sum(if(ms.audit_status_ = 'PASS' ,1,0)) as musicSheetNum,
  380. sum(if( ms.state_ = 1,1,0)) as enableMusicSheetNum,
  381. sum(if( ms.state_ = 1 and ms.source_type_ = 'PLATFORM',1,0)) as enablePlatformMusicSheetNum,
  382. sum(if(ms.source_type_ = 'PLATFORM',1,0)) as musicPlatformSheetNum,
  383. sum(if(ms.source_type_ = 'TEACHER' and ms.state_ = 1 and ms.audit_status_ = 'PASS',1,0)) as enableTeacherMusicSheetNum,
  384. sum(if(ms.source_type_ = 'TEACHER' and ms.audit_status_ = 'PASS',1,0)) as musicTeacherSheetNum
  385. from music_sheet ms
  386. where ms.del_flag_ = 0
  387. group by ms.music_subject_
  388. ) a on a.music_subject_ = s.id_
  389. left join (
  390. select
  391. cg.subject_id_,
  392. count(1) as practiceNum
  393. from course_group cg
  394. where cg.type_ = 'PRACTICE' and cg.status_ in ( 'ING','COMPLETE')
  395. group by cg.subject_id_
  396. ) b on b.subject_id_ = s.id_
  397. left join (
  398. select
  399. cg.subject_id_,
  400. count(1) as pianoClassNum
  401. from course_group cg
  402. where cg.type_ = 'PIANO_ROOM_CLASS' and cg.status_ in ( 'ING','COMPLETE')
  403. group by cg.subject_id_
  404. ) c on c.subject_id_ = s.id_
  405. left join (
  406. select
  407. cg.subject_id_,
  408. count(1) as liveNum
  409. from course_group cg
  410. where cg.type_ = 'LIVE' and cg.status_ in ( 'NOT_SALE','APPLY','ING','COMPLETE')
  411. group by cg.subject_id_
  412. ) d on d.subject_id_ = s.id_
  413. left join (
  414. select
  415. vlg.lesson_subject_,
  416. count(1) as videoNum
  417. from video_lesson_group vlg
  418. where vlg.shelves_flag_ = 1 and vlg.audit_status_ = 'PASS'
  419. group by vlg.lesson_subject_
  420. ) e on e.lesson_subject_ = s.id_
  421. where s.parent_subject_id_ !=0 and s.parent_subject_id_ is not null
  422. order by
  423. <choose>
  424. <when test="query.sortType == 'MUSIC'">
  425. a.enableMusicSheetNum
  426. </when>
  427. <when test="query.sortType == 'PLATFORM_MUSIC'">
  428. a.enablePlatformMusicSheetNum
  429. </when>
  430. <when test="query.sortType == 'TEACHER_MUSIC'">
  431. a.enableTeacherMusicSheetNum
  432. </when>
  433. <when test="query.sortType == 'PRACTICE'">
  434. b.practiceNum
  435. </when>
  436. <when test="query.sortType == 'PIANO'">
  437. c.pianoClassNum
  438. </when>
  439. <when test="query.sortType == 'LIVE'">
  440. d.liveNum
  441. </when>
  442. <when test="query.sortType == 'VIDEO'">
  443. e.videoNum
  444. </when>
  445. <otherwise>
  446. a.enableMusicSheetNum
  447. </otherwise>
  448. </choose>
  449. <choose>
  450. <when test="query.order == 'desc'">
  451. desc
  452. </when>
  453. <when test="query.order == 'asc'">
  454. asc
  455. </when>
  456. <otherwise>
  457. desc
  458. </otherwise>
  459. </choose>
  460. </select>
  461. </mapper>