<?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.gxwebsoft.tower.mapper.TowerLendingSettleListMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM tower_lending_settle_list a
        <where>
            <if test="param.lendingSettleListId != null">
                AND a.lending_settle_list_id = #{param.lendingSettleListId}
            </if>
            <if test="param.lendingId != null">
                AND a.lending_id = #{param.lendingId}
            </if>
            <if test="param.equipmentId != null">
                AND a.equipment_id = #{param.equipmentId}
            </if>
            <if test="param.lendingPath != null">
                AND a.lending_path LIKE CONCAT('%', #{param.lendingPath}, '%')
            </if>
            <if test="param.coopWay != null">
                AND a.coop_way LIKE CONCAT('%', #{param.coopWay}, '%')
            </if>
            <if test="param.startDate != null">
                AND a.start_date LIKE CONCAT('%', #{param.startDate}, '%')
            </if>
            <if test="param.stopDate != null">
                AND a.stop_date LIKE CONCAT('%', #{param.stopDate}, '%')
            </if>
            <if test="param.calDay != null">
                AND a.cal_day = #{param.calDay}
            </if>
            <if test="param.isFullMonth != null">
                AND a.is_full_month = #{param.isFullMonth}
            </if>
            <if test="param.daysInMonth != null">
                AND a.days_in_month = #{param.daysInMonth}
            </if>
            <if test="param.monthRentAmount != null">
                AND a.month_rent_amount = #{param.monthRentAmount}
            </if>
            <if test="param.shouldPayRentAmount != null">
                AND a.should_pay_rent_amount = #{param.shouldPayRentAmount}
            </if>
            <if test="param.dailyRentAmount != null">
                AND a.daily_rent_amount = #{param.dailyRentAmount}
            </if>
            <if test="param.shouldSupplementAmount != null">
                AND a.should_supplement_amount = #{param.shouldSupplementAmount}
            </if>
            <if test="param.shouldDeductionAmount != null">
                AND a.should_deduction_amount = #{param.shouldDeductionAmount}
            </if>
            <if test="param.paidAmount != null">
                AND a.paid_amount = #{param.paidAmount}
            </if>
            <if test="param.taxRate != null">
                AND a.tax_rate = #{param.taxRate}
            </if>
            <if test="param.taxAmount != null">
                AND a.tax_amount = #{param.taxAmount}
            </if>
            <if test="param.totalAmountWithTax != null">
                AND a.total_amount_with_tax = #{param.totalAmountWithTax}
            </if>
            <if test="param.remark != null">
                AND a.remark LIKE CONCAT('%', #{param.remark}, '%')
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.deleted != null">
                AND a.deleted = #{param.deleted}
            </if>
            <if test="param.deleted == null">
                AND a.deleted = 0
            </if>
            <if test="param.createTimeStart != null">
                AND a.create_time &gt;= #{param.createTimeStart}
            </if>
            <if test="param.createTimeEnd != null">
                AND a.create_time &lt;= #{param.createTimeEnd}
            </if>
        </where>
    </sql>

    <!-- 分页查询 -->
    <select id="selectPageRel" resultType="com.gxwebsoft.tower.entity.TowerLendingSettleList">
        <include refid="selectSql"></include>
    </select>

    <!-- 查询全部 -->
    <select id="selectListRel" resultType="com.gxwebsoft.tower.entity.TowerLendingSettleList">
        <include refid="selectSql"></include>
    </select>

</mapper>
