<?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.dxhy.erp.dao.TdxCheckRecordInvoiceDao">
    <select id="selectAllCount" resultType="Integer" databaseId="mysql">
        select
        count(1)
        from t_dx_check_record_invoice t
        where date_format(t.create_date,'%Y%m%d%H%i%s') between #{pramsMap.createDateBegin} and
        #{pramsMap.createDateEnd}
        <if test="pramsMap.company !=null and pramsMap.company != ''">
            and t.company = #{pramsMap.company}
        </if>
        <if test="pramsMap.invoiceType != null and pramsMap.invoiceType != ''">
            and t.fpzl = #{pramsMap.invoiceType}
        </if>
        and t.CYJG_CODE = '0001'

    </select>


    <select id="selectAllCount" resultType="Integer" databaseId="oracle">
        select
        count(1)
        from t_dx_check_record_invoice t
        where
        to_char(t.create_date,'YYYYMMDDHH24MISS') between #{pramsMap.createDateBegin} and
        #{pramsMap.createDateEnd}
        <if test="pramsMap.company !=null and pramsMap.company != ''">
            and t.company = #{pramsMap.company}
        </if>
        <if test="pramsMap.invoiceType != null and pramsMap.invoiceType != ''">
            and t.fpzl = #{pramsMap.invoiceType}
        </if>
        and t.CYJG_CODE = '0001'

    </select>


    <select id="selectCheckInvoice" resultType="com.dxhy.erp.entity.TdxCheckRecordInvoice" databaseId="mysql">
        select
        *
        from t_dx_check_record_invoice t
        where date_format(t.create_date,'%Y%m%d%H%i%s') between #{pramsMap.createDateBegin} and
        #{pramsMap.createDateEnd}
        <if test="pramsMap.company !=null and pramsMap.company != ''">
            and t.company = #{pramsMap.company}
        </if>
        <if test="pramsMap.invoiceType != null and pramsMap.invoiceType != ''">
            and t.fpzl = #{pramsMap.invoiceType}
        </if>
        and t.CYJG_CODE = '0001'
        order by t.create_date limit #{pramsMap.start},#{pramsMap.num}
    </select>


    <select id="selectCheckInvoice" resultType="com.dxhy.erp.entity.TdxCheckRecordInvoice" databaseId="oracle">
        select b.* from (
        select c.*,rownum r from (
        select
        *
        from t_dx_check_record_invoice t
        where to_char(t.create_date,'YYYYMMDDHH24MISS') between #{pramsMap.createDateBegin} and
        #{pramsMap.createDateEnd}
        <if test="pramsMap.company !=null and pramsMap.company != ''">
            and t.company = #{pramsMap.company}
        </if>
        <if test="pramsMap.invoiceType != null and pramsMap.invoiceType != ''">
            and t.fpzl = #{pramsMap.invoiceType}
        </if>
        and t.CYJG_CODE = '0001'
        order by t.create_date
        ) c where  <![CDATA[rownum<= #{pramsMap.num}+ #{pramsMap.start}]]>
        )  b  where b.r > #{pramsMap.start}

    </select>

    <select id="selectVehicle" resultType="com.dxhy.erp.entity.TdxCheckVehicleSale">
        select *
        from t_dx_check_vehicle_sale
        where uuid = #{uuid}
    </select>
    <select id="selectDetailInfo" resultType="com.dxhy.api.model.invoice.invoiceCheck.TdxCheckInvoiceDetail">
        select *
        from t_dx_check_invoice_detail
        where uuid = #{uuid}
    </select>
</mapper>
