<?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.TdxRecordInvoiceDao">
    <select id="selectAllCount" resultType="Integer" databaseId="mysql">
        select
        count(1)
        from t_dx_record_invoice t
        where t.detail_yesorno = '1'
        and date_format(t.create_date,'%Y%m%d%H%i%s') between #{pramsMap.createDateBegin} and
        #{pramsMap.createDateEnd}
        <if test="pramsMap.buyerTaxNo !=null and pramsMap.buyerTaxNo != ''">
            and t.gf_tax_no = #{pramsMap.buyerTaxNo}
        </if>
        <if test="pramsMap.invoiceType != null and pramsMap.invoiceType != ''">
            and t.invoice_type = #{pramsMap.invoiceType}
        </if>
        <if test="pramsMap.qsStatus != null and pramsMap.qsStatus != ''">
            and t.qs_status = #{pramsMap.qsStatus}
        </if>
        <if test="pramsMap.qsDateBegin !=null and pramsMap.qsDateBegin != ''">
            <![CDATA[   and date_format(qs_date,'%Y%m%d%H%i%s') >= #{pramsMap.qsDateBegin}  ]]>
        </if>
        <if test="pramsMap.qsDateEnd !=null and pramsMap.qsDateEnd != ''">
            <![CDATA[   and date_format(qs_date,'%Y%m%d%H%i%s') <=#{pramsMap.qsDateEnd} ]]>
        </if>
        <if test="pramsMap.rzhStatus != null and pramsMap.rzhStatus != ''">
            and rzh_yesorno = #{pramsMap.rzhStatus}
        </if>
        <if test="pramsMap.taxPeriod != null and pramsMap.taxPeriod != ''">
            and rzh_belong_date = #{pramsMap.taxPeriod}
        </if>

    </select>


    <select id="selectAllCount" resultType="Integer" databaseId="oracle">
        select
        count(1)
        from t_dx_record_invoice t
        where t.detail_yesorno = '1'
        and to_char(t.create_date,'YYYYMMDDHH24MISS') between #{pramsMap.createDateBegin} and
        #{pramsMap.createDateEnd}
        <if test="pramsMap.buyerTaxNo !=null and pramsMap.buyerTaxNo != ''">
            and t.gf_tax_no = #{pramsMap.buyerTaxNo}
        </if>
        <if test="pramsMap.invoiceType != null and pramsMap.invoiceType != ''">
            and t.invoice_type = #{pramsMap.invoiceType}
        </if>
        <if test="pramsMap.qsStatus != null and pramsMap.qsStatus != ''">
            and t.qs_status = #{pramsMap.qsStatus}
        </if>
        <if test="pramsMap.qsDateBegin !=null and pramsMap.qsDateBegin != ''">
            <![CDATA[    and to_char(t.qs_date,'YYYYMMDDHH24MISS') >= #{pramsMap.qsDateBegin} ]]>
        </if>
        <if test="pramsMap.qsDateEnd !=null and pramsMap.qsDateEnd != ''">
            <![CDATA[   and  to_char(t.qs_date,'YYYYMMDDHH24MISS') <=#{pramsMap.qsDateEnd} ]]>
        </if>
        <if test="pramsMap.rzhStatus != null and pramsMap.rzhStatus != ''">
            and rzh_yesorno = #{pramsMap.rzhStatus}
        </if>
        <if test="pramsMap.taxPeriod != null and pramsMap.taxPeriod != ''">
            and rzh_belong_date = #{pramsMap.taxPeriod}
        </if>

    </select>


    <select id="selectSingleInvoice" resultType="com.dxhy.erp.entity.TdxRecordInvoice">
        select *
        from t_dx_record_invoice
        where gf_tax_no = #{buyerTaxNo}
        <if test="invoiceCode!=null and invoiceCode!=''">
            and invoice_code = #{invoiceCode}
        </if>
          and invoice_no = #{invoiceNo}
          and detail_yesorno = '1'
    </select>
    <select id="getRecordInvoice" resultType="com.dxhy.erp.entity.TdxRecordInvoice">
        select *
        from t_dx_record_invoice
        where gf_tax_no = #{buyerTaxNo}
          and invoice_no = #{invoiceNo}
          <if test="invoiceCode!='' and invoiceCode!=null ">
              and invoice_code = #{invoiceCode}
          </if>
    </select>
    <!-- 亚宝SQL -->
    <select id="getRecordInvoiceByUuid" resultType="com.dxhy.erp.entity.TdxRecordInvoice">
        select *
        from t_dx_record_invoice
        where uuid = #{uuid}
    </select>
    <select id="getInvoiceAccount" resultType="com.dxhy.erp.model.TdxInvoiceAccount">
        select *
        from t_dx_invoice_account
        where uuid = #{uuid}
    </select>
    <select id="getInvoice" resultType="com.dxhy.erp.model.InvoiceScanEntity">
        select *
        from t_dx_invoice
        where uuid = #{uuid}
    </select>
    <update id="updateRecordInvoice" parameterType="com.dxhy.erp.entity.TdxRecordInvoice">
        update t_dx_record_invoice
        set voucher_number=#{entity.voucherNumber},
            qs_date=now(),
            qs_type=#{entity.qsType},
            qs_status=#{entity.qsStatus},
            last_update_date=now()
        where uuid = #{uuid}
    </update>

    <insert id="saveInvoiceScan" parameterType="com.dxhy.erp.model.InvoiceScanEntity">
        insert into t_dx_invoice
        (xf_name,
         gf_name,
         tax_amount,
         total_amount,
         xf_tax_no,
         user_account,
         user_name,
         gf_tax_no,
         invoice_type,
         invoice_code,
         invoice_no,
         invoice_amount,
         invoice_date,
         qs_type,
         qs_status,
         uuid,
         notes,
         check_code,
         valid,
         create_date,
         qs_date)
        values (#{xfName},
                #{gfName},
                #{taxAmount},
                #{totalAmount},
                #{xfTaxNo},
                #{userAccount},
                #{userName},
                #{gfTaxNo},
                #{invoiceType},
                #{invoiceCode},
                #{invoiceNo},
                #{invoiceAmount},
                #{invoiceDate},
                #{qsType},
                #{qsStatus},
                #{uuId},
                #{notes},
                #{checkCode},
                1,
                now(),
                now())
    </insert>

    <update id="updateInvoiceScan" parameterType="com.dxhy.erp.model.InvoiceScanEntity">
        update t_dx_invoice
        set xf_name= #{xfName},
            gf_name=#{gfName},
            tax_amount=#{taxAmount},
            total_amount= #{totalAmount},
            xf_tax_no =#{xfTaxNo},
            user_account=#{userAccount},
            user_name =#{userName},
            gf_tax_no =#{gfTaxNo},
            invoice_type =#{invoiceType},
            invoice_code =#{invoiceCode},
            invoice_no=#{invoiceNo},
            invoice_amount= #{invoiceAmount},
            invoice_date= #{invoiceDate},
            qs_type=#{qsType},
            qs_status=#{qsStatus},
            notes=#{notes},
            check_code=#{checkCode},
            qs_date= now(),
            update_date=now()
        where uuid = #{uuId}

    </update>

    <update id="updateInvoiceAccount" parameterType="com.dxhy.erp.model.TdxInvoiceAccount">

        update t_dx_invoice_account
        set gf_tax_no=#{gfTaxNo},
            xf_tax_no=#{xfTaxNo},
            invoice_amount=#{invoiceAmount},
            invoice_date=#{invoiceDate},
            pzh=#{pzh},
            bxr=#{bxr},
            check_code=#{checkCode},
            update_date=now(),
            is_sign=#{isSign}
        where uuid = #{uuid}

    </update>

    <insert id="saveInvoiceAccount"
            parameterType="com.dxhy.erp.model.TdxInvoiceAccount">
        insert into t_dx_invoice_account (invoice_code, invoice_no, gf_tax_no, xf_tax_no, invoice_amount, invoice_date,
                                          uuid, create_date, pzh, bxr, check_code, is_sign)
        VALUES (#{invoiceCode}, #{invoiceNo}, #{gfTaxNo}, #{xfTaxNo}, #{invoiceAmount},
                STR_TO_DATE(#{invoiceDate}, '%Y-%m-%d %H'), #{uuid},
                now(), #{pzh}, #{bxr}, #{checkCode}, #{isSign})
    </insert>


    <select id="selectByCollect" resultType="com.dxhy.erp.entity.TdxRecordInvoice" databaseId="mysql">
        select
        *
        from t_dx_record_invoice t
        where t.detail_yesorno = '1'
        and date_format(t.create_date,'%Y%m%d%H%i%s') between #{pramsMap.createDateBegin} and
        #{pramsMap.createDateEnd}
        <if test="pramsMap.buyerTaxNo !=null and pramsMap.buyerTaxNo != ''">
            and t.gf_tax_no = #{pramsMap.buyerTaxNo}
        </if>
        <if test="pramsMap.invoiceType != null and pramsMap.invoiceType != ''">
            and t.invoice_type = #{pramsMap.invoiceType}
        </if>
        <if test="pramsMap.qsStatus != null and pramsMap.qsStatus != ''">
            and t.qs_status = #{pramsMap.qsStatus}
        </if>
        <if test="pramsMap.qsDateBegin !=null and pramsMap.qsDateBegin != ''">
            <![CDATA[   and date_format(qs_date,'%Y%m%d%H%i%s') >= #{pramsMap.qsDateBegin} ]]>
        </if>
        <if test="pramsMap.qsDateEnd !=null and pramsMap.qsDateEnd != ''">
            <![CDATA[   and date_format(qs_date,'%Y%m%d%H%i%s') <=#{pramsMap.qsDateEnd} ]]>
        </if>
        <if test="pramsMap.rzhStatus != null and pramsMap.rzhStatus != ''">
            and rzh_yesorno = #{pramsMap.rzhStatus}
        </if>
        <if test="pramsMap.taxPeriod != null and pramsMap.taxPeriod != ''">
            and rzh_belong_date = #{pramsMap.taxPeriod}
        </if>
        order by t.create_date limit #{pramsMap.start},#{pramsMap.num}
    </select>

    <select id="selectByCollect" resultType="com.dxhy.erp.entity.TdxRecordInvoice"
            databaseId="oracle">
        select * from (

        select
        t.*,rownum num
        from t_dx_record_invoice t
        where t.detail_yesorno = '1'
        and to_char(t.create_date,'YYYYMMDDHH24MISS') between #{pramsMap.createDateBegin} and
        #{pramsMap.createDateEnd}
        <if test="pramsMap.buyerTaxNo !=null and pramsMap.buyerTaxNo != ''">
            and t.gf_tax_no = #{pramsMap.buyerTaxNo}
        </if>
        <if test="pramsMap.invoiceType != null and pramsMap.invoiceType != ''">
            and t.invoice_type = #{pramsMap.invoiceType}
        </if>
        <if test="pramsMap.qsStatus != null and pramsMap.qsStatus != ''">
            and t.qs_status = #{pramsMap.qsStatus}
        </if>
        <if test="pramsMap.qsDateBegin !=null and pramsMap.qsDateBegin != ''">
            <![CDATA[  and  to_char(t.qs_date,'YYYYMMDDHH24MISS')  >= #{pramsMap.qsDateBegin} ]]>
        </if>
        <if test="pramsMap.qsDateEnd !=null and pramsMap.qsDateEnd != ''">
            <![CDATA[   and to_char(t.qs_date,'YYYYMMDDHH24MISS')<=#{pramsMap.qsDateEnd} ]]>
        </if>
        <if test="pramsMap.rzhStatus != null and pramsMap.rzhStatus != ''">
            and rzh_yesorno = #{pramsMap.rzhStatus}
        </if>
        <if test="pramsMap.taxPeriod != null and pramsMap.taxPeriod != ''">
            and rzh_belong_date = #{pramsMap.taxPeriod}
        </if>
        order by t.create_date
        )
        where  <![CDATA[  num> #{pramsMap.start}  and num<=#{pramsMap.num}+ #{pramsMap.start}  ]]>
    </select>


    <select id="selectByStateAllCount" resultType="Integer" databaseId="mysql">
        select
        count(1)
        from t_dx_record_invoice t
        where
        detail_yesorno='1'
        and date_format(last_update_date,'%Y%m%d%H%i%s') between #{pramsMap.startDate} and
        #{pramsMap.endDate}
        <if test="pramsMap.buyerTaxNo !=null and pramsMap.buyerTaxNo != ''">
            and gf_tax_no = #{pramsMap.buyerTaxNo}
        </if>
    </select>


    <select id="selectByStateAllCount" resultType="Integer" databaseId="oracle">
        select
        count(1)
        from t_dx_record_invoice t
        where
        detail_yesorno='1'
        and to_char(last_update_date,'YYYYMMDDHH24MISS')
        between #{pramsMap.startDate} and
        #{pramsMap.endDate}
        <if test="pramsMap.buyerTaxNo !=null and pramsMap.buyerTaxNo != ''">
            and gf_tax_no = #{pramsMap.buyerTaxNo}
        </if>
    </select>


    <select id="selectByState" resultType="com.dxhy.erp.model.State" databaseId="mysql">
        select
        invoice_code invoiceCode,
        invoice_no invoiceNo,
        invoice_status invoiceStatus,
        qs_status qsStatus,
        qs_name qsUser,
        date_format(qs_date,'%Y%m%d') qsDate,
        rzh_yesorno legalizeState,
        date_format(rzh_date,'%Y%m%d') legalizeDate,
        rzh_belong_date legalizeBelongDate,
        rzlx,
        glzt managementStatus,
        xxly informationSources,
        dk_tax_amount taxCredit,
        yqkgxbz overdueCheckMark,
        yclx exceptionType
        from t_dx_record_invoice
        where
        detail_yesorno='1'
        and date_format(last_update_date,'%Y%m%d%H%i%s') between #{pramsMap.startDate} and
        #{pramsMap.endDate}
        <if test="pramsMap.buyerTaxNo !=null and pramsMap.buyerTaxNo != ''">
            and gf_tax_no = #{pramsMap.buyerTaxNo}
        </if>
        order by last_update_date desc limit #{pramsMap.start},#{pramsMap.num}
    </select>

    <delete id="deleteByuuid" parameterType="string">
        delete from t_dx_record_invoice_out where uuid in
        <foreach collection="uuids" open="(" close=")" separator="," item="item">
            #{item}
        </foreach>
    </delete>


    <select id="selectByState" resultType="com.dxhy.erp.model.State" databaseId="oracle">
        select * from (
        select
        rownum num,
        invoice_code invoiceCode,
        invoice_no invoiceNo,
        invoice_status invoiceStatus,
        qs_status qsStatus,
        qs_name qsUser,
        to_char(qs_date,'YYYYMMDD') qsDate,
        rzh_yesorno legalizeState,
        to_char(rzh_date,'YYYYMMDD') legalizeDate,
        rzh_belong_date legalizeBelongDate,
        rzlx,
        glzt managementStatus,
        xxly informationSources,
        dk_tax_amount taxCredit,
        yqkgxbz overdueCheckMark,
        yclx exceptionType
        from t_dx_record_invoice
        where
        detail_yesorno='1'
        and to_char(last_update_date,'YYYYMMDDHH24MISS')between #{pramsMap.startDate} and
        #{pramsMap.endDate}
        <if test="pramsMap.buyerTaxNo !=null and pramsMap.buyerTaxNo != ''">and gf_tax_no =
            #{pramsMap.buyerTaxNo}
        </if>
        order by
        last_update_date desc
        )
        where  <![CDATA[  num> #{pramsMap.start}  and num<=#{pramsMap.num}+ #{pramsMap.start}  ]]>
    </select>


    <select id="selectVehicle" resultType="com.dxhy.erp.model.VehicleSaleInvoices">
        select *
        from t_dx_vehicle_sale_invoice
        where uuid = #{uuid}
    </select>
    <select id="selectDetailInfo" resultType="com.dxhy.erp.model.InvoiceDetailInfo">
        select *
        from t_dx_record_invoice_detail
        where uuid = #{uuid}
    </select>

    <select id="selectAuth" resultType="com.dxhy.erp.entity.TdxRecordInvoice" databaseId="mysql">
        select
        t.invoice_code,
        t.invoice_no,
        t.is_auth
        from t_dx_record_invoice t
        where t.invoice_type in('01','03','14')
        and t.rzh_yesorno = '0'
        and date_format(t.invoice_date,'%Y-%m-%d') between #{pramsMap.invoiceDateBegin} and
        #{pramsMap.invoiceDateEnd}
        <if test="pramsMap.buyerTaxNo !=null and pramsMap.buyerTaxNo != ''">
            and t.gf_tax_no = #{pramsMap.buyerTaxNo}
        </if>

    </select>


    <select id="selectAuth" resultType="com.dxhy.erp.entity.TdxRecordInvoice" databaseId="oracle">
        select
        t.invoice_code,
        t.invoice_no,
        t.is_auth
        from t_dx_record_invoice t
        where t.invoice_type in('01','03','14')
        and t.rzh_yesorno = '0'
        and to_char(t.invoice_date,'YYYY-MM-DD') between #{pramsMap.invoiceDateBegin} and
        #{pramsMap.invoiceDateEnd}
        <if test="pramsMap.buyerTaxNo !=null and pramsMap.buyerTaxNo != ''">
            and t.gf_tax_no = #{pramsMap.buyerTaxNo}
        </if>

    </select>


    <!--申请撤销认证 -->
    <update id="updateCxrz" databaseId="mysql">
        update t_dx_record_invoice
        set rzlx='5',
            cxrz_status='1',
            cxrz_current_period=#{taxPeriod},
            cxrz_date=now()
        where uuid = #{uuid}
    </update>

    <update id="updateCxrz" databaseId="oracle">
        update t_dx_record_invoice
        set rzlx='5',
            cxrz_status='1',
            cxrz_current_period=#{taxPeriod},
            cxrz_date=sysdate
        where uuid = #{uuid}
    </update>
    <update id="updateCxbdk" databaseId="mysql">
        update t_dx_record_invoice
        set rzlx='6',
            cxbdk_status='1',
            bdk_current_period=#{taxPeriod},
            cxbdk_date=now()
        where uuid = #{uuid}
    </update>
    <update id="updateCxbdk" databaseId="oracle">
        update t_dx_record_invoice
        set rzlx='6',
            cxbdk_status='1',
            bdk_current_period=#{taxPeriod},
            cxbdk_date=sysdate
        where uuid = #{uuid}
    </update>

    <update id="updateRz" databaseId="mysql">
        update t_dx_record_invoice
        set rzlx           = #{rzlx},
            sfygx='1',
            auth_status='2',
            bdk_status=#{bdkStatus},
            confirm_date=now(),
            confirm_user=#{pramsMap.rz_user},
            gx_user_account=#{pramsMap.rz_user},
            gx_user_name=#{pramsMap.rz_user},
            gx_date=now(),
            rzh_belong_date=#{pramsMap.applyTaxPeriod},
            cxrz_date=null,
            cxrz_status='0',
            cxbdk_date=null,
            cxbdk_status='0'
        where uuid = #{uuid}
    </update>

    <update id="updateRz" databaseId="oracle">
        update t_dx_record_invoice
        set rzlx           = #{rzlx},
            sfygx='1',
            auth_status='2',
            bdk_status=#{bdkStatus},
            confirm_date=sysdate,
            confirm_user=#{pramsMap.rz_user},
            gx_user_account=#{pramsMap.rz_user},
            gx_user_name=#{pramsMap.rz_user},
            gx_date=sysdate,
            rzh_belong_date=#{pramsMap.applyTaxPeriod},
            cxrz_date=null,
            cxrz_status='0',
            cxbdk_date=null,
            cxbdk_status='0'
        where uuid = #{uuid}
    </update>


    <select id="selectAuthResult" resultType="com.dxhy.erp.model.AuthStatus" databaseId="mysql">
        select t.invoice_code                    invoiceCode,
               t.invoice_no                      invoiceNo,
               t.rzh_yesorno                     legalizeState,
               date_format(t.rzh_date, '%Y%m%d') legalizeDate,
               t.rzh_back_msg                    failureReason,
               t.auth_status                     authState,
               t.rzh_belong_date                 legalizeBelongDate,
               t.gf_tax_no                       buyerTaxNo,
               t.rzlx,
               t.dk_tax_amount                   taxCredit,
               t.glzt                            managementStatus,
               t.xxly                            informationSources,
               t.yqkgxbz                         overdueCheckMark,
               d.batch_no                        batchNo
        from t_dx_record_invoice t,
             t_dx_auth_record d
        where t.uuid = d.uuid
          and d.batch_no = #{batchNo}
          and (t.auth_status in ('1', '2', '3')
            or t.cxrz_status in ( '1', '2') or t.cxbdk_status in ('1','2'))
    </select>

    <select id="selectAuthResult" resultType="com.dxhy.erp.model.AuthStatus" databaseId="oracle">
        select t.invoice_code                  invoiceCode,
               t.invoice_no                    invoiceNo,
               t.rzh_yesorno                   legalizeState,
               to_char(t.rzh_date, 'YYYYMMDD') legalizeDate,
               t.rzh_back_msg                  failureReason,
               t.auth_status                   authState,
               t.rzh_belong_date               legalizeBelongDate,
               t.gf_tax_no                     buyerTaxNo,
               t.rzlx,
               t.dk_tax_amount                 taxCredit,
               t.glzt                          managementStatus,
               t.xxly                          informationSources,
               t.yqkgxbz                       overdueCheckMark,
               d.batch_no                      batchNo
        from t_dx_record_invoice t,
             t_dx_auth_record d
       where t.uuid = d.uuid
          and d.batch_no = #{batchNo}
          and (t.auth_status in ('1', '2', '3')
            or t.cxrz_status in ( '1', '2') or t.cxbdk_status in ('1','2'))
    </select>

    <select id="selectAuthResultBack" resultType="com.dxhy.erp.model.AuthStatus" databaseId="mysql">
       select d.invoice_code                    invoiceCode,
               d.invoice_no                      invoiceNo,
               t.rzh_yesorno                     legalizeState,
               date_format(t.rzh_date, '%Y%m%d') legalizeDate,
               t.rzh_back_msg                    failureReason,
               t.auth_status                     authState,
               t.rzh_belong_date                 legalizeBelongDate,
               d.buyer_tax_no                    buyerTaxNo,
               d.rzlx,
               t.dk_tax_amount                   taxCredit,
               t.glzt                            managementStatus,
               t.xxly                            informationSources,
               t.yqkgxbz                         overdueCheckMark,
               d.batch_no                        batchNo,
               t.cxrz_status                     cxrzStatus,
               t.cxbdk_status                    cxbdkStatus
        from t_dx_auth_record d
                 left join t_dx_record_invoice t on t.uuid = d.uuid
        where d.batch_no = #{batchNo}
    </select>

    <select id="selectAuthResultBack" resultType="com.dxhy.erp.model.AuthStatus" databaseId="oracle">
        select d.invoice_code                  invoiceCode,
               d.invoice_no                    invoiceNo,
               t.rzh_yesorno                   legalizeState,
               to_char(t.rzh_date, 'YYYYMMDD') legalizeDate,
               t.rzh_back_msg                  failureReason,
               t.auth_status                   authState,
               t.rzh_belong_date               legalizeBelongDate,
               d.buyer_tax_no                  buyerTaxNo,
               d.rzlx,
               t.dk_tax_amount                 taxCredit,
               t.glzt                          managementStatus,
               t.xxly                          informationSources,
               t.yqkgxbz                       overdueCheckMark,
               d.batch_no                      batchNo,
                t.cxrz_status                     cxrzStatus,
               t.cxbdk_status                    cxbdkStatus
        from t_dx_auth_record d
                 left join t_dx_record_invoice t on t.uuid = d.uuid
        where d.batch_no = #{batchNo}
    </select>


    <select id="selectAuthResultCount" resultType="Integer">
        select
        count(1)
        from t_dx_record_invoice t
        where 1=1
        <if test="pramsMap.buyerTaxNo !=null and pramsMap.buyerTaxNo != ''">
            and t.gf_tax_no = #{pramsMap.buyerTaxNo}
        </if>
        <if test="pramsMap.rzhStatus != null and pramsMap.rzhStatus != ''">
            and rzh_yesorno = #{pramsMap.rzhStatus}
        </if>
        <if test="pramsMap.taxPeriod != null and pramsMap.taxPeriod != ''">
            and rzh_belong_date = #{pramsMap.taxPeriod}
        </if>
        <if test="pramsMap.rzhUser != null and pramsMap.rzhUser != ''">
            and confirm_user = #{pramsMap.rzhUser}
        </if>

    </select>
    <select id="selectAllAuthResult" resultType="com.dxhy.erp.model.AuthStatus" databaseId="mysql">
        select
        invoice_code invoiceCode,
        invoice_no invoiceNo,
        invoice_amount invoiceAmount,
        tax_amount taxAmount,
        date_format(invoice_date,'%Y%m%d') invoiceDate,
        rzh_back_msg failureReason,
        auth_status authState,
        rzh_belong_date legalizeBelongDate,
        rzlx ,
        glzt managementStatus,
        xxly informationSources,
        dk_tax_amount taxCredit,
        yqkgxbz overdueCheckMark,
        date_format(rzh_date,'%Y%m%d') legalizeDate
        from t_dx_record_invoice t
        where 1=1
        <if test="pramsMap.buyerTaxNo !=null and pramsMap.buyerTaxNo != ''">
            and t.gf_tax_no = #{pramsMap.buyerTaxNo}
        </if>
        <if test="pramsMap.rzhStatus != null and pramsMap.rzhStatus != ''">
            and rzh_yesorno = #{pramsMap.rzhStatus}
        </if>
        <if test="pramsMap.taxPeriod != null and pramsMap.taxPeriod != ''">
            and rzh_belong_date = #{pramsMap.taxPeriod}
        </if>
        <if test="pramsMap.rzhUser != null and pramsMap.rzhUser != ''">
            and confirm_user = #{pramsMap.rzhUser}
        </if>
        order by t.create_date limit #{pramsMap.start},#{pramsMap.num}
    </select>


    <select id="selectAllAuthResult" resultType="com.dxhy.erp.model.AuthStatus" databaseId="oracle">

        select * from (
        select
        rownum num,
        invoice_code invoiceCode,
        invoice_no invoiceNo,
        invoice_amount invoiceAmount,
        tax_amount taxAmount,
        to_char(invoice_date,'YYYYMMDD') invoiceDate,
        rzh_back_msg failureReason,
        auth_status authState,
        rzh_belong_date legalizeBelongDate,
        rzlx ,
        glzt managementStatus,
        xxly informationSources,
        dk_tax_amount taxCredit,
        yqkgxbz overdueCheckMark,
        to_char(rzh_date,'YYYYMMDD') legalizeDate
        from t_dx_record_invoice t
        where 1=1
        <if test="pramsMap.buyerTaxNo !=null and pramsMap.buyerTaxNo != ''">and t.gf_tax_no =
            #{pramsMap.buyerTaxNo}
            and rzh_yesorno = #{pramsMap.rzhStatus}
        </if>
        <if test=" pramsMap.rzhStatus != null and pramsMap.rzhStatus != ''"></if>
        <if test="pramsMap.taxPeriod != null and pramsMap.taxPeriod != ''">
            and rzh_belong_date = #{pramsMap.taxPeriod}
        </if>
        <if test="pramsMap.rzhUser != null and pramsMap.rzhUser != ''">
            and confirm_user = #{pramsMap.rzhUser}
        </if>
        order by t.create_date
        )
        where  <![CDATA[  num> #{pramsMap.start}  and num<=#{pramsMap.num}+ #{pramsMap.start}  ]]>
    </select>
    <select id="selectRzhStatus" resultType="com.dxhy.erp.entity.TdxRecordInvoice">
        select t.invoice_code,
               t.invoice_no,
               t.rzh_yesorno,
               t.rzh_belong_date,
               t.rzh_date,
               t.rzlx,
               t.is_auth,
               t.dk_tax_amount
        from t_dx_record_invoice t
        where uuid = #{uuid}

    </select>


</mapper>
