<?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="SKcBbStoreinventorycostMapper" >
    <!-- 通用查询映射结果 -->

    <select id="selectSKcBbStoreinventorycostList" parameterType="pd" resultType="pd">
        select * from s_kc_bb_storeinventorycost where 1=1
        <if test="sequenceNumber !=null and sequenceNumber !='' ">
            and sequenceNumber = #{sequenceNumber}
        </if>
        <if test="period !=null and period !='' ">
            and period = #{period}
        </if>
        <if test="storeId !=null and storeId !='' ">
            and storeId = #{storeId}
        </if>
        <if test="storeName !=null and storeName !='' ">
            and storeName = #{storeName}
        </if>
        <if test="initialStockCost !=null and initialStockCost !='' ">
            and initialStockCost = #{initialStockCost}
        </if>
        <if test="deliveryCost !=null and deliveryCost !='' ">
            and deliveryCost = #{deliveryCost}
        </if>
        <if test="returnWarehouseCost !=null and returnWarehouseCost !='' ">
            and returnWarehouseCost = #{returnWarehouseCost}
        </if>
        <if test="salesCost !=null and salesCost !='' ">
            and salesCost = #{salesCost}
        </if>
        <if test="salesReturnAmount !=null and salesReturnAmount !='' ">
            and salesReturnAmount = #{salesReturnAmount}
        </if>
        <if test="lossCost !=null and lossCost !='' ">
            and lossCost = #{lossCost}
        </if>
        <if test="gainCost !=null and gainCost !='' ">
            and gainCost = #{gainCost}
        </if>
        <if test="finalStockCost !=null and finalStockCost !='' ">
            and finalStockCost = #{finalStockCost}
        </if>
    </select>


    <update id="updateSKcBbStoreinventorycost" parameterType="pd" >
        update s_kc_bb_storeinventorycost
        <trim prefix=" SET " suffix="" prefixOverrides="," suffixOverrides=",">
        <if test="sequenceNumber !=null and sequenceNumber !='' ">
            sequenceNumber = #{sequenceNumber},
        </if>
        <if test="period !=null and period !='' ">
            period = #{period},
        </if>
        <if test="storeId !=null and storeId !='' ">
            storeId = #{storeId},
        </if>
        <if test="storeName !=null and storeName !='' ">
            storeName = #{storeName},
        </if>
        <if test="initialStockCost !=null and initialStockCost !='' ">
            initialStockCost = #{initialStockCost},
        </if>
        <if test="deliveryCost !=null and deliveryCost !='' ">
            deliveryCost = #{deliveryCost},
        </if>
        <if test="returnWarehouseCost !=null and returnWarehouseCost !='' ">
            returnWarehouseCost = #{returnWarehouseCost},
        </if>
        <if test="salesCost !=null and salesCost !='' ">
            salesCost = #{salesCost},
        </if>
        <if test="salesReturnAmount !=null and salesReturnAmount !='' ">
            salesReturnAmount = #{salesReturnAmount},
        </if>
        <if test="lossCost !=null and lossCost !='' ">
            lossCost = #{lossCost},
        </if>
        <if test="gainCost !=null and gainCost !='' ">
            gainCost = #{gainCost},
        </if>
        <if test="finalStockCost !=null and finalStockCost !='' ">
            finalStockCost = #{finalStockCost},
        </if>
        </trim>
        <if test="up != null and up!=''">
            <if test="id != null and id!=''">
                where id=#{id}
            </if>
        </if>
    </update>

    <delete id="SKcBbStoreinventorycostRemove" parameterType="pd">
        <if test="ids != null">
            delete from s_kc_bb_storeinventorycost where
            <if test="ids != null">
                id in(${ids})
            </if>
        </if>
    </delete>

    <insert id="addSKcBbStoreinventorycost" parameterType="pd" >

        insert into s_kc_bb_storeinventorycost
        <trim prefix="(" suffix=")" prefixOverrides="," suffixOverrides=",">

        <if test="sequenceNumber !=null and sequenceNumber !='' ">
            sequenceNumber,
        </if>
        <if test="period !=null and period !='' ">
            period,
        </if>
        <if test="storeId !=null and storeId !='' ">
            storeId,
        </if>
        <if test="storeName !=null and storeName !='' ">
            storeName,
        </if>
        <if test="initialStockCost !=null and initialStockCost !='' ">
            initialStockCost,
        </if>
        <if test="deliveryCost !=null and deliveryCost !='' ">
            deliveryCost,
        </if>
        <if test="returnWarehouseCost !=null and returnWarehouseCost !='' ">
            returnWarehouseCost,
        </if>
        <if test="salesCost !=null and salesCost !='' ">
            salesCost,
        </if>
        <if test="salesReturnAmount !=null and salesReturnAmount !='' ">
            salesReturnAmount,
        </if>
        <if test="lossCost !=null and lossCost !='' ">
            lossCost,
        </if>
        <if test="gainCost !=null and gainCost !='' ">
            gainCost,
        </if>
        <if test="finalStockCost !=null and finalStockCost !='' ">
            finalStockCost,
        </if>
        </trim>
        <trim prefix=" VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
        <if test="sequenceNumber !=null and sequenceNumber !='' ">
             #{sequenceNumber},
        </if>
        <if test="period !=null and period !='' ">
             #{period},
        </if>
        <if test="storeId !=null and storeId !='' ">
             #{storeId},
        </if>
        <if test="storeName !=null and storeName !='' ">
             #{storeName},
        </if>
        <if test="initialStockCost !=null and initialStockCost !='' ">
             #{initialStockCost},
        </if>
        <if test="deliveryCost !=null and deliveryCost !='' ">
             #{deliveryCost},
        </if>
        <if test="returnWarehouseCost !=null and returnWarehouseCost !='' ">
             #{returnWarehouseCost},
        </if>
        <if test="salesCost !=null and salesCost !='' ">
             #{salesCost},
        </if>
        <if test="salesReturnAmount !=null and salesReturnAmount !='' ">
             #{salesReturnAmount},
        </if>
        <if test="lossCost !=null and lossCost !='' ">
             #{lossCost},
        </if>
        <if test="gainCost !=null and gainCost !='' ">
             #{gainCost},
        </if>
        <if test="finalStockCost !=null and finalStockCost !='' ">
             #{finalStockCost},
        </if>
        </trim>

    </insert>

</mapper>
