<?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.huyi.service.invoice.mapper.OwnInvoiceMapper">

    <select id="selectInvoiceInfList" parameterType="map" resultType="map">
        SELECT
              i.zii_id              'ziiId',
              i.zii_no              'ziiNo',
              DATE_FORMAT(i.zii_date ,'%Y-%m-%d') 'ziiDate',
              i.zii_amount          'ziiAmount',
              i.zii_type            'ziiType',
              i.zii_purchaser_no    'ziiPurchaserNo',
              i.zii_seller_no       'ziiSellerNo',
              i.zii_total_amount    'ziiTotalAmount',
              i.create_time         'createTime',
              i.update_time         'updateTime',
              u.nick_name           'createName',
              m.nick_name           'updateName',
              i.zii_purchaser_name  'ziiPurchaserName',
              i.zii_seller_name     'ziiSellerName',
              f.pfi_url             'pfiUrl',
              i.zii_file            'ziiFile'

        FROM        zc_invoice_inf     i
        LEFT JOIN   sys_user u
        ON u.user_id = i.create_by
        LEFT JOIN   sys_user m
        ON m.user_id = i.update_by
        LEFT JOIN pub_file_inf f
        ON f.pfi_file_id = i.zii_file
        WHERE 1 = 1
        <if test="paramMap.ziiCompanyId != null  and paramMap.ziiCompanyId != ''">
            and i.zii_company_id = #{paramMap.ziiCompanyId}
        </if>

        <if test="paramMap.ziiPurchaserNo != null  and paramMap.ziiPurchaserNo != ''">
            and i.zii_purchaser_no like concat('%', #{paramMap.ziiPurchaserNo}, '%')
        </if>

        <if test="paramMap.ziiSellerNo != null  and paramMap.ziiSellerNo != ''">
            and i.zii_seller_no like concat('%', #{paramMap.ziiSellerNo}, '%')
        </if>

        <if test="paramMap.ziiNo != null  and paramMap.ziiNo != ''">
            and i.zii_no like concat('%', #{paramMap.ziiNo}, '%')
        </if>
        <if test="paramMap.ziiPurchaserName != null  and paramMap.ziiPurchaserName != ''">
            and i.zii_purchaser_name like concat('%', #{paramMap.ziiPurchaserName}, '%')
        </if>
        <if test="paramMap.ziiSellerName != null  and paramMap.ziiSellerName != ''">
            and i.zii_seller_name like concat('%', #{paramMap.ziiSellerName}, '%')
        </if>

        <if test="paramMap.startTime != null  and paramMap.startTime != ''">
            and DATE_FORMAT(i.zii_date, '%Y-%m-%d') &gt;= #{paramMap.startTime}
        </if>

        <if test="paramMap.endTime != null  and paramMap.endTime != ''">
            and DATE_FORMAT(i.zii_date, '%Y-%m-%d') &lt;=  #{paramMap.endTime}
        </if>
        order by i.create_time desc

    </select>




</mapper>