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

    <select id="selectSXsglXsmxZkmxSalesdiscountinfoList" parameterType="pd" resultType="pd">
        select * from s_xsgl_xsmx_zkmx_salesdiscountinfo where 1=1
        <if test="productCode !=null and productCode !='' ">
            and productCode = #{productCode}
        </if>
        <if test="productName !=null and productName !='' ">
            and productName = #{productName}
        </if>
        <if test="storeName !=null and storeName !='' ">
            and storeName = #{storeName}
        </if>
        <if test="saleDate !=null and saleDate !='' ">
            and saleDate = #{saleDate}
        </if>
        <if test="saleDocumentNumber !=null and saleDocumentNumber !='' ">
            and saleDocumentNumber = #{saleDocumentNumber}
        </if>
        <if test="member !=null and member !='' ">
            and member = #{member}
        </if>
        <if test="cashier !=null and cashier !='' ">
            and cashier = #{cashier}
        </if>
        <if test="retailPrice !=null and retailPrice !='' ">
            and retailPrice = #{retailPrice}
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
            and batchNumber = #{batchNumber}
        </if>
        <if test="batch !=null and batch !='' ">
            and batch = #{batch}
        </if>
        <if test="actualSalePrice !=null and actualSalePrice !='' ">
            and actualSalePrice = #{actualSalePrice}
        </if>
        <if test="actualReceiptAmount !=null and actualReceiptAmount !='' ">
            and actualReceiptAmount = #{actualReceiptAmount}
        </if>
        <if test="estimatedCostAmount !=null and estimatedCostAmount !='' ">
            and estimatedCostAmount = #{estimatedCostAmount}
        </if>
        <if test="grossProfitAmount !=null and grossProfitAmount !='' ">
            and grossProfitAmount = #{grossProfitAmount}
        </if>
        <if test="cartLineNo !=null and cartLineNo !='' ">
            and cartLineNo = #{cartLineNo}
        </if>
        <if test="lineQuantity !=null and lineQuantity !='' ">
            and lineQuantity = #{lineQuantity}
        </if>
        <if test="discountType !=null and discountType !='' ">
            and discountType = #{discountType}
        </if>
        <if test="discountDocumentNumber !=null and discountDocumentNumber !='' ">
            and discountDocumentNumber = #{discountDocumentNumber}
        </if>
        <if test="discountSubDocumentNumber !=null and discountSubDocumentNumber !='' ">
            and discountSubDocumentNumber = #{discountSubDocumentNumber}
        </if>
        <if test="discountUnitPrice !=null and discountUnitPrice !='' ">
            and discountUnitPrice = #{discountUnitPrice}
        </if>
        <if test="discountAmount !=null and discountAmount !='' ">
            and discountAmount = #{discountAmount}
        </if>
        <if test="points !=null and points !='' ">
            and points = #{points}
        </if>
    </select>


    <update id="updateSXsglXsmxZkmxSalesdiscountinfo" parameterType="pd" >
        update s_xsgl_xsmx_zkmx_salesdiscountinfo
        <trim prefix=" SET " suffix="" prefixOverrides="," suffixOverrides=",">
        <if test="productCode !=null and productCode !='' ">
            productCode = #{productCode},
        </if>
        <if test="productName !=null and productName !='' ">
            productName = #{productName},
        </if>
        <if test="storeName !=null and storeName !='' ">
            storeName = #{storeName},
        </if>
        <if test="saleDate !=null and saleDate !='' ">
            saleDate = #{saleDate},
        </if>
        <if test="saleDocumentNumber !=null and saleDocumentNumber !='' ">
            saleDocumentNumber = #{saleDocumentNumber},
        </if>
        <if test="member !=null and member !='' ">
            member = #{member},
        </if>
        <if test="cashier !=null and cashier !='' ">
            cashier = #{cashier},
        </if>
        <if test="retailPrice !=null and retailPrice !='' ">
            retailPrice = #{retailPrice},
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
            batchNumber = #{batchNumber},
        </if>
        <if test="batch !=null and batch !='' ">
            batch = #{batch},
        </if>
        <if test="actualSalePrice !=null and actualSalePrice !='' ">
            actualSalePrice = #{actualSalePrice},
        </if>
        <if test="actualReceiptAmount !=null and actualReceiptAmount !='' ">
            actualReceiptAmount = #{actualReceiptAmount},
        </if>
        <if test="estimatedCostAmount !=null and estimatedCostAmount !='' ">
            estimatedCostAmount = #{estimatedCostAmount},
        </if>
        <if test="grossProfitAmount !=null and grossProfitAmount !='' ">
            grossProfitAmount = #{grossProfitAmount},
        </if>
        <if test="cartLineNo !=null and cartLineNo !='' ">
            cartLineNo = #{cartLineNo},
        </if>
        <if test="lineQuantity !=null and lineQuantity !='' ">
            lineQuantity = #{lineQuantity},
        </if>
        <if test="discountType !=null and discountType !='' ">
            discountType = #{discountType},
        </if>
        <if test="discountDocumentNumber !=null and discountDocumentNumber !='' ">
            discountDocumentNumber = #{discountDocumentNumber},
        </if>
        <if test="discountSubDocumentNumber !=null and discountSubDocumentNumber !='' ">
            discountSubDocumentNumber = #{discountSubDocumentNumber},
        </if>
        <if test="discountUnitPrice !=null and discountUnitPrice !='' ">
            discountUnitPrice = #{discountUnitPrice},
        </if>
        <if test="discountAmount !=null and discountAmount !='' ">
            discountAmount = #{discountAmount},
        </if>
        <if test="points !=null and points !='' ">
            points = #{points},
        </if>
        </trim>
        <if test="up != null and up!=''">
            <if test="id != null and id!=''">
                where id=#{id}
            </if>
        </if>
    </update>

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

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

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

        <if test="productCode !=null and productCode !='' ">
            productCode,
        </if>
        <if test="productName !=null and productName !='' ">
            productName,
        </if>
        <if test="storeName !=null and storeName !='' ">
            storeName,
        </if>
        <if test="saleDate !=null and saleDate !='' ">
            saleDate,
        </if>
        <if test="saleDocumentNumber !=null and saleDocumentNumber !='' ">
            saleDocumentNumber,
        </if>
        <if test="member !=null and member !='' ">
            member,
        </if>
        <if test="cashier !=null and cashier !='' ">
            cashier,
        </if>
        <if test="retailPrice !=null and retailPrice !='' ">
            retailPrice,
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
            batchNumber,
        </if>
        <if test="batch !=null and batch !='' ">
            batch,
        </if>
        <if test="actualSalePrice !=null and actualSalePrice !='' ">
            actualSalePrice,
        </if>
        <if test="actualReceiptAmount !=null and actualReceiptAmount !='' ">
            actualReceiptAmount,
        </if>
        <if test="estimatedCostAmount !=null and estimatedCostAmount !='' ">
            estimatedCostAmount,
        </if>
        <if test="grossProfitAmount !=null and grossProfitAmount !='' ">
            grossProfitAmount,
        </if>
        <if test="cartLineNo !=null and cartLineNo !='' ">
            cartLineNo,
        </if>
        <if test="lineQuantity !=null and lineQuantity !='' ">
            lineQuantity,
        </if>
        <if test="discountType !=null and discountType !='' ">
            discountType,
        </if>
        <if test="discountDocumentNumber !=null and discountDocumentNumber !='' ">
            discountDocumentNumber,
        </if>
        <if test="discountSubDocumentNumber !=null and discountSubDocumentNumber !='' ">
            discountSubDocumentNumber,
        </if>
        <if test="discountUnitPrice !=null and discountUnitPrice !='' ">
            discountUnitPrice,
        </if>
        <if test="discountAmount !=null and discountAmount !='' ">
            discountAmount,
        </if>
        <if test="points !=null and points !='' ">
            points,
        </if>
        </trim>
        <trim prefix=" VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
        <if test="productCode !=null and productCode !='' ">
             #{productCode},
        </if>
        <if test="productName !=null and productName !='' ">
             #{productName},
        </if>
        <if test="storeName !=null and storeName !='' ">
             #{storeName},
        </if>
        <if test="saleDate !=null and saleDate !='' ">
             #{saleDate},
        </if>
        <if test="saleDocumentNumber !=null and saleDocumentNumber !='' ">
             #{saleDocumentNumber},
        </if>
        <if test="member !=null and member !='' ">
             #{member},
        </if>
        <if test="cashier !=null and cashier !='' ">
             #{cashier},
        </if>
        <if test="retailPrice !=null and retailPrice !='' ">
             #{retailPrice},
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
             #{batchNumber},
        </if>
        <if test="batch !=null and batch !='' ">
             #{batch},
        </if>
        <if test="actualSalePrice !=null and actualSalePrice !='' ">
             #{actualSalePrice},
        </if>
        <if test="actualReceiptAmount !=null and actualReceiptAmount !='' ">
             #{actualReceiptAmount},
        </if>
        <if test="estimatedCostAmount !=null and estimatedCostAmount !='' ">
             #{estimatedCostAmount},
        </if>
        <if test="grossProfitAmount !=null and grossProfitAmount !='' ">
             #{grossProfitAmount},
        </if>
        <if test="cartLineNo !=null and cartLineNo !='' ">
             #{cartLineNo},
        </if>
        <if test="lineQuantity !=null and lineQuantity !='' ">
             #{lineQuantity},
        </if>
        <if test="discountType !=null and discountType !='' ">
             #{discountType},
        </if>
        <if test="discountDocumentNumber !=null and discountDocumentNumber !='' ">
             #{discountDocumentNumber},
        </if>
        <if test="discountSubDocumentNumber !=null and discountSubDocumentNumber !='' ">
             #{discountSubDocumentNumber},
        </if>
        <if test="discountUnitPrice !=null and discountUnitPrice !='' ">
             #{discountUnitPrice},
        </if>
        <if test="discountAmount !=null and discountAmount !='' ">
             #{discountAmount},
        </if>
        <if test="points !=null and points !='' ">
             #{points},
        </if>
        </trim>

    </insert>

</mapper>
