<?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="pwc.taxtech.atms.vat.dao.InputVATInvoiceMapper">
    <resultMap id="BaseResultMap" type="pwc.taxtech.atms.vat.entity.InputVATInvoice">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <id column="ID" jdbcType="VARCHAR" property="ID"/>
        <result column="PeriodID" jdbcType="INTEGER" property="periodID"/>
        <result column="InvoiceCode" jdbcType="VARCHAR" property="invoiceCode"/>
        <result column="InvoiceNumber" jdbcType="VARCHAR" property="invoiceNumber"/>
        <result column="InvoiceDate" jdbcType="TIMESTAMP" property="invoiceDate"/>
        <result column="SellerTaxNumber" jdbcType="VARCHAR" property="sellerTaxNumber"/>
        <result column="Amount" jdbcType="DECIMAL" property="amount"/>
        <result column="TaxAmount" jdbcType="DECIMAL" property="taxAmount"/>
        <result column="InvoiceType" jdbcType="INTEGER" property="invoiceType"/>
        <result column="CertificationResult" jdbcType="VARCHAR" property="certificationResult"/>
        <result column="CertificationDate" jdbcType="TIMESTAMP" property="certificationDate"/>
        <result column="CreatorID" jdbcType="VARCHAR" property="creatorID"/>
        <result column="CreateTime" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="Status" jdbcType="INTEGER" property="status"/>
        <result column="PartAccntedPeriod" jdbcType="INTEGER" property="partAccntedPeriod"/>
        <result column="AccntedPeriod" jdbcType="INTEGER" property="accntedPeriod"/>
    </resultMap>
    <sql id="Example_Where_Clause">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <where>
            <foreach collection="oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Update_By_Example_Where_Clause">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <where>
            <foreach collection="example.oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        ID, PeriodID, InvoiceCode, InvoiceNumber, InvoiceDate, SellerTaxNumber, Amount, TaxAmount,
        InvoiceType, CertificationResult, CertificationDate, CreatorID, CreateTime, Status,
        PartAccntedPeriod, AccntedPeriod
    </sql>
    <select id="selectByExample" parameterType="pwc.taxtech.atms.vat.entity.InputVATInvoiceExample"
            resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from InputVATInvoice
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select
        <include refid="Base_Column_List"/>
        from InputVATInvoice
        where ID = #{ID,jdbcType=VARCHAR}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        delete from InputVATInvoice
        where ID = #{ID,jdbcType=VARCHAR}
    </delete>
    <delete id="deleteByExample" parameterType="pwc.taxtech.atms.vat.entity.InputVATInvoiceExample">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        delete from InputVATInvoice
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <insert id="insert" parameterType="pwc.taxtech.atms.vat.entity.InputVATInvoice">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into InputVATInvoice (ID, PeriodID, InvoiceCode,
        InvoiceNumber, InvoiceDate, SellerTaxNumber,
        Amount, TaxAmount, InvoiceType,
        CertificationResult, CertificationDate,
        CreatorID, CreateTime, Status,
        PartAccntedPeriod, AccntedPeriod)
        values (#{ID,jdbcType=VARCHAR}, #{periodID,jdbcType=INTEGER}, #{invoiceCode,jdbcType=VARCHAR},
        #{invoiceNumber,jdbcType=VARCHAR}, #{invoiceDate,jdbcType=TIMESTAMP}, #{sellerTaxNumber,jdbcType=VARCHAR},
        #{amount,jdbcType=DECIMAL}, #{taxAmount,jdbcType=DECIMAL}, #{invoiceType,jdbcType=INTEGER},
        #{certificationResult,jdbcType=VARCHAR}, #{certificationDate,jdbcType=TIMESTAMP},
        #{creatorID,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER},
        #{partAccntedPeriod,jdbcType=INTEGER}, #{accntedPeriod,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective" parameterType="pwc.taxtech.atms.vat.entity.InputVATInvoice">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into InputVATInvoice
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="ID != null">
                ID,
            </if>
            <if test="periodID != null">
                PeriodID,
            </if>
            <if test="invoiceCode != null">
                InvoiceCode,
            </if>
            <if test="invoiceNumber != null">
                InvoiceNumber,
            </if>
            <if test="invoiceDate != null">
                InvoiceDate,
            </if>
            <if test="sellerTaxNumber != null">
                SellerTaxNumber,
            </if>
            <if test="amount != null">
                Amount,
            </if>
            <if test="taxAmount != null">
                TaxAmount,
            </if>
            <if test="invoiceType != null">
                InvoiceType,
            </if>
            <if test="certificationResult != null">
                CertificationResult,
            </if>
            <if test="certificationDate != null">
                CertificationDate,
            </if>
            <if test="creatorID != null">
                CreatorID,
            </if>
            <if test="createTime != null">
                CreateTime,
            </if>
            <if test="status != null">
                Status,
            </if>
            <if test="partAccntedPeriod != null">
                PartAccntedPeriod,
            </if>
            <if test="accntedPeriod != null">
                AccntedPeriod,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="ID != null">
                #{ID,jdbcType=VARCHAR},
            </if>
            <if test="periodID != null">
                #{periodID,jdbcType=INTEGER},
            </if>
            <if test="invoiceCode != null">
                #{invoiceCode,jdbcType=VARCHAR},
            </if>
            <if test="invoiceNumber != null">
                #{invoiceNumber,jdbcType=VARCHAR},
            </if>
            <if test="invoiceDate != null">
                #{invoiceDate,jdbcType=TIMESTAMP},
            </if>
            <if test="sellerTaxNumber != null">
                #{sellerTaxNumber,jdbcType=VARCHAR},
            </if>
            <if test="amount != null">
                #{amount,jdbcType=DECIMAL},
            </if>
            <if test="taxAmount != null">
                #{taxAmount,jdbcType=DECIMAL},
            </if>
            <if test="invoiceType != null">
                #{invoiceType,jdbcType=INTEGER},
            </if>
            <if test="certificationResult != null">
                #{certificationResult,jdbcType=VARCHAR},
            </if>
            <if test="certificationDate != null">
                #{certificationDate,jdbcType=TIMESTAMP},
            </if>
            <if test="creatorID != null">
                #{creatorID,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="status != null">
                #{status,jdbcType=INTEGER},
            </if>
            <if test="partAccntedPeriod != null">
                #{partAccntedPeriod,jdbcType=INTEGER},
            </if>
            <if test="accntedPeriod != null">
                #{accntedPeriod,jdbcType=INTEGER},
            </if>
        </trim>
    </insert>
    <select id="countByExample" parameterType="pwc.taxtech.atms.vat.entity.InputVATInvoiceExample"
            resultType="java.lang.Long">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select count(*) from InputVATInvoice
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </select>
    <update id="updateByExampleSelective" parameterType="map">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update InputVATInvoice
        <set>
            <if test="record.ID != null">
                ID = #{record.ID,jdbcType=VARCHAR},
            </if>
            <if test="record.periodID != null">
                PeriodID = #{record.periodID,jdbcType=INTEGER},
            </if>
            <if test="record.invoiceCode != null">
                InvoiceCode = #{record.invoiceCode,jdbcType=VARCHAR},
            </if>
            <if test="record.invoiceNumber != null">
                InvoiceNumber = #{record.invoiceNumber,jdbcType=VARCHAR},
            </if>
            <if test="record.invoiceDate != null">
                InvoiceDate = #{record.invoiceDate,jdbcType=TIMESTAMP},
            </if>
            <if test="record.sellerTaxNumber != null">
                SellerTaxNumber = #{record.sellerTaxNumber,jdbcType=VARCHAR},
            </if>
            <if test="record.amount != null">
                Amount = #{record.amount,jdbcType=DECIMAL},
            </if>
            <if test="record.taxAmount != null">
                TaxAmount = #{record.taxAmount,jdbcType=DECIMAL},
            </if>
            <if test="record.invoiceType != null">
                InvoiceType = #{record.invoiceType,jdbcType=INTEGER},
            </if>
            <if test="record.certificationResult != null">
                CertificationResult = #{record.certificationResult,jdbcType=VARCHAR},
            </if>
            <if test="record.certificationDate != null">
                CertificationDate = #{record.certificationDate,jdbcType=TIMESTAMP},
            </if>
            <if test="record.creatorID != null">
                CreatorID = #{record.creatorID,jdbcType=VARCHAR},
            </if>
            <if test="record.createTime != null">
                CreateTime = #{record.createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="record.status != null">
                Status = #{record.status,jdbcType=INTEGER},
            </if>
            <if test="record.partAccntedPeriod != null">
                PartAccntedPeriod = #{record.partAccntedPeriod,jdbcType=INTEGER},
            </if>
            <if test="record.accntedPeriod != null">
                AccntedPeriod = #{record.accntedPeriod,jdbcType=INTEGER},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByExample" parameterType="map">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update InputVATInvoice
        set ID = #{record.ID,jdbcType=VARCHAR},
        PeriodID = #{record.periodID,jdbcType=INTEGER},
        InvoiceCode = #{record.invoiceCode,jdbcType=VARCHAR},
        InvoiceNumber = #{record.invoiceNumber,jdbcType=VARCHAR},
        InvoiceDate = #{record.invoiceDate,jdbcType=TIMESTAMP},
        SellerTaxNumber = #{record.sellerTaxNumber,jdbcType=VARCHAR},
        Amount = #{record.amount,jdbcType=DECIMAL},
        TaxAmount = #{record.taxAmount,jdbcType=DECIMAL},
        InvoiceType = #{record.invoiceType,jdbcType=INTEGER},
        CertificationResult = #{record.certificationResult,jdbcType=VARCHAR},
        CertificationDate = #{record.certificationDate,jdbcType=TIMESTAMP},
        CreatorID = #{record.creatorID,jdbcType=VARCHAR},
        CreateTime = #{record.createTime,jdbcType=TIMESTAMP},
        Status = #{record.status,jdbcType=INTEGER},
        PartAccntedPeriod = #{record.partAccntedPeriod,jdbcType=INTEGER},
        AccntedPeriod = #{record.accntedPeriod,jdbcType=INTEGER}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="pwc.taxtech.atms.vat.entity.InputVATInvoice">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update InputVATInvoice
        <set>
            <if test="periodID != null">
                PeriodID = #{periodID,jdbcType=INTEGER},
            </if>
            <if test="invoiceCode != null">
                InvoiceCode = #{invoiceCode,jdbcType=VARCHAR},
            </if>
            <if test="invoiceNumber != null">
                InvoiceNumber = #{invoiceNumber,jdbcType=VARCHAR},
            </if>
            <if test="invoiceDate != null">
                InvoiceDate = #{invoiceDate,jdbcType=TIMESTAMP},
            </if>
            <if test="sellerTaxNumber != null">
                SellerTaxNumber = #{sellerTaxNumber,jdbcType=VARCHAR},
            </if>
            <if test="amount != null">
                Amount = #{amount,jdbcType=DECIMAL},
            </if>
            <if test="taxAmount != null">
                TaxAmount = #{taxAmount,jdbcType=DECIMAL},
            </if>
            <if test="invoiceType != null">
                InvoiceType = #{invoiceType,jdbcType=INTEGER},
            </if>
            <if test="certificationResult != null">
                CertificationResult = #{certificationResult,jdbcType=VARCHAR},
            </if>
            <if test="certificationDate != null">
                CertificationDate = #{certificationDate,jdbcType=TIMESTAMP},
            </if>
            <if test="creatorID != null">
                CreatorID = #{creatorID,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                CreateTime = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="status != null">
                Status = #{status,jdbcType=INTEGER},
            </if>
            <if test="partAccntedPeriod != null">
                PartAccntedPeriod = #{partAccntedPeriod,jdbcType=INTEGER},
            </if>
            <if test="accntedPeriod != null">
                AccntedPeriod = #{accntedPeriod,jdbcType=INTEGER},
            </if>
        </set>
        where ID = #{ID,jdbcType=VARCHAR}
    </update>
    <update id="updateByPrimaryKey" parameterType="pwc.taxtech.atms.vat.entity.InputVATInvoice">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update InputVATInvoice
        set PeriodID = #{periodID,jdbcType=INTEGER},
        InvoiceCode = #{invoiceCode,jdbcType=VARCHAR},
        InvoiceNumber = #{invoiceNumber,jdbcType=VARCHAR},
        InvoiceDate = #{invoiceDate,jdbcType=TIMESTAMP},
        SellerTaxNumber = #{sellerTaxNumber,jdbcType=VARCHAR},
        Amount = #{amount,jdbcType=DECIMAL},
        TaxAmount = #{taxAmount,jdbcType=DECIMAL},
        InvoiceType = #{invoiceType,jdbcType=INTEGER},
        CertificationResult = #{certificationResult,jdbcType=VARCHAR},
        CertificationDate = #{certificationDate,jdbcType=TIMESTAMP},
        CreatorID = #{creatorID,jdbcType=VARCHAR},
        CreateTime = #{createTime,jdbcType=TIMESTAMP},
        Status = #{status,jdbcType=INTEGER},
        PartAccntedPeriod = #{partAccntedPeriod,jdbcType=INTEGER},
        AccntedPeriod = #{accntedPeriod,jdbcType=INTEGER}
        where ID = #{ID,jdbcType=VARCHAR}
    </update>
    <select id="selectByExampleWithRowbounds" parameterType="pwc.taxtech.atms.vat.entity.InputVATInvoiceExample"
            resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from InputVATInvoice
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
    </select>
    <select id="getInputVATInvoiceCountByCondition"
            parameterType="pwc.taxtech.atms.dto.vatdto.InputInvoicePreviewQueryParam" resultType="java.lang.Long">
        SELECT COUNT(1) FROM InputVATInvoice WHERE 1=1
        <if test="paras.periodStart">
            AND PeriodID&gt;=#{paras.periodStart,jdbcType=VARCHAR}
        </if>
        <if test="paras.periodEnd">
            AND PeriodID&lt;=#{paras.periodEnd,jdbcType=VARCHAR}
        </if>
        <if test="paras.certificationDateStart != null">
            AND CertificationDate&gt;=#{paras.certificationDateStart,jdbcType=VARCHAR}
        </if>
        <if test="paras.certificationDateEnd != null">
            AND CertificationDate&lt;=#{paras.certificationDateEnd,jdbcType=VARCHAR}
        </if>
        <if test="paras.invoiceCode != null and paras.invoiceCode!=''">
            AND InvoiceCode LIKE concat('%',#{paras.invoiceCode,jdbcType=VARCHAR},'%')
        </if>
        <if test="paras.invoiceNumber!=null and paras.invoiceNumber!=''">
            AND InvoiceNumber LIKE concat('%',#{paras.invoiceNumber,jdbcType=VARCHAR},'%')
        </if>
        <if test="paras.sellerTaxNumber!=null and paras.sellerTaxNumber!=''">
            AND SellerTaxNumber LIKE concat('%',#{paras.sellerTaxNumber,jdbcType=VARCHAR},'%')
        </if>
        <if test="paras.amountStart != null">
            AND Amount&gt;=#{paras.amountStart,jdbcType=DECIMAL}
        </if>
        <if test="paras.amountEnd != null">
            AND Amount&lt;=#{paras.amountEnd,jdbcType=DECIMAL}
        </if>
        <if test="paras.taxAmountStart != null">
            AND TaxAmount&gt;=#{paras.taxAmountStart,jdbcType=DECIMAL}
        </if>
        <if test="paras.taxAmountEnd != null">
            AND TaxAmount&lt;=#{paras.taxAmountEnd,jdbcType=DECIMAL}
        </if>
        <if test="paras.invoiceType!=null and paras.invoiceType!=999">
            AND InvoiceType=#{param.invoiceType,jdbcType=INTEGER}
        </if>
        <if test="paras.certificationStatus==1">
            AND CertificationResult LIKE '%1%'
        </if>
        <if test="paras.certificationStatus==2">
            AND CertificationResult LIKE '%2%'
        </if>
    </select>
    <select id="getInputVATInvoiceCountByConditionWithPaging" resultMap="BaseResultMap">
        SELECT * FROM InputVATInvoice WHERE 1=1
        <if test="paras.periodStart">
            AND PeriodID&gt;=#{paras.periodStart,jdbcType=VARCHAR}
        </if>
        <if test="paras.periodEnd">
            AND PeriodID&lt;=#{paras.periodEnd,jdbcType=VARCHAR}
        </if>
        <if test="paras.certificationDateStart != null">
            AND CertificationDate&gt;=#{paras.certificationDateStart,jdbcType=VARCHAR}
        </if>
        <if test="paras.certificationDateEnd != null">
            AND CertificationDate&lt;=#{paras.certificationDateEnd,jdbcType=VARCHAR}
        </if>
        <if test="paras.invoiceCode != null and paras.invoiceCode!=''">
            AND InvoiceCode LIKE concat('%',#{paras.invoiceCode,jdbcType=VARCHAR},'%')
        </if>
        <if test="paras.invoiceNumber!=null and paras.invoiceNumber!=''">
            AND InvoiceNumber LIKE concat('%',#{paras.invoiceNumber,jdbcType=VARCHAR},'%')
        </if>
        <if test="paras.sellerTaxNumber!=null and paras.sellerTaxNumber!=''">
            AND SellerTaxNumber LIKE concat('%',#{paras.sellerTaxNumber,jdbcType=VARCHAR},'%')
        </if>
        <if test="paras.amountStart != null">
            AND Amount&gt;=#{paras.amountStart,jdbcType=DECIMAL}
        </if>
        <if test="paras.amountEnd != null">
            AND Amount&lt;=#{paras.amountEnd,jdbcType=DECIMAL}
        </if>
        <if test="paras.taxAmountStart != null">
            AND TaxAmount&gt;=#{paras.taxAmountStart,jdbcType=DECIMAL}
        </if>
        <if test="paras.taxAmountEnd != null">
            AND TaxAmount&lt;=#{paras.taxAmountEnd,jdbcType=DECIMAL}
        </if>
        <if test="paras.invoiceType!=null and paras.invoiceType!=999">
            AND InvoiceType=#{param.invoiceType,jdbcType=INTEGER}
        </if>
        <if test="paras.certificationStatus==1">
            AND CertificationResult LIKE '%1%'
        </if>
        <if test="paras.certificationStatus==2">
            AND CertificationResult LIKE '%2%'
        </if>
        ORDER BY InvoiceDate
        <if test="paras.pageInfo!=null and paras.pageInfo.pageSize!=null and limitFrom!=null">
            LIMIT #{limitFrom,jdbcType=INTEGER},#{paras.pageInfo.pageSize,jdbcType=INTEGER}
        </if>
    </select>
</mapper>