LibVipMapper.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 lv.id vipId,
  41. lv.child_name studentName,
  42. lv.school,
  43. lv.grade,
  44. lv.img_url imgUrl
  45. from (select vip_id
  46. from (select class_id from tb_class_teacher where teacher_id = #{teacherId} and status = 1) ct, tb_class_student cs
  47. where ct.class_id = cs.class_id
  48. and cs.status = 1) fcs, tb_lib_vip lv
  49. where fcs.vip_id = lv.id
  50. and lv.stat = '1'
  51. and lv.user_id is not null
  52. and not exists(select 1
  53. from tb_lib_subscribe
  54. where vip_id = lv.id
  55. and flow_stat = '3'
  56. and stat = '1'
  57. and to_days(ryke_time) = to_days(now())
  58. )
  59. and exists(
  60. select 1
  61. from (select s.*
  62. from (select *
  63. from tb_lib_vip_service
  64. where stat = 1
  65. and species in ('S003', 'S999')
  66. and to_days(now()) between to_days(start_time) and to_days(end_time)
  67. order by service_sort) s
  68. group by s.vip_id) s1
  69. where s1.vip_id = lv.id
  70. and (s1.lib_id is null
  71. or not exists(
  72. select 1
  73. from tb_vacation_limit s2
  74. where s2.set_state = 2
  75. and to_days(now()) between to_days(s2.start_date) and to_days(s2.end_date)
  76. and s1.lib_id = s2.lib_id
  77. )
  78. )
  79. )
  80. <if test="studentName != null and studentName != '' ">
  81. and lv.child_name regexp #{studentName}
  82. </if>
  83. </select>
  84. <select id="findStudentList4SignOff" resultType="com.ssj.service.conch.teacher.library.dto.StudentDto">
  85. select lv.id vip_id,
  86. lv.child_name student_name,
  87. lv.school,
  88. lv.grade,
  89. lv.img_url
  90. from (select vip_id
  91. from (select class_id from tb_class_teacher where teacher_id = #{teacherId} and status = 1) ct, tb_class_student cs
  92. where ct.class_id = cs.class_id
  93. and cs.status = 1) fcs, tb_lib_vip lv
  94. where fcs.vip_id = lv.id
  95. and lv.stat = '1'
  96. and lv.user_id is not null
  97. and exists(select 1
  98. from tb_lib_subscribe
  99. where vip_id = lv.id
  100. and flow_stat = '3'
  101. and stat = '1'
  102. and to_days(ryke_time) = to_days(now()))
  103. <if test="studentName != null and studentName != ''">
  104. and lv.child_name like '%${studentName}%'
  105. </if>
  106. </select>
  107. <select id="getServiceRecords" resultType="java.util.Map">
  108. select `type`,lib_service,platform_service,create_time,
  109. (select child_name from tb_lib_vip s where s.id=vip_id) child_name
  110. from tb_lib_join_consume
  111. where (from_lib_id=#{libId} or to_lib_id=#{libId})
  112. <if test="vipId != null and vipId != '' ">
  113. and vip_id = #{vipId}
  114. </if>
  115. order by create_time desc
  116. </select>
  117. <select id="checkClass" resultType="java.lang.Integer">
  118. select count(*)
  119. from tb_class_student cs,
  120. tb_class_teacher ct
  121. where cs.class_id = ct.class_id
  122. and cs.status = 1
  123. and ct.status = 1
  124. and cs.vip_id = #{vipId}
  125. and ct.teacher_id = #{teacherId}
  126. </select>
  127. </mapper>