123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542 |
- <?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.TeacherDao">
- <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.Teacher">
- <result column="user_id_" property="userId"/>
- <result column="education_background_" property="educationBackground"/>
- <result column="graduate_school_" property="graduateSchool"/>
- <result column="technical_titles_" property="technicalTitles"/>
- <result column="work_unit_" property="workUnit"/>
- <result column="subject_id_" property="subjectId"/>
- <result column="default_subject_" property="defaultSubject"/>
- <result column="introduction_" property="introduction"/>
- <result column="subject_" property="subject"/>
- <result column="grad_certificate_" property="gradCertificate"/>
- <result column="degree_certificate_" property="degreeCertificate"/>
- <result column="teacher_certificate_" property="teacherCertificate"/>
- <result column="entry_flag_" property="entryFlag"/>
- <result column="entry_auth_date_" property="entryAuthDate"/>
- <result column="musician_flag_" property="musicianFlag"/>
- <result column="musician_date_" property="musicianDate"/>
- <result column="member_rank_setting_id_" property="memberRankSettingId"/>
- <result column="membership_start_time_" property="membershipStartTime"/>
- <result column="membership_end_time_" property="membershipEndTime"/>
- <result column="live_flag_" property="liveFlag"/>
- <result column="live_date_" property="liveDate"/>
- <result column="music_date_" property="musicDate"/>
- <result column="video_date_" property="videoDate"/>
- <result column="style_date_" property="styleDate"/>
- <result column="degree_date_" property="degreeDate"/>
- <result column="teacher_date_" property="teacherDate"/>
- <result column="degree_flag_" property="degreeFlag"/>
- <result column="teacher_flag_" property="teacherFlag"/>
- <result column="browse_" property="browse"/>
- <result column="memo_" property="memo"/>
- <result column="lock_flag_" property="lockFlag"/>
- <result column="is_settlement_" property="isSettlement"/>
- <result column="is_test_user_" property="isTestUser"/>
- <result column="tenant_id_" property="tenantId"/>
- <result column="settlement_from_" property="settlementFrom"/>
- <result column="create_time_" property="createTime"/>
- <result column="update_time_" property="updateTime"/>
- <result column="im_device_id_" property="imDeviceId"/>
- <result column="customer_service_" property="customerService"/>
- <result column="customer_id_" property="customerId"/>
- </resultMap>
- <resultMap id="HotTeacherVoMap" type="com.yonge.cooleshow.biz.dal.vo.HotTeacherVo">
- <result column="user_id_" property="userId"/>
- <result column="avatar_" property="avatar"/>
- <result column="graduate_school_" property="graduateSchool"/>
- <result column="username_" property="username"/>
- <result column="isLiving_" property="isLiving"/>
- <result column="fansNum" property="fansNum"/>
- </resultMap>
- <!-- 表字段 -->
- <sql id="baseColumns">
- t.user_id_ as "userId"
- , t.education_background_ as "educationBackground"
- , t.graduate_school_ as "graduateSchool"
- , t.technical_titles_ as "technicalTitles"
- , t.work_unit_ as "workUnit"
- , t.subject_id_ as "subjectId"
- , t.default_subject_ as defaultSubject
- , t.introduction_ as "introduction"
- , t.subject_ as "subject"
- , t.grad_certificate_ as "gradCertificate"
- , t.degree_certificate_ as "degreeCertificate"
- , t.teacher_certificate_ as "teacherCertificate"
- , t.entry_flag_ as "entryFlag"
- , t.entry_auth_date_ as "entryAuthDate"
- , t.musician_flag_ as "musicianFlag"
- , t.musician_date_ as "musicianDate"
- , t.live_flag_ as "liveFlag"
- , t.music_date_ as "musicDate"
- , t.video_date_ as "videoDate"
- , t.style_date_ as "styleDate"
- , t.degree_date_ as "degreeDate"
- , t.teacher_date_ as "teacherDate"
- , t.degree_flag_ as "degreeFlag"
- , t.teacher_flag_ as "teacherFlag"
- , t.member_rank_setting_id_ as "memberRankSettingId"
- <!-- , t.membership_start_time_ as "membershipStartTime"-->
- <!-- , t.membership_end_time_ as "membershipEndTime"-->
- , t.browse_ as "browse"
- , t.memo_ as "memo"
- , t.tag_ as "tag"
- , t.is_settlement_ as "isSettlement"
- , t.is_test_user_ as "isTestUser"
- , t.create_time_ as "createTime"
- , t.update_time_ as "updateTime"
- , t.train_time_ as trainTime
- , t.evaluate_time_ as evaluateTime
- , t.tenant_id_ as tenantId
- , t.settlement_from_ as settlementFrom
- , t.im_device_id_ as imDeviceId
- , t.customer_service_ as customerService
- , t.customer_id_ as customerId
- , t.im_customer_id_ AS imCustomerId
- </sql>
- <!-- 分页查询 -->
- <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherVo">
- SELECT
- <include refid="baseColumns"/>,
- if(u.lock_flag_ = 0 and t.lock_flag_ = 0,0,1) as lockFlag,
- u.username_ as username,
- u.phone_ as phone,
- u.real_name_ as realName,
- u.avatar_ as avatar,
- u.birthdate_ as birthdate,
- u.gender_ as gender,
- <!-- (case when t.membership_end_time_ >= now() then 1 else 0 end) isVip,-->
- <!-- t.tag_ tag,-->
- u.del_flag_ as delFlag,
- ifnull(vcr2.vip_type_ ,'NORMAL') as vipType,
- max(if(vcr.vip_type_ = 'VIP', vcr.end_time_, null)) vipEndTime,
- max(if(vcr.vip_type_ = 'SVIP' and vcr.type_ = 'PERPETUAL', vcr.end_time_ , null)) perSvipEndTime,
- max(if(vcr.vip_type_ = 'SVIP', vcr.end_time_, null)) svipEndTime,
- max(vcr.end_time_) currentVipEndTime,
- (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
- (case when isnull(b.user_id_) then 0 else 1 end) as isBank,
- (case when t.tenant_id_ = -1 then '平台' else ti.name_ end) as tenantName
- FROM teacher t
- left join sys_user u on t.user_id_ = u.id_
- left join (
- select distinct user_id_ from user_bank_card where del_flag_ = 0
- ) b on t.user_id_ = b.user_id_
- left join tenant_info ti on t.tenant_id_ = ti.id_
- left join vip_card_record vcr on t.user_id_ = vcr.user_id_ and vcr.efficient_flag_ = 1 and vcr.client_type_='TEACHER'
- left join vip_card_record vcr2 on t.user_id_ = vcr2.user_id_ and vcr2.efficient_flag_ = 1 and vcr2.end_time_ > now() and now() >= vcr2.start_time_ and vcr2.client_type_='TEACHER'
- <where>
- <if test="null != param.search and '' != param.search">
- AND (
- t.user_id_ LIKE CONCAT('%', #{param.search}, '%') or
- u.username_ LIKE CONCAT('%', #{param.search}, '%') or
- u.real_name_ LIKE CONCAT('%', #{param.search}, '%') or
- u.phone_ LIKE CONCAT('%', #{param.search}, '%')
- )
- </if>
- <if test="null != param.teacherType and '' != param.teacherType">
- and (
- 1=0
- <if test='param.teacherType.contains("TOURIST")'>
- or (t.entry_flag_ = 0 and t.musician_flag_ = 0)
- </if>
- <if test='param.teacherType.contains("ENTRY")'>
- or t.entry_flag_ = 1
- </if>
- <if test='param.teacherType.contains("MUSICIAN")'>
- or t.musician_flag_ = 1
- </if>
- )
- </if>
- <if test="param.vipType != null">
- <if test="param.vipType.code == 'NORMAL'">
- and vcr2.id_ is null
- </if>
- <if test="param.vipType.code != 'NORMAL'">
- and vcr2.vip_type_ = #{param.vipType}
- </if>
- </if>
- <!-- <if test="param.isVip != null">-->
- <!-- <if test="param.isVip == 0">-->
- <!-- and (t.membership_end_time_ is null or t.membership_end_time_ < now())-->
- <!-- </if>-->
- <!-- <if test="param.isVip == 1">-->
- <!-- and t.membership_end_time_ >= now()-->
- <!-- </if>-->
- <!-- </if>-->
- <if test="param.tag != null">
- and find_in_set(#{param.tag},t.tag_)
- </if>
- <if test="null != param.lockFlag">
- and t.lock_flag_ = #{param.lockFlag}
- </if>
- <if test="null != param.delFlag">
- and u.del_flag_ = #{param.delFlag}
- </if>
- <if test="param.subjectId != null">
- and find_in_set(#{param.subjectId},t.subject_id_)
- </if>
- <if test="param.subjectIds != null and param.subjectIds.size() != 0">
- and (
- <foreach collection="param.subjectIds" item="subjectId" separator=" or " open="(" close=")">
- find_in_set(#{subjectId},t.subject_id_)
- </foreach>
- )
- </if>
- <if test="param.isSettlement != null">
- and t.is_settlement_ = #{param.isSettlement}
- </if>
- <if test="param.isTestUser != null">
- and t.is_test_user_ = #{param.isTestUser}
- </if>
- <if test="null != param.vipEndTime">
- and vcr.end_time_ <= #{param.vipEndTime}
- </if>
- <if test="null != param.vipStartTime">
- and vcr.end_time_ >= #{param.vipStartTime}
- </if>
- <if test="param.trainFlag != null">
- AND t.train_time_ > 0
- </if>
- <if test="param.evaluateFlag != null">
- AND t.evaluate_time_ > 0
- </if>
- <if test="param.tenantId != null">
- AND t.tenant_id_ = #{param.tenantId}
- </if>
- <if test="param.bindTenant != null and param.bindTenant == 0">
- and t.tenant_id_ = -1
- </if>
- <if test="param.bindTenant != null and param.bindTenant == 1">
- and t.tenant_id_ != -1
- </if>
- <if test="param.settlementFrom != null">
- AND t.settlement_from_ = #{param.settlementFrom}
- </if>
- <if test="param.tenantName != null and param.tenantName.trim() != ''">
- and ti.name_ like concat('%',#{param.tenantName},'%')
- </if>
- <if test="param.customerService != null">
- AND t.customer_service_ = #{param.customerService}
- </if>
- </where>
- group by t.user_id_
- <if test="param.vipStartTime != null and param.vipEndTime != null">
- <!-- having ((vipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> vipEndTime) or (svipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> svipEndTime))-->
- having currentVipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> currentVipEndTime
- </if>
- <choose>
- <when test="param.orderBy != null and param.orderBy.trim() != ''">
- order by ${param.orderBy}
- </when>
- <otherwise>
- order by t.create_time_ desc
- </otherwise>
- </choose>
- </select>
- <resultMap id="BasicUserInfo" type="com.yonge.cooleshow.biz.dal.dto.BasicUserInfo">
- <result property="userId" column="user_id_"/>
- <result property="username" column="username_"/>
- <result property="realName" column="real_name_"/>
- <result property="avatar" column="avatar_"/>
- <result property="phone" column="phone_"/>
- <result property="gender" column="gender_"/>
- <result property="birthdate" column="birthdate_"/>
- </resultMap>
- <select id="getBasicUserInfo" resultMap="BasicUserInfo">
- SELECT id_ user_id_, username_, real_name_, avatar_, phone_, gender_, birthdate_
- FROM sys_user
- WHERE del_flag_ = 0
- and id_ = #{userId}
- LIMIT 1
- </select>
- <select id="findBasicUserInfo" resultMap="BasicUserInfo">
- SELECT id_ user_id_,username_,real_name_,avatar_, phone_ FROM sys_user
- WHERE del_flag_ = 0 and id_ IN
- <foreach collection="studentIds" open="(" close=")" separator="," item="userId">
- #{userId}
- </foreach>
- </select>
- <select id="detail" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherVo">
- SELECT
- <include refid="baseColumns"/>,
- if(u.lock_flag_ = 0 and t.lock_flag_ = 0,0,1) as lockFlag,
- u.avatar_ as avatar,
- u.username_ as username,
- u.gender_ as `gender`,
- u.birthdate_ as birthdate,
- u.phone_ as phone,
- (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
- (!isnull(membership_end_time_) and membership_end_time_ > now()) as isVip,
- u.real_name_ as realName,
- u.id_card_no_ as idCardNo,
- if(vcr.type_ = 'PERMANENT',null,vcr.end_time_) as membershipEndTime,
- (case when isnull(b.user_id_) then 0 else 1 end) as isBank,
- (
- SELECT GROUP_CONCAT(name_ ORDER by locate(id_,t.subject_id_)) FROM subject WHERE FIND_IN_SET(id_,t.subject_id_)
- ) as subjectName,
- u.user_type_ as userType
- FROM teacher t
- left join sys_user u on t.user_id_ = u.id_
- left join (
- select distinct user_id_ from user_bank_card where del_flag_ = 0 and user_id_ = #{userId}
- ) b on t.user_id_ = b.user_id_
- left join vip_card_record vcr on t.user_id_ = vcr.user_id_ and vcr.client_type_ = 'TEACHER'
- and vcr.efficient_flag_ = 1 and vcr.end_time_ >= now() and now() > vcr.start_time_ and (vcr.vip_type_ = 'VIP' or vcr.vip_type_ = 'SVIP') and vcr.client_type_ = 'TEACHER'
- where t.user_id_ = #{userId}
- </select>
- <select id="querySubject" resultMap="com.yonge.cooleshow.biz.dal.dao.SubjectDao.Subject">
- SELECT s.*
- FROM `subject` s
- LEFT JOIN teacher t ON FIND_IN_SET(s.id_, t.subject_id_)
- WHERE t.user_id_ = #{userId}
- </select>
- <update id="setSubject">
- update teacher
- set subject_id_ = #{subjectIds},
- update_time_ = now()
- where user_id_ = #{id}
- </update>
- <update id="addHomeBrowse">
- update teacher
- set browse_ = browse_ + 1
- where user_id_ = #{userId}
- </update>
- <select id="querySubjectItem" resultType="com.yonge.cooleshow.biz.dal.entity.Subject">
- select t.* from subject t
- join (
- select a.subject_id_ from (
- <trim prefixOverrides="union all">
- <if test="type == null or type =='MUSIC'">
- union all
- (select music_subject_ as subject_id_ from music_sheet where user_id_ = #{userId} GROUP BY
- music_subject_)
- </if>
- <if test="type == null or type =='VIDEO'">
- union all
- (select lesson_subject_ as subject_id_ from video_lesson_group where teacher_id_ = #{userId} GROUP BY
- lesson_subject_)
- </if>
- <if test="type == null or type =='PIANO_ROOM'">
- union all
- (select subject_id_ as subject_id_ from course_group where type_ = 'PIANO_ROOM_CLASS' and teacher_id_ =
- #{userId} GROUP BY subject_id_)
- </if>
- <if test="type == null or type =='PRACTICE'">
- union all
- (select subject_id_ as subject_id_ from course_group where type_ = 'PRACTICE' and teacher_id_ =
- #{userId} GROUP BY subject_id_)
- </if>
- <if test="type == null or type =='VIP'">
- union all
- (select subject_id_ as subject_id_ from course_group where type_ = 'VIP' and teacher_id_ =
- #{userId} GROUP BY subject_id_)
- </if>
- <if test="type == null or type =='GROUP'">
- union all
- (select subject_id_ as subject_id_ from course_group where type_ = 'GROUP' and teacher_id_ =
- #{userId} GROUP BY subject_id_)
- </if>
- <if test="type == null or type =='LIVE'">
- union all
- (select subject_id_ as subject_id_ from course_group where type_ = 'LIVE' and teacher_id_ = #{userId}
- GROUP BY subject_id_)
- </if>
- </trim>
- ) a group by a.subject_id_
- ) a on t.id_ = a.subject_id_
- where t.parent_subject_id_ != 0
- and not exists(
- select 1 from teacher s where s.user_id_ = #{userId} and find_in_set(t.id_,s.subject_id_)
- )
- </select>
- <select id="queryMyFans" resultType="com.yonge.cooleshow.biz.dal.vo.MyFens">
- SELECT
- s.student_id_ AS userId,
- s.create_time_ AS starTime,
- u.avatar_ AS avatar,
- u.username_ AS userName,
- u.real_name_ AS realName,
- u.gender_ AS gender,
- u.phone_ AS phone,
- u.birthdate_ AS birthdate,
- (SELECT group_concat(name_) FROM `subject` WHERE find_in_set(id_,sr.subject_id_)) AS subjectName
- <!-- if(sr.membership_start_time_ <= now() and sr.membership_end_time_ >= now(),1,0) AS isVip-->
- FROM student_star s
- LEFT JOIN sys_user u ON s.student_id_ = u.id_
- LEFT JOIN student sr ON s.student_id_ = sr.user_id_
- <where>
- <!-- u.del_flag_ = 0-->
- <if test="record.teacherId != null">
- AND s.teacher_id_ =#{record.teacherId}
- </if>
- <if test="record.nickname != null">
- AND u.username_ LIKE '%${record.nickname}%'
- </if>
- <if test="record.userId != null">
- AND u.id_ = #{record.userId}
- </if>
- <if test="record.phone != null">
- AND u.phone_ = #{record.phone}
- </if>
- <if test="record.startTime != null and record.endTime != null">
- AND ( #{record.startTime} <= s.create_time_ AND s.create_time_ <= #{record.endTime})
- </if>
- </where>
- </select>
- <select id="queryHotTeacherList" resultMap="HotTeacherVoMap">
- select t.user_id_, t.graduate_school_, u.username_, u.avatar_, ifnull(a.speaker_id_, 0) isLiving_,tt.fans_num_ fansNum
- from teacher t
- left join sys_user u on t.user_id_ = u.id_
- left join teacher_total tt on tt.user_id_ = t.user_id_
- left join (SELECT lr.speaker_id_
- from live_room lr
- WHERE live_state_ = 1 and type_ = 'temp'
- group by lr.speaker_id_) a on a.speaker_id_ = t.user_id_
- left join (select tft.teacher_id_,COUNT(DISTINCT tsp.course_type_) num from teacher_free_time tft
- left join teacher_subject_price tsp ON tsp.teacher_id_ = tft.teacher_id_
- group by tft.teacher_id_) tft ON tft.teacher_id_ = t.user_id_
- left join (select create_by_,COUNT(DISTINCT create_by_) num from music_sheet where del_flag_ = 0 AND state_ = 1 AND source_type_ = 'TEACHER'
- GROUP BY create_by_) ms ON ms.create_by_ = t.user_id_
- where t.entry_flag_ = 1
- and t.is_test_user_ = 0 AND t.lock_flag_ = 0
- and find_in_set(#{subjectId}, t.subject_id_)
- order by tft.num desc ,ms.num DESC ,tt.fans_num_ desc,t.user_id_
- limit 10
- </select>
- <!--老师学生人数统计-->
- <select id="selectTeacherStudentNumberStatInfo"
- resultType="com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper">
- SELECT t1.teacher_id_ AS id, COUNT(DISTINCT t1.id_) AS total FROM user_binding_teacher t1
- <where>
- <if test="teacherIds != null">
- AND t1.teacher_id_ IN (<foreach collection="teacherIds" separator="," item="item">
- #{item}
- </foreach>)
- </if>
- </where>
- GROUP BY t1.teacher_id_
- </select>
- <select id="countTeacherByTenantIds" resultType="com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper$UserCount">
- select tenant_id_ tenantId, count(tenant_id_) count
- from teacher
- <where>
- lock_flag_ = 0
- <if test="tenantIdList != null">
- AND tenant_id_ in
- <foreach collection="tenantIdList" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- </where>
- group by tenant_id_
- </select>
- <select id="queryTeacherCounts" resultType="java.lang.Integer">
- select count(tenant_id_)
- from teacher
- <where>
- lock_flag_ = 0
- <if test="id != null">
- and tenant_id_ = #{id}
- </if>
- </where>
- </select>
- <!--老师学生人数统计-->
- <select id="getCustomerServiceByFriendLeast" resultMap="BaseResultMap">
- select
- t.*
- from
- ( SELECT
- te.user_id_,
- count(iuf.friend_id_) friends
- from teacher te
- left join sys_user su on te.user_id_ = su.id_
- left join im_user_friend iuf on te.user_id_ = iuf.user_id_ and iuf.source_form_='CUSTOMER'
- where te.lock_flag_ = 0 and te.customer_service_ = 1 and su.del_flag_ = 0 and su.lock_flag_ = 0
- group by te.user_id_
- order by friends
- limit 1) m
- left join teacher t on m.user_id_ = t.user_id_
- </select>
- <select id="getCustomerServiceFriendNums" resultType="com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherWrapper$TeacherFriend">
- SELECT te.user_id_ teacherId,
- count(k.user_id_) friendNums
- from teacher te
- left join sys_user su on te.user_id_ = su.id_
- left join (select s.user_id_, s.customer_id_
- from student s
- where s.customer_id_ is not null
- union all
- select te.user_id_, te.customer_id_
- from teacher te
- where te.customer_service_ = 0 and te.customer_id_ is not null) k on te.user_id_ = k.customer_id_
- where te.lock_flag_ = 0
- and te.customer_service_ = 1
- and su.del_flag_ = 0
- and su.lock_flag_ = 0
- group by te.user_id_
- order by friendNums
- </select>
- <!--系统客服列表-->
- <select id="selectCustomerServiceV2" resultType="com.yonge.cooleshow.biz.dal.entity.Teacher">
- SELECT t.im_customer_id_ AS imCustomerId FROM (
- SELECT CONCAT(t1.user_id_, '_TEACHER') AS im_customer_id_ FROM teacher t1 LEFT JOIN sys_user t2 ON t1.user_id_ = t2.id_ WHERE t1.customer_service_ = 1 AND t1.lock_flag_ = 0 AND t2.lock_flag_ = 0
- UNION ALL
- SELECT CONCAT(t1.user_id_, '_SYSTEM') AS im_customer_id_ FROM employee t1 LEFT JOIN sys_user t2 ON t1.user_id_ = t2.id_ WHERE t1.customer_service_ = 1 AND t1.lock_flag_ = 0 AND t2.lock_flag_ = 0
- ) t
- </select>
- <!--系统客服好友统计-->
- <select id="countCustomerServiceMemberNum"
- resultType="com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper">
- SELECT t.im_customer_id_ AS gid, COUNT(t.user_id_) AS total FROM (
- SELECT t1.im_customer_id_, t1.user_id_ FROM teacher t1 WHERE t1.im_customer_id_ != '' AND t1.customer_service_ = 0
- UNION ALL
- SELECT t1.im_customer_id_, t1.user_id_ FROM student t1 WHERE t1.im_customer_id_ != ''
- ) t GROUP BY t.im_customer_id_
- </select>
- <select id="getStudentIds" resultType="java.lang.Long">
- select distinct cssp.user_id_ from course_group cg
- left join course_schedule_student_payment cssp ON cssp.course_group_id_ = cg.id_
- <if test="startTime != null and startTime != ''">
- left join course_schedule cs ON cssp.course_id_ = cs.id_
- </if>
- <if test="subjectId != null">
- left join student st ON st.user_id_ = cssp.user_id_
- </if>
- where cg.status_ = 'ING' AND cg.teacher_id_ = #{teacherId}
- <if test="startTime != null and startTime != ''">
- AND cs.class_date_ BETWEEN #{startTime} AND #{endTime}
- </if>
- <if test="subjectId != null">
- and find_in_set(#{subjectId},st.subject_id_)
- </if>
- union
- select distinct st.user_id_ from tenant_group tg
- left join student st ON st.tenant_group_id_ = tg.id_
- where tg.admin_id_ = #{teacherId}
- <if test="subjectId != null">
- and find_in_set(#{subjectId},st.subject_id_)
- </if>
- </select>
- </mapper>
|