123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576 |
- <?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.ssj.service.mapper.CuratorMapper">
- <select id="findMyInfo" resultType="com.ssj.service.conch.curator.dto.CuratorDTO">
- select tb_lib_manager.name curator_name,
- tb_lib_manager.telephone phone,
- tb_lib_manager.lib_id,
- tb_lib_join.league_name lib_name
- from tb_lib_manager,
- tb_lib_join
- where tb_lib_manager.lib_id = tb_lib_join.id
- and tb_lib_manager.user_id = #{curatorUserId}
- and tb_lib_manager.type = 4
- and tb_lib_manager.state = 1
- limit 1
- </select>
- <select id="findApplyInfo" resultType="com.ssj.service.conch.curator.dto.CuratorDTO">
- select tb_lib_manager_audit.name curator_name,
- tb_lib_manager_audit.telephone phone,
- tb_lib_manager_audit.lib_id,
- tb_lib_join.league_name lib_name
- from tb_lib_manager_audit,
- tb_lib_join
- where tb_lib_manager_audit.lib_id = tb_lib_join.id
- and tb_lib_manager_audit.user_id = #{curatorUserId}
- and tb_lib_manager_audit.type = 4
- limit 1
- </select>
- <!--校长端老师列表-->
- <select id="findCuratorTeacherList" resultType="com.ssj.bean.conch.curator.dto.CuratorTeacherListDto">
- select lm.user_id teacher_id, group_concat(lm.type) teacher_type_list, group_concat(distinct course_name) subject,
- lm.name, lm.t_photo img_url, lm.telephone phone,ct.class_sum from tb_lib_manager lm
- left join (select teacher_id, count(class_id) class_sum from tb_class_teacher where status=1 and lib_id=#{libId} group by teacher_id) ct
- on ct.teacher_id=lm.user_id
- where lm.type in
- <foreach collection="types" open="(" item="type" separator="," close=")">
- #{type}
- </foreach>
- <if test="searchKey != null and searchKey != '' ">
- and lm.name regexp #{searchKey}
- </if>
- and lm.state=1 and lm.lib_id=#{libId}
- group by lm.user_id
- </select>
- <select id="findCuratorAuditTeacherList" resultType="com.ssj.bean.conch.curator.dto.CuratorTeacherListDto">
- select lm.user_id teacher_id, group_concat(lm.type) teacher_type_list, group_concat(distinct subject) subject,
- lm.name, (select t_photo from tb_lib_manager where id=lm.lib_manager_id) img_url, lm.telephone phone,0 class_sum
- from tb_lib_manager_audit lm
- where lm.type in
- <foreach collection="types" open="(" item="type" separator="," close=")">
- #{type}
- </foreach>
- <if test="searchKey != null and searchKey != '' ">
- and lm.name regexp #{searchKey}
- </if>
- and lm.status=3
- and lm.lib_id=#{libId}
- group by lm.user_id
- </select>
- <!--老师详情-->
- <select id="findCuratorTeacherDetailData" resultType="com.ssj.bean.conch.curator.dto.CuratorTeacherListDto">
- select lm.user_id teacher_id, group_concat(lm.type) teacher_type_list, group_concat(distinct course_name) subject,
- lm.name, lm.t_photo img_url, lm.telephone phone from tb_lib_manager lm
- where lm.state = 1 and lm.user_id=#{teacherId} and lm.type in
- <foreach collection="types" open="(" item="type" separator="," close=")">
- #{type}
- </foreach>
- group by lm.user_id
- </select>
- <!--老师详情-->
- <select id="findCuratorTeacherDetailDataV1" resultType="com.ssj.bean.conch.curator.dto.CuratorTeacherListDto">
- select lm.user_id teacher_id, group_concat(lm.type) teacher_type_list, group_concat(distinct course_name) subject,
- lm.name, lm.t_photo img_url, lm.telephone phone from tb_lib_manager lm
- where lm.state = 1 and lm.user_id=#{teacherId} and lm.lib_id=#{libId} and lm.type in
- <foreach collection="types" open="(" item="type" separator="," close=")">
- #{type}
- </foreach>
- group by lm.user_id
- </select>
- <!--查询老师详情的班级列表-->
- <select id="findTeacherDetailClassList" resultType="com.ssj.bean.conch.curator.dto.TeacherDetailClassListDto">
- select c.id class_id, c.class_name, if(c.status=2, 1, 0) is_default from tb_class_teacher ct
- left join tb_class c on ct.class_id=c.id
- where ct.teacher_id=#{teacherId} and ct.status=1 and c.status in (1, 2)
- </select>
- <!--查询老师详情的班级列表-->
- <select id="findTeacherDetailClassListV1" resultType="com.ssj.bean.conch.curator.dto.TeacherDetailClassListDto">
- select c.id class_id, c.class_name, if(c.status=2, 1, 0) is_default from tb_class_teacher ct
- left join tb_class c on ct.class_id=c.id
- where ct.teacher_id=#{teacherId} and ct.lib_id=#{libId} and ct.status=1 and c.status in (1, 2)
- </select>
- <!--查询班级列表的学生数-->
- <select id="findClassStudentCount" resultType="com.ssj.bean.conch.curator.dto.TeacherDetailClassListDto">
- select class_id, count(1) student_sum from tb_class_student t1 left join tb_lib_vip t2
- on t1.vip_id=t2.id
- where t1.class_id in
- <foreach collection="classIds" open="(" item="classId" separator="," close=")">
- #{classId}
- </foreach>
- and t1.lib_id=t2.lib_id
- and t1.status in(1,2)
- and t1.vip_id is not null
- group by t1.class_id
- </select>
- <!--查询班级列表的学生数-->
- <select id="findClassTeacherCount" resultType="com.ssj.bean.conch.curator.dto.TeacherDetailClassListDto">
- select class_id, count(1) teacher_sum from tb_class_teacher
- where class_id in
- <foreach collection="classIds" open="(" item="classId" separator="," close=")">
- #{classId}
- </foreach>
- and status = 1
- group by class_id
- </select>
- <!--查询老师不在的的班级列表-->
- <select id="findTeacherNotInClassList" resultType="com.ssj.bean.conch.curator.dto.TeacherDetailClassListDto">
- select class.id class_id, class.class_name, if(class.status=2, 1, 0) is_default from tb_class class
- left join tb_class_teacher teacher on class.id=teacher.class_id
- and teacher.status=1
- and teacher.teacher_id = #{teacherId}
- where class.lib_id=#{libId} and class.status in (1, 2) and teacher.id is null
- </select>
- <sql id="studentDetail">
- select t.class_name className,t.id classId, t2.id vipId,t2.child_name childName,t2.img_url imgUrl,t2.grade,t2.sex,t2.school,IF(t3.mobile is null,t2.phone,t3.mobile) phone,
- case when t4.stat = 2 or t4.stat is null then -1 else 0 end as correctType,
- case when t4.stat = 2 or t4.stat is null then 1 else 0 end sort_no
- from tb_lib_vip t2
- left join (select tc.class_name,tc.id,tcs.vip_id
- from tb_class_student tcs,tb_class tc
- where tcs.status in (1,2)
- and tcs.lib_id=#{libId}
- and tc.status=1
- and tcs.class_id=tc.id
- ) t on t2.id=t.vip_id
- left join tb_user t3 on t2.user_id=t3.id
- left join tb_lib_vip_service t4 on t2.id = t4.vip_id and t4.type='C025' and t4.species='S003'
- where 1=1
- and t4.lib_id=#{libId}
- </sql>
- <select id="findCorrectType" resultType="Integer">
- select IF(ts.species='S999',999,correct_type) from tb_lib_vip_service ts
- where ts.vip_id=#{vipId}
- and ts.stat = 1
- and ts.species in ('S003','S999')
- and to_days(ts.start_time) <=to_days(now())
- and to_days(ts.end_time) >= to_days(now())
- ORDER BY ts.species,ts.service_sort,ts.correct_type,ts.start_time limit 1
- </select>
- <!--查询校区指定班级的学生-->
- <select id="findClassStudentDetail" resultType="java.util.Map">
- <include refid="studentDetail" />
- and t.id=#{classId}
- <if test="name != null and name != '' ">
- and t2.child_name regexp #{name}
- </if>
- order by convert(childName using gbk) asc
- </select>
- <!--查询校区所有学生,包含分班和未分班的-->
- <select id="findClassStudentDetailByLibId" resultType="java.util.Map">
- <include refid="studentDetail" />
- <if test="name != null and name != '' ">
- and t2.child_name regexp #{name}
- </if>
- order by sort_no,convert(childName using gbk) asc
- </select>
- <!--查询不在本班的其余学生列表,包含分班和未分班的-->
- <select id="findOtherClassStudentDetail" resultType="java.util.Map">
- <include refid="studentDetail" />
- and (t.id !=#{classId} or t.id is null)
- and t4.stat=1
- <if test="name != null and name != '' ">
- and t2.child_name regexp #{name}
- </if>
- order by sort_no,convert(childName using gbk) asc
- </select>
- <!--查询校区对应学生详情-->
- <select id="findStudentDetailByVipId" resultType="java.util.Map">
- <include refid="studentDetail" />
- and t2.id=#{vipId}
- limit 1
- </select>
- <select id="findClassList" resultType="java.util.Map">
- select t1.id classId,
- t1.class_name className,
- (select count(distinct t2.vip_id)
- from tb_class_student t2,
- tb_lib_subscribe ls
- where t2.class_id = t1.id
- and t2.status = 1
- and ls.vip_id = t2.vip_id
- and to_days(ls.ryke_time) = to_days(now())
- and ls.lib_id = #{libId}
- and ls.stat = '1'
- and ls.flow_stat in ('3', '4')
- and t2.vip_id is not null) signedStudentCount,
- (select count(distinct t2.vip_id)
- from tb_class_student t2,tb_lib_vip t3
- where t2.vip_id = t3.id
- and t2.lib_id = t3.lib_id
- and t2.class_id = t1.id
- and t2.status =1
- and t2.vip_id is not null) studentSum,
- (select count(distinct t3.teacher_id)
- from tb_class_teacher t3
- where t3.class_id = t1.id
- and t3.lib_id = t1.lib_id
- and t3.status = 1
- and exists(
- select t4.user_id
- from tb_lib_manager t4
- where t4.lib_id = t1.lib_id
- and t4.user_id = t3.teacher_id
- and t4.state = 1
- and t4.type in (2, 10, 15)
- and t4.is_cancelled = 0
- )
- and t3.teacher_id is not null) teacherSum
- from tb_class t1
- where t1.lib_id = #{libId}
- and t1.status =1
- order by t1.status desc, t1.create_time
- </select>
- <!--查询学生不在的的班级列表-->
- <select id="findStudentNotInClass" resultType="java.util.Map">
- select t1.id classId,t1.class_name className,
- (
- select count(distinct t2.vip_id) from tb_class_student t2 where
- t2.class_id=t1.id
- and t2.lib_id=t1.lib_id
- and t2.status =1
- and t2.vip_id is not null
- ) as studentSum,
- (
- select count(distinct t3.teacher_id) from tb_class_teacher t3
- where t3.class_id=t1.id and t3.lib_id=t1.lib_id
- and t3.status=1
- and exists(
- select t4.user_id from tb_lib_manager t4
- where t4.lib_id=t1.lib_id
- and t4.user_id=t3.teacher_id
- and t4.state=1
- and t4.type in(2,10,15)
- and t4.is_cancelled=0
- )
- and t3.teacher_id is not null
- ) as teacherSum
- from tb_class t1
- where
- <if test="libId != null and libId != '' ">
- t1.lib_id =#{libId}
- </if>
- <if test="classId != null and classId != '' ">
- and t1.id !=#{classId}
- </if>
- and t1.status =1
- order by t1.status desc,t1.create_time
- </select>
- <select id="getTodayStudentHomeworkSum" resultType="java.util.Map">
- select sum(case when s.is_delete = 0 then 1 else 0 end) homeworkNum,
- sum(case when s.is_delete = 0 and s.is_feedback = 1 then 1 else 0 end ) feedbackNum1,
- sum(case when s.is_delete = 0 and s.is_feedback = 0 and s.is_mark in(1,3) then 1 else 0 end ) feedbackNum2
- from scon_homework_picture s where s.vip_id = #{vipId} and s.is_delete = 0 and TO_DAYS(s.create_time) = TO_DAYS(NOW())
- </select>
- <select id="getUploadHomeworkSumByClassId" resultType="java.lang.Integer">
- select count(*) from (
- select s.vip_id from scon_homework_picture s where s.vip_id in (
- select t1.vip_id from tb_class t left join tb_class_student t1
- on t.id=t1.class_id
- left join tb_lib_vip t2
- on t1.vip_id=t2.id
- where t.id=#{classId}
- and t1.status=1
- and t1.lib_id=t2.lib_id
- and t2.stat=1)
- and s.create_time regexp #{date} and s.is_delete = 0 GROUP BY s.vip_id) as sss
- </select>
- <select id="getNoCorrectSumByClassId" resultType="java.lang.Integer">
- select count(*) from (
- select s.vip_id from scon_homework_picture s where s.vip_id in (
- select t1.vip_id from tb_class t left join tb_class_student t1
- on t.id=t1.class_id
- left join tb_lib_vip t2
- on t1.vip_id=t2.id
- where t.id=#{classId}
- and t1.status=1
- and t1.lib_id=t2.lib_id
- and t2.stat=1)
- and s.create_time regexp #{date} and s.is_delete = 0 and s.is_feedback = 0 and is_mark in (0, 2) GROUP BY s.vip_id) as sss
- </select>
- <select id="getStudentSumByClassId" resultType="java.lang.Integer">
- select count(*) from (
- select t1.vip_id from tb_class t left join tb_class_student t1
- on t.id=t1.class_id
- left join tb_lib_vip t2
- on t1.vip_id=t2.id
- where t.id=#{classId}
- and t1.status=1
- and t1.lib_id=t2.lib_id
- and t2.stat=1) as sss
- </select>
- <select id="renewStudentList" resultType="java.util.Map">
- select t.id vipId,
- t.child_name childName,
- t.img_url imgUrl,
- t.grade,
- (select concat(IF(ts.species = 'S999', 999, ts.correct_type), '#S', ts.end_time)
- from tb_lib_vip_service ts
- where ts.stat = 1
- and ts.species in ('S003', 'S999')
- and to_days(ts.start_time) <= to_days(now())
- and to_days(ts.end_time) >= to_days(now())
- and t.id = ts.vip_id
- ORDER BY ts.species, ts.service_sort, ts.correct_type, ts.start_time
- limit 1
- ) serviceInfo,
- (select tc.class_name from tb_class_student tcs,tb_class tc
- where tcs.class_id = tc.id and t.id = tcs.vip_id and tcs.status = 1 and tc.status>0 limit 1) className
- from tb_lib_vip t
- where 1 = 1
- <if test="map.libId != null and map.libId != '' ">
- and t.lib_id=#{map.libId}
- </if>
- <if test="map.classIdList != null and map.classIdList.size() > 0">
- and exists(select 1 from tb_class_student tc where t.id = tc.vip_id and status = 1
- and tc.class_id in
- <foreach collection="map.classIdList" index="i" item="classId" open="(" close=")" separator=",">
- #{classId}
- </foreach>
- )
- </if>
- </select>
- <select id="getUploadHomeworkSumByLibId" resultType="java.lang.Integer">
- select count(*) from (
- select s.id from scon_homework_picture s where s.vip_id in (
- select t2.id from tb_lib_vip t2
- where t2.lib_id=#{libId}
- and t2.stat=1)
- and TO_DAYS(s.create_time) = TO_DAYS(NOW()) and s.is_delete = 0 GROUP BY s.vip_id) as sss
- </select>
- <select id="homeworkIndex" resultType="java.util.Map">
- select t11.vip_id,t.id,t12.child_name,t12.grade,t13.league_name,t12.school,count(1) as pictureCount,group_concat(t11.file_key) as file_keys,t11.create_time,t.`subject`
- ,count(IF(t11.corrected_picture_url is not null,true,null)) as correctedCount,group_concat(t11.corrected_picture_url) as corrected_keys
- ,count(IF(t.subject='语文',true,null)) as count1,count(IF(t.subject='数学',true,null)) as count2,count(IF(t.subject='英语',true,null)) as count3
- from scon_homework t
- left join scon_homework_picture t11 on t.id = t11.homework_id
- left join tb_lib_vip t12 on t11.vip_id = t12.id
- left join tb_lib_join t13 on t12.lib_id = t13.id
- where t11.create_time regexp #{queryDate}
- and t12.lib_id=#{libId} and t11.is_delete = 0
- <if test="searchValue != '' ">
- and t12.child_name regexp #{searchValue}
- </if>
- group by t11.vip_id
- order by t.subject,t11.create_time desc
- </select>
- <select id="findPageStudentList" resultType="java.util.Map">
- select distinct t.class_name className,t.id classId, t1.vip_id vipId,t2.child_name childName,t2.img_url imgUrl,t2.grade grade,t3.mobile phone
- from tb_class t left join tb_class_student t1
- on t.id=t1.class_id
- left join tb_lib_vip t2 on t1.vip_id=t2.id
- left join tb_user t3 on t2.user_id=t3.id
- left join tb_lib_vip_service t4 on t2.id = t4.vip_id
- where t.lib_id=#{map.libId}
- and t1.status=1
- and t2.stat=1
- <if test="map.searchValue != null and map.searchValue != '' ">
- and t2.child_name regexp #{map.searchValue}
- </if>
- <if test="map.startDate != null and map.startDate != '' ">
- and to_days(t4.end_time) >= to_days(#{map.startDate})
- </if>
- <if test="map.endDate != null and map.endDate != '' ">
- and to_days(#{map.endDate}) >= to_days(t4.end_time)
- </if>
- <if test="map.stat != null and map.stat != '' ">
- and t4.stat=#{map.stat}
- </if>
- <if test="map.classId != null and map.classId != '' ">
- and t.id=#{map.classId}
- </if>
- <if test="map.serviceType != null and map.serviceType != '' and map.serviceType=='S999'">
- and t4.species='S999'
- </if>
- <if test="map.serviceType != null and map.serviceType != '' and map.serviceType!='S999'">
- and t4.correct_type=#{map.serviceType}
- </if>
- group by t2.id
- </select>
- <select id="findServiceListByVipId" resultType="java.util.Map">
- select t.start_time,t.end_time,case when t.stat=1 then '有效' else '无效' end stat,
- case when t.species='S999' then '内部用户' when t.correct_type=0 then '无服务' when t.correct_type=1 then '平台服务(家长购买)'
- when t.correct_type=2 then '校区服务' when t.correct_type=4 then '平台服务(机构购买)' when t.correct_type=0 then '服务已关闭' else '批改服务'
- end as correct_type
- from tb_lib_vip_service t
- where t.vip_id=#{map.vipId} and t.species in ('S003', 'S999')
- <if test="map.startDate != null and map.startDate != '' ">
- and to_days(t.end_time) >= to_days(#{map.startDate})
- </if>
- <if test="map.endDate != null and map.endDate != '' ">
- and to_days(#{map.endDate}) >= to_days(t.end_time)
- </if>
- <if test="map.stat != null and map.stat != '' ">
- and t.stat=#{map.stat}
- </if>
- <if test="map.serviceType != null and map.serviceType != '' and map.serviceType=='S999'">
- and t.species='S999'
- </if>
- <if test="map.serviceType != null and map.serviceType != '' and map.serviceType!='S999'">
- and t.correct_type=#{map.serviceType}
- </if>
- order by t.end_time desc
- </select>
- <select id="findClassListBySys" resultType="java.util.Map">
- select t1.id classId,
- t1.class_name className,
- (select count(distinct t2.vip_id)
- from tb_class_student t2,
- tb_lib_subscribe ls
- where t2.class_id = t1.id
- and t2.status = 1
- and ls.vip_id = t2.vip_id
- and to_days(ls.ryke_time) = to_days(now())
- and ls.lib_id = #{libId}
- and ls.stat = '1'
- and ls.flow_stat in ('3', '4')
- and t2.vip_id is not null) signedStudentCount,
- (select count(distinct t2.vip_id)
- from tb_class_student t2,tb_lib_vip t3
- where t2.vip_id = t3.id
- and t2.lib_id = t3.lib_id
- and t2.class_id = t1.id
- and t2.status = 1
- and t2.vip_id is not null) studentSum,
- (select count(distinct t3.teacher_id)
- from tb_class_teacher t3
- where t3.class_id = t1.id
- and t3.lib_id = t1.lib_id
- and t3.status = 1
- and exists(
- select t4.user_id
- from tb_lib_manager t4
- where t4.lib_id = t1.lib_id
- and t4.user_id = t3.teacher_id
- and t4.state = 1
- and t4.type in (2, 10, 15)
- and t4.is_cancelled = 0
- )
- and t3.teacher_id is not null) teacherSum
- from tb_class t1
- where t1.lib_id = #{libId}
- and t1.status in (1, 2)
- <if test="searchValue != null and searchValue != '' ">
- and t1.class_name regexp #{searchValue}
- </if>
- <if test="teacherId != null and teacherId != '' ">
- and t1.id in (
- select class_id from tb_class_teacher where status = 1
- and teacher_id=#{teacherId}
- )
- </if>
- order by t1.status desc, t1.create_time
- </select>
- <select id="findCuratorTeacherListBySys" resultType="com.ssj.bean.conch.curator.dto.CuratorTeacherListDto">
- select lm.user_id teacher_id, group_concat(distinct lm.type) teacher_type_list, group_concat(distinct lm.course_name) subject,
- lm.name, lm.t_photo img_url, lm.telephone phone,count(distinct ct.class_id) as class_sum from tb_lib_manager lm
- left join tb_class_teacher ct on ct.teacher_id=lm.user_id and lm.lib_id = ct.lib_id and ct.status = 1
- where lm.type in
- <foreach collection="types" open="(" item="type" separator="," close=")">
- #{type}
- </foreach>
- <if test="searchKey != null and searchKey != '' ">
- and lm.name regexp #{searchKey}
- </if>
- <if test="classId != null and classId != '' ">
- and ct.class_id = #{classId}
- </if>
- and lm.state=1 and lm.lib_id=#{libId} and lm.is_cancelled = 0
- group by lm.user_id
- </select>
- <select id="findClassStudentScore" resultType="java.util.Map">
- select user_name name, img_url imgUrl,ifNull(ranking_num,0) rankNum, rowno as `index`, class_name className, vip_id vipId
- from (select a.child_name as user_name,
- a.img_url,
- a.vip_id,
- a.class_name,
- a.ranking_num,
- (@rowno := @rowno + 1) as rowno
- from (select tcs.vip_id ,shr.ranking_num ,tlv.child_name,tlv.img_url, c.class_name,shr.update_time
- from tb_class_student tcs left join scon_homework_ranking shr
- on tcs.vip_id=shr.vip_id
- left join tb_lib_vip tlv on tcs.vip_id=tlv.id
- join tb_class c on tcs.class_id = c.id
- where tlv.stat = 1
- <if test="classId != null and classId != '' ">
- and tcs.class_id = #{classId}
- </if>
- and tcs.lib_id=#{libId}
- and tcs.status=1) as a,
- (select @rowno := 0) as row
- order by a.ranking_num desc, a.update_time desc) as temp
- </select>
- <select id="allLibIndex" resultType="java.util.Map">
- select count(1) as totolCount,count(if(t.subject='语文',true,null)) as chineseCount,count(if(t.subject='数学',true,null)) as shuxueCount,count(if(t.subject='英语',true,null)) as englishCount from
- scon_homework_picture t
- left join tb_lib_vip t1 on t.vip_id = t1.id
- where t.is_delete = 0 and t1.lib_id is not null
- <if test="queryDate != null and queryDate != '' ">
- and t.create_time regexp #{queryDate}
- </if>
- </select>
- <select id="searchHomeworkAllTop" resultType="java.util.Map">
- SELECT sum(totolCount) as totolCount,a.lib_id,b.league_name from (
- select count(1) as totolCount,t1.lib_id
- from scon_homework_picture t
- left join tb_lib_vip t1 on t.vip_id = t1.id
- where is_delete = 0 and t1.lib_id is not null
- <if test="startDate != null and startDate != '' ">
- and t.create_time >= #{startDate}
- </if>
- <if test="endDate != null and endDate != '' ">
- and #{endDate} >= t.create_time
- </if>
- <if test="subject != null and subject != '' ">
- and t.subject = #{subject}
- </if>
- group by t1.lib_id
- order by totolCount desc)a join tb_lib_join b on a.lib_id = b.id
- GROUP BY a.lib_id
- order by totolCount desc
- </select>
- <select id="searchActiveTop" resultType="java.util.Map">
- select t2.league_name,t1.lib_id ,
- (select count(1) from tb_lib_vip a where a.lib_id = t1.lib_id) as all_vips,
- count(distinct t.vip_id) as active_count
- from scon_homework t
- left join tb_lib_vip t1 on t.vip_id = t1.id
- join tb_lib_join t2 on t1.lib_id = t2.id
- where t1.lib_id is not null
- <if test="startDate != null and startDate != '' ">
- and t.create_time >= #{startDate}
- </if>
- <if test="endDate != null and endDate != '' ">
- and #{endDate} >= t.create_time
- </if>
- group by t1.lib_id
- </select>
- </mapper>
|