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 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 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
#{type}
and lm.name regexp #{searchKey}
and lm.state=1 and lm.lib_id=#{libId}
group by lm.user_id
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
#{type}
and lm.name regexp #{searchKey}
and lm.status=3
and lm.lib_id=#{libId}
group by lm.user_id
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
#{type}
group by lm.user_id
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
#{type}
group by lm.user_id
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 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 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
#{classId}
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 class_id, count(1) teacher_sum from tb_class_teacher
where class_id in
#{classId}
and status = 1
group by class_id
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 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}
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
and t.id=#{classId}
and t2.child_name regexp #{name}
order by convert(childName using gbk) asc
and t2.child_name regexp #{name}
order by sort_no,convert(childName using gbk) asc
and (t.id !=#{classId} or t.id is null)
and t4.stat=1
and t2.child_name regexp #{name}
order by sort_no,convert(childName using gbk) asc
and t2.id=#{vipId}
limit 1
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 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
t1.lib_id =#{libId}
and t1.id !=#{classId}
and t1.status =1
order by t1.status desc,t1.create_time
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 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 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 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 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
and t.lib_id=#{map.libId}
and exists(select 1 from tb_class_student tc where t.id = tc.vip_id and status = 1
and tc.class_id in
#{classId}
)
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 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
and t12.child_name regexp #{searchValue}
group by t11.vip_id
order by t.subject,t11.create_time desc
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
and t2.child_name regexp #{map.searchValue}
and to_days(t4.end_time) >= to_days(#{map.startDate})
and to_days(#{map.endDate}) >= to_days(t4.end_time)
and t4.stat=#{map.stat}
and t.id=#{map.classId}
and t4.species='S999'
and t4.correct_type=#{map.serviceType}
group by t2.id
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')
and to_days(t.end_time) >= to_days(#{map.startDate})
and to_days(#{map.endDate}) >= to_days(t.end_time)
and t.stat=#{map.stat}
and t.species='S999'
and t.correct_type=#{map.serviceType}
order by t.end_time desc
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)
and t1.class_name regexp #{searchValue}
and t1.id in (
select class_id from tb_class_teacher where status = 1
and teacher_id=#{teacherId}
)
order by t1.status desc, t1.create_time
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
#{type}
and lm.name regexp #{searchKey}
and ct.class_id = #{classId}
and lm.state=1 and lm.lib_id=#{libId} and lm.is_cancelled = 0
group by lm.user_id
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
and tcs.class_id = #{classId}
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 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
and t.create_time regexp #{queryDate}
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
and t.create_time >= #{startDate}
and #{endDate} >= t.create_time
and t.subject = #{subject}
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 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
and t.create_time >= #{startDate}
and #{endDate} >= t.create_time
group by t1.lib_id