<?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.core.dao.BbyqfpDao">

    <resultMap id="BaseResultMap"
               type="com.dxhy.core.model.BbyqfpRespVO">
        <result column="invoice_code" property="invoiceCode"/>
        <result column="invoice_no" property="invoiceNo"/>
        <result column="kprq" property="invoiceDate"/>
        <result column="invoiceType" property="invoiceType"/>
        <result column="gfsh" property="gfsh"/>
        <result column="gfmc" property="gfmc"/>
        <result column="xfsh" property="xfsh"/>
        <result column="xfmc" property="xfmc"/>
        <result column="je" property="invoiceAmount"/>
        <result column="se" property="taxAmount"/>
        <result column="dkAmount" property="dkTaxAmount"/>
    </resultMap>

    <resultMap id="YqfpcxhjResultMap"
               type="com.dxhy.core.model.BbyqfpRespVO">
        <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,DATE_FORMAT(t.invoice_date,'%Y-%m-%d')
        kprq,t.gf_tax_no gfsh,t.gf_name gfmc,
        t.xf_tax_no xfsh,t.xf_name
        xfmc,t.tax_amount se,t.invoice_amount je ,t.dk_tax_amount dkAmount , t.invoice_type invoiceType
        from t_dx_record_invoice t,t_dx_tax_current c
        WHERE t.invoice_amount > 0
        and t.gf_tax_no = c.taxno
        and DATE_FORMAT(t.invoice_date,'%Y%m%d') &lt; c.select_start_date
        and t.invoice_status = '0'
        and t.rzh_yesorno = '0'
        and t.invoice_type in ('01','03','14')
        and t.gf_tax_no in
        <foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        <if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
            and t.xf_name like CONCAT(#{xfmc},'%')
        </if>
        <if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
            and t.invoice_no = #{invoiceNo}
        </if>

        order by t.invoice_date desc
    </select>
    <select id="selectByPramsMap" parameterType="java.util.Map"
            resultMap="BaseResultMap" databaseId="oracle">
        select
        t.invoice_code,t.invoice_no,to_char(t.invoice_date,'yyyy-mm-dd')
        kprq,t.gf_tax_no gfsh,t.gf_name gfmc,
        t.xf_tax_no xfsh,t.xf_name
        xfmc,t.tax_amount se,t.invoice_amount je,t.dk_tax_amount dkAmount , t.invoice_type invoiceType
        from t_dx_record_invoice t,t_dx_tax_current c
        WHERE t.invoice_amount > 0
        and t.gf_tax_no = c.taxno
        and to_char(t.invoice_date,'yyyyMMdd') &lt; c.select_start_date
        and t.invoice_status = '0'
        and t.rzh_yesorno = '0'
        and t.invoice_type in ('01','03','14')
        and t.gf_tax_no in
        <foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        <if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
            and t.xf_name like CONCAT(#{xfmc},'%')
        </if>
        <if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
            and t.invoice_no = #{invoiceNo}
        </if>

        order by t.invoice_date desc
    </select>

    <select id="selectBbyqfpHj" parameterType="java.util.Map"
            resultMap="YqfpcxhjResultMap" databaseId="mysql">
        select count(1) hjsl,sum(t.invoice_amount)hjje,sum(t.tax_amount)hjse
        from t_dx_record_invoice t,t_dx_tax_current c
        where t.invoice_amount > 0
        and t.gf_tax_no = c.taxno
        and DATE_FORMAT(t.invoice_date,'%Y%m%d') &lt; c.select_start_date
        and t.invoice_status = '0'
        and t.rzh_yesorno = '0'
        and t.invoice_type in ('01','03','14')
        and t.gf_tax_no in
        <foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        <if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
            and t.xf_name like CONCAT(#{xfmc},'%')
        </if>
        <if
                test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
            and t.invoice_no = #{invoiceNo}
        </if>

    </select>
    <select id="selectBbyqfpHj" parameterType="java.util.Map"
            resultMap="YqfpcxhjResultMap" databaseId="oracle">
        select count(1) hjsl,sum(t.invoice_amount)hjje,sum(t.tax_amount)hjse
        from t_dx_record_invoice t,t_dx_tax_current c
        where t.invoice_amount > 0
        and t.gf_tax_no = c.taxno
        and to_char(t.invoice_date,'yyyyMMdd') &lt; c.select_start_date
        and t.invoice_status = '0'
        and t.rzh_yesorno = '0'
        and t.invoice_type in ('01','03','14')
        and t.gf_tax_no in
        <foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        <if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
            and t.xf_name like CONCAT(#{xfmc},'%')
        </if>
        <if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
            and t.invoice_no = #{invoiceNo}
        </if>

    </select>


</mapper>
