<?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.bailuntec.mapper.DcBaseFinanceEbayMapper">
    <resultMap id="BaseResultMap" type="com.bailuntec.domain.entity.DcBaseFinanceEbay">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="bj_create" jdbcType="TIMESTAMP" property="bjCreate"/>
        <result column="bj_modified" jdbcType="TIMESTAMP" property="bjModified"/>
        <result column="account_entry_type" jdbcType="VARCHAR" property="accountEntryType"/>
        <result column="description" jdbcType="VARCHAR" property="description"/>
        <result column="gmt_date" jdbcType="TIMESTAMP" property="gmtDate"/>
        <result column="bj_date" jdbcType="TIMESTAMP" property="bjDate"/>
        <result column="gross_amount" jdbcType="DECIMAL" property="grossAmount"/>
        <result column="item_id" jdbcType="VARCHAR" property="itemId"/>
        <result column="memo" jdbcType="VARCHAR" property="memo"/>
        <result column="net_amount" jdbcType="DECIMAL" property="netAmount"/>
        <result column="ref_number" jdbcType="VARCHAR" property="refNumber"/>
        <result column="vat_percent" jdbcType="DECIMAL" property="vatPercent"/>
        <result column="title" jdbcType="VARCHAR" property="title"/>
        <result column="order_line_id" jdbcType="VARCHAR" property="orderLineId"/>
        <result column="transaction_id" jdbcType="VARCHAR" property="transactionId"/>
        <result column="company_id" jdbcType="INTEGER" property="companyId"/>
        <result column="received_top_rated_discount" jdbcType="BIT" property="receivedTopRatedDiscount"/>
        <result column="account_id" jdbcType="INTEGER" property="accountId"/>
        <result column="currency" jdbcType="VARCHAR" property="currency"/>
        <result column="exchange_rate" jdbcType="DECIMAL" property="exchangeRate"/>
        <result column="exchange_rate_usd" jdbcType="DECIMAL" property="exchangeRateUsd"/>
        <result column="report_date" jdbcType="DATE" property="reportDate"/>
    </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, bj_create, bj_modified, account_entry_type, description, gmt_date, bj_date, gross_amount,
        item_id, memo, net_amount, ref_number, vat_percent, title, order_line_id, transaction_id,
        company_id, received_top_rated_discount, account_id, currency, exchange_rate, exchange_rate_usd,
        report_date
    </sql>
    <select id="selectByExample" parameterType="com.bailuntec.domain.example.DcBaseFinanceEbayExample"
            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 dc_base_finance_ebay
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        <if test="rows != null">
            <if test="offset != null">
                limit ${offset}, ${rows}
            </if>
            <if test="offset == null">
                limit ${rows}
            </if>
        </if>
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select
        <include refid="Base_Column_List"/>
        from dc_base_finance_ebay
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        delete from dc_base_finance_ebay
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <delete id="deleteByExample" parameterType="com.bailuntec.domain.example.DcBaseFinanceEbayExample">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        delete from dc_base_finance_ebay
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <delete id="delDup">
        DELETE
        from dc_base_finance_fee
        where id in (SELECT id
                     from dc_base_finance_ebay
                     group by ref_number, item_id, account_entry_type, gmt_date
                     HAVING count(id) > 1)
    </delete>

    <insert id="insert" parameterType="com.bailuntec.domain.entity.DcBaseFinanceEbay">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into dc_base_finance_ebay (id, bj_create, bj_modified,
        account_entry_type, description, gmt_date,
        bj_date, gross_amount, item_id,
        memo, net_amount, ref_number,
        vat_percent, title, order_line_id,
        transaction_id, company_id, received_top_rated_discount,
        account_id, currency, exchange_rate,
        exchange_rate_usd, report_date)
        values (#{id,jdbcType=INTEGER}, #{bjCreate,jdbcType=TIMESTAMP}, #{bjModified,jdbcType=TIMESTAMP},
        #{accountEntryType,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{gmtDate,jdbcType=TIMESTAMP},
        #{bjDate,jdbcType=TIMESTAMP}, #{grossAmount,jdbcType=DECIMAL}, #{itemId,jdbcType=VARCHAR},
        #{memo,jdbcType=VARCHAR}, #{netAmount,jdbcType=DECIMAL}, #{refNumber,jdbcType=VARCHAR},
        #{vatPercent,jdbcType=DECIMAL}, #{title,jdbcType=VARCHAR}, #{orderLineId,jdbcType=VARCHAR},
        #{transactionId,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER}, #{receivedTopRatedDiscount,jdbcType=BIT},
        #{accountId,jdbcType=INTEGER}, #{currency,jdbcType=VARCHAR}, #{exchangeRate,jdbcType=DECIMAL},
        #{exchangeRateUsd,jdbcType=DECIMAL}, #{reportDate,jdbcType=DATE})
    </insert>
    <insert id="insertSelective" parameterType="com.bailuntec.domain.entity.DcBaseFinanceEbay">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into dc_base_finance_ebay
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="bjCreate != null">
                bj_create,
            </if>
            <if test="bjModified != null">
                bj_modified,
            </if>
            <if test="accountEntryType != null">
                account_entry_type,
            </if>
            <if test="description != null">
                description,
            </if>
            <if test="gmtDate != null">
                gmt_date,
            </if>
            <if test="bjDate != null">
                bj_date,
            </if>
            <if test="grossAmount != null">
                gross_amount,
            </if>
            <if test="itemId != null">
                item_id,
            </if>
            <if test="memo != null">
                memo,
            </if>
            <if test="netAmount != null">
                net_amount,
            </if>
            <if test="refNumber != null">
                ref_number,
            </if>
            <if test="vatPercent != null">
                vat_percent,
            </if>
            <if test="title != null">
                title,
            </if>
            <if test="orderLineId != null">
                order_line_id,
            </if>
            <if test="transactionId != null">
                transaction_id,
            </if>
            <if test="companyId != null">
                company_id,
            </if>
            <if test="receivedTopRatedDiscount != null">
                received_top_rated_discount,
            </if>
            <if test="accountId != null">
                account_id,
            </if>
            <if test="currency != null">
                currency,
            </if>
            <if test="exchangeRate != null">
                exchange_rate,
            </if>
            <if test="exchangeRateUsd != null">
                exchange_rate_usd,
            </if>
            <if test="reportDate != null">
                report_date,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="bjCreate != null">
                #{bjCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjModified != null">
                #{bjModified,jdbcType=TIMESTAMP},
            </if>
            <if test="accountEntryType != null">
                #{accountEntryType,jdbcType=VARCHAR},
            </if>
            <if test="description != null">
                #{description,jdbcType=VARCHAR},
            </if>
            <if test="gmtDate != null">
                #{gmtDate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjDate != null">
                #{bjDate,jdbcType=TIMESTAMP},
            </if>
            <if test="grossAmount != null">
                #{grossAmount,jdbcType=DECIMAL},
            </if>
            <if test="itemId != null">
                #{itemId,jdbcType=VARCHAR},
            </if>
            <if test="memo != null">
                #{memo,jdbcType=VARCHAR},
            </if>
            <if test="netAmount != null">
                #{netAmount,jdbcType=DECIMAL},
            </if>
            <if test="refNumber != null">
                #{refNumber,jdbcType=VARCHAR},
            </if>
            <if test="vatPercent != null">
                #{vatPercent,jdbcType=DECIMAL},
            </if>
            <if test="title != null">
                #{title,jdbcType=VARCHAR},
            </if>
            <if test="orderLineId != null">
                #{orderLineId,jdbcType=VARCHAR},
            </if>
            <if test="transactionId != null">
                #{transactionId,jdbcType=VARCHAR},
            </if>
            <if test="companyId != null">
                #{companyId,jdbcType=INTEGER},
            </if>
            <if test="receivedTopRatedDiscount != null">
                #{receivedTopRatedDiscount,jdbcType=BIT},
            </if>
            <if test="accountId != null">
                #{accountId,jdbcType=INTEGER},
            </if>
            <if test="currency != null">
                #{currency,jdbcType=VARCHAR},
            </if>
            <if test="exchangeRate != null">
                #{exchangeRate,jdbcType=DECIMAL},
            </if>
            <if test="exchangeRateUsd != null">
                #{exchangeRateUsd,jdbcType=DECIMAL},
            </if>
            <if test="reportDate != null">
                #{reportDate,jdbcType=DATE},
            </if>
        </trim>
    </insert>

    <insert id="insertTestSelective" parameterType="com.bailuntec.domain.entity.DcBaseFinanceEbay">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into dc_base_finance_ebay3_copy
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="bjCreate != null">
                bj_create,
            </if>
            <if test="bjModified != null">
                bj_modified,
            </if>
            <if test="accountEntryType != null">
                account_entry_type,
            </if>
            <if test="description != null">
                description,
            </if>
            <if test="gmtDate != null">
                gmt_date,
            </if>
            <if test="bjDate != null">
                bj_date,
            </if>
            <if test="grossAmount != null">
                gross_amount,
            </if>
            <if test="itemId != null">
                item_id,
            </if>
            <if test="memo != null">
                memo,
            </if>
            <if test="netAmount != null">
                net_amount,
            </if>
            <if test="refNumber != null">
                ref_number,
            </if>
            <if test="vatPercent != null">
                vat_percent,
            </if>
            <if test="title != null">
                title,
            </if>
            <if test="orderLineId != null">
                order_line_id,
            </if>
            <if test="transactionId != null">
                transaction_id,
            </if>
            <if test="companyId != null">
                company_id,
            </if>
            <if test="receivedTopRatedDiscount != null">
                received_top_rated_discount,
            </if>
            <if test="accountId != null">
                account_id,
            </if>
            <if test="currency != null">
                currency,
            </if>
            <if test="exchangeRate != null">
                exchange_rate,
            </if>
            <if test="exchangeRateUsd != null">
                exchange_rate_usd,
            </if>
            <if test="reportDate != null">
                report_date,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="bjCreate != null">
                #{bjCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjModified != null">
                #{bjModified,jdbcType=TIMESTAMP},
            </if>
            <if test="accountEntryType != null">
                #{accountEntryType,jdbcType=VARCHAR},
            </if>
            <if test="description != null">
                #{description,jdbcType=VARCHAR},
            </if>
            <if test="gmtDate != null">
                #{gmtDate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjDate != null">
                #{bjDate,jdbcType=TIMESTAMP},
            </if>
            <if test="grossAmount != null">
                #{grossAmount,jdbcType=DECIMAL},
            </if>
            <if test="itemId != null">
                #{itemId,jdbcType=VARCHAR},
            </if>
            <if test="memo != null">
                #{memo,jdbcType=VARCHAR},
            </if>
            <if test="netAmount != null">
                #{netAmount,jdbcType=DECIMAL},
            </if>
            <if test="refNumber != null">
                #{refNumber,jdbcType=VARCHAR},
            </if>
            <if test="vatPercent != null">
                #{vatPercent,jdbcType=DECIMAL},
            </if>
            <if test="title != null">
                #{title,jdbcType=VARCHAR},
            </if>
            <if test="orderLineId != null">
                #{orderLineId,jdbcType=VARCHAR},
            </if>
            <if test="transactionId != null">
                #{transactionId,jdbcType=VARCHAR},
            </if>
            <if test="companyId != null">
                #{companyId,jdbcType=INTEGER},
            </if>
            <if test="receivedTopRatedDiscount != null">
                #{receivedTopRatedDiscount,jdbcType=BIT},
            </if>
            <if test="accountId != null">
                #{accountId,jdbcType=INTEGER},
            </if>
            <if test="currency != null">
                #{currency,jdbcType=VARCHAR},
            </if>
            <if test="exchangeRate != null">
                #{exchangeRate,jdbcType=DECIMAL},
            </if>
            <if test="exchangeRateUsd != null">
                #{exchangeRateUsd,jdbcType=DECIMAL},
            </if>
            <if test="reportDate != null">
                #{reportDate,jdbcType=DATE},
            </if>
        </trim>
    </insert>

    <select id="countByExample" parameterType="com.bailuntec.domain.example.DcBaseFinanceEbayExample"
            resultType="java.lang.Long">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select count(*) from dc_base_finance_ebay
        <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 dc_base_finance_ebay3_copy
        <set>
            <if test="record.id != null">
                id = #{record.id,jdbcType=INTEGER},
            </if>
            <if test="record.bjCreate != null">
                bj_create = #{record.bjCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="record.bjModified != null">
                bj_modified = #{record.bjModified,jdbcType=TIMESTAMP},
            </if>
            <if test="record.accountEntryType != null">
                account_entry_type = #{record.accountEntryType,jdbcType=VARCHAR},
            </if>
            <if test="record.description != null">
                description = #{record.description,jdbcType=VARCHAR},
            </if>
            <if test="record.gmtDate != null">
                gmt_date = #{record.gmtDate,jdbcType=TIMESTAMP},
            </if>
            <if test="record.bjDate != null">
                bj_date = #{record.bjDate,jdbcType=TIMESTAMP},
            </if>
            <if test="record.grossAmount != null">
                gross_amount = #{record.grossAmount,jdbcType=DECIMAL},
            </if>
            <if test="record.itemId != null">
                item_id = #{record.itemId,jdbcType=VARCHAR},
            </if>
            <if test="record.memo != null">
                memo = #{record.memo,jdbcType=VARCHAR},
            </if>
            <if test="record.netAmount != null">
                net_amount = #{record.netAmount,jdbcType=DECIMAL},
            </if>
            <if test="record.refNumber != null">
                ref_number = #{record.refNumber,jdbcType=VARCHAR},
            </if>
            <if test="record.vatPercent != null">
                vat_percent = #{record.vatPercent,jdbcType=DECIMAL},
            </if>
            <if test="record.title != null">
                title = #{record.title,jdbcType=VARCHAR},
            </if>
            <if test="record.orderLineId != null">
                order_line_id = #{record.orderLineId,jdbcType=VARCHAR},
            </if>
            <if test="record.transactionId != null">
                transaction_id = #{record.transactionId,jdbcType=VARCHAR},
            </if>
            <if test="record.companyId != null">
                company_id = #{record.companyId,jdbcType=INTEGER},
            </if>
            <if test="record.receivedTopRatedDiscount != null">
                received_top_rated_discount = #{record.receivedTopRatedDiscount,jdbcType=BIT},
            </if>
            <if test="record.accountId != null">
                account_id = #{record.accountId,jdbcType=INTEGER},
            </if>
            <if test="record.currency != null">
                currency = #{record.currency,jdbcType=VARCHAR},
            </if>
            <if test="record.exchangeRate != null">
                exchange_rate = #{record.exchangeRate,jdbcType=DECIMAL},
            </if>
            <if test="record.exchangeRateUsd != null">
                exchange_rate_usd = #{record.exchangeRateUsd,jdbcType=DECIMAL},
            </if>
            <if test="record.reportDate != null">
                report_date = #{record.reportDate,jdbcType=DATE},
            </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 dc_base_finance_ebay
        set id = #{record.id,jdbcType=INTEGER},
        bj_create = #{record.bjCreate,jdbcType=TIMESTAMP},
        bj_modified = #{record.bjModified,jdbcType=TIMESTAMP},
        account_entry_type = #{record.accountEntryType,jdbcType=VARCHAR},
        description = #{record.description,jdbcType=VARCHAR},
        gmt_date = #{record.gmtDate,jdbcType=TIMESTAMP},
        bj_date = #{record.bjDate,jdbcType=TIMESTAMP},
        gross_amount = #{record.grossAmount,jdbcType=DECIMAL},
        item_id = #{record.itemId,jdbcType=VARCHAR},
        memo = #{record.memo,jdbcType=VARCHAR},
        net_amount = #{record.netAmount,jdbcType=DECIMAL},
        ref_number = #{record.refNumber,jdbcType=VARCHAR},
        vat_percent = #{record.vatPercent,jdbcType=DECIMAL},
        title = #{record.title,jdbcType=VARCHAR},
        order_line_id = #{record.orderLineId,jdbcType=VARCHAR},
        transaction_id = #{record.transactionId,jdbcType=VARCHAR},
        company_id = #{record.companyId,jdbcType=INTEGER},
        received_top_rated_discount = #{record.receivedTopRatedDiscount,jdbcType=BIT},
        account_id = #{record.accountId,jdbcType=INTEGER},
        currency = #{record.currency,jdbcType=VARCHAR},
        exchange_rate = #{record.exchangeRate,jdbcType=DECIMAL},
        exchange_rate_usd = #{record.exchangeRateUsd,jdbcType=DECIMAL},
        report_date = #{record.reportDate,jdbcType=DATE}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.bailuntec.domain.entity.DcBaseFinanceEbay">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_base_finance_ebay
        <set>
            <if test="bjCreate != null">
                bj_create = #{bjCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjModified != null">
                bj_modified = #{bjModified,jdbcType=TIMESTAMP},
            </if>
            <if test="accountEntryType != null">
                account_entry_type = #{accountEntryType,jdbcType=VARCHAR},
            </if>
            <if test="description != null">
                description = #{description,jdbcType=VARCHAR},
            </if>
            <if test="gmtDate != null">
                gmt_date = #{gmtDate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjDate != null">
                bj_date = #{bjDate,jdbcType=TIMESTAMP},
            </if>
            <if test="grossAmount != null">
                gross_amount = #{grossAmount,jdbcType=DECIMAL},
            </if>
            <if test="itemId != null">
                item_id = #{itemId,jdbcType=VARCHAR},
            </if>
            <if test="memo != null">
                memo = #{memo,jdbcType=VARCHAR},
            </if>
            <if test="netAmount != null">
                net_amount = #{netAmount,jdbcType=DECIMAL},
            </if>
            <if test="refNumber != null">
                ref_number = #{refNumber,jdbcType=VARCHAR},
            </if>
            <if test="vatPercent != null">
                vat_percent = #{vatPercent,jdbcType=DECIMAL},
            </if>
            <if test="title != null">
                title = #{title,jdbcType=VARCHAR},
            </if>
            <if test="orderLineId != null">
                order_line_id = #{orderLineId,jdbcType=VARCHAR},
            </if>
            <if test="transactionId != null">
                transaction_id = #{transactionId,jdbcType=VARCHAR},
            </if>
            <if test="companyId != null">
                company_id = #{companyId,jdbcType=INTEGER},
            </if>
            <if test="receivedTopRatedDiscount != null">
                received_top_rated_discount = #{receivedTopRatedDiscount,jdbcType=BIT},
            </if>
            <if test="accountId != null">
                account_id = #{accountId,jdbcType=INTEGER},
            </if>
            <if test="currency != null">
                currency = #{currency,jdbcType=VARCHAR},
            </if>
            <if test="exchangeRate != null">
                exchange_rate = #{exchangeRate,jdbcType=DECIMAL},
            </if>
            <if test="exchangeRateUsd != null">
                exchange_rate_usd = #{exchangeRateUsd,jdbcType=DECIMAL},
            </if>
            <if test="reportDate != null">
                report_date = #{reportDate,jdbcType=DATE},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.bailuntec.domain.entity.DcBaseFinanceEbay">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update dc_base_finance_ebay
        set bj_create = #{bjCreate,jdbcType=TIMESTAMP},
        bj_modified = #{bjModified,jdbcType=TIMESTAMP},
        account_entry_type = #{accountEntryType,jdbcType=VARCHAR},
        description = #{description,jdbcType=VARCHAR},
        gmt_date = #{gmtDate,jdbcType=TIMESTAMP},
        bj_date = #{bjDate,jdbcType=TIMESTAMP},
        gross_amount = #{grossAmount,jdbcType=DECIMAL},
        item_id = #{itemId,jdbcType=VARCHAR},
        memo = #{memo,jdbcType=VARCHAR},
        net_amount = #{netAmount,jdbcType=DECIMAL},
        ref_number = #{refNumber,jdbcType=VARCHAR},
        vat_percent = #{vatPercent,jdbcType=DECIMAL},
        title = #{title,jdbcType=VARCHAR},
        order_line_id = #{orderLineId,jdbcType=VARCHAR},
        transaction_id = #{transactionId,jdbcType=VARCHAR},
        company_id = #{companyId,jdbcType=INTEGER},
        received_top_rated_discount = #{receivedTopRatedDiscount,jdbcType=BIT},
        account_id = #{accountId,jdbcType=INTEGER},
        currency = #{currency,jdbcType=VARCHAR},
        exchange_rate = #{exchangeRate,jdbcType=DECIMAL},
        exchange_rate_usd = #{exchangeRateUsd,jdbcType=DECIMAL},
        report_date = #{reportDate,jdbcType=DATE}
        where id = #{id,jdbcType=INTEGER}
    </update>
    <insert id="upsertSelective" parameterType="com.bailuntec.domain.entity.DcBaseFinanceEbay">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        insert into dc_base_finance_ebay
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="bjCreate != null">
                bj_create,
            </if>
            <if test="bjModified != null">
                bj_modified,
            </if>
            <if test="accountEntryType != null">
                account_entry_type,
            </if>
            <if test="description != null">
                description,
            </if>
            <if test="gmtDate != null">
                gmt_date,
            </if>
            <if test="bjDate != null">
                bj_date,
            </if>
            <if test="grossAmount != null">
                gross_amount,
            </if>
            <if test="itemId != null">
                item_id,
            </if>
            <if test="memo != null">
                memo,
            </if>
            <if test="netAmount != null">
                net_amount,
            </if>
            <if test="refNumber != null">
                ref_number,
            </if>
            <if test="vatPercent != null">
                vat_percent,
            </if>
            <if test="title != null">
                title,
            </if>
            <if test="orderLineId != null">
                order_line_id,
            </if>
            <if test="transactionId != null">
                transaction_id,
            </if>
            <if test="companyId != null">
                company_id,
            </if>
            <if test="receivedTopRatedDiscount != null">
                received_top_rated_discount,
            </if>
            <if test="accountId != null">
                account_id,
            </if>
            <if test="currency != null">
                currency,
            </if>
            <if test="exchangeRate != null">
                exchange_rate,
            </if>
            <if test="exchangeRateUsd != null">
                exchange_rate_usd,
            </if>
            <if test="reportDate != null">
                report_date,
            </if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="bjCreate != null">
                #{bjCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjModified != null">
                #{bjModified,jdbcType=TIMESTAMP},
            </if>
            <if test="accountEntryType != null">
                #{accountEntryType,jdbcType=VARCHAR},
            </if>
            <if test="description != null">
                #{description,jdbcType=VARCHAR},
            </if>
            <if test="gmtDate != null">
                #{gmtDate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjDate != null">
                #{bjDate,jdbcType=TIMESTAMP},
            </if>
            <if test="grossAmount != null">
                #{grossAmount,jdbcType=DECIMAL},
            </if>
            <if test="itemId != null">
                #{itemId,jdbcType=VARCHAR},
            </if>
            <if test="memo != null">
                #{memo,jdbcType=VARCHAR},
            </if>
            <if test="netAmount != null">
                #{netAmount,jdbcType=DECIMAL},
            </if>
            <if test="refNumber != null">
                #{refNumber,jdbcType=VARCHAR},
            </if>
            <if test="vatPercent != null">
                #{vatPercent,jdbcType=DECIMAL},
            </if>
            <if test="title != null">
                #{title,jdbcType=VARCHAR},
            </if>
            <if test="orderLineId != null">
                #{orderLineId,jdbcType=VARCHAR},
            </if>
            <if test="transactionId != null">
                #{transactionId,jdbcType=VARCHAR},
            </if>
            <if test="companyId != null">
                #{companyId,jdbcType=INTEGER},
            </if>
            <if test="receivedTopRatedDiscount != null">
                #{receivedTopRatedDiscount,jdbcType=BIT},
            </if>
            <if test="accountId != null">
                #{accountId,jdbcType=INTEGER},
            </if>
            <if test="currency != null">
                #{currency,jdbcType=VARCHAR},
            </if>
            <if test="exchangeRate != null">
                #{exchangeRate,jdbcType=DECIMAL},
            </if>
            <if test="exchangeRateUsd != null">
                #{exchangeRateUsd,jdbcType=DECIMAL},
            </if>
            <if test="reportDate != null">
                #{reportDate,jdbcType=DATE},
            </if>
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=INTEGER},
            </if>
            <if test="bjCreate != null">
                bj_create = #{bjCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjModified != null">
                bj_modified = #{bjModified,jdbcType=TIMESTAMP},
            </if>
            <if test="accountEntryType != null">
                account_entry_type = #{accountEntryType,jdbcType=VARCHAR},
            </if>
            <if test="description != null">
                description = #{description,jdbcType=VARCHAR},
            </if>
            <if test="gmtDate != null">
                gmt_date = #{gmtDate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjDate != null">
                bj_date = #{bjDate,jdbcType=TIMESTAMP},
            </if>
            <if test="grossAmount != null">
                gross_amount = #{grossAmount,jdbcType=DECIMAL},
            </if>
            <if test="itemId != null">
                item_id = #{itemId,jdbcType=VARCHAR},
            </if>
            <if test="memo != null">
                memo = #{memo,jdbcType=VARCHAR},
            </if>
            <if test="netAmount != null">
                net_amount = #{netAmount,jdbcType=DECIMAL},
            </if>
            <if test="refNumber != null">
                ref_number = #{refNumber,jdbcType=VARCHAR},
            </if>
            <if test="vatPercent != null">
                vat_percent = #{vatPercent,jdbcType=DECIMAL},
            </if>
            <if test="title != null">
                title = #{title,jdbcType=VARCHAR},
            </if>
            <if test="orderLineId != null">
                order_line_id = #{orderLineId,jdbcType=VARCHAR},
            </if>
            <if test="transactionId != null">
                transaction_id = #{transactionId,jdbcType=VARCHAR},
            </if>
            <if test="companyId != null">
                company_id = #{companyId,jdbcType=INTEGER},
            </if>
            <if test="receivedTopRatedDiscount != null">
                received_top_rated_discount = #{receivedTopRatedDiscount,jdbcType=BIT},
            </if>
            <if test="accountId != null">
                account_id = #{accountId,jdbcType=INTEGER},
            </if>
            <if test="currency != null">
                currency = #{currency,jdbcType=VARCHAR},
            </if>
            <if test="exchangeRate != null">
                exchange_rate = #{exchangeRate,jdbcType=DECIMAL},
            </if>
            <if test="exchangeRateUsd != null">
                exchange_rate_usd = #{exchangeRateUsd,jdbcType=DECIMAL},
            </if>
            <if test="reportDate != null">
                report_date = #{reportDate,jdbcType=DATE},
            </if>
        </trim>
    </insert>
    <insert id="upsert" parameterType="com.bailuntec.domain.entity.DcBaseFinanceEbay">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        insert into dc_base_finance_ebay
        (id, bj_create, bj_modified, account_entry_type, description, gmt_date, bj_date,
        gross_amount, item_id, memo, net_amount, ref_number, vat_percent, title, order_line_id,
        transaction_id, company_id, received_top_rated_discount, account_id, currency,
        exchange_rate, exchange_rate_usd, report_date)
        values
        (#{id,jdbcType=INTEGER}, #{bjCreate,jdbcType=TIMESTAMP}, #{bjModified,jdbcType=TIMESTAMP},
        #{accountEntryType,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{gmtDate,jdbcType=TIMESTAMP},
        #{bjDate,jdbcType=TIMESTAMP}, #{grossAmount,jdbcType=DECIMAL}, #{itemId,jdbcType=VARCHAR},
        #{memo,jdbcType=VARCHAR}, #{netAmount,jdbcType=DECIMAL}, #{refNumber,jdbcType=VARCHAR},
        #{vatPercent,jdbcType=DECIMAL}, #{title,jdbcType=VARCHAR}, #{orderLineId,jdbcType=VARCHAR},
        #{transactionId,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER}, #{receivedTopRatedDiscount,jdbcType=BIT},
        #{accountId,jdbcType=INTEGER}, #{currency,jdbcType=VARCHAR}, #{exchangeRate,jdbcType=DECIMAL},
        #{exchangeRateUsd,jdbcType=DECIMAL}, #{reportDate,jdbcType=DATE})
        on duplicate key update
        id = #{id,jdbcType=INTEGER},
        bj_create = #{bjCreate,jdbcType=TIMESTAMP},
        bj_modified = #{bjModified,jdbcType=TIMESTAMP},
        account_entry_type = #{accountEntryType,jdbcType=VARCHAR},
        description = #{description,jdbcType=VARCHAR},
        gmt_date = #{gmtDate,jdbcType=TIMESTAMP},
        bj_date = #{bjDate,jdbcType=TIMESTAMP},
        gross_amount = #{grossAmount,jdbcType=DECIMAL},
        item_id = #{itemId,jdbcType=VARCHAR},
        memo = #{memo,jdbcType=VARCHAR},
        net_amount = #{netAmount,jdbcType=DECIMAL},
        ref_number = #{refNumber,jdbcType=VARCHAR},
        vat_percent = #{vatPercent,jdbcType=DECIMAL},
        title = #{title,jdbcType=VARCHAR},
        order_line_id = #{orderLineId,jdbcType=VARCHAR},
        transaction_id = #{transactionId,jdbcType=VARCHAR},
        company_id = #{companyId,jdbcType=INTEGER},
        received_top_rated_discount = #{receivedTopRatedDiscount,jdbcType=BIT},
        account_id = #{accountId,jdbcType=INTEGER},
        currency = #{currency,jdbcType=VARCHAR},
        exchange_rate = #{exchangeRate,jdbcType=DECIMAL},
        exchange_rate_usd = #{exchangeRateUsd,jdbcType=DECIMAL},
        report_date = #{reportDate,jdbcType=DATE}
    </insert>
    <select id="selectOneByExample" parameterType="com.bailuntec.domain.example.DcBaseFinanceEbayExample"
            resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        select
        <include refid="Base_Column_List"/>
        from dc_base_finance_ebay
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        limit 1
    </select>

    <resultMap id="BaseResultMap1" type="com.bailuntec.domain.dto.DcBaseFinanceEbayItemDto">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <result column="id" jdbcType="INTEGER" property="id"/>
        <result column="account_entry_type" jdbcType="VARCHAR" property="accountEntryType"/>
        <result column="description" jdbcType="VARCHAR" property="description"/>
        <result column="gmt_date" jdbcType="TIMESTAMP" property="gmtDate"/>
        <result column="bj_date" jdbcType="TIMESTAMP" property="bjDate"/>
        <result column="gross_amount" jdbcType="DECIMAL" property="grossAmount"/>
        <result column="item_id" jdbcType="VARCHAR" property="itemId"/>
        <result column="title" jdbcType="VARCHAR" property="title"/>
        <result column="order_line_id" jdbcType="VARCHAR" property="orderLineId"/>
        <result column="transaction_id" jdbcType="VARCHAR" property="transactionId"/>
        <result column="company_id" jdbcType="INTEGER" property="companyId"/>
        <result column="received_top_rated_discount" jdbcType="BIT" property="receivedTopRatedDiscount"/>
        <result column="account_id" jdbcType="INTEGER" property="accountId"/>
        <result column="currency" jdbcType="VARCHAR" property="currency"/>
        <result column="exchange_rate" jdbcType="DECIMAL" property="exchangeRate"/>
        <result column="exchange_rate_usd" jdbcType="DECIMAL" property="exchangeRateUsd"/>
        <result column="report_date" jdbcType="DATE" property="reportDate"/>
        <collection property="dcBaseSkuMappingList" column="item_id"
                    ofType="com.bailuntec.domain.dto.DcBaseEbaySkuMappingDto" select="selectSkuMapping">
        </collection>
    </resultMap>

    <select id="selectSkuMapping" resultType="com.bailuntec.domain.dto.DcBaseEbaySkuMappingDto">
        select dc0.*, dc1.unit_price, count(1) as skuCount
        from dc_base_ebay_sku_mapping dc0
                 left join dc_base_sku dc1 on dc0.sku_code = dc1.bailun_sku
        where dc0.item_id = #{itemId}
        group by dc0.sku_code
    </select>

    <resultMap id="BaseResultMap2" type="com.bailuntec.domain.dto.DcBaseFinanceEbayItemDto">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <result column="id" jdbcType="INTEGER" property="id"/>
        <result column="account_entry_type" jdbcType="VARCHAR" property="accountEntryType"/>
        <result column="description" jdbcType="VARCHAR" property="description"/>
        <result column="gmt_date" jdbcType="TIMESTAMP" property="gmtDate"/>
        <result column="bj_date" jdbcType="TIMESTAMP" property="bjDate"/>
        <result column="gross_amount" jdbcType="DECIMAL" property="grossAmount"/>
        <result column="item_id" jdbcType="VARCHAR" property="itemId"/>
        <result column="title" jdbcType="VARCHAR" property="title"/>
        <result column="order_line_id" jdbcType="VARCHAR" property="orderLineId"/>
        <result column="transaction_id" jdbcType="VARCHAR" property="transactionId"/>
        <result column="company_id" jdbcType="INTEGER" property="companyId"/>
        <result column="received_top_rated_discount" jdbcType="BIT" property="receivedTopRatedDiscount"/>
        <result column="account_id" jdbcType="INTEGER" property="accountId"/>
        <result column="currency" jdbcType="VARCHAR" property="currency"/>
        <result column="exchange_rate" jdbcType="DECIMAL" property="exchangeRate"/>
        <result column="exchange_rate_usd" jdbcType="DECIMAL" property="exchangeRateUsd"/>
        <result column="report_date" jdbcType="DATE" property="reportDate"/>
    </resultMap>

    <!--calculate start-->
    <select id="selectEbayList" resultMap="BaseResultMap1">
        select *
        from dc_base_finance_ebay
        where bj_date &gt;= #{startTime}
          and bj_date &lt; #{endTime}
        order by id asc
        limit ${pageIndex * pageSize} , #{pageSize}
    </select>

    <select id="selectSkuPrice" resultType="java.math.BigDecimal">
        select unit_price
        from dc_base_sku
        where bailun_sku = #{skuCode}
    </select>
    <!--calculate end-->

    <!-- ebayitem start -->
    <select id="countByGroup" resultType="java.lang.Long">
        select count(1)
        from (select item_id
              from dc_base_finance_ebay
              where bj_date &gt;= #{startTime}
                and bj_date &lt; #{endTime}
              group by item_id) b
    </select>

    <select id="selectEbay" resultMap="BaseResultMap1">
        select *
        from dc_base_finance_ebay
        where bj_date &gt;= #{startTime}
          and bj_date &lt; #{endTime}
        group by item_id
        order by id asc
        limit ${pageIndex * pageSize} , #{pageSize}
    </select>

    <select id="selectEbayItem" resultType="java.lang.String">
        select item_id
        from dc_base_finance_ebay
        where bj_date &gt;= #{startTime}
          and bj_date &lt; #{endTime}
        group by item_id
        order by id asc
        limit ${pageIndex * pageSize} , #{pageSize}
    </select>
    <select id="selectDup" resultType="com.bailuntec.domain.entity.DcBaseFinanceEbay">
        SELECT *
        from dc_base_finance_ebay
        group by ref_number, item_id, account_entry_type, gmt_date
        HAVING count(id) > 1
    </select>
    <select id="selectGroup" resultType="com.bailuntec.domain.entity.DcBaseFinanceEbay">
        SELECT *
        from dc_base_finance_ebay
        where ref_number = #{refNumber}
          and item_id = #{itemId}
          and account_entry_type = #{accountEntryType}
          and gmt_date = #{gmtDate}
    </select>
    <!-- ebayitem end -->

</mapper>
