| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <?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.xjrsoft.module.textbook.mapper.TextbookStudentClaimMapper">
- <select id="getTextbookClaimList" parameterType="com.xjrsoft.module.textbook.dto.TextbookClaimStudentConfirmDto"
- resultType="com.xjrsoft.module.textbook.vo.TextbookClaimVO">
- SELECT t.id AS textbookStudentClaimId,
- t1.price * t1.discount/10 AS discountPrice,
- t.sort_code as sortCode,
- t.textbook_id as textbookId,
- t.is_claim as isClaim,
- t1.book_name as bookName,
- t1.price as price
- FROM textbook_student_claim t
- inner JOIN textbook t1 ON (t1.id = t.textbook_id)
- WHERE t.delete_mark = 0
- AND (t.student_user_id = #{dto.studentUserId})
- AND (t.base_semester_id = #{dto.baseSemesterId})
- <if test="dto.showOrConfirm != null and dto.showOrConfirm == 2">
- and t.is_claim = 0
- </if>
- ORDER BY t.id DESC
- </select>
- <select id="getTeacherCheckByclassList" parameterType="com.xjrsoft.module.textbook.dto.TeacherCheckByclassDto"
- resultType="com.xjrsoft.module.textbook.vo.TeacherCheckByclassVo">
- WITH textbook_claim_counts AS
- (SELECT t.base_semester_id, t.class_id, t1.textbook_id, sum(t1.issue_number) AS received_num
- FROM wf_textbook_claim t
- inner JOIN wf_textbook_claim_item t1 ON t1.wf_textbook_claim_id = t.id
- where t.delete_mark = 0
- and t1.delete_mark = 0
- <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
- AND t.base_semester_id = #{dto.baseSemesterId}
- </if>
- <if test="dto.classIdList != null and dto.classIdList.size() > 0">
- AND t.class_id IN
- <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
- separator=",">
- #{classId}
- </foreach>
- </if>
- AND t.claim_type = 'claim_class'
- GROUP BY t.base_semester_id, t.class_id, t1.textbook_id),
- actual_claim_counts AS
- (SELECT base_semester_id, class_id, textbook_id, count(is_claim) AS claim_num
- FROM textbook_student_claim
- WHERE is_claim = 1
- and delete_mark = 0
- <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
- AND base_semester_id = #{dto.baseSemesterId}
- </if>
- <if test="dto.classIdList != null and dto.classIdList.size() > 0">
- AND class_id IN
- <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
- separator=",">
- #{classId}
- </foreach>
- </if>
- GROUP BY base_semester_id, class_id, textbook_id),
- class_stu_num AS
- (SELECT class_id, count(t.id) AS total_student
- FROM base_student_school_roll t
- WHERE t.delete_mark = 0
- and t.archives_status = 'FB2901'
- <if test="dto.classIdList != null and dto.classIdList.size() > 0">
- AND t.class_id IN
- <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
- separator=",">
- #{classId}
- </foreach>
- </if>
- GROUP BY class_id)
- SELECT t.base_semester_id,
- t.class_id,
- t.textbook_id,
- t1.book_name,
- t2.name as classIdCn,
- t5.name as baseSemesterIdCN,
- ifnull(t.received_num, 0) AS actualReceivedNum,
- ifnull(t4.total_student, 0) AS classStudentNum,
- ifnull(t3.claim_num, 0) AS actualClaimNum,
- if(t.received_num > 0, 1, 0) as is_issue
- FROM textbook_claim_counts t
- inner join textbook t1 on t1.id = t.textbook_id
- LEFT JOIN base_class t2 ON t2.id = t.class_id
- LEFT JOIN base_semester t5 ON t5.id = t.base_semester_id
- LEFT JOIN actual_claim_counts t3 ON t3.base_semester_id = t.base_semester_id AND t3.class_id = t.class_id AND
- t3.textbook_id = t.textbook_id
- LEFT JOIN class_stu_num t4 ON t4.class_id = t.class_id
- where t.class_id <> 0
- <if test="dto.classIdList != null and dto.classIdList.size() > 0">
- AND t.class_id IN
- <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
- separator=",">
- #{classId}
- </foreach>
- </if>
- <if test="dto.claimStatus != null and dto.claimStatus == 2">
- AND t.received_num <= t3.claim_num
- </if>
- <if test="dto.claimStatus != null and dto.claimStatus == 3">
- AND t.received_num > t3.claim_num
- </if>
- </select>
- <select id="getTeacherCheckStuClaimList" parameterType="com.xjrsoft.module.textbook.dto.TeacherCheckStuClaimDto"
- resultType="com.xjrsoft.module.textbook.vo.TeacherCheckStuClaimVo">
- SELECT t.id as textbookStudentClaimId,
- t.textbook_id,
- t1.book_name as bookName,
- t.student_user_id,
- t2.student_id as studentId,
- t3.name as studentName,
- t.is_claim
- FROM textbook_student_claim t
- LEFT JOIN textbook t1 ON (t1.id = t.textbook_id)
- LEFT JOIN base_student t2 ON (t2.user_id = t.student_user_id)
- LEFT JOIN xjr_user t3 ON (t3.id = t.student_user_id)
- WHERE t.delete_mark = 0
- and t.class_id = #{dto.classId}
- and t.textbook_id = #{dto.textbookId}
- ORDER BY t.is_claim
- </select>
- <select id="getTeacherCheckByStuList" parameterType="com.xjrsoft.module.textbook.dto.TeacherCheckByStuDto"
- resultType="com.xjrsoft.module.textbook.vo.TeacherCheckByStuVo">
- SELECT
- t.id as studentUserId,
- t.name as studentUserIdCN,
- t1.student_id as studentId
- FROM xjr_user t
- LEFT JOIN base_student t1 ON (t1.user_id = t.id)
- where t.id in (SELECT distinct student_user_id
- FROM textbook_student_claim t
- WHERE delete_mark = 0
- <if test="dto.claimStatus != null and dto.claimStatus == 3">
- 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)
- </if>
- <if test="dto.claimStatus != null and dto.claimStatus == 2">
- 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)
- </if>
- <if test="dto.classIdList != null and dto.classIdList.size() > 0">
- and class_id in
- <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
- separator=",">
- #{classId}
- </foreach>
- </if>
- )
- <if test="dto.studentUserId != null and dto.studentUserId != 0 and dto.studentUserId != ''">
- and t.id = #{dto.studentUserId}
- </if>
- </select>
- <select id="getTextbookClaimVOList"
- resultType="com.xjrsoft.module.textbook.vo.TextbookClaimVO">
- SELECT t.id as textbookStudentClaimId,
- t.textbook_id,
- t1.book_name as bookName,
- t.is_claim
- FROM textbook_student_claim t
- LEFT JOIN textbook t1 ON (t1.id = t.textbook_id)
- where t.student_user_id = #{studentUserId}
- ORDER BY t.is_claim
- </select>
- </mapper>
|