<?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.job.dao.TDxRecordInvoiceStatisticsJobDao">
    <!-- 保存税率数据-->
    <insert id="saveStatistics" parameterType="com.dxhy.core.job.entity.TDxRecordInvoiceStatisticsJobEntity"
            databaseId="mysql">
        INSERT IGNORE INTO t_dx_record_invoice_statistics
        (invoice_code,
         invoice_no,
         detail_amount,
         tax_rate,
         tax_amount,
         total_amount,
         create_date)
        VALUES (#{invoiceCode},
                #{invoiceNo},
                #{detailAmount},
                #{taxRate},
                #{taxAmount},
                #{totalAmount},
                NOW());
    </insert>
    <insert id="saveStatistics" parameterType="com.dxhy.core.job.entity.TDxRecordInvoiceStatisticsJobEntity"
            databaseId="oracle">
        INSERT INTO t_dx_record_invoice_statistics
        (invoice_code,
         invoice_no,
         detail_amount,
         tax_rate,
         tax_amount,
         total_amount,
         create_date)
        VALUES (#{invoiceCode},
                #{invoiceNo},
                #{detailAmount},
                #{taxRate},
                #{taxAmount},
                #{totalAmount},
                sysdate);
    </insert>
    <delete id="delStatistics" parameterType="java.lang.String">
        delete
        from t_dx_record_invoice_statistics
        where invoice_no = #{invoiceNo}
        <if test="invoiceCode!=null and invoiceCode!=''">
            and  invoice_code = #{invoiceCode}
        </if>

    </delete>

    <select id="getStatisticsCount" parameterType="java.lang.String" resultType="java.lang.Integer">
        select count(1)
        from t_dx_record_invoice_statistics
        where invoice_no = #{invoiceNo}
        <if test="invoiceCode!=null and invoiceCode!=''">
            and  invoice_code = #{invoiceCode}
        </if>
    </select>

</mapper>
