TextbookStudentClaimMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.xjrsoft.module.textbook.mapper.TextbookStudentClaimMapper">
  6. <select id="getTextbookClaimList" parameterType="com.xjrsoft.module.textbook.dto.TextbookClaimStudentConfirmDto"
  7. resultType="com.xjrsoft.module.textbook.vo.TextbookClaimVO">
  8. SELECT t.id AS textbookStudentClaimId,
  9. t1.price * t1.discount/10 AS discountPrice,
  10. t.sort_code as sortCode,
  11. t.textbook_id as textbookId,
  12. t.is_claim as isClaim,
  13. t1.book_name as bookName,
  14. t1.price as price
  15. FROM textbook_student_claim t
  16. LEFT JOIN textbook t1 ON (t1.id = t.textbook_id)
  17. WHERE t.delete_mark = 0
  18. AND (t.student_user_id = #{dto.studentUserId})
  19. AND (t.base_semester_id = #{dto.baseSemesterId})
  20. <if test="dto.showOrConfirm != null and dto.showOrConfirm == 2">
  21. and t.is_claim = 0
  22. </if>
  23. ORDER BY t.id DESC
  24. </select>
  25. <select id="getTeacherCheckByclassList" parameterType="com.xjrsoft.module.textbook.dto.TeacherCheckByclassDto"
  26. resultType="com.xjrsoft.module.textbook.vo.TeacherCheckByclassVo">
  27. WITH textbook_claim_counts AS (
  28. SELECT t.class_id, t1.textbook_id, count(t1.issue_number) AS received_num
  29. FROM wf_textbook_claim t
  30. LEFT JOIN wf_textbook_claim_item t1 ON t1.wf_textbook_claim_id = t.id
  31. GROUP BY t.class_id, t1.textbook_id
  32. ),
  33. actual_claim_counts AS (
  34. SELECT class_id, textbook_id, count(is_claim) AS claim_num
  35. FROM textbook_student_claim
  36. WHERE is_claim = 1
  37. GROUP BY class_id, textbook_id
  38. )
  39. SELECT a.class_id,
  40. b.id AS textbookId,
  41. b.book_name,
  42. c.name,
  43. d.total_student AS classStudentNum,
  44. tcc.received_num AS actualReceivedNum,
  45. acc.claim_num AS actualClaimNum
  46. FROM textbook b
  47. INNER JOIN (
  48. SELECT class_id, textbook_id
  49. FROM textbook_student_claim
  50. GROUP BY class_id, textbook_id
  51. ) a ON a.textbook_id = b.id
  52. INNER JOIN base_class c ON a.class_id = c.id
  53. INNER JOIN base_class_major_set d ON c.id = d.class_id
  54. LEFT JOIN textbook_claim_counts tcc ON tcc.class_id = a.class_id AND tcc.textbook_id = a.textbook_id
  55. LEFT JOIN actual_claim_counts acc ON acc.class_id = a.class_id AND acc.textbook_id = a.textbook_id
  56. WHERE a.class_id &lt;&gt; 0
  57. <if test="dto.classIdList != null and dto.classIdList.size() > 0">
  58. AND a.class_id IN
  59. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
  60. separator=",">
  61. #{classId}
  62. </foreach>
  63. </if>
  64. <if test="dto.claimStatus != null and dto.claimStatus == 2">
  65. AND tcc.received_num = acc.claim_num
  66. </if>
  67. <if test="dto.claimStatus != null and dto.claimStatus == 3">
  68. AND tcc.received_num > acc.claim_num
  69. </if>
  70. </select>
  71. <select id="getTeacherCheckStuClaimList" parameterType="com.xjrsoft.module.textbook.dto.TeacherCheckStuClaimDto"
  72. resultType="com.xjrsoft.module.textbook.vo.TeacherCheckStuClaimVo">
  73. SELECT
  74. t.id as textbookStudentClaimId,
  75. t.textbook_id,
  76. t1.book_name as bookName,
  77. t.student_user_id,
  78. t2.student_id as studentId,
  79. t3.name as studentName,
  80. t.is_claim
  81. FROM textbook_student_claim t
  82. LEFT JOIN textbook t1 ON (t1.id = t.textbook_id)
  83. LEFT JOIN base_student t2 ON (t2.user_id = t.student_user_id)
  84. LEFT JOIN xjr_user t3 ON (t3.id = t.student_user_id)
  85. WHERE t.delete_mark = 0
  86. and t.class_id = #{dto.classId} and t.textbook_id = #{dto.textbookId}
  87. ORDER BY t.is_claim
  88. </select>
  89. <select id="getTeacherCheckByStuList" parameterType="com.xjrsoft.module.textbook.dto.TeacherCheckByStuDto"
  90. resultType="com.xjrsoft.module.textbook.vo.TeacherCheckByStuVo">
  91. SELECT
  92. t.id as studentUserId,
  93. t.name as studentUserIdCN,
  94. t1.student_id as studentId
  95. FROM xjr_user t
  96. LEFT JOIN base_student t1 ON (t1.user_id = t.id)
  97. where t.id in (SELECT distinct student_user_id
  98. FROM textbook_student_claim t
  99. WHERE delete_mark = 0
  100. <if test="dto.claimStatus != null and dto.claimStatus == 3">
  101. and (select count(*) from textbook_student_claim where is_claim = 1 and student_user_id = t.student_user_id) != (select count(*) from textbook_student_claim where student_user_id = t.student_user_id)
  102. </if>
  103. <if test="dto.claimStatus != null and dto.claimStatus == 2">
  104. and (select count(*) from textbook_student_claim where is_claim = 1 and student_user_id = t.student_user_id) = (select count(*) from textbook_student_claim where student_user_id = t.student_user_id)
  105. </if>
  106. <if test="dto.classIdList != null and dto.classIdList.size() > 0">
  107. and class_id in
  108. <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
  109. separator=",">
  110. #{classId}
  111. </foreach>
  112. </if>)
  113. <if test="dto.studentUserId != null and dto.studentUserId != 0 and dto.studentUserId != ''">
  114. and t.id = #{dto.studentUserId}
  115. </if>
  116. </select>
  117. <select id="getTextbookClaimVOList"
  118. resultType="com.xjrsoft.module.textbook.vo.TextbookClaimVO">
  119. SELECT
  120. t.id as textbookStudentClaimId,
  121. t.textbook_id,
  122. t1.book_name as bookName,
  123. t.is_claim
  124. FROM textbook_student_claim t
  125. LEFT JOIN textbook t1 ON (t1.id = t.textbook_id)
  126. where t.student_user_id = #{studentUserId}
  127. ORDER BY t.is_claim
  128. </select>
  129. </mapper>