LibVipMapper.xml 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.ssj.service.mapper.LibVipMapper">
  4. <select id="findManageStudentList" resultType="com.ssj.service.weixin.library.dto.StudentDTO">
  5. select tb_lib_vip.id vipId,
  6. tb_lib_vip.child_name studentName,
  7. tb_lib_vip.img_url,
  8. service.service_sort,
  9. service.end_time,
  10. service.correct_type,
  11. service.type
  12. from tb_lib_vip
  13. join (select tb_lib_vip_service.vip_id,
  14. ifnull(tb_lib_vip_service.service_sort, 0) service_sort,
  15. tb_lib_vip_service.end_time,
  16. tb_lib_vip_service.correct_type,
  17. tb_lib_vip_service.type
  18. from (select vip_id
  19. from (select class_id
  20. from tb_class_teacher
  21. where lib_id = #{libId}
  22. and teacher_id = #{teacherId}
  23. and status = 1) classTeacher
  24. join tb_class_student
  25. on classTeacher.class_id = tb_class_student.class_id and
  26. tb_class_student.status = 1) classStudent
  27. join tb_lib_vip_service
  28. on classStudent.vip_id = tb_lib_vip_service.vip_id and
  29. tb_lib_vip_service.stat = 1 and
  30. now() between start_time and end_time) service
  31. on service.vip_id = tb_lib_vip.id and tb_lib_vip.lib_id = #{libId}
  32. </select>
  33. <select id="findGradeAndSchoolById" resultType="com.ssj.bean.weixin.libmy.domain.LibVip">
  34. SELECT v.school,v.grade from tb_lib_vip v where v.id=#{vipId}
  35. </select>
  36. <select id="findGradeAndSchoolAndSubjectByHomeworkId" resultType="com.ssj.bean.weixin.libmy.domain.LibVip">
  37. 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}
  38. </select>
  39. <select id="findSignInStudentList" resultType="com.ssj.service.conch.teacher.library.dto.StudentDto">
  40. select t.id vipId,
  41. t.child_name studentName,
  42. t.school,
  43. t.grade,
  44. t.img_url imgUrl
  45. from tb_lib_vip t
  46. where t.lib_id = #{libId} and t.user_id is not null
  47. <!--and t.stat='1'-->
  48. and t.id not in
  49. (select vip_id
  50. from tb_lib_subscribe
  51. where lib_id = #{libId}
  52. and flow_stat = '3'
  53. and stat = '1'
  54. and to_days(ryke_time) = to_days(now())
  55. )
  56. <!--当前有服务且不在节假日中间-->
  57. and exists(
  58. select 1
  59. from (select s.*
  60. from (select *
  61. from tb_lib_vip_service
  62. where stat = 1
  63. and species in ('S003', 'S999')
  64. and to_days(start_time) &lt;= to_days(now())
  65. and to_days(end_time) >= to_days(now())
  66. order by service_sort) s
  67. group by s.vip_id) s1
  68. where s1.vip_id = t.id
  69. and (s1.lib_id is null
  70. or not exists(
  71. select 1
  72. from tb_vacation_limit s2
  73. where s2.set_state = 2
  74. and to_days(s2.start_date) &lt;= to_days(now())
  75. and to_days(s2.end_date) >= to_days(now())
  76. and s1.lib_id = s2.lib_id
  77. )
  78. )
  79. )
  80. <if test="studentName != null and studentName != '' ">
  81. and t.child_name regexp #{studentName}
  82. </if>
  83. </select>
  84. </mapper>