1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255 |
- <?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.ym.mec.biz.dal.dao.StudentDao">
- <resultMap type="com.ym.mec.biz.dal.entity.Student" id="Student">
- <result column="user_id_" property="userId"/>
- <result column="subject_id_list_" property="subjectIdList"/>
- <result column="service_tag_" property="serviceTag"/>
- <result column="operating_tag_" property="operatingTag"/>
- <result column="operating_temp_tag_" property="operatingTempTag"/>
- <result column="teacher_id_" property="teacherId"/>
- <result column="teacher_name_" property="teacherName"/>
- <result column="is_new_user_" property="isNewUser"/>
- <result column="create_time_" property="createTime"/>
- <result column="update_time_" property="updateTime"/>
- <result column="care_package_" property="carePackage"/>
- <result column="come_on_package_" property="comeOnPackage"/>
- <result column="current_grade_num_" property="currentGradeNum"/>
- <result column="current_class_" property="currentClass"/>
- <result column="cooperation_organ_id_" property="cooperationOrganId"/>
- <result column="member_rank_setting_id_" property="memberRankSettingId"/>
- <result column="membership_start_time_" property="membershipStartTime"/>
- <result column="membership_end_time_" property="membershipEndTime"/>
- <result column="experience_member_rank_setting_id_" property="experienceMemberRankSettingId"/>
- <result column="experience_membership_start_time_" property="experienceMembershipStartTime"/>
- <result column="experience_membership_end_time_" property="experienceMembershipEndTime"/>
- <result column="activity_course_detail_" property="activityCourseDetail"/>
- <result column="organ_name_" property="organName"/>
- <result column="phone_" property="phone"/>
- <result column="username_" property="username"/>
- </resultMap>
- <!-- 根据主键查询一条记录 -->
- <select id="get" resultMap="Student">
- SELECT *
- FROM student
- WHERE user_id_ = #{id}
- </select>
-
- <select id="getLocked" resultMap="Student">
- SELECT *
- FROM student
- WHERE user_id_ = #{id} for update
- </select>
- <!-- 全查询 -->
- <select id="findAll" resultMap="Student">
- SELECT *
- FROM student
- </select>
- <select id="lockUser" resultType="int" useCache="false" flushCache="true">
- SELECT id_
- FROM sys_user
- WHERE id_ = #{userId} FOR
- UPDATE
- </select>
- <select id="lockUserReturnInfo" resultMap="com.ym.mec.biz.dal.dao.TeacherDao.SysUser">
- SELECT *
- FROM sys_user
- WHERE id_ = #{userId} FOR UPDATE
- </select>
- <select id="getUser" resultMap="com.ym.mec.biz.dal.dao.TeacherDao.SysUser">
- SELECT *
- FROM sys_user
- WHERE id_ = #{userId}
- </select>
- <!-- 向数据库增加一条记录 -->
- <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.Student" useGeneratedKeys="true" keyColumn="id"
- keyProperty="id">
- INSERT INTO student (user_id_,subject_id_list_,
- <if test="serviceTag != null">
- service_tag_,
- </if>
- <if test="operatingTag != null">
- operating_tag_,
- </if>
- teacher_id_,create_time_,update_time_,service_tag_update_time_,cooperation_organ_id_,
- care_package_,come_on_package_,member_rank_setting_id_,membership_start_time_,membership_end_time_)
- VALUES
- (#{userId},#{subjectIdList},
- <if test="serviceTag != null">
- #{serviceTag},
- </if>
- <if test="operatingTag != null">
- #{operatingTag},
- </if>
- #{teacherId},NOW(),NOW(),NOW(),#{cooperationOrganId},
- #{carePackage},#{comeOnPackage},#{memberRankSettingId},#{membershipStartTime},#{membershipEndTime})
- </insert>
- <update id="update" parameterType="com.ym.mec.biz.dal.entity.Student">
- UPDATE student
- <set>
- <if test="subjectIdList != null">
- subject_id_list_ = #{subjectIdList},
- </if>
- <if test="serviceTag != null">
- service_tag_update_time_=IF(service_tag_ = #{serviceTag}, service_tag_update_time_, NOW()),
- service_tag_ = #{serviceTag},
- </if>
- <if test="operatingTag != null">
- operating_tag_ = #{operatingTag},
- </if>
- <if test="operatingTempTag != null">
- operating_temp_tag_ = #{operatingTempTag},
- </if>
- <if test="teacherId != null">
- teacher_id_=#{teacherId},
- </if>
- <if test="isNewUser != null">
- is_new_user_=#{isNewUser},
- </if>
- <if test="carePackage != null">
- care_package_=#{carePackage},
- </if>
- <if test="comeOnPackage != null">
- come_on_package_=#{comeOnPackage},
- </if>
- <if test="currentGradeNum != null">
- current_grade_num_=#{currentGradeNum},
- </if>
- <if test="currentClass != null">
- current_class_=#{currentClass},
- </if>
- <if test="memberRankSettingId != null">
- member_rank_setting_id_=#{memberRankSettingId},
- </if>
- <if test="membershipStartTime != null">
- membership_start_time_=#{membershipStartTime},
- </if>
- <if test="membershipEndTime != null">
- membership_end_time_=#{membershipEndTime},
- </if>
- <if test="experienceMemberRankSettingId != null">
- experience_member_rank_setting_id_=#{experienceMemberRankSettingId},
- </if>
- <if test="experienceMembershipStartTime != null">
- experience_membership_start_time_=#{experienceMembershipStartTime},
- </if>
- <if test="experienceMembershipEndTime != null">
- experience_membership_end_time_=#{experienceMembershipEndTime},
- </if>
- <if test="activityCourseDetail != null">
- activity_course_detail_=#{activityCourseDetail},
- </if>
- cooperation_organ_id_=#{cooperationOrganId},
- update_time_ = NOW()
- </set>
- WHERE user_id_ = #{userId}
- </update>
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="Student" parameterType="map">
- SELECT s.*,su.username_,su.phone_,o.name_ organ_name_ FROM student s
- LEFT JOIN sys_user su ON su.id_ = s.user_id_
- LEFT JOIN organization o ON o.id_ = su.organ_id_
- <include refid="queryPageSql"/>
- ORDER BY s.activity_course_detail_ DESC
- <include refid="global.limit"/>
- </select>
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(s.user_id_) FROM student s
- LEFT JOIN sys_user su ON su.id_ = s.user_id_
- <include refid="queryPageSql"/>
- </select>
- <sql id="queryPageSql">
- <where>
- <if test="organId != null and organId != ''">
- AND FIND_IN_SET(su.organ_id_,#{organId})
- </if>
- <if test="search != null and search != ''">
- AND (s.user_id_ = #{search} OR su.username_ LIKE CONCAT('%', #{search}, '%') OR su.phone_ LIKE CONCAT('%', #{search}, '%'))
- </if>
- </where>
- </sql>
- <select id="findStudents" resultMap="com.ym.mec.biz.dal.dao.TeacherDao.SysUser">
- SELECT id_, username_, phone_,avatar_ FROM sys_user
- <include refid="studentQueryCondition"/>
- ORDER BY id_
- <include refid="global.limit"/>
- </select>
- <select id="countStudents" resultType="int">
- SELECT COUNT(id_) FROM sys_user
- <include refid="studentQueryCondition"/>
- </select>
- <sql id="studentQueryCondition">
- <where>
- <if test="organIdList!=null">
- organ_id_ IN
- <foreach collection="organIdList" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- <if test="search!=null">
- AND (username_ LIKE CONCAT('%', #{search}, '%') OR phone_ LIKE CONCAT('%', #{search}, '%'))
- </if>
- AND FIND_IN_SET("STUDENT", user_type_)
- </where>
- </sql>
- <select id="queryByOperatingTempTag" resultMap="Student">
- SELECT *
- FROM student
- WHERE operating_temp_tag_ = #{operatingTempTag}
- </select>
- <update id="batchUpdate" parameterType="java.util.List">
- <foreach collection="studentList" item="item" index="index" open="" close="" separator=";">
- UPDATE student
- <set>
- <if test="item.subjectIdList != null">
- subject_id_list_ = #{item.subjectIdList},
- </if>
- <if test="item.currentGradeNum != null">
- current_grade_num_=#{item.currentGradeNum},
- </if>
- <if test="item.serviceTag != null">
- service_tag_ = #{item.serviceTag},
- </if>
- <if test="item.operatingTag != null">
- operating_tag_ = #{item.operatingTag},
- </if>
- <if test="item.operatingTempTag != null">
- operating_temp_tag_ = #{item.operatingTempTag},
- </if>
- <if test="item.teacherId != null">
- teacher_id_=#{item.teacherId},
- </if>
- <if test="item.updateTime != null">
- update_time_ = #{item.updateTime},
- </if>
- <if test="item.carePackage != null">
- care_package_=#{item.carePackage},
- </if>
- <if test="item.comeOnPackage != null">
- come_on_package_=#{item.comeOnPackage},
- </if>
- <if test="item.cooperationOrganId != null">
- cooperation_organ_id_=#{item.cooperationOrganId},
- </if>
- <if test="item.activityCourseDetail != null">
- activity_course_detail_=#{item.activityCourseDetail},
- </if>
- <if test="item.memberRankSettingId != null">
- member_rank_setting_id_=#{item.memberRankSettingId},
- </if>
- <if test="item.membershipStartTime != null">
- membership_start_time_=#{item.membershipStartTime},
- </if>
- <if test="item.membershipEndTime != null">
- membership_end_time_=#{item.membershipEndTime},
- </if>
- update_time_ = NOW()
- </set>
- WHERE user_id_ = #{item.userId}
- </foreach>
- </update>
- <update id="updateStudentServiceOrOperatingTag">
- UPDATE student
- <set>
- <if test="serviceTag != null">
- service_tag_ = #{serviceTag},
- </if>
- <if test="operatingTag != null">
- operating_tag_ = #{operatingTag},
- </if>
- update_time_ = NOW()
- </set>
- WHERE
- <if test="studentId!=null">
- user_id_ = #{studentId}
- </if>
- <if test="studentIds!=null and studentIds.size()>0">
- user_id_ IN
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- </if>
- </update>
- <update id="updateStudentServiceTag">
- UPDATE student
- <set>
- <if test="serviceTag != null">
- service_tag_update_time_ = IF(service_tag_=#{serviceTag}, service_tag_update_time_, NOW()),
- service_tag_ = #{serviceTag},
- </if>
- update_time_ = NOW()
- </set>
- WHERE
- service_tag_=0
- <if test="studentId!=null">
- AND user_id_ = #{studentId}
- </if>
- <if test="studentIds!=null and studentIds.size()>0">
- AND user_id_ IN
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- </if>
- </update>
- <update id="batchUpdateAdviser">
- UPDATE student s SET s.teacher_id_ = #{teacherId},s.update_time_ = NOW() WHERE FIND_IN_SET(s.user_id_,#{studentIds})
- </update>
- <update id="updateServiceTag">
- UPDATE student SET service_tag_ = #{serviceTag},update_time_ = NOW() WHERE user_id_ IN
- <foreach collection="studentIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </update>
- <resultMap id="student4operating" type="com.ym.mec.biz.dal.dto.Student4operating">
- <result column="organ_name_" property="organName"/>
- <result column="organ_id_" property="organId"/>
- <result column="student_name_" property="studentName"/>
- <result column="student_id_" property="studentId"/>
- <result column="teacher_id_" property="teacherId"/>
- <result column="teacher_name_" property="teacherName"/>
- <result column="operating_tag_" property="operatingTag"/>
- <result column="vip_times_" property="vipTimes"/>
- <result column="free_practice_times_" property="freePracticeTimes"/>
- <result column="buy_practice_times_" property="buyPracticeTimes"/>
- <result column="music_netWork_times_" property="musicNetWorkTimes"/>
- <result column="student_num_" property="studentNum"/>
- </resultMap>
- <select id="getOperatingStudents" resultMap="student4operating">
- SELECT su.organ_id_,
- o.name_ organ_name_,
- su.username_ student_name_,
- s.user_id_ student_id_,
- tsu.id_ teacher_id_,
- tsu.real_name_ teacher_name_,
- s.operating_tag_,
- a.vip_times_,
- a.buy_practice_times_,
- a.music_netWork_times_,
- p.free_practice_times_
- FROM student s
- LEFT JOIN sys_user su ON s.user_id_ = su.id_
- LEFT JOIN sys_user tsu ON tsu.id_ = s.teacher_id_
- LEFT JOIN organization o ON o.id_ = su.organ_id_
- LEFT JOIN (
- SELECT cssp.user_id_,
- SUM(case when (cs.group_type_ = 'VIP' AND cs.teach_mode_='ONLINE') then 1 ELSE 0 END) vip_times_,
- SUM(case when (pg.type_='CHARGE') then 1 ELSE 0 END) buy_practice_times_,
- SUM(case when (cs.type_='MUSIC_NETWORK' OR cs.type_='HIGH_ONLINE') then 1 ELSE 0 END) music_netWork_times_
- FROM course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
- LEFT JOIN practice_group pg ON pg.`id_` = cs.`music_group_id_` AND cs.`group_type_` = 'PRACTICE'
- WHERE cs.status_ IN ('NOT_START','UNDERWAY') AND (cs.is_lock_ IS NULL OR cs.is_lock_=0) AND (cs.del_flag_ IS NULL OR cs.del_flag_=0)
- GROUP BY cssp.user_id_
- ) a on a.user_id_ = s.user_id_
- LEFT JOIN (
- SELECT student_id_, count(id_) free_practice_times_
- FROM practice_group
- WHERE type_='FREE' AND group_status_ IN ('NORMAL', 'FINISH')
- GROUP BY student_id_
- ) p ON p.student_id_ = s.user_id_
- <include refid="student4OperatingQueryCondition"/>
- ORDER BY s.user_id_
- <include refid="global.limit"/>
- </select>
- <select id="countOperatingStudents" resultType="int">
- SELECT COUNT(s.user_id_) FROM student s
- LEFT JOIN sys_user su ON s.user_id_ = su.id_
- LEFT JOIN sys_user tsu ON tsu.id_ = s.teacher_id_
- LEFT JOIN (
- SELECT cssp.user_id_,
- SUM(case when (cs.group_type_ = 'VIP' AND cs.teach_mode_='ONLINE') then 1 ELSE 0 END) vip_times_,
- SUM(case when (pg.type_='CHARGE') then 1 ELSE 0 END) buy_practice_times_,
- SUM(case when (cs.type_='MUSIC_NETWORK' OR cs.type_='HIGH_ONLINE') then 1 ELSE 0 END) music_netWork_times_
- FROM course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
- LEFT JOIN practice_group pg ON pg.`id_` = cs.`music_group_id_` AND cs.`group_type_` = 'PRACTICE'
- WHERE cs.status_ IN ('NOT_START','UNDERWAY') AND (cs.is_lock_ IS NULL OR cs.is_lock_=0) AND (cs.del_flag_ IS NULL OR cs.del_flag_=0)
- GROUP BY cssp.user_id_
- ) a on a.user_id_ = s.user_id_
- LEFT JOIN (
- SELECT student_id_, count(id_) free_practice_times_
- FROM practice_group
- WHERE type_='FREE' AND group_status_ IN ('NORMAL', 'FINISH')
- GROUP BY student_id_
- ) p ON p.student_id_ = s.user_id_
- <include refid="student4OperatingQueryCondition"/>
- </select>
- <sql id="student4OperatingQueryCondition">
- <where>
- su.user_type_ LIKE '%STUDENT%'
- <if test="search != null and search != ''">
- AND (su.phone_ LIKE CONCAT('%',#{search},'%') OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.id_
- LIKE CONCAT('%',#{search},'%'))
- </if>
- <if test="organId != null and organId != ''">
- AND FIND_IN_SET(su.organ_id_,#{organId})
- </if>
- <if test="teacherId!=null">
- AND s.teacher_id_ = #{teacherId}
- </if>
- <if test="operatingTag !=null">
- AND s.operating_tag_ = #{operatingTag}
- </if>
- <if test='hasVip != null and hasVip=="1"'>
- AND a.vip_times_ >=1
- </if>
- <if test='hasVip != null and hasVip=="0"'>
- AND (a.vip_times_ =0 OR a.vip_times_ IS NULL)
- </if>
- <if test='hasFreePractice != null and hasFreePractice=="1"'>
- AND p.free_practice_times_ >=1
- </if>
- <if test='hasFreePractice != null and hasFreePractice=="0"'>
- AND (p.free_practice_times_ =0 OR p.free_practice_times_ IS NULL)
- </if>
- <if test='hasBuyPractice != null and hasBuyPractice=="1"'>
- AND a.buy_practice_times_ >=1
- </if>
- <if test='hasBuyPractice != null and hasBuyPractice=="0"'>
- AND (a.buy_practice_times_ =0 OR a.buy_practice_times_ IS NULL)
- </if>
- <if test='hasMusicNetWork != null and hasMusicNetWork=="1"'>
- AND a.music_netWork_times_ >=1
- </if>
- <if test='hasMusicNetWork != null and hasMusicNetWork=="0"'>
- AND (a.music_netWork_times_ =0 OR a.music_netWork_times_ IS NULL)
- </if>
- </where>
- </sql>
- <select id="getTeacherOperatingStudentsNum" resultType="java.util.Map">
- select teacher_id_ 'key', count(*) 'value'
- FROM student
- WHERE FIND_IN_SET(teacher_id_, #{teacherIds})
- AND operating_tag_ = 1
- GROUP BY teacher_id_
- </select>
- <select id="getBuyNums" resultType="java.util.Map">
- SELECT s.teacher_id_ 'key', COUNT(DISTINCT cssp.user_id_) 'value'
- FROM course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_ AND cs.teach_mode_ = 'ONLINE'
- LEFT JOIN student s ON s.user_id_ = cssp.user_id_
- <if test="groupType != null and groupType==@com.ym.mec.biz.dal.enums.GroupType@PRACTICE">
- LEFT JOIN practice_group pg ON cssp.music_group_id_ = pg.id_ AND cssp.group_type_ = 'PRACTICE'
- </if>
- WHERE s.teacher_id_ = #{teacherId}
- AND cs.status_ IN ('NOT_START', 'UNDERWAY')
- AND (cs.is_lock_ IS NULL OR cs.is_lock_ = 0)
- <if test="groupType != null">
- AND cs.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
- </if>
- <if test="groupType != null and groupType==@com.ym.mec.biz.dal.enums.GroupType@PRACTICE">
- AND pg.group_status_ IN ('NORMAL', 'FINISH')
- AND pg.buy_months_ >= 1
- </if>
- GROUP BY s.teacher_id_
- </select>
- <select id="getPracticeAndVipNums" resultType="java.util.Map">
- SELECT s.teacher_id_ 'key', COUNT(DISTINCT pg.student_id_) 'value'
- FROM practice_group pg
- LEFT JOIN student s on s.user_id_ = pg.student_id_
- LEFT JOIN course_schedule_student_payment vcssp
- ON vcssp.user_id_ = pg.student_id_ AND vcssp.group_type_ = 'VIP'
- LEFT JOIN course_schedule_student_payment pcssp
- ON pcssp.user_id_ = pg.student_id_ AND pcssp.group_type_ = 'PRACTICE'
- LEFT JOIN course_schedule vcs ON vcs.id_ = vcssp.course_schedule_id_ AND vcs.teach_mode_ = 'ONLINE'
- LEFT JOIN course_schedule pcs ON pcs.id_ = pcssp.course_schedule_id_
- WHERE FIND_IN_SET(s.teacher_id_, #{teacherIds})
- AND pg.group_status_ IN ('NORMAL', 'FINISH')
- AND vcs.status_ IN ('NOT_START', 'UNDERWAY')
- AND pcs.status_ IN ('NOT_START', 'UNDERWAY')
- AND (vcs.is_lock_ IS NULL OR vcs.is_lock_ = 0)
- AND (pcs.is_lock_ IS NULL OR pcs.is_lock_ = 0)
- AND pg.buy_months_ >= 1
- GROUP BY s.teacher_id_
- </select>
- <select id="getServiceStudents" resultMap="Student">
- SELECT su.id_ user_id_,s.teacher_id_ FROM sys_user su
- LEFT JOIN student s ON s.user_id_=su.id_
- WHERE s.service_tag_=1 AND FIND_IN_SET('STUDENT', su.user_type_)
- </select>
- <resultMap id="StudentServeDto" type="com.ym.mec.biz.dal.dto.StudentServeDto" extends="Student">
- <result column="group_type_" property="groupType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="teach_mode_" property="teachMode" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result property="courseStartTime" column="course_start_time_"/>
- </resultMap>
- <select id="getBeServiceStudents" resultMap="StudentServeDto">
- SELECT
- s.user_id_,
- s.teacher_id_,
- cs.group_type_,
- cs.teach_mode_,
- IF(CONCAT( cs.class_date_, ' ', cs.end_class_time_ )<#{courseExpireDate} AND (sa.status_ != 'NORMAL' OR sa.status_ IS NULL), NULL, cs.class_date_) course_start_time_
- FROM
- student s
- LEFT JOIN course_schedule_student_payment cssp ON cssp.user_id_ = s.user_id_
- LEFT JOIN student_attendance sa ON cssp.course_schedule_id_=sa.course_schedule_id_ AND sa.user_id_=cssp.user_id_
- LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
- AND cs.group_type_ IN ('VIP', 'PRACTICE')
- AND CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) > #{monday}
- WHERE
- s.service_tag_ = 1
- </select>
- <select id="getBeServiceStudentsInfoWithStudents" resultMap="StudentServeDto">
- SELECT
- s.user_id_,
- s.teacher_id_,
- cs.group_type_,
- cs.teach_mode_,
- IF(CONCAT( cs.class_date_, ' ', cs.end_class_time_ )<#{courseExpireDate} AND (sa.status_ != 'NORMAL' OR sa.status_ IS NULL), NULL, cs.class_date_) course_start_time_
- FROM
- student s
- LEFT JOIN course_schedule_student_payment cssp ON cssp.user_id_ = s.user_id_
- LEFT JOIN student_attendance sa ON cssp.course_schedule_id_=sa.course_schedule_id_ AND sa.user_id_=cssp.user_id_
- LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
- AND cs.group_type_ IN ('VIP', 'PRACTICE')
- AND CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) > #{monday}
- WHERE
- s.service_tag_ = 1 AND s.user_id_ IN
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- </select>
- <select id="getBeServiceStudentsInfoWithStudentsForHistory" resultMap="StudentServeDto">
- SELECT
- s.student_id_ user_id_,
- s.teacher_id_,
- cs.group_type_,
- cs.teach_mode_,
- IF(CONCAT( cs.class_date_, ' ', cs.end_class_time_ )<#{courseExpireDate} AND (sa.status_ != 'NORMAL' OR sa.status_ IS NULL), NULL, cs.class_date_) course_start_time_
- FROM
- student_extracurricular_exercises_situation_ s
- LEFT JOIN course_schedule_student_payment cssp ON cssp.user_id_ = s.student_id_
- LEFT JOIN student_attendance sa ON cssp.course_schedule_id_=sa.course_schedule_id_ AND sa.user_id_=cssp.user_id_
- LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
- AND cs.group_type_ IN ('VIP', 'PRACTICE')
- AND CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) > #{monday}
- WHERE
- s.monday_ = #{monday} AND s.student_id_ IN
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- </select>
- <select id="getServeStudentIds" resultType="int">
- SELECT user_id_
- FROM student stu
- LEFT JOIN sys_user su ON stu.user_id_=su.id_
- WHERE service_tag_=1 AND su.del_flag_=0
- </select>
- <select id="getServeStudentCourseStartTimes" resultType="com.ym.mec.biz.dal.dto.StudentServeCourseDto">
- SELECT
- cssp.user_id_ studentId,
- stu.service_tag_update_time_ serviceTagUpdateTime,
- CONCAT(cs.class_date_, ' ', cs.start_class_time_) courseStartTime
- FROM course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cs.id_=cssp.course_schedule_id_
- LEFT JOIN student stu ON cssp.user_id_ = stu.user_id_
- WHERE stu.service_tag_=1 AND class_date_>=#{monday}
- </select>
- <resultMap id="StudentServeCourseDto" type="com.ym.mec.biz.dal.dto.StudentServeCourseDto">
- <result column="student_id_" property="studentId"/>
- <result column="lead_teacher_id_" property="leadTeacherId"/>
- <result column="course_schedule_id_" property="courseScheduleId"/>
- <result column="group_type_" property="groupType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="music_group_id_" property="musicGroupId"/>
- <result column="class_group_id_" property="classGroupId"/>
- <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="actual_teacher_id_" property="actualTeacherId"/>
- <result column="course_start_time_" property="courseStartTime"/>
- <result column="teach_mode_" property="teachMode"/>
- </resultMap>
- <select id="getStudentFutureCourseInfo" resultMap="StudentServeCourseDto">
- SELECT
- cssp.user_id_ student_id_,
- stu.teacher_id_ lead_teacher_id_,
- cs.id_ course_schedule_id_,
- cs.group_type_,
- cs.music_group_id_,
- cs.class_group_id_,
- cs.status_,
- CASE cs.type_ WHEN 'TRAINING_SINGLE' THEN 'SINGLE' WHEN 'TRAINING_MIX' THEN 'MIX' ELSE cs.type_ END type_,
- cs.actual_teacher_id_,
- CONCAT(cs.class_date_, ' ', cs.start_class_time_) course_start_time_,
- cs.teach_mode_
- FROM course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
- LEFT JOIN student stu ON cssp.user_id_ = stu.user_id_
- WHERE stu.service_tag_=1
- AND (stu.service_tag_update_time_ IS NULL OR stu.service_tag_update_time_<#{nextMonday})
- AND (cs.del_flag_ IS NULL OR cs.del_flag_=0)
- AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_)
- AND cs.class_date_>=#{monday}
- AND cs.type_ IN ('SINGLE', 'TRAINING_SINGLE', 'VIP', 'MIX', 'TRAINING_MIX', 'PRACTICE')
- AND cssp.create_time_<#{nextMonday}
- <if test="studentIds!=null and studentIds.size()>0">
- AND cssp.user_id_ IN
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- </if>
- ORDER BY cssp.user_id_,course_start_time_
- </select>
- <select id="getNoCourseBeServeStudentInfo" resultMap="StudentServeCourseDto">
- SELECT
- sr.user_id_ student_id_,
- stu.teacher_id_ lead_teacher_id_,
- 'MUSIC' group_type_,
- sr.music_group_id_
- FROM
- student_registration sr
- LEFT JOIN student stu ON sr.user_id_ = stu.user_id_
- LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
- WHERE
- mg.del_flag_ = 0
- AND mg.organ_id_ IS NOT NULL
- AND mg.status_ = 'PROGRESS'
- AND sr.music_group_status_ = 'NORMAL'
- <if test="noCourseStudentIds!=null and noCourseStudentIds.size()>0">
- AND sr.user_id_ IN
- <foreach collection="noCourseStudentIds" item="noCourseStudentId" open="(" close=")" separator=",">
- #{noCourseStudentId}
- </foreach>
- </if>
- </select>
- <select id="getStudentNames" resultType="string">
- SELECT username_ FROM sys_user WHERE id_ IN
- <foreach collection="studentIds" item="studentId" separator="," open="(" close=")">
- #{studentId}
- </foreach>
- </select>
- <select id="getStudentsWithOrgan" resultType="com.ym.mec.biz.dal.dto.SimpleUserDto">
- SELECT
- su.id_ userId,su.username_ userName, su.avatar_ avatar, su.phone_ phone
- FROM
- sys_user su
- WHERE
- 1=1
- AND su.del_flag_=0 AND su.lock_flag_=0
- AND FIND_IN_SET('STUDENT',su.user_type_)
- <if test="organIds!=null">
- AND su.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- <if test="search != null">
- AND (su.username_ LIKE CONCAT('%', #{search}, '%') OR su.phone_ LIKE CONCAT('%', #{search}, '%'))
- </if>
- ORDER BY su.id_
- <include refid="global.limit"/>
- </select>
- <select id="countStudentsWithOrgan" resultType="int">
- SELECT
- COUNT(su.id_)
- FROM
- sys_user su
- WHERE
- 1=1
- AND su.del_flag_=0 AND su.lock_flag_=0
- AND FIND_IN_SET('STUDENT',su.user_type_)
- <if test="organIds!=null">
- AND su.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- <if test="search != null">
- AND (su.username_ LIKE CONCAT('%', #{search}, '%') OR su.phone_ LIKE CONCAT('%', #{search}, '%'))
- </if>
- </select>
- <select id="getStudentTeacher" resultMap="Student">
- SELECT s.user_id_,t.real_name_ teacher_name_ FROM student s
- LEFT JOIN sys_user t ON t.id_ = s.teacher_id_
- WHERE s.user_id_ IN
- <foreach collection="studentIds" item="id" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </select>
- <select id="findByStudentIds" resultMap="Student">
- SELECT * FROM student WHERE user_id_ IN
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- </select>
- <select id="lockStudents" resultMap="Student">
- SELECT * FROM student WHERE user_id_ IN
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- FOR UPDATE
- </select>
- <select id="queryCloseServiceTagIds" resultType="java.lang.Integer">
- SELECT s.user_id_ FROM student s
- LEFT JOIN course_schedule_student_payment cssp ON cssp.user_id_ = s.user_id_
- LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
- LEFT JOIN student_registration sr ON sr.user_id_ = s.user_id_
- LEFT JOIN music_group mg ON mg.id_ = sr.music_group_id_
- WHERE s.service_tag_ = 1
- GROUP BY s.user_id_ HAVING COUNT(CASE WHEN cs.status_ = 'NOT_START' THEN 1 ELSE NULL END) = 0
- AND COUNT(CASE WHEN sr.music_group_status_ = 'NORMAL' AND mg.status_ = 'PROGRESS' THEN 1 ELSE NULL END) = 0;
- </select>
- <select id="getStudentSubjects" resultMap="com.ym.mec.biz.dal.dao.SubjectDao.Subject">
- SELECT
- DISTINCT sub.*
- FROM
- student stu
- LEFT JOIN `subject` sub ON FIND_IN_SET( sub.id_, stu.subject_id_list_ )
- WHERE
- stu.user_id_ IN
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- AND sub.id_ IS NOT NULL
- ORDER BY sub.id_ DESC
- </select>
- <select id="queryByIds" resultMap="Student">
- SELECT * FROM student
- WHERE user_id_ IN
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- ORDER BY user_id_
- <include refid="global.limit"></include>
- </select>
- <select id="countByIds" resultType="int">
- SELECT count(user_id_) FROM student
- WHERE user_id_ IN
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- </select>
- <select id="getNoTeacherOrNoSubjectStudent" resultMap="Student">
- SELECT * FROM student WHERE teacher_id_ IS NULL OR subject_id_list_ IS NULL OR cooperation_organ_id_ IS NULL;
- </select>
- <select id="getHasVipCourseStudentIdsFromNewStudents" resultType="int">
- SELECT DISTINCT s.user_id_
- FROM student s
- LEFT JOIN course_schedule_student_payment cssp ON s.user_id_=cssp.user_id_
- WHERE s.is_new_user_=1 AND cssp.group_type_='VIP'
- </select>
- <select id="getMemberNum" resultType="int">
- SELECT COUNT(0) FROM student WHERE member_rank_setting_id_ IS NOT NULL AND FIND_IN_SET(user_id_,#{studentIdsStr})
- </select>
- <select id="queryPushMemberRenew" resultType="java.lang.Integer">
- SELECT s.user_id_ FROM student s
- LEFT JOIN cloud_teacher_order cto ON cto.student_id_ = s.user_id_ AND cto.status_ IN (1,2)
- GROUP BY s.user_id_ HAVING (MAX(cto.id_) IS NULL OR MIN(cto.status_) > 1)
- AND DATEDIFF(MAX(cto.end_time_),NOW()) = #{pushMemberRenew}
- </select>
- <select id="getOrganStudentNum" resultType="int">
- SELECT COUNT(DISTINCT user_id_)
- FROM ((SELECT sr.user_id_
- FROM student_registration sr
- LEFT JOIN music_group mg ON sr.music_group_id_=mg.id_
- LEFT JOIN sys_user su ON sr.user_id_=su.id_
- WHERE su.del_flag_=0
- AND mg.status_='PROGRESS'
- AND sr.music_group_status_='NORMAL'
- AND su.organ_id_ = #{organId})
- UNION ALL
- (SELECT
- cssp.user_id_
- FROM
- course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
- LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
- WHERE
- cssp.group_type_ IN ('VIP', 'PRACTICE')
- AND cs.status_='NOT_START'
- AND su.del_flag_ = 0
- AND su.organ_id_ = #{organId})) t
- WHERE t.user_id_ NOT IN (SELECT user_id_ FROM student WHERE subject_id_list_ REGEXP '21|25|26|27|28|29')
- </select>
- <select id="getOrgansTotalStudentNum" resultType="int">
- SELECT COUNT(DISTINCT user_id_)
- FROM ((SELECT sr.user_id_
- FROM student_registration sr
- LEFT JOIN music_group mg ON sr.music_group_id_=mg.id_
- WHERE mg.status_='PROGRESS'
- AND sr.music_group_status_='NORMAL')
- UNION ALL
- (SELECT
- cssp.user_id_
- FROM
- course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
- LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
- WHERE
- cssp.group_type_ IN ('VIP', 'PRACTICE')
- AND cs.status_='NOT_START')) t
- LEFT JOIN sys_user su ON t.user_id_=su.id_
- WHERE su.del_flag_=0
- <if test="organIds!=null and organIds.size()>0">
- AND su.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- </select>
- <select id="getOrgansStudentNum" resultType="map">
- SELECT su.organ_id_ 'key',COUNT(DISTINCT user_id_) 'value'
- FROM ((SELECT sr.user_id_
- FROM student_registration sr
- LEFT JOIN music_group mg ON sr.music_group_id_=mg.id_
- WHERE mg.status_='PROGRESS'
- AND sr.music_group_status_='NORMAL')
- UNION ALL
- (SELECT
- cssp.user_id_
- FROM
- course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
- WHERE
- cssp.group_type_ IN ('VIP', 'PRACTICE')
- AND cs.status_='NOT_START')) t
- LEFT JOIN sys_user su ON t.user_id_=su.id_
- WHERE su.del_flag_=0 AND t.user_id_ NOT IN (SELECT user_id_ FROM student WHERE subject_id_list_ REGEXP '21|25|26|27|28|29')
- <!-- <if test="organIds!=null and organIds.size()>0">-->
- <!-- AND su.organ_id_ IN-->
- <!-- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">-->
- <!-- #{organId}-->
- <!-- </foreach>-->
- <!-- </if>-->
- GROUP BY su.organ_id_
- </select>
- <select id="getOrganTeacherStudentNum" resultType="map">
- SELECT stu.teacher_id_ 'key',COUNT(DISTINCT t.user_id_) 'value'
- FROM ((SELECT sr.user_id_
- FROM student_registration sr
- LEFT JOIN music_group mg ON sr.music_group_id_=mg.id_
- WHERE mg.status_='PROGRESS' AND sr.music_group_status_='NORMAL')
- UNION ALL
- (SELECT
- cssp.user_id_
- FROM
- course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
- WHERE
- cssp.group_type_ IN ('VIP', 'PRACTICE')
- AND cs.status_='NOT_START')) t
- LEFT JOIN student stu ON t.user_id_=stu.user_id_
- LEFT JOIN sys_user su ON t.user_id_ = su.id_
- LEFT JOIN teacher tea ON stu.teacher_id_=tea.id_
- WHERE su.del_flag_=0
- <if test="organId!=null">
- AND tea.organ_id_=#{organId}
- </if>
- <if test="teacherIds!=null and teacherIds.size()>0">
- AND stu.teacher_id_ IN
- <foreach collection="teacherIds" item="teacherId" open="(" close=")" separator=",">
- #{teacherId}
- </foreach>
- </if>
- GROUP BY stu.teacher_id_
- </select>
- <select id="getOrganNoTeacherStudentNum" resultType="int">
- SELECT COUNT(DISTINCT stu.user_id_)
- FROM student stu
- LEFT JOIN sys_user su ON stu.user_id_ = su.id_
- WHERE su.del_flag_=0 AND stu.teacher_id_ IS NULL
- <if test="organId!=null">
- AND su.organ_id_=#{organId}
- </if>
- </select>
- <select id="getCloudStudyStudentNum" resultType="int">
- SELECT
- COUNT(DISTINCT smcr.user_id_)
- FROM sys_music_compare_record smcr
- LEFT JOIN sys_user su ON smcr.user_id_=su.id_
- LEFT JOIN student stu ON smcr.user_id_=stu.user_id_
- WHERE su.del_flag_=0 AND stu.user_id_ IS NOT NULL AND su.organ_id_=#{organId};
- </select>
- <select id="getOrgansTotalCloudStudyStudentNum" resultType="int">
- SELECT
- COUNT(DISTINCT smcr.user_id_)
- FROM sys_music_compare_record smcr
- LEFT JOIN sys_user su ON smcr.user_id_=su.id_
- LEFT JOIN student stu ON smcr.user_id_=stu.user_id_
- WHERE su.del_flag_=0 AND stu.user_id_ IS NOT NULL
- <if test="organIds!=null and organIds.size()>0">
- AND su.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- </select>
- <select id="getOrgansTodayTotalCloudStudyStudentNum" resultType="int">
- SELECT
- COUNT(DISTINCT smcr.user_id_)
- FROM sys_music_compare_record smcr
- LEFT JOIN sys_user su ON smcr.user_id_=su.id_
- LEFT JOIN student stu ON smcr.user_id_=stu.user_id_
- WHERE su.del_flag_=0 AND stu.user_id_ IS NOT NULL
- AND DATE(smcr.create_time_) = CURDATE()
- <if test="organIds!=null and organIds.size()>0">
- AND su.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- </select>
- <select id="getOrganCloudStudyStudentNum" resultType="map">
- SELECT
- su.organ_id_ 'key',
- COUNT(DISTINCT smcr.user_id_) 'value'
- FROM sys_music_compare_record smcr
- LEFT JOIN sys_user su ON smcr.user_id_=su.id_
- LEFT JOIN student stu ON smcr.user_id_=stu.user_id_
- WHERE su.del_flag_=0 AND stu.user_id_ IS NOT NULL
- <if test="organIds!=null and organIds.size()>0">
- AND su.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- GROUP BY su.organ_id_
- </select>
- <select id="getOrganTeacherCloudStudyStudentNum" resultType="map">
- SELECT
- stu.teacher_id_ 'key',
- COUNT(DISTINCT smcr.user_id_) 'value'
- FROM sys_music_compare_record smcr
- LEFT JOIN sys_user su ON smcr.user_id_=su.id_
- LEFT JOIN student stu ON smcr.user_id_=stu.user_id_
- LEFT JOIN teacher tea ON stu.teacher_id_=tea.id_
- WHERE su.del_flag_=0 AND stu.user_id_ IS NOT NULL
- <if test="organId!=null">
- AND tea.organ_id_=#{organId}
- </if>
- <if test="teacherIds!=null and teacherIds.size()>0">
- AND stu.teacher_id_ IN
- <foreach collection="teacherIds" item="teacherId" open="(" close=")" separator=",">
- #{teacherId}
- </foreach>
- </if>
- GROUP BY stu.teacher_id_
- </select>
- <select id="getCloudStudyLivelyStudentNum" resultType="int">
- SELECT COUNT(user_id_)
- FROM (SELECT
- smcr.user_id_,
- COUNT(DISTINCT(CASE WHEN DATEDIFF(NOW(), smcr.create_time_)<=15 THEN DATE_FORMAT(smcr.create_time_, '%Y-%m-%d') ELSE NULL END)) days
- FROM sys_music_compare_record smcr
- LEFT JOIN sys_user su ON smcr.user_id_=su.id_
- LEFT JOIN student stu ON smcr.user_id_=stu.user_id_
- WHERE su.del_flag_=0 AND stu.user_id_ IS NOT NULL AND su.organ_id_=#{organId}
- GROUP BY smcr.user_id_) t WHERE t.days>=5
- </select>
- <select id="getOrganTotalCloudStudyLivelyStudentNum" resultType="int">
- SELECT COUNT(user_id_)
- FROM (SELECT
- smcr.user_id_,
- COUNT(DISTINCT(CASE WHEN DATEDIFF(NOW(), smcr.create_time_)<=15 THEN DATE_FORMAT(smcr.create_time_, '%Y-%m-%d') ELSE NULL END)) days
- FROM sys_music_compare_record smcr
- LEFT JOIN sys_user su ON smcr.user_id_=su.id_
- LEFT JOIN student stu ON smcr.user_id_=stu.user_id_
- WHERE su.del_flag_=0 AND stu.user_id_ IS NOT NULL
- <if test="organIds!=null and organIds.size()>0">
- AND su.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- GROUP BY smcr.user_id_) t WHERE t.days>=5
- </select>
- <select id="getOrganCloudStudyLivelyStudentNum" resultType="map">
- SELECT
- t.organ_id_ 'key',
- COUNT(user_id_) 'value'
- FROM (SELECT
- su.organ_id_,
- smcr.user_id_,
- COUNT(DISTINCT(CASE WHEN DATEDIFF(NOW(), smcr.create_time_)<=15 THEN DATE_FORMAT(smcr.create_time_, '%Y-%m-%d') ELSE NULL END)) days
- FROM sys_music_compare_record smcr
- LEFT JOIN sys_user su ON smcr.user_id_=su.id_
- LEFT JOIN student stu ON smcr.user_id_=stu.user_id_
- WHERE su.del_flag_=0 AND stu.user_id_ IS NOT NULL
- <if test="organIds!=null and organIds.size()>0">
- AND su.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- GROUP BY smcr.user_id_) t WHERE t.days>=5
- GROUP BY t.organ_id_
- </select>
- <sql id="queryCloudStudyStudentDataCondition">
- <where>
- su.del_flag_=0 AND t.user_id_ NOT IN (SELECT user_id_ FROM student WHERE subject_id_list_ REGEXP '21|25|26|27|28|29')
- <if test="organId!=null">
- AND su.organ_id_=#{organId}
- </if>
- <if test="search!=null and search!=''">
- AND (t.user_id_=#{search} OR su.username_ LIKE CONCAT('%', #{search}, '%'))
- </if>
- </where>
- </sql>
- <select id="queryCloudStudyStudentData" resultType="com.ym.mec.biz.dal.dto.EduOrganStudentListDto">
- SELECT
- stu.user_id_ studentId,
- su.username_ studentName,
- stu.teacher_id_ teacherId,
- tea.real_name_ teacherName,
- sub.name_ subjectName,
- stu.cloud_study_sequence_days_ cloudStudyRunningDays,
- COUNT(DISTINCT smcr.behavior_id_) cloudStudyUseNum,
- SUM(CASE WHEN smcr.play_time_ IS NULL THEN 0 ELSE play_time_ END) cloudStudyUseTime,
- COUNT(DISTINCT DATE(smcr.create_time_)) cloudStudyUseDays,
- stu.membership_end_time_ membershipEndTime
- FROM (SELECT DISTINCT t1.user_id_ FROM ((
- SELECT
- sr.user_id_
- FROM
- student_registration sr
- LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
- WHERE
- mg.status_ = 'PROGRESS'
- AND sr.music_group_status_ = 'NORMAL'
- ) UNION ALL
- (
- SELECT
- cssp.user_id_
- FROM
- course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
- WHERE
- cssp.group_type_ IN ( 'VIP', 'PRACTICE' )
- AND cs.status_ = 'NOT_START'
- )) t1) t
- LEFT JOIN student stu ON t.user_id_=stu.user_id_
- LEFT JOIN sys_user su ON stu.user_id_=su.id_
- LEFT JOIN sys_user tea ON stu.teacher_id_=tea.id_
- LEFT JOIN `subject` sub ON stu.subject_id_list_ = sub.id_
- LEFT JOIN sys_music_compare_record smcr ON stu.user_id_ = smcr.user_id_
- <include refid="queryCloudStudyStudentDataCondition" />
- GROUP BY stu.user_id_
- <trim prefix="ORDER BY " suffixOverrides=",">
- <if test="cloudStudyUseTime==null and cloudStudyRunningDays==null">
- stu.user_id_,
- </if>
- <if test="cloudStudyUseTime!=null">
- cloudStudyUseTime ${cloudStudyUseTime},
- </if>
- <if test="cloudStudyRunningDays!=null">
- cloudStudyRunningDays ${cloudStudyRunningDays}
- </if>
- </trim>
- <include refid="global.limit"></include>
- </select>
- <select id="countCloudStudyStudentData" resultType="int">
- SELECT
- COUNT( DISTINCT user_id_ )
- FROM
- ((
- SELECT
- sr.user_id_
- FROM
- student_registration sr
- LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
- WHERE
- mg.status_ = 'PROGRESS'
- AND sr.music_group_status_ = 'NORMAL'
- ) UNION ALL
- (
- SELECT
- cssp.user_id_
- FROM
- course_schedule_student_payment cssp
- LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
- WHERE
- cssp.group_type_ IN ( 'VIP', 'PRACTICE' )
- AND cs.status_ = 'NOT_START'
- )) t
- LEFT JOIN sys_user su ON t.user_id_ = su.id_
- <include refid="queryCloudStudyStudentDataCondition" />
- </select>
- <select id="getOrganEVipStudentNum" resultType="int">
- SELECT COUNT(DISTINCT stu.user_id_)
- FROM student stu
- LEFT JOIN cloud_teacher_order cto ON stu.user_id_=cto.student_id_
- LEFT JOIN sys_user su ON su.id_=stu.user_id_
- WHERE su.del_flag_=0 AND su.organ_id_=#{organId} AND stu.experience_member_rank_setting_id_ IS NOT NULL
- AND NOT EXISTS (SELECT student_id_ FROM cloud_teacher_order WHERE student_id_=stu.user_id_ AND status_ IN (1,2))
- </select>
- <select id="getOrgansTotalEVipStudentNum" resultType="int">
- SELECT COUNT(DISTINCT stu.user_id_)
- FROM student stu
- LEFT JOIN cloud_teacher_order cto ON stu.user_id_=cto.student_id_
- LEFT JOIN sys_user su ON su.id_=stu.user_id_
- WHERE su.del_flag_=0 AND stu.experience_member_rank_setting_id_ IS NOT NULL AND (cto.id_ IS NULL OR cto.status_ NOT IN (1, 2))
- <if test="organIds!=null and organIds.size()>0">
- AND su.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- </select>
- <select id="getOrgansEVipStudentNum" resultType="map">
- SELECT
- su.organ_id_ 'key',
- COUNT(DISTINCT stu.user_id_) 'value'
- FROM student stu
- LEFT JOIN cloud_teacher_order cto ON stu.user_id_=cto.student_id_
- LEFT JOIN sys_user su ON su.id_=stu.user_id_
- WHERE su.del_flag_=0 AND stu.experience_member_rank_setting_id_ IS NOT NULL
- AND stu.user_id_ NOT IN (SELECT DISTINCT student_id_ FROM cloud_teacher_order WHERE status_ IN (1,2))
- <if test="organIds!=null and organIds.size()>0">
- AND su.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- GROUP BY su.organ_id_
- </select>
- <select id="getTeacherExperienceMemberStudentNum" resultType="map">
- SELECT
- stu.teacher_id_ 'key',
- COUNT(DISTINCT stu.user_id_) 'value'
- FROM student stu
- LEFT JOIN cloud_teacher_order cto ON stu.user_id_=cto.student_id_
- LEFT JOIN sys_user su ON su.id_=stu.user_id_
- WHERE su.del_flag_=0 AND stu.experience_member_rank_setting_id_ IS NOT NULL AND (cto.id_ IS NULL OR cto.status_ NOT IN (1, 2))
- <if test="organId!=null">
- AND su.organ_id_=#{organId}
- </if>
- <if test="teacherIds!=null and teacherIds.size()>0">
- AND stu.teacher_id_ IN
- <foreach collection="teacherIds" item="teacherId" open="(" close=")" separator=",">
- #{teacherId}
- </foreach>
- </if>
- GROUP BY stu.teacher_id_
- </select>
- <select id="getStudentSubjectMapList" resultType="java.util.Map">
- SELECT stu.user_id_ 'key',sub.name_ 'value'
- FROM student stu
- LEFT JOIN `subject` sub ON stu.subject_id_list_ = sub.id_
- WHERE stu.user_id_ IN
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- </select>
- <select id="groupOrganId" resultMap="com.ym.mec.biz.dal.dao.IndexBaseMonthDataDao.IndexBaseMonthData">
- SELECT su.organ_id_,CURDATE() month_,
- COUNT(DISTINCT su.id_) total_num_ ,
- COUNT(DISTINCT su.id_) activate_num_ ,
- COUNT(DISTINCT su.id_) percent_
- FROM sys_user su
- WHERE 1 = 1
- <if test="userIds!=null and userIds.size() > 0">
- AND su.id_ IN
- <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
- #{userId}
- </foreach>
- </if>
- <if test="organIds!=null and organIds.size() > 0">
- AND su.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- GROUP BY su.organ_id_
- </select>
- <update id="updateGrade"><![CDATA[
- UPDATE student SET current_grade_num_=current_grade_num_+1
- WHERE current_grade_num_>=1
- AND current_grade_num_<= 11
- ]]>
- </update>
- <update id="updateNewStudentsToOld">
- UPDATE student SET is_new_user_=0
- WHERE user_id_ IN
- <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
- #{userId}
- </foreach>
- </update>
- <update id="cleanStudentMember">
- UPDATE student SET member_rank_setting_id_ = NULL WHERE NOW() > membership_end_time_
- </update>
- <update id="cleanExperienceStudentMember">
- UPDATE student SET experience_member_rank_setting_id_ = NULL WHERE NOW() > experience_membership_end_time_
- </update>
- <update id="cleanMember">
- UPDATE student SET member_rank_setting_id_ = NULL,membership_start_time_ = NULL,membership_end_time_ = NULL
- WHERE user_id_ = #{userId}
- </update>
- <update id="updateMemberExperience">
- UPDATE student SET
- member_rank_setting_id_ = #{rankId},membership_start_time_ = NOW(),membership_end_time_ = #{endTime},
- experience_member_rank_setting_id_ = #{rankId},experience_membership_start_time_ = NOW(),experience_membership_end_time_ = #{endTime}
- WHERE member_rank_setting_id_ IS NULL AND experience_member_rank_setting_id_ IS NULL
- AND FIND_IN_SET(user_id_,#{studentIds})
- </update>
- <update id="addStudentCloudStudySequenceDays">
- UPDATE student SET cloud_study_sequence_days_=cloud_study_sequence_days_+1,cloud_study_use_last_day_=curdate() WHERE user_id_=#{userId} AND (cloud_study_use_last_day_ IS NULL OR cloud_study_use_last_day_=date_sub(curdate(), interval 1 day))
- </update>
- <update id="updateStudentsCloudStudySequenceDays">
- UPDATE student SET cloud_study_sequence_days_=#{days} WHERE user_id_=#{userId}
- </update>
- <update id="cleanStudentCloudStudySequenceDays">
- UPDATE student SET cloud_study_sequence_days_=0,cloud_study_use_last_day_=date_sub(curdate(), interval 1 day) WHERE cloud_study_use_last_day_<date_sub(curdate(), interval 1 day)
- </update>
- </mapper>
|