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

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM tower_invoicing a
        <where>
            <if test="param.invoicingId != null">
                AND a.invoicing_id = #{param.invoicingId}
            </if>
            <if test="param.contractId != null">
                AND a.contract_id = #{param.contractId}
            </if>
            <if test="param.invoicingDate != null">
                AND a.invoicing_date LIKE CONCAT('%', #{param.invoicingDate}, '%')
            </if>
            <if test="param.invoicingCompany != null">
                AND a.invoicing_company LIKE CONCAT('%', #{param.invoicingCompany}, '%')
            </if>
            <if test="param.requestName != null">
                AND a.request_name LIKE CONCAT('%', #{param.requestName}, '%')
            </if>
            <if test="param.invoicingAmount != null">
                AND a.invoicing_amount = #{param.invoicingAmount}
            </if>
            <if test="param.invoicingNo != null">
                AND a.invoicing_no LIKE CONCAT('%', #{param.invoicingNo}, '%')
            </if>
            <if test="param.fileList != null">
                AND a.file_list LIKE CONCAT('%', #{param.fileList}, '%')
            </if>
            <if test="param.remark != null">
                AND a.remark LIKE CONCAT('%', #{param.remark}, '%')
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </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.TowerInvoicing">
        <include refid="selectSql"></include>
    </select>

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

</mapper>
