<?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.student.mapper.PbVXssfdetailMapper">
    <select id="getPage" parameterType="com.xjrsoft.module.student.dto.PbVXssfdetailPageDto" resultType="com.xjrsoft.module.student.vo.PbVXssfdetailPageVo">
        SELECT t2.user_id,t2.student_id,t1.name,t4.name AS gender_cn,t6.name AS semester_name,t3.feeitemname,t3.paytype,t3.paydate,t3.payorder,t3.mny, t8.state FROM xjr_user t1
        INNER JOIN base_student t2 ON t1.id = t2.user_id
        INNER JOIN pb_v_xssfdetail t3 ON t1.credential_number = t3.personalid
        LEFT JOIN xjr_dictionary_detail t4 ON t1.gender = t4.code AND t4.item_id = 2023000000000000004
        LEFT JOIN pb_semester_config t5 ON t3.beltcode = t5.beltcode AND t5.delete_mark = 0
        LEFT JOIN base_semester t6 ON t6.id = t5.base_semester_id
        LEFT JOIN base_student_school_roll t7 ON t7.user_id = t1.id
        LEFT join pb_cse_feeobjupdate t8 on t8.studentcode = t2.student_id
        WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
        <if test="dto.name != null and dto.name != ''">
            and t1.name like concat('%', #{dto.name},'%')
        </if>
        <if test="dto.semesterId != null">
            and t6.id = #{dto.semesterId}
        </if>
        <if test="dto.feeitemname != null and dto.feeitemname != ''">
            and t3.feeitemname like concat('%', #{dto.feeitemname},'%')
        </if>
        <if test="dto.studentId != null and dto.studentId != ''">
            and t2.student_id like concat('%', #{dto.studentId},'%')
        </if>
        <if test="dto.payorder != null and dto.payorder != ''">
            and t3.payorder like concat('%', #{dto.payorder},'%')
        </if>
        <if test="dto.startDate != null and dto.startDate != '' and dto.endDate != null and dto.endDate != ''">
            and t3.paydate between #{dto.startDate} and #{dto.endDate}
        </if>
        <if test="dto.category != null">
            <if test="dto.category == 1">
                and t3.mny > 0
            </if>
            <if test="dto.category == -1">
                and 0 > t3.mny
            </if>
        </if>
        <if test="dto.classIdList != null and !dto.classIdList.isEmpty()">
            and t7.class_id in
            <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")" separator=",">
                #{classId}
            </foreach>
        </if>
    </select>
    <select id="getList" parameterType="com.xjrsoft.module.student.dto.PbVXssfdetailExcelDto" resultType="com.xjrsoft.module.student.vo.PbVXssfdetailExcelVo">
        SELECT t2.user_id,t2.student_id,t1.name,t4.name AS gender_cn,t6.name AS semester_name,t3.feeitemname,t3.paytype,t3.paydate,t3.payorder,t3.mny FROM xjr_user t1
        INNER JOIN base_student t2 ON t1.id = t2.user_id
        INNER JOIN pb_v_xssfdetail t3 ON t1.credential_number = t3.personalid
        LEFT JOIN xjr_dictionary_detail t4 ON t1.gender = t4.code AND t4.item_id = 2023000000000000004
        LEFT JOIN pb_semester_config t5 ON t3.beltcode = t5.beltcode AND t5.delete_mark = 0
        LEFT JOIN base_semester t6 ON t6.id = t5.base_semester_id
        WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
        <if test="dto.payorders == null">
            <if test="dto.name != null and dto.name != ''">
                and t1.name like concat('%', #{dto.name},'%')
            </if>
            <if test="dto.semesterId != null">
                and t6.id = #{dto.semesterId}
            </if>
            <if test="dto.feeitemname != null and dto.feeitemname != ''">
                and t3.feeitemname like concat('%', #{dto.feeitemname},'%')
            </if>
            <if test="dto.studentId != null and dto.studentId != ''">
                and t2.student_id like concat('%', #{dto.studentId},'%')
            </if>
            <if test="dto.payorder != null and dto.payorder != ''">
                and t3.payorder like concat('%', #{dto.payorder},'%')
            </if>
            <if test="dto.startDate != null and dto.startDate != '' and dto.endDate != null and dto.endDate != ''">
                and t3.paydate between #{dto.startDate} and #{dto.endDate}
            </if>
            <if test="dto.category != null">
                <if test="dto.category == 1">
                    and t3.mny > 0
                </if>
                <if test="dto.category == -1">
                    and 0 > t3.mny
                </if>
            </if>
        </if>
        <if test="dto.payorders != null">
            and t3.payorder in
            <foreach item="payorder" index="index" collection="dto.payorders" open="(" close=")" separator=",">
                #{payorder}
            </foreach>
        </if>
    </select>
</mapper>