<?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.extend.dao.ExtFprzybDao">

    <resultMap id="FprzybResultMap" type="com.dxhy.extend.model.ExtFprzybRespVO">
        <result column="skssq" property="skssq"/>
        <result column="fpsl" property="fpsl"/>
        <result column="hjje" property="hjje"/>
        <result column="hjse" property="hjse"/>
        <result column="dkse" property="dkse"/>
        <result column="rzDate" property="rzDate"/>

    </resultMap>
    <select id="selectByGfshAndRznf" parameterType="java.util.Map"
            resultMap="FprzybResultMap" databaseId="mysql">
        select right(t.rzh_belong_date, 2) rzDate,
               t.rzh_belong_date           skssq,
               COUNT(t.id)         as      fpsl,
               sum(invoice_amount) as      hjje,
               sum(tax_amount)     as      hjse,
               sum(dk_tax_amount)  as      dkse
        from t_dx_record_invoice t
        where t.auth_status = '4'
          <!--and rzh_yesorno = '1'-->
          and t.invoice_type in ('01', '03', '08', '14','31')
          and t.company = #{company}
          and t.gf_tax_no = #{gfsh}
          <if test="dklx!=null and dklx!=''">
              and t.rzh_yesorno = #{dklx}
          </if>
          and LEFT(rzh_belong_date, 4) = #{rznf}
        GROUP BY t.rzh_belong_date
        ORDER by t.rzh_belong_date
    </select>


    <select id="selectRzfphzByRznf" parameterType="java.util.Map"
            resultMap="FprzybResultMap" databaseId="mysql">
        select
        right (t.rzh_belong_date,2) rzDate,
        t.rzh_belong_date skssq,
        COUNT(t.id ) as fpsl,
        sum(invoice_amount) as hjje,
        sum(tax_amount) as hjse ,
        sum(dk_tax_amount) as dkse
        from t_dx_record_invoice t
        where
        t.auth_status = '4' <!--and rzh_yesorno='1'-->
        and t.invoice_type in ('01','03','08','14','31')
        and t.company = #{company}
        and t.gf_tax_no in
        <foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        <if test="dklx!=null and dklx!=''">
            and t.rzh_yesorno = #{dklx}
        </if>
        and LEFT(rzh_belong_date,4) = #{rznf}
        GROUP BY t.rzh_belong_date ORDER by t.rzh_belong_date
    </select>


    <select id="selectByGfshAndRznf" parameterType="java.util.Map"
            resultMap="FprzybResultMap" databaseId="oracle">
        select SUBSTR(t.rzh_belong_date, 5) rzDate,
               t.rzh_belong_date            skssq,
               COUNT(t.id)         as       fpsl,
               sum(invoice_amount) as       hjje,
               sum(tax_amount)     as       hjse,
               sum(dk_tax_amount)  as       dkse
        from t_dx_record_invoice t
        where t.auth_status = '4'
          <!--and rzh_yesorno = '1'-->
          and t.invoice_type in ('01', '03', '08', '14','31')
          and t.company = #{company}
          and t.gf_tax_no = #{gfsh}
          <if test="dklx!=null and dklx!=''">
              and t.rzh_yesorno = #{dklx}
          </if>
          and SUBSTR(t.rzh_belong_date, 0, LENGTH(t.rzh_belong_date) - 2) = #{rznf}
        GROUP BY t.rzh_belong_date, SUBSTR(t.rzh_belong_date, 5)
        ORDER by t.rzh_belong_date
    </select>


    <select id="selectRzfphzByRznf" parameterType="java.util.Map"
            resultMap="FprzybResultMap" databaseId="oracle">
        select
        SUBSTR (t.rzh_belong_date,5) rzDate,
        t.rzh_belong_date skssq,
        COUNT(t.id ) as fpsl,
        sum(invoice_amount) as hjje,
        sum(tax_amount) as hjse ,
        sum(dk_tax_amount) as dkse
        from t_dx_record_invoice t
        where
        t.auth_status = '4' <!--and rzh_yesorno='1'-->
        and t.invoice_type in ('01','03','08','14','31')
        and t.company = #{company}
        and t.gf_tax_no in
        <foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        <if test="dklx!=null and dklx!=''">
            and t.rzh_yesorno = #{dklx}
        </if>
        and SUBSTR (t.rzh_belong_date,0,LENGTH(t.rzh_belong_date) - 2) = #{rznf}
        GROUP BY t.rzh_belong_date,SUBSTR (t.rzh_belong_date,5) ORDER by t.rzh_belong_date
    </select>

    <select id="selectTaxList" resultType="com.dxhy.extend.entity.ExtTdxTaxCurrent">
        select * from t_dx_tax_current where taxno in
        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>

</mapper>
