<?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.reptileclient.jlifeapp.dao.hm.HmPaymentItemSkuMapper">
    <resultMap id="BaseResultMap" type="com.reptileclient.jlifeapp.entity.hm.HmPaymentItemSku">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="payment_no" property="paymentNo" jdbcType="VARCHAR"/>
        <result column="buy_amount" property="buyAmount" jdbcType="DECIMAL"/>
        <result column="cost_price" property="costPrice" jdbcType="DECIMAL"/>
        <result column="item_id" property="itemId" jdbcType="VARCHAR"/>
        <result column="item_name" property="itemName" jdbcType="VARCHAR"/>
        <result column="origin_cost_price" property="originCostPrice" jdbcType="DECIMAL"/>
        <result column="pic_url" property="picUrl" jdbcType="VARCHAR"/>
        <result column="shop_code" property="shopCode" jdbcType="VARCHAR"/>
        <result column="sku_code" property="skuCode" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">
        id
        , payment_no, buy_amount, cost_price, item_id, item_name, origin_cost_price, pic_url,
    shop_code, sku_code, create_time
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List"/>
        from hm_payment_item_sku
        where id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete
        from hm_payment_item_sku
        where id = #{id,jdbcType=BIGINT}
    </delete>
    <delete id="deleteByPaymentNo">
        delete
        from hm_payment_item_sku
        where payment_no = #{paymentNo}
    </delete>
    <insert id="insert" parameterType="com.reptileclient.jlifeapp.entity.hm.HmPaymentItemSku">
        insert into hm_payment_item_sku (id, payment_no, buy_amount,
                                         cost_price, item_id, item_name,
                                         origin_cost_price, pic_url, shop_code,
                                         sku_code, create_time)
        values (#{id,jdbcType=BIGINT}, #{paymentNo,jdbcType=VARCHAR}, #{buyAmount,jdbcType=DECIMAL},
                #{costPrice,jdbcType=DECIMAL}, #{itemId,jdbcType=VARCHAR}, #{itemName,jdbcType=VARCHAR},
                #{originCostPrice,jdbcType=DECIMAL}, #{picUrl,jdbcType=VARCHAR}, #{shopCode,jdbcType=VARCHAR},
                #{skuCode,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.reptileclient.jlifeapp.entity.hm.HmPaymentItemSku">
        insert into hm_payment_item_sku
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="paymentNo != null">
                payment_no,
            </if>
            <if test="buyAmount != null">
                buy_amount,
            </if>
            <if test="costPrice != null">
                cost_price,
            </if>
            <if test="itemId != null">
                item_id,
            </if>
            <if test="itemName != null">
                item_name,
            </if>
            <if test="originCostPrice != null">
                origin_cost_price,
            </if>
            <if test="picUrl != null">
                pic_url,
            </if>
            <if test="shopCode != null">
                shop_code,
            </if>
            <if test="skuCode != null">
                sku_code,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            <if test="paymentNo != null">
                #{paymentNo,jdbcType=VARCHAR},
            </if>
            <if test="buyAmount != null">
                #{buyAmount,jdbcType=DECIMAL},
            </if>
            <if test="costPrice != null">
                #{costPrice,jdbcType=DECIMAL},
            </if>
            <if test="itemId != null">
                #{itemId,jdbcType=VARCHAR},
            </if>
            <if test="itemName != null">
                #{itemName,jdbcType=VARCHAR},
            </if>
            <if test="originCostPrice != null">
                #{originCostPrice,jdbcType=DECIMAL},
            </if>
            <if test="picUrl != null">
                #{picUrl,jdbcType=VARCHAR},
            </if>
            <if test="shopCode != null">
                #{shopCode,jdbcType=VARCHAR},
            </if>
            <if test="skuCode != null">
                #{skuCode,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>
    <insert id="insertByBatch" parameterType="List">
        insert into hm_payment_item_sku (payment_no, buy_amount,
        cost_price, item_id, item_name,
        origin_cost_price, pic_url, shop_code,
        sku_code)
        values
        <foreach collection="itemSkuVoList" item="item" index="index" separator=",">
            (#{paymentNo,jdbcType=VARCHAR}, #{item.buyAmount,jdbcType=DECIMAL},
            #{item.costPrice,jdbcType=DECIMAL}, #{item.itemId,jdbcType=VARCHAR}, #{item.itemName,jdbcType=VARCHAR},
            #{item.originCostPrice,jdbcType=DECIMAL}, #{item.picUrl,jdbcType=VARCHAR},
            #{item.shopCode,jdbcType=VARCHAR},
            #{item.skuCode,jdbcType=VARCHAR})
        </foreach>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.reptileclient.jlifeapp.entity.hm.HmPaymentItemSku">
        update hm_payment_item_sku
        <set>
            <if test="paymentNo != null">
                payment_no = #{paymentNo,jdbcType=VARCHAR},
            </if>
            <if test="buyAmount != null">
                buy_amount = #{buyAmount,jdbcType=DECIMAL},
            </if>
            <if test="costPrice != null">
                cost_price = #{costPrice,jdbcType=DECIMAL},
            </if>
            <if test="itemId != null">
                item_id = #{itemId,jdbcType=VARCHAR},
            </if>
            <if test="itemName != null">
                item_name = #{itemName,jdbcType=VARCHAR},
            </if>
            <if test="originCostPrice != null">
                origin_cost_price = #{originCostPrice,jdbcType=DECIMAL},
            </if>
            <if test="picUrl != null">
                pic_url = #{picUrl,jdbcType=VARCHAR},
            </if>
            <if test="shopCode != null">
                shop_code = #{shopCode,jdbcType=VARCHAR},
            </if>
            <if test="skuCode != null">
                sku_code = #{skuCode,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.reptileclient.jlifeapp.entity.hm.HmPaymentItemSku">
        update hm_payment_item_sku
        set payment_no        = #{paymentNo,jdbcType=VARCHAR},
            buy_amount        = #{buyAmount,jdbcType=DECIMAL},
            cost_price        = #{costPrice,jdbcType=DECIMAL},
            item_id           = #{itemId,jdbcType=VARCHAR},
            item_name         = #{itemName,jdbcType=VARCHAR},
            origin_cost_price = #{originCostPrice,jdbcType=DECIMAL},
            pic_url           = #{picUrl,jdbcType=VARCHAR},
            shop_code         = #{shopCode,jdbcType=VARCHAR},
            sku_code          = #{skuCode,jdbcType=VARCHAR},
            create_time       = #{createTime,jdbcType=TIMESTAMP}
        where id = #{id,jdbcType=BIGINT}
    </update>
</mapper>