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

    <select id="selectSKcBbRetailsalesList" parameterType="pd" resultType="pd">
        select * from s_kc_bb_retailsales where 1=1
        <if test="productCode !=null and productCode !='' ">
            and productCode = #{productCode}
        </if>
        <if test="storeShortName !=null and storeShortName !='' ">
            and storeShortName = #{storeShortName}
        </if>
        <if test="saleDate !=null and saleDate !='' ">
            and saleDate = #{saleDate}
        </if>
        <if test="productName !=null and productName !='' ">
            and productName = #{productName}
        </if>
        <if test="retailDocumentNumber !=null and retailDocumentNumber !='' ">
            and retailDocumentNumber = #{retailDocumentNumber}
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
            and manufacturer = #{manufacturer}
        </if>
        <if test="saleQuantity !=null and saleQuantity !='' ">
            and saleQuantity = #{saleQuantity}
        </if>
        <if test="price !=null and price !='' ">
            and price = #{price}
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
            and batchNumber = #{batchNumber}
        </if>
        <if test="productionDate !=null and productionDate !='' ">
            and productionDate = #{productionDate}
        </if>
        <if test="saleAmount !=null and saleAmount !='' ">
            and saleAmount = #{saleAmount}
        </if>
        <if test="specification !=null and specification !='' ">
            and specification = #{specification}
        </if>
        <if test="approvalNumber !=null and approvalNumber !='' ">
            and approvalNumber = #{approvalNumber}
        </if>
        <if test="expirationDate !=null and expirationDate !='' ">
            and expirationDate = #{expirationDate}
        </if>
    </select>


    <update id="updateSKcBbRetailsales" parameterType="pd" >
        update s_kc_bb_retailsales
        <trim prefix=" SET " suffix="" prefixOverrides="," suffixOverrides=",">
        <if test="productCode !=null and productCode !='' ">
            productCode = #{productCode},
        </if>
        <if test="storeShortName !=null and storeShortName !='' ">
            storeShortName = #{storeShortName},
        </if>
        <if test="saleDate !=null and saleDate !='' ">
            saleDate = #{saleDate},
        </if>
        <if test="productName !=null and productName !='' ">
            productName = #{productName},
        </if>
        <if test="retailDocumentNumber !=null and retailDocumentNumber !='' ">
            retailDocumentNumber = #{retailDocumentNumber},
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
            manufacturer = #{manufacturer},
        </if>
        <if test="saleQuantity !=null and saleQuantity !='' ">
            saleQuantity = #{saleQuantity},
        </if>
        <if test="price !=null and price !='' ">
            price = #{price},
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
            batchNumber = #{batchNumber},
        </if>
        <if test="productionDate !=null and productionDate !='' ">
            productionDate = #{productionDate},
        </if>
        <if test="saleAmount !=null and saleAmount !='' ">
            saleAmount = #{saleAmount},
        </if>
        <if test="specification !=null and specification !='' ">
            specification = #{specification},
        </if>
        <if test="approvalNumber !=null and approvalNumber !='' ">
            approvalNumber = #{approvalNumber},
        </if>
        <if test="expirationDate !=null and expirationDate !='' ">
            expirationDate = #{expirationDate},
        </if>
        </trim>
        <if test="up != null and up!=''">
            <if test="id != null and id!=''">
                where id=#{id}
            </if>
        </if>
    </update>

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

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

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

        <if test="productCode !=null and productCode !='' ">
            productCode,
        </if>
        <if test="storeShortName !=null and storeShortName !='' ">
            storeShortName,
        </if>
        <if test="saleDate !=null and saleDate !='' ">
            saleDate,
        </if>
        <if test="productName !=null and productName !='' ">
            productName,
        </if>
        <if test="retailDocumentNumber !=null and retailDocumentNumber !='' ">
            retailDocumentNumber,
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
            manufacturer,
        </if>
        <if test="saleQuantity !=null and saleQuantity !='' ">
            saleQuantity,
        </if>
        <if test="price !=null and price !='' ">
            price,
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
            batchNumber,
        </if>
        <if test="productionDate !=null and productionDate !='' ">
            productionDate,
        </if>
        <if test="saleAmount !=null and saleAmount !='' ">
            saleAmount,
        </if>
        <if test="specification !=null and specification !='' ">
            specification,
        </if>
        <if test="approvalNumber !=null and approvalNumber !='' ">
            approvalNumber,
        </if>
        <if test="expirationDate !=null and expirationDate !='' ">
            expirationDate,
        </if>
        </trim>
        <trim prefix=" VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
        <if test="productCode !=null and productCode !='' ">
             #{productCode},
        </if>
        <if test="storeShortName !=null and storeShortName !='' ">
             #{storeShortName},
        </if>
        <if test="saleDate !=null and saleDate !='' ">
             #{saleDate},
        </if>
        <if test="productName !=null and productName !='' ">
             #{productName},
        </if>
        <if test="retailDocumentNumber !=null and retailDocumentNumber !='' ">
             #{retailDocumentNumber},
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
             #{manufacturer},
        </if>
        <if test="saleQuantity !=null and saleQuantity !='' ">
             #{saleQuantity},
        </if>
        <if test="price !=null and price !='' ">
             #{price},
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
             #{batchNumber},
        </if>
        <if test="productionDate !=null and productionDate !='' ">
             #{productionDate},
        </if>
        <if test="saleAmount !=null and saleAmount !='' ">
             #{saleAmount},
        </if>
        <if test="specification !=null and specification !='' ">
             #{specification},
        </if>
        <if test="approvalNumber !=null and approvalNumber !='' ">
             #{approvalNumber},
        </if>
        <if test="expirationDate !=null and expirationDate !='' ">
             #{expirationDate},
        </if>
        </trim>

    </insert>

</mapper>
