<?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.jianshui.income.mapper.InvoiceCheckMapper">

    <resultMap type="com.jianshui.income.domain.entity.InvoiceCheckEntity" id="InvoiceCheckResult">
        <result property="id"    column="id"    />
        <result property="companyId"    column="company_id"    />
        <result property="pch"    column="pch"    />
        <result property="cyjg"    column="cyjg"    />
        <result property="cyjgxx"    column="cyjgxx"    />
        <result property="fpzl"    column="fpzl"    />
        <result property="fpdm"    column="fpdm"    />
        <result property="fphm"    column="fphm"    />
        <result property="cycs"    column="cycs"    />
        <result property="xhfmc"    column="xhfmc"    />
        <result property="xhfsbh"    column="xhfsbh"    />
        <result property="xhfdzdh"    column="xhfdzdh"    />
        <result property="xhfyhzh"    column="xhfyhzh"    />
        <result property="gmfsbh"    column="gmfsbh"    />
        <result property="gmfmc"    column="gmfmc"    />
        <result property="gmfdzdh"    column="gmfdzdh"    />
        <result property="gmfyhzh"    column="gmfyhzh"    />
        <result property="kprq"    column="kprq"    />
        <result property="fpje"    column="fpje"    />
        <result property="fpse"    column="fpse"    />
        <result property="jshj"    column="jshj"    />
        <result property="bz"    column="bz"    />
        <result property="jqbh"    column="jqbh"    />
        <result property="kpr"    column="kpr"    />
        <result property="skr"    column="skr"    />
        <result property="fhr"    column="fhr"    />
        <result property="jym"    column="jym"    />
        <result property="zfbz"    column="zfbz"    />
        <result property="status"    column="status"    />
        <result property="createdAt"    column="created_at"    />
        <result property="dqskssq"    column="dqskssq"    />
        <result property="gxjzr"    column="gxjzr"    />
        <result property="gxrqq"    column="gxrqq"    />
        <result property="gxrqz"    column="gxrqz"    />
        <result property="fpzt"    column="fpzt"    />
        <result property="rzzt"    column="rzzt"    />
        <result property="rzrq"    column="rzrq"    />
        <result property="rzsq"    column="rzsq"    />
        <result property="rzlx"    column="rzlx"    />
        <result property="xxly"    column="xxly"    />
        <result property="yxse"    column="yxse"    />
        <result property="yqkgxbz"    column="yqkgxbz"    />
        <result property="glzt"    column="glzt"    />
        <result property="rzclzt"    column="rzclzt"    />
        <result property="sbyy"    column="sbyy"    />
    </resultMap>

    <sql id="selectInvoiceCheckVo">
        select id, company_id, pch, cyjg, cyjgxx, fpzl, fpdm, fphm, cycs, xhfmc, xhfsbh, xhfdzdh, xhfyhzh, gmfsbh, gmfmc, gmfdzdh, gmfyhzh, date_format(kprq,'%Y-%m-%d') kprq, fpje, fpse, jshj, bz, jqbh, kpr, skr, fhr, jym, zfbz, status, created_at, dqskssq, gxjzr, gxrqq, gxrqz, fpzt, rzzt, rzrq, rzsq, rzlx, xxly, yxse, yqkgxbz, glzt, rzclzt, sbyy from invoice_check
    </sql>

    <select id="selectInvoiceCheckListInfo" parameterType="com.jianshui.income.domain.entity.InvoiceCheckEntity" resultMap="InvoiceCheckResult">
        <include refid="selectInvoiceCheckVo"/>
        <where>
            <if test="fpzl != null  and fpzl != ''"> and fpzl = #{fpzl}</if>
            <if test="fpdm != null  and fpdm != ''"> and fpdm = #{fpdm}</if>
            <if test="fphm != null  and fphm != ''"> and fphm = #{fphm}</if>
            <if test="kprq != null  and kprq != ''"> and kprq = #{kprq}</if>
            <if test="jym != null  and jym != ''"> and jym = #{jym}</if>
            <if test="companyId != null  and companyId != ''"> and company_id = #{companyId}</if>
            <if test="gmfsbh != null  and gmfsbh != ''"> and gmfsbh = #{gmfsbh}</if>
            <if test="cyjg != null  and cyjg != ''"> and cyjg = #{cyjg}</if>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                AND date_format(kprq,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                AND date_format(kprq,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
            </if>
        </where>
        order by created_at desc
    </select>

</mapper>
