| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.yonge.cooleshow.biz.dal.dao.HomeDao">
- <select id="getUserToDoNum" resultType="com.yonge.cooleshow.biz.dal.vo.res.HomeUserToDoNum">
- select
- (select count(1) from teacher_auth_entry_record a
- left join sys_user u on a.user_id_ = u.id_
- where u.del_flag_ =0 and a.teacher_auth_status_ = 'DOING') as entryNum,
- (select count(1) from teacher_auth_musician_record a
- left join sys_user u on a.user_id_ = u.id_
- where u.del_flag_ =0 and a.teacher_auth_status_ = 'DOING') as musicianNum,
- (select count(1) from music_sheet_auth_record where audit_state_ = last_audit_state_ and audit_state_ = 'DOING') as musicNum,
- (select count(1) from video_lesson_group where audit_status_ = 'DOING') as videoCourseNum,
- (select count(1) from teacher_style_video a
- left join sys_user u on a.user_id_ = u.id_
- where u.del_flag_ =0 and a.del_flag_ = 0 and a.auth_status_ = 'DOING') as styleNum
- from dual
- </select>
- <select id="totalTeacher" resultType="com.yonge.cooleshow.biz.dal.vo.res.HomeTotalTeacher">
- select
- <if test="timeType != null and timeType == 'MONTH'">
- t.sys_day_ymd_ as timeStr,
- </if>
- <if test="timeType != null and timeType == 'YEAR'">
- t.sys_day_ym_ as timeStr,
- </if>
- sum(a.registerNum) as registerNum,
- sum(b.entryNum) as entryNum,
- sum(c.liveNum) as liveNum,
- sum(d.musicianNum) as musicianNum
- from sys_day t
- left join (
- select
- DATE_FORMAT(t.create_time_,'%Y-%m-%d') as timeStr,
- count(1) as registerNum
- from teacher t
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND t.create_time_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.create_time_ < #{param.endTime} ]]>
- </if>
- </where>
- group by DATE_FORMAT(t.create_time_,'%Y-%m-%d')
- ) a on t.sys_day_ymd_ = a.timeStr
- left join (
- select
- DATE_FORMAT(t.entry_auth_date_,'%Y-%m-%d') as timeStr,
- count(1) as entryNum
- from teacher t
- <where>
- t.entry_flag_ = 1
- <if test="param.startTime !=null">
- <![CDATA[AND t.entry_auth_date_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.entry_auth_date_ < #{param.endTime} ]]>
- </if>
- </where>
- group by DATE_FORMAT(t.entry_auth_date_,'%Y-%m-%d')
- ) b on t.sys_day_ymd_ = b.timeStr
- left join (
- select
- DATE_FORMAT(t.live_date_,'%Y-%m-%d') as timeStr,
- count(1) as liveNum
- from teacher t
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND t.live_date_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.live_date_ < #{param.endTime} ]]>
- </if>
- </where>
- group by DATE_FORMAT(t.live_date_,'%Y-%m-%d')
- ) c on t.sys_day_ymd_ = c.timeStr
- left join (
- select
- DATE_FORMAT(t.musician_date_,'%Y-%m-%d') as timeStr,
- count(1) as musicianNum
- from teacher t
- <where>
- t.musician_flag_ = 1
- <if test="param.startTime !=null">
- <![CDATA[AND t.musician_date_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.musician_date_ < #{param.endTime} ]]>
- </if>
- </where>
- group by DATE_FORMAT(t.musician_date_,'%Y-%m-%d')
- ) d on t.sys_day_ymd_ = d.timeStr
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND t.sys_day_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.sys_day_ < #{param.endTime} ]]>
- </if>
- </where>
- <if test="timeType != null and timeType == 'MONTH'">
- group by t.sys_day_ymd_
- </if>
- <if test="timeType != null and timeType == 'YEAR'">
- group by t.sys_day_ym_
- </if>
- order by t.sys_day_
- </select>
- <select id="totalStudent" resultType="com.yonge.cooleshow.biz.dal.vo.res.HomeTotalStudent">
- select
- <if test="timeType != null and timeType == 'MONTH'">
- t.sys_day_ymd_ as timeStr,
- </if>
- <if test="timeType != null and timeType == 'YEAR'">
- t.sys_day_ym_ as timeStr,
- </if>
- sum(a.registerNum) as registerNum,
- sum(b.vipNum) as vipNum,
- sum(b2.svipNum) as svipNum,
- sum(c.practiceNum) as practiceNum,
- sum(d.videoNum) as videoNum,
- sum(e.liveNum) as liveNum,
- sum(f.musicNum) as musicNum,
- sum(g.shoppingNum) as shoppingNum
- ,sum(h.payNum) as payStudentNum
- from sys_day t
- left join (
- select
- DATE_FORMAT(t.create_time_,'%Y-%m-%d') as timeStr,
- count(1) as registerNum
- from student t
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND t.create_time_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.create_time_ < #{param.endTime} ]]>
- </if>
- </where>
- group by DATE_FORMAT(t.create_time_,'%Y-%m-%d')
- ) a on t.sys_day_ymd_ = a.timeStr
- left join (
- select
- DATE_FORMAT(t.first_vip_time_,'%Y-%m-%d') as timeStr,
- count(1) as vipNum
- from student_time t
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND t.first_vip_time_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.first_vip_time_ < #{param.endTime} ]]>
- </if>
- </where>
- group by DATE_FORMAT(t.first_vip_time_,'%Y-%m-%d')
- ) b on t.sys_day_ymd_ = b.timeStr
- left join (
- select
- DATE_FORMAT(t.first_svip_time_,'%Y-%m-%d') as timeStr,
- count(1) as svipNum
- from student_time t
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND t.first_svip_time_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.first_svip_time_ < #{param.endTime} ]]>
- </if>
- </where>
- group by DATE_FORMAT(t.first_svip_time_,'%Y-%m-%d')
- ) b2 on t.sys_day_ymd_ = b2.timeStr
- left join (
- select
- DATE_FORMAT(t.first_pay_time_,'%Y-%m-%d') as timeStr,
- count(1) as payNum
- from student_time t
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND t.first_pay_time_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.first_pay_time_ < #{param.endTime} ]]>
- </if>
- </where>
- group by DATE_FORMAT(t.first_pay_time_,'%Y-%m-%d')
- ) h on t.sys_day_ymd_ = h.timeStr
- left join (
- select
- DATE_FORMAT(t.first_practice_time_,'%Y-%m-%d') as timeStr,
- count(1) as practiceNum
- from student_time t
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND t.first_practice_time_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.first_practice_time_ < #{param.endTime} ]]>
- </if>
- </where>
- group by DATE_FORMAT(t.first_practice_time_,'%Y-%m-%d')
- ) c on t.sys_day_ymd_ = c.timeStr
- left join (
- select
- DATE_FORMAT(t.first_video_time_,'%Y-%m-%d') as timeStr,
- count(1) as videoNum
- from student_time t
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND t.first_video_time_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.first_video_time_ < #{param.endTime} ]]>
- </if>
- </where>
- group by DATE_FORMAT(t.first_video_time_,'%Y-%m-%d')
- ) d on t.sys_day_ymd_ = d.timeStr
- left join (
- select
- DATE_FORMAT(t.first_live_time_,'%Y-%m-%d') as timeStr,
- count(1) as liveNum
- from student_time t
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND t.first_live_time_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.first_live_time_ < #{param.endTime} ]]>
- </if>
- </where>
- group by DATE_FORMAT(t.first_live_time_,'%Y-%m-%d')
- ) e on t.sys_day_ymd_ = e.timeStr
- left join (
- select
- DATE_FORMAT(t.first_music_time_,'%Y-%m-%d') as timeStr,
- count(1) as musicNum
- from student_time t
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND t.first_music_time_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.first_music_time_ < #{param.endTime} ]]>
- </if>
- </where>
- group by DATE_FORMAT(t.first_music_time_,'%Y-%m-%d')
- ) f on t.sys_day_ymd_ = f.timeStr
- left join (
- select
- DATE_FORMAT(t.first_mall_time_,'%Y-%m-%d') as timeStr,
- count(1) as shoppingNum
- from student_time t
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND t.first_mall_time_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.first_mall_time_ < #{param.endTime} ]]>
- </if>
- </where>
- group by DATE_FORMAT(t.first_mall_time_,'%Y-%m-%d')
- ) g on t.sys_day_ymd_ = g.timeStr
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND t.sys_day_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND t.sys_day_ < #{param.endTime} ]]>
- </if>
- </where>
- <if test="timeType != null and timeType == 'MONTH'">
- group by t.sys_day_ymd_
- </if>
- <if test="timeType != null and timeType == 'YEAR'">
- group by t.sys_day_ym_
- </if>
- order by t.sys_day_
- </select>
- <select id="tagTeacher" resultType="com.yonge.cooleshow.biz.dal.vo.TagTotalTeacher">
- SELECT
- <if test="timeType != null and timeType == 'MONTH'">
- DATE_FORMAT(live_date_,'%Y-%m-%d') as timeStr,
- </if>
- <if test="timeType != null and timeType == 'YEAR'">
- DATE_FORMAT(live_date_,'%Y-%m') as timeStr,
- </if>
- user_id_ ,
- 'LIVE' as tagType
- FROM
- teacher
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND live_date_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND live_date_ < #{param.endTime} ]]>
- </if>
- </where>
- UNION all
- SELECT
- <if test="timeType != null and timeType == 'MONTH'">
- DATE_FORMAT(style_date_,'%Y-%m-%d') as timeStr,
- </if>
- <if test="timeType != null and timeType == 'YEAR'">
- DATE_FORMAT(style_date_,'%Y-%m') as timeStr,
- </if>
- user_id_ ,
- 'STYLE' as tagType
- FROM
- teacher
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND style_date_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND style_date_ < #{param.endTime} ]]>
- </if>
- </where>
- UNION all
- SELECT
- <if test="timeType != null and timeType == 'MONTH'">
- DATE_FORMAT(music_date_,'%Y-%m-%d') as timeStr,
- </if>
- <if test="timeType != null and timeType == 'YEAR'">
- DATE_FORMAT(music_date_,'%Y-%m') as timeStr,
- </if>
- user_id_ ,
- 'MUSIC' as tagType
- FROM
- teacher
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND music_date_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND music_date_ < #{param.endTime} ]]>
- </if>
- </where>
- UNION all
- SELECT
- <if test="timeType != null and timeType == 'MONTH'">
- DATE_FORMAT(video_date_,'%Y-%m-%d') as timeStr,
- </if>
- <if test="timeType != null and timeType == 'YEAR'">
- DATE_FORMAT(video_date_,'%Y-%m') as timeStr,
- </if>
- user_id_ ,
- 'VIDEO' as tagType
- FROM
- teacher
- <where>
- <if test="param.startTime !=null">
- <![CDATA[AND video_date_ >= #{param.startTime} ]]>
- </if>
- <if test="param.endTime !=null">
- <![CDATA[AND video_date_ < #{param.endTime} ]]>
- </if>
- </where>
- </select>
- <select id="selectSubjectHome" resultType="com.yonge.cooleshow.biz.dal.vo.SubjectHomeVo">
- select
- s.id_ as subjectId
- ,s.name_ as subjectName
- ,a.musicSheetNum as musicSheetNum
- ,a.enableMusicSheetNum as enableMusicSheetNum
- ,a.enablePlatformMusicSheetNum as enablePlatformMusicSheetNum
- ,a.musicPlatformSheetNum as musicPlatformSheetNum
- ,a.enableTeacherMusicSheetNum as enableTeacherMusicSheetNum
- ,a.musicTeacherSheetNum as musicTeacherSheetNum
- ,b.practiceNum as practiceNum
- ,c.pianoClassNum as pianoClassNum
- ,d.liveNum as liveNum
- ,e.videoNum as videoNum
- from subject s
- left join (
- select
- ms.music_subject_ ,
- sum(if(ms.audit_status_ = 'PASS' ,1,0)) as musicSheetNum,
- sum(if( ms.state_ = 1,1,0)) as enableMusicSheetNum,
- sum(if( ms.state_ = 1 and ms.source_type_ = 'PLATFORM',1,0)) as enablePlatformMusicSheetNum,
- sum(if(ms.source_type_ = 'PLATFORM',1,0)) as musicPlatformSheetNum,
- sum(if(ms.source_type_ = 'TEACHER' and ms.state_ = 1 and ms.audit_status_ = 'PASS',1,0)) as enableTeacherMusicSheetNum,
- sum(if(ms.source_type_ = 'TEACHER' and ms.audit_status_ = 'PASS',1,0)) as musicTeacherSheetNum
- from music_sheet ms
- where ms.del_flag_ = 0
- group by ms.music_subject_
- ) a on a.music_subject_ = s.id_
- left join (
- select
- cg.subject_id_,
- count(1) as practiceNum
- from course_group cg
- where cg.type_ = 'PRACTICE' and cg.status_ in ( 'ING','COMPLETE')
- group by cg.subject_id_
- ) b on b.subject_id_ = s.id_
- left join (
- select
- cg.subject_id_,
- count(1) as pianoClassNum
- from course_group cg
- where cg.type_ = 'PIANO_ROOM_CLASS' and cg.status_ in ( 'ING','COMPLETE')
- group by cg.subject_id_
- ) c on c.subject_id_ = s.id_
- left join (
- select
- cg.subject_id_,
- count(1) as liveNum
- from course_group cg
- where cg.type_ = 'LIVE' and cg.status_ in ( 'NOT_SALE','APPLY','ING','COMPLETE')
- group by cg.subject_id_
- ) d on d.subject_id_ = s.id_
- left join (
- select
- vlg.lesson_subject_,
- count(1) as videoNum
- from video_lesson_group vlg
- where vlg.shelves_flag_ = 1 and vlg.audit_status_ = 'PASS'
- group by vlg.lesson_subject_
- ) e on e.lesson_subject_ = s.id_
- where s.parent_subject_id_ !=0 and s.parent_subject_id_ is not null
- order by
- <choose>
- <when test="query.sortType == 'MUSIC'">
- a.enableMusicSheetNum
- </when>
- <when test="query.sortType == 'PLATFORM_MUSIC'">
- a.enablePlatformMusicSheetNum
- </when>
- <when test="query.sortType == 'TEACHER_MUSIC'">
- a.enableTeacherMusicSheetNum
- </when>
- <when test="query.sortType == 'PRACTICE'">
- b.practiceNum
- </when>
- <when test="query.sortType == 'PIANO'">
- c.pianoClassNum
- </when>
- <when test="query.sortType == 'LIVE'">
- d.liveNum
- </when>
- <when test="query.sortType == 'VIDEO'">
- e.videoNum
- </when>
- <otherwise>
- a.enableMusicSheetNum
- </otherwise>
- </choose>
- <choose>
- <when test="query.order == 'desc'">
- desc
- </when>
- <when test="query.order == 'asc'">
- asc
- </when>
- <otherwise>
- desc
- </otherwise>
- </choose>
- </select>
- </mapper>
|