<?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.base.dao.BaseFpxxZhDao">

    <resultMap id="BaseResultMap"
               type="com.dxhy.base.model.BaseFpRzRespVO">
        <result column="id" property="id"/>
        <result column="deptName" property="deptName"/>
        <result column="invoice_code" property="invoiceCode"/>
        <result column="invoice_no" property="invoiceNo"/>
        <result column="kprq" property="invoiceDate"/>
        <result column="invoice_type" property="invoiceType"/>
        <result column="gfsh" property="gfsh"/>
        <result column="image_id" property="imageId"/>
        <result column="image_id" property="imageNumber"/>
        <result column="gfmc" property="gfmc"/>
        <result column="gf_tax_no" property="gfsh"/>
        <result column="account_period" property="accountPeriod"/>
        <result column="gf_name" property="gfmc"/>
        <result column="rzh_date" property="rzsj"/>
        <result column="xf_tax_no" property="xfsh"/>
        <result column="xf_name" property="xfmc"/>
        <result column="invoice_amount" property="invoiceAmount"/>
        <result column="tax_amount" property="taxAmount"/>
        <result column="dk_tax_amount" property="dkTaxAmount"/>
        <result column="invoice_status" property="invoiceStatus"/>
        <result column="rzh_date" property="rzsj"/>
        <result column="qs_date" property="qsrq"/>
        <result column="rzh_type" property="rzfs"/>
        <result column="dqskssq" property="skssq"/>
        <result column="auth_status" property="rzclzt"/>
        <result column="qs_type" property="qsfs"/>
        <result column="qs_status" property="qszt"/>
        <result column="confirm_user" property="rzr"/>
        <result column="qs_name" property="qsr"/>
        <result column="rzh_yesorno" property="rzzt"/>
        <result column="deptId" property="deptId"/>
        <result column="deptName" property="businessName"/>
        <result column="cxrz_status" property="cxrzStatus"/>
        <result column="out_status" property="outStatus"/>
        <result column="bdk_status" property="bdkStatus"/>
        <result column="bdk_current_period" property="bdkCurrentPeriod"/>
        <result column="bdk_date" property="bdkDate"/>
        <result column="bzdh" property="bzdh"/>
        <result column="inaccount_status" property="inAccountStatus"/>
        <result column="payment_date" property="paymentDate"/>
        <result column="payment_status" property="paymentStatus"/>
        <result column="voucher_number" property="voucherNumber"/>
        <result column="sn_voucher_number" property="snVoucherNumber"/>
        <result column="ele_invoice_no" property="eleInvoiceNo"/>
        <result column="comp_code" property="compCode"/>
    </resultMap>

    <resultMap id="RzcxhjResultMap"
               type="com.dxhy.base.model.BaseFpRzRespVO">
        <result column="hjsl" property="id"/>
        <result column="hjje" property="invoiceAmount"/>
        <result column="hjse" property="taxAmount"/>
    </resultMap>

    <select id="selectByPramsMap" parameterType="java.util.Map"
            resultMap="BaseResultMap" databaseId="mysql">
        select
        t.invoice_code,t.invoice_no,t.invoice_type,DATE_FORMAT(t.invoice_date,'%Y-%m-%d')kprq,t.gf_tax_no,t.gf_name,t.image_id,
        t.dept_id deptId,t.dept_name deptName,t.comp_code,
        t.xf_tax_no,t.xf_name,t.tax_amount,t.dk_tax_amount,t.invoice_status,t.invoice_amount,date_format(t.rzh_date,'%Y-%m-%d') rzh_date,
        date_format(t.qs_date,'%Y-%m-%d') qs_date,t.rzh_type,t.id id,
        t.gx_user_name,t.rzh_belong_date,t.inaccount_status,t.bzdh,
        t.rzh_belong_date as dqskssq,t.auth_status,t.qs_type,t.qs_status,t.confirm_user,t.qs_name,t.rzh_yesorno,t.cxrz_status,t.out_status,
        t.bdk_status,t.bdk_current_period,date_format(t.bdk_date,'%Y-%m-%d')
        bdk_date,t.rzh_back_msg,t.in_account_status,t.payment_status,date_format(t.payment_date,'%Y-%m-%d')payment_date,
        voucher_number,t.ele_invoice_no, sn_voucher_number, account_period, posting_time ,image_id
        from t_dx_record_invoice t
        WHERE date_format(t.invoice_date,'%Y-%m-%d') between #{kpksrq} and #{kpjsrq}
        and (t.invoice_type in('01','03','08','14','31','283','161','183','185') or (t.invoice_type ='32' and t.lq_tdyslxDm='08'))
        and t.bdk_status in ('1','2')
        and t.export_mark = '0'
        and t.auth_status != '0'
        and t.company = #{company}
        and t.gf_tax_no in
        <foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>

        <if test="companyCodes != null and companyCodes != '99' and companyCodes != '88' and companyCodes != '' and companyCodes != 'null'" >
            and t.comp_code = #{companyCodes}
        </if>
        <if test="companyCodes != null and companyCodes != ''  and companyCodes == '88'">
            and (t.comp_code = '' or t.comp_code is null)
        </if>

        <if test="invoiceStatus != null and invoiceStatus != '' and invoiceStatus != 'null' ">
            and t.invoice_status = #{invoiceStatus}
        </if>
        <if test="voucherNumber != null and voucherNumber != ''">
            and t.voucher_number like concat('%',concat(#{voucherNumber},'%'))
        </if>
        <if test="bzdh != null and bzdh != '' and bzdh != 'null'">
            and t.bzdh = #{bzdh}
        </if>
        <if test="inAccountStatus != null and inAccountStatus != '' and inAccountStatus != 'null' and inAccountStatus != '99' ">
            and t.inaccount_status = #{inAccountStatus}
        </if>
        <if test="qszt != null and qszt != '' and qszt != 'null' and qszt != '99'">
            and t.qs_status = #{qszt}
        </if>
        <if test="qsfs != null and qsfs != '' and qsfs != 'null'">
            and t.qs_type = #{qsfs}
        </if>
        <if test="wrzfpStart != null and wrzfpStart != '' and wrzfpStart != 'null' and wrzfpEnd != null and wrzfpEnd != '' and wrzfpEnd != 'null'">
           and rzh_yesorno = '0' and date_format(t.invoice_date,'%Y-%m-%d') between #{wrzfpStart} and #{wrzfpEnd}
        </if>
       <if test="qsksrq != null and qsksrq != '' and qsksrq != 'null' and qsjsrq != null and qsjsrq != '' and qsjsrq != 'null'">
            and date_format(t.qs_date,'%Y-%m-%d') between #{qsksrq} and #{qsjsrq}
        </if>
        <if
                test="rzksrq != null and rzksrq != '' and rzksrq != 'null' and rzjsrq != null and rzjsrq != '' and rzjsrq != 'null'">
            and date_format(t.rzh_date,'%Y-%m-%d') between #{rzksrq} and #{rzjsrq}
        </if>
         <if test="accountPeriodStart != null and accountPeriodStart != '' and accountPeriodStart != 'null'
         and accountPeriodEnd != null and accountPeriodEnd != '' and accountPeriodEnd != 'null'">
            and date_format(t.account_period,'%Y-%m') between #{accountPeriodStart} and #{accountPeriodEnd}
        </if>
        <if test="postingTimeStart != null and postingTimeStart != '' and postingTimeStart != 'null'
        and postingTimeEnd != null and postingTimeEnd != '' and postingTimeEnd != 'null'">
            and date_format(t.posting_time,'%Y-%m-%d') between #{postingTimeStart} and #{postingTimeEnd}
        </if>
        <if test="rzzt != null and rzzt != '' and rzzt != 'null' and rzzt != '3'">
            and t.rzh_yesorno = #{rzzt}
        </if>
        <if test="rzzt != null and rzzt != '' and rzzt != 'null' and rzzt == '3'">
            and (t.rzh_yesorno = '1' or t.rzh_yesorno = '2')
        </if>
        <if test="imageId != null and imageId != '' and imageId != 'null' ">
            and t.image_id = #{imageId}
        </if>
        <if test="rzclzt !=null and rzclzt != ''">
            and t.auth_status = #{rzclzt}
        </if>
        <if test="rzlx!=null and rzlx!=''">
            and t.bdk_status = #{rzlx}
        </if>
        <if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '14' ">
            and (t.invoice_type = '14' or (t.invoice_type = '32' and t.lq_tdyslxDm='08') )
        </if>
        <if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '14' ">
            and t.invoice_type = #{invoiceType}
        </if>
        <if test="invoiceSource!=null and invoiceSource!='' and invoiceSource!='null' and invoiceSource!='99'">
            and t.invoice_source = #{invoiceSource}
        </if>
        <if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
            and t.ele_invoice_no = #{eleInvoiceNo}
        </if>
        <if
                test="qsfs != null and qsfs != '' and qsfs != 'null' ">
            and t.qs_type = #{qsfs}
        </if>
        <if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
            and t.xf_name like concat(#{xfmc},'%')
        </if>
        <if test="qsr != null and qsr != '' and qsr != 'null' ">
            and t.qs_name = #{qsr}
        </if>
        <if test="rzhr != null and rzhr != '' and rzhr != 'null' ">
            and t.confirm_user in
            <foreach collection="rzhr" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if
                test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
            and t.invoice_no = #{invoiceNo}
        </if>
        <if test="paymentDateStart != null and paymentDateStart != '' and paymentDateStart != 'null' ">
            <![CDATA[ AND date_format(t.payment_date,'%Y-%m-%d') >= #{paymentDateStart} ]]>
        </if>
        <if test="paymentDateEnd != null and paymentDateEnd != '' and paymentDateEnd != 'null' ">
            <![CDATA[ AND date_format(t.payment_date,'%Y-%m-%d')  <= #{paymentDateEnd} ]]>
        </if>
        <if test="paymentStatus != null and paymentStatus != '' and paymentStatus != '99'">
            and t.payment_status = #{paymentStatus}
        </if>
        <if
                test="skssq != null and skssq != '' and skssq != 'null' ">
            and t.rzh_belong_date = #{skssq}
        </if>
         <if test="snVoucherNumber != null and snVoucherNumber != '' and snVoucherNumber != 'null' ">
            and t.sn_voucher_number = #{snVoucherNumber}
        </if>
        <if
                test="businessCode != '99' and businessCode != null and businessCode != '' and businessCode != 'null' ">
            and t.dept_id = #{businessCode}
        </if>
        <if test="businessCode==''">
            and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
        </if>
        <if test='businessCode == "99" and business!=null and business.size()>0'>
            and (t.dept_id in
            <foreach collection="business" index="index" item="item" open="(" separator="," close="">
                #{item.businessCode}
            </foreach>
            ) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
        </if>
<!--        <if test='inAccountStatus!=null and inAccountStatus!="" and inAccountStatus !="99"'>-->
<!--            and t.in_account_status = #{inAccountStatus}-->
<!--        </if>-->
        <if test="snVoucherNumber != null and snVoucherNumber != '' and snVoucherNumber != 'null' and snVoucherNumber != '99'">
            and t.sn_voucher_number = #{snVoucherNumber}
        </if>
        <if test="postingTimeStart != null and postingTimeEnd != null and postingTimeStart != '' and postingTimeEnd != ''">
            and t.posting_time between #{postingTimeStart} and #{postingTimeEnd}
        </if>
        <if test="imageNumber != null and imageNumber != '' and imageNumber != 'null' and imageNumber != '99'">
            and t.image_id = #{imageNumber}
        </if>
        <if test="accountPeriod != null and accountPeriod != '' and accountPeriod != 'null' and accountPeriod != '99'">
            and t.account_period = #{accountPeriod}
        </if>
        order by t.rzh_date desc,t.invoice_date desc
    </select>
    <select id="selectByPramsMap" parameterType="java.util.Map"
            resultMap="BaseResultMap" databaseId="oracle">
        select
        t.invoice_code,t.invoice_no,t.invoice_type,to_char(t.invoice_date,'yyyy-mm-dd')kprq,t.gf_tax_no
        gfsh,
        t.gf_name gfmc,t.dept_id deptId,t.dept_name deptName,
        t.xf_tax_no,t.xf_name,t.tax_amount,t.dk_tax_amount,t.invoice_status,t.invoice_amount,to_char(t.rzh_date,'yyyy-mm-dd')
        rzh_date,
        to_char(t.qs_date,'yyyy-mm-dd') qs_date,t.rzh_type,t.id id,
        t.gx_user_name,t.rzh_belong_date
        dqskssq,t.auth_status,t.qs_type,t.qs_status,t.confirm_user,t.qs_name,t.rzh_yesorno,t.cxrz_status,t.out_status,
        t.bdk_status,t.bdk_current_period,to_char(t.bdk_date,'yyyy-mm-dd') bdk_date
        ,t.rzh_back_msg,t.in_account_status,t.payment_status,to_char(t.payment_date,'yyyy-mm-dd')payment_date
        from t_dx_record_invoice t
        WHERE to_char(t.invoice_date,'yyyy-mm-dd') between #{kpksrq} and #{kpjsrq}
        and t.auth_status != '0'
        and (t.invoice_type in('01','03','08','14','31','283','161','183','185') or (t.invoice_type ='32' and t.lq_tdyslxDm='08'))
        and t.bdk_status in ('1','2')
        and t.export_mark = '0'
        and t.company = #{company}
        and t.gf_tax_no in
        <foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        <if test="invoiceStatus != null and invoiceStatus != '' and invoiceStatus != 'null' ">
            and t.invoice_status = #{invoiceStatus}
        </if>
        <if test="qszt != null and qszt != '' and qszt != 'null' ">
            and t.qs_status = #{qszt}
        </if>
        <if test="rzzt != null and rzzt != '' and rzzt != 'null' ">
            and t.rzh_yesorno = #{rzzt}
        </if>
        <if
                test="qsksrq != null and qsksrq != '' and qsksrq != 'null' and qsjsrq != null and qsjsrq != '' and qsjsrq != 'null'">
            and to_char(t.qs_date,'yyyy-mm-dd') between #{qsksrq} and #{qsjsrq}
        </if>
        <if
                test="rzksrq != null and rzksrq != '' and rzksrq != 'null' and rzjsrq != null and rzjsrq != '' and rzjsrq != 'null'">
            and to_char(t.rzh_date,'yyyy-mm-dd') between #{rzksrq} and #{rzjsrq}
        </if>
        <if test="rzclzt !=null and rzclzt != ''">
            and t.auth_status = #{rzclzt}
        </if>
        <if test="rzlx!=null and rzlx!=''">
            and t.bdk_status = #{rzlx}
        </if>
        <if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '14' ">
            and (t.invoice_type = '14' or (t.invoice_type = '32' and t.lq_tdyslxDm='08') )
        </if>
        <if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '14' ">
            and t.invoice_type = #{invoiceType}
        </if>
        <if test="invoiceSource!=null and invoiceSource!='' and invoiceSource!='null' and invoiceSource!='99'">
            and t.invoice_source = #{invoiceSource}
        </if>
        <if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
            and t.ele_invoice_no = #{eleInvoiceNo}
        </if>
        <if
                test="qsfs != null and qsfs != '' and qsfs != 'null' ">
            and t.qs_type = #{qsfs}
        </if>
        <if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
            and t.xf_name like concat(#{xfmc},'%')
        </if>
        <if test="qsr != null and qsr != '' and qsr != 'null' ">
            and t.qs_name = #{qsr}
        </if>
        <if test="rzhr != null and rzhr != '' and rzhr != 'null' ">
            and t.confirm_user in
            <foreach collection="rzhr" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="paymentDateStart != null and paymentDateStart != '' and paymentDateStart != 'null' ">
            <![CDATA[ AND date_format(t.payment_date,'%Y-%m-%d') >= #{paymentDateStart} ]]>
        </if>
        <if test="paymentDateEnd != null and paymentDateEnd != '' and paymentDateEnd != 'null' ">
            <![CDATA[ AND date_format(t.payment_date,'%Y-%m-%d')  <= #{paymentDateEnd} ]]>
        </if>
        <if test="paymentStatus != null and paymentStatus != '' and paymentStatus != '99'">
            and t.payment_status = #{paymentStatus}
        </if>
        <if
                test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
            and t.invoice_no = #{invoiceNo}
        </if>
        <if
                test="skssq != null and skssq != '' and skssq != 'null' ">
            and t.rzh_belong_date = #{skssq}
        </if>
        <if
                test="businessCode != '99' and businessCode != null and businessCode != '' and businessCode != 'null' ">
            and t.dept_id = #{businessCode}
        </if>
        <if test="businessCode==''">
            and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
        </if>
        <if test='businessCode == "99" and business!=null and business.size()>0'>
            and (t.dept_id in
            <foreach collection="business" index="index" item="item" open="(" separator="," close="">
                #{item.businessCode}
            </foreach>
            ) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
        </if>
        <if test='inAccountStatus!=null and inAccountStatus!="" and inAccountStatus !="99"'>
            and t.in_account_status = #{inAccountStatus}
        </if>
        order by t.rzh_date desc,t.invoice_date desc
    </select>

    <select id="selectRzfpHj" parameterType="java.util.Map"
            resultMap="RzcxhjResultMap" databaseId="mysql">
        select count(1) hjsl,sum(t.invoice_amount)hjje,sum(t.tax_amount)hjse
        from t_dx_record_invoice t
        WHERE date_format(t.invoice_date,'%Y-%m-%d') between #{kpksrq} and #{kpjsrq}
        and (t.invoice_type in('01','03','08','14','31','283','161','183','185') or (t.invoice_type ='32' and t.lq_tdyslxDm='08'))
        and t.auth_status != '0'
        and t.bdk_status in ('1','2')
        and t.export_mark = '0'
        and t.company =#{company}
        and t.gf_tax_no in
        <foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        <if test="companyCodes != null and companyCodes != '99' and companyCodes != '88' and companyCodes != '' and companyCodes != 'null'" >
            and t.comp_code = #{companyCodes}
        </if>
        <if test="companyCodes != null and companyCodes != ''  and companyCodes == '88'">
            and (t.comp_code = '' or t.comp_code is null)
        </if>
        <if  test="invoiceStatus != null and invoiceStatus != '' and invoiceStatus != 'null' ">
            and t.invoice_status = #{invoiceStatus}
        </if>
        <if test="snVoucherNumber != null and snVoucherNumber != '' and snVoucherNumber != 'null' and snVoucherNumber != '99'">
            and t.sn_voucher_number = #{snVoucherNumber}
        </if>
        <if test="postingTimeStart != null and postingTimeEnd != null and postingTimeStart != '' and postingTimeEnd != ''">
            and t.posting_time between #{postingTimeStart} and #{postingTimeEnd}
        </if>
        <if test="imageNumber != null and imageNumber != '' and imageNumber != 'null' and imageNumber != '99'">
            and t.image_id = #{imageNumber}
        </if>
        <if test="accountPeriod != null and accountPeriod != '' and accountPeriod != 'null' and accountPeriod != '99'">
            and t.account_period = #{accountPeriod}
        </if>
        <if test="voucherNumber != null and voucherNumber != ''">
            and t.voucher_number like concat('%',concat(#{voucherNumber},'%'))
        </if>
        <if test="bzdh != null and bzdh != '' and bzdh != 'null' and bzdh != '99'">
            and t.bzdh = #{bzdh}
        </if>
        <if test="inAccountStatus != null and inAccountStatus != '' and inAccountStatus != 'null' and inAccountStatus != '99' ">
            and t.inaccount_status = #{inAccountStatus}
        </if>
        <if test="qszt != null and qszt != '' and qszt != 'null' ">
            and t.qs_status = #{qszt}
        </if>
        <if
                test="qsksrq != null and qsksrq != '' and qsksrq != 'null' and qsjsrq != null and qsjsrq != '' and qsjsrq != 'null'">
            and date_format(t.qs_date,'%Y-%m-%d') between #{qsksrq} and #{qsjsrq}
        </if>
        <if
                test="rzksrq != null and rzksrq != '' and rzksrq != 'null' and rzjsrq != null and rzjsrq != '' and rzjsrq != 'null'">
            and date_format(t.rzh_date,'%Y-%m-%d') between #{rzksrq} and #{rzjsrq}
        </if>
        <if test="rzzt != null and rzzt != '' and rzzt != 'null' ">
            and t.rzh_yesorno = #{rzzt}
        </if>
        <if test="rzclzt != null and rzclzt != '' and rzclzt != 'null' ">
            and t.auth_status = #{rzclzt}
        </if>
        <if test="rzlx!=null and rzlx!=''">
            and t.bdk_status = #{rzlx}
        </if>
        <if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '14' ">
            and (t.invoice_type = '14' or (t.invoice_type = '32' and t.lq_tdyslxDm='08') )
        </if>
        <if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '14' ">
            and t.invoice_type = #{invoiceType}
        </if>
        <if test="invoiceSource!=null and invoiceSource!='' and invoiceSource!='null' and invoiceSource!='99'">
            and t.invoice_source = #{invoiceSource}
        </if>
        <if
                test="qsfs != null and qsfs != '' and qsfs != 'null' ">
            and t.qs_type = #{qsfs}
        </if>
        <if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
            and t.xf_name like concat(#{xfmc},'%')
        </if>
        <if test="qsr != null and qsr != '' and qsr != 'null' ">
            and t.qs_name = #{qsr}
        </if>
        <if test="rzhr != null and rzhr != '' and rzhr != 'null' ">
            and t.confirm_user in
            <foreach collection="rzhr" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="paymentDateStart != null and paymentDateStart != '' and paymentDateStart != 'null' ">
            <![CDATA[ AND date_format(t.payment_date,'%Y-%m-%d') >= #{paymentDateStart} ]]>
        </if>
        <if test="paymentDateEnd != null and paymentDateEnd != '' and paymentDateEnd != 'null' ">
            <![CDATA[ AND date_format(t.payment_date,'%Y-%m-%d')  <= #{paymentDateEnd} ]]>
        </if>
        <if test="paymentStatus != null and paymentStatus != '' and paymentStatus != '99'">
            and t.payment_status = #{paymentStatus}
        </if>
        <if
                test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
            and t.invoice_no = #{invoiceNo}
        </if>
        <if
                test="skssq != null and skssq != '' and skssq != 'null' ">
            and t.rzh_belong_date = #{skssq}
        </if>
        <if
                test="businessCode != '99' and businessCode != null and businessCode != '' and businessCode != 'null' ">
            and t.dept_id = #{businessCode}
        </if>
        <if test="businessCode==''">
            and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
        </if>
        <if test='businessCode == "99" and business!=null and business.size()>0'>
            and (t.dept_id in
            <foreach collection="business" index="index" item="item" open="(" separator="," close="">
                #{item.businessCode}
            </foreach>
            ) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
        </if>
<!--        <if test='inAccountStatus!=null and inAccountStatus!="" and inAccountStatus !="99"'>-->
<!--            and t.in_account_status = #{inAccountStatus}-->
<!--        </if>-->
        <if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
            and t.ele_invoice_no = #{eleInvoiceNo}
        </if>
    </select>
    <select id="selectRzfpHj" parameterType="java.util.Map"
            resultMap="RzcxhjResultMap" databaseId="oracle">
        select count(1) hjsl,sum(t.invoice_amount)hjje,sum(t.tax_amount)hjse
        from t_dx_record_invoice t
        WHERE to_char(t.invoice_date,'yyyy-mm-dd') between #{kpksrq} and #{kpjsrq}
        and t.auth_status != '0'
        and (t.invoice_type in('01','03','08','14','31','283','161','183','185') or (t.invoice_type ='32' and t.lq_tdyslxDm='08'))
        and t.bdk_status in ('1','2')
        and t.export_mark = '0'
        and t.company =#{company}
        and t.gf_tax_no in
        <foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        <if
                test="invoiceStatus != null and invoiceStatus != '' and invoiceStatus != 'null' ">
            and t.invoice_status = #{invoiceStatus}
        </if>
        <if test="qszt != null and qszt != '' and qszt != 'null' ">
            and t.qs_status = #{qszt}
        </if>
        <if test="rzzt != null and rzzt != '' and rzzt != 'null' ">
            and t.rzh_yesorno = #{rzzt}
        </if>
        <if
                test="qsksrq != null and qsksrq != '' and qsksrq != 'null' and qsjsrq != null and qsjsrq != '' and qsjsrq != 'null'">
            and to_char(t.qs_date,'yyyy-mm-dd') between #{qsksrq} and #{qsjsrq}
        </if>
        <if
                test="rzksrq != null and rzksrq != '' and rzksrq != 'null' and rzjsrq != null and rzjsrq != '' and rzjsrq != 'null'">
            and to_char(t.rzh_date,'yyyy-mm-dd') between #{rzksrq} and #{rzjsrq}
        </if>
        <if test="rzclzt != null and rzclzt != '' and rzclzt != 'null' ">
            and t.auth_status = #{rzclzt}
        </if>
        <if test="rzlx!=null and rzlx!=''">
            and t.bdk_status = #{rzlx}
        </if>
        <if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '14' ">
            and (t.invoice_type = '14' or (t.invoice_type = '32' and t.lq_tdyslxDm='08') )
        </if>
        <if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '14' ">
            and t.invoice_type = #{invoiceType}
        </if>
        <if test="invoiceSource!=null and invoiceSource!='' and invoiceSource!='null' and invoiceSource!='99'">
            and t.invoice_source = #{invoiceSource}
        </if>
        <if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
            and t.ele_invoice_no = #{eleInvoiceNo}
        </if>
        <if
                test="qsfs != null and qsfs != '' and qsfs != 'null' ">
            and t.qs_type = #{qsfs}
        </if>
        <if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
            and t.xf_name like concat(#{xfmc},'%')
        </if>
        <if test="rzhr != null and rzhr != '' and rzhr != 'null' ">
            and t.confirm_user in
            <foreach collection="rzhr" index="index" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="qsr != null and qsr != '' and qsr != 'null' ">
            and t.qs_name = #{qsr}
        </if>
        <if test="paymentDateStart != null and paymentDateStart != '' and paymentDateStart != 'null' ">
            <![CDATA[ AND to_char(t.payment_date,'%Y-%m-%d') >= #{paymentDateStart} ]]>
        </if>
        <if test="paymentDateEnd != null and paymentDateEnd != '' and paymentDateEnd != 'null' ">
            <![CDATA[ AND to_char(t.payment_date,'%Y-%m-%d')  <= #{paymentDateEnd} ]]>
        </if>
        <if test="paymentStatus != null and paymentStatus != '' and paymentStatus != '99'">
            and t.payment_status = #{paymentStatus}
        </if>
        <if
                test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
            and t.invoice_no = #{invoiceNo}
        </if>
        <if
                test="skssq != null and skssq != '' and skssq != 'null' ">
            and t.rzh_belong_date = #{skssq}
        </if>
        <if
                test="businessCode != '99' and businessCode != null and businessCode != '' and businessCode != 'null' ">
            and t.dept_id = #{businessCode}
        </if>
        <if test="businessCode==''">
            and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
        </if>
        <if test='businessCode == "99" and business!=null and business.size()>0'>
            and (t.dept_id in
            <foreach collection="business" index="index" item="item" open="(" separator="," close="">
                #{item.businessCode}
            </foreach>
            ) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
        </if>
        <if test='inAccountStatus!=null and inAccountStatus!="" and inAccountStatus !="99"'>
            and t.in_account_status = #{inAccountStatus}
        </if>
    </select>

</mapper>
