123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <?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.LibVipMapper">
- <select id="findManageStudentList" resultType="com.ssj.service.weixin.library.dto.StudentDTO">
- select tb_lib_vip.id vipId,
- tb_lib_vip.child_name studentName,
- tb_lib_vip.img_url,
- service.service_sort,
- service.end_time,
- service.correct_type,
- service.type
- from tb_lib_vip
- join (select tb_lib_vip_service.vip_id,
- ifnull(tb_lib_vip_service.service_sort, 0) service_sort,
- tb_lib_vip_service.end_time,
- tb_lib_vip_service.correct_type,
- tb_lib_vip_service.type
- from (select vip_id
- from (select class_id
- from tb_class_teacher
- where lib_id = #{libId}
- and teacher_id = #{teacherId}
- and status = 1) classTeacher
- join tb_class_student
- on classTeacher.class_id = tb_class_student.class_id and
- tb_class_student.status = 1) classStudent
- join tb_lib_vip_service
- on classStudent.vip_id = tb_lib_vip_service.vip_id and
- tb_lib_vip_service.stat = 1 and
- now() between start_time and end_time) service
- on service.vip_id = tb_lib_vip.id and tb_lib_vip.lib_id = #{libId}
- </select>
- <select id="findGradeAndSchoolById" resultType="com.ssj.bean.weixin.libmy.domain.LibVip">
- SELECT v.school,v.grade from tb_lib_vip v where v.id=#{vipId}
- </select>
- <select id="findGradeAndSchoolAndSubjectByHomeworkId" resultType="com.ssj.bean.weixin.libmy.domain.LibVip">
- SELECT v.school,v.grade, h.subject course_name from tb_lib_vip v left join scon_homework h on v.id=h.vip_id where h.id=#{homeworkId}
- </select>
- <select id="findSignInStudentList" resultType="com.ssj.service.conch.teacher.library.dto.StudentDto">
- select lv.id vipId,
- lv.child_name studentName,
- lv.school,
- lv.grade,
- lv.img_url imgUrl
- from (select vip_id
- from (select class_id from tb_class_teacher where teacher_id = #{teacherId} and status = 1) ct, tb_class_student cs
- where ct.class_id = cs.class_id
- and cs.status = 1) fcs, tb_lib_vip lv
- where fcs.vip_id = lv.id
- and lv.stat = '1'
- and lv.user_id is not null
- and not exists(select 1
- from tb_lib_subscribe
- where vip_id = lv.id
- and flow_stat = '3'
- and stat = '1'
- and to_days(ryke_time) = to_days(now())
- )
- and exists(
- select 1
- from (select s.*
- from (select *
- from tb_lib_vip_service
- where stat = 1
- and species in ('S003', 'S999')
- and to_days(now()) between to_days(start_time) and to_days(end_time)
- order by service_sort) s
- group by s.vip_id) s1
- where s1.vip_id = lv.id
- and (s1.lib_id is null
- or not exists(
- select 1
- from tb_vacation_limit s2
- where s2.set_state = 2
- and to_days(now()) between to_days(s2.start_date) and to_days(s2.end_date)
- and s1.lib_id = s2.lib_id
- )
- )
- )
- <if test="studentName != null and studentName != '' ">
- and lv.child_name regexp #{studentName}
- </if>
- </select>
- <select id="findStudentList4SignOff" resultType="com.ssj.service.conch.teacher.library.dto.StudentDto">
- select lv.id vip_id,
- lv.child_name student_name,
- lv.school,
- lv.grade,
- lv.img_url
- from (select vip_id
- from (select class_id from tb_class_teacher where teacher_id = #{teacherId} and status = 1) ct, tb_class_student cs
- where ct.class_id = cs.class_id
- and cs.status = 1) fcs, tb_lib_vip lv
- where fcs.vip_id = lv.id
- and lv.stat = '1'
- and lv.user_id is not null
- and exists(select 1
- from tb_lib_subscribe
- where vip_id = lv.id
- and flow_stat = '3'
- and stat = '1'
- and to_days(ryke_time) = to_days(now()))
- <if test="studentName != null and studentName != ''">
- and lv.child_name like '%${studentName}%'
- </if>
- </select>
- <select id="getServiceRecords" resultType="java.util.Map">
- select `type`,lib_service,platform_service,create_time,
- (select child_name from tb_lib_vip s where s.id=vip_id) child_name
- from tb_lib_join_consume
- where (from_lib_id=#{libId} or to_lib_id=#{libId})
- <if test="vipId != null and vipId != '' ">
- and vip_id = #{vipId}
- </if>
- order by create_time desc
- </select>
- <select id="checkClass" resultType="java.lang.Integer">
- select count(*)
- from tb_class_student cs,
- tb_class_teacher ct
- where cs.class_id = ct.class_id
- and cs.status = 1
- and ct.status = 1
- and cs.vip_id = #{vipId}
- and ct.teacher_id = #{teacherId}
- </select>
- </mapper>
|