<?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.TowerHistorySettleMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM tower_history_settle a
        <where>
            <if test="param.historySettleId != null">
                AND a.history_settle_id = #{param.historySettleId}
            </if>
            <if test="param.projectId != null">
                AND a.project_id = #{param.projectId}
            </if>
            <if test="param.contractNo != null">
                AND a.contract_no LIKE CONCAT('%', #{param.contractNo}, '%')
            </if>
            <if test="param.equipmentId != null">
                AND a.equipment_id = #{param.equipmentId}
            </if>
            <if test="param.amountWithTax != null">
                AND a.amount_with_tax = #{param.amountWithTax}
            </if>
            <if test="param.taxAmount != null">
                AND a.tax_amount = #{param.taxAmount}
            </if>
            <if test="param.inOutWithTax != null">
                AND a.in_out_with_tax = #{param.inOutWithTax}
            </if>
            <if test="param.inOutTax != null">
                AND a.in_out_tax = #{param.inOutTax}
            </if>
            <if test="param.workerAmountWithTax != null">
                AND a.worker_amount_with_tax = #{param.workerAmountWithTax}
            </if>
            <if test="param.workerTax != null">
                AND a.worker_tax = #{param.workerTax}
            </if>
            <if test="param.otherAmountWithTax != null">
                AND a.other_amount_with_tax = #{param.otherAmountWithTax}
            </if>
            <if test="param.otherTax != null">
                AND a.other_tax = #{param.otherTax}
            </if>
            <if test="param.startDate != null">
                AND a.start_date LIKE CONCAT('%', #{param.startDate}, '%')
            </if>
            <if test="param.endDate != null">
                AND a.end_date LIKE CONCAT('%', #{param.endDate}, '%')
            </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.TowerHistorySettle">
        <include refid="selectSql"></include>
    </select>

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

</mapper>
