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

    <select id="selectSXsglXsmxSpmxSalesdetailinfoList" parameterType="pd" resultType="pd">
        select * from s_xsgl_xsmx_spmx_salesdetailinfo where 1=1
        <if test="productId !=null and productId !='' ">
            and productId = #{productId}
        </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="orderStatus !=null and orderStatus !='' ">
            and orderStatus = #{orderStatus}
        </if>
        <if test="specification !=null and specification !='' ">
            and specification = #{specification}
        </if>
        <if test="marketingCategory !=null and marketingCategory !='' ">
            and marketingCategory = #{marketingCategory}
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
            and manufacturer = #{manufacturer}
        </if>
        <if test="unit !=null and unit !='' ">
            and unit = #{unit}
        </if>
        <if test="dosageForm !=null and dosageForm !='' ">
            and dosageForm = #{dosageForm}
        </if>
        <if test="productionBatchNumber !=null and productionBatchNumber !='' ">
            and productionBatchNumber = #{productionBatchNumber}
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
            and batchNumber = #{batchNumber}
        </if>
        <if test="retailPrice !=null and retailPrice !='' ">
            and retailPrice = #{retailPrice}
        </if>
        <if test="actualSalePrice !=null and actualSalePrice !='' ">
            and actualSalePrice = #{actualSalePrice}
        </if>
        <if test="quantity !=null and quantity !='' ">
            and quantity = #{quantity}
        </if>
        <if test="discountRate !=null and discountRate !='' ">
            and discountRate = #{discountRate}
        </if>
        <if test="receivableAmount !=null and receivableAmount !='' ">
            and receivableAmount = #{receivableAmount}
        </if>
        <if test="salesperson !=null and salesperson !='' ">
            and salesperson = #{salesperson}
        </if>
        <if test="cashier !=null and cashier !='' ">
            and cashier = #{cashier}
        </if>
        <if test="authorizer !=null and authorizer !='' ">
            and authorizer = #{authorizer}
        </if>
        <if test="saleAttribute !=null and saleAttribute !='' ">
            and saleAttribute = #{saleAttribute}
        </if>
        <if test="isGift !=null and isGift !='' ">
            and isGift = #{isGift}
        </if>
        <if test="isDispensed !=null and isDispensed !='' ">
            and isDispensed = #{isDispensed}
        </if>
        <if test="promotionDocumentNumber !=null and promotionDocumentNumber !='' ">
            and promotionDocumentNumber = #{promotionDocumentNumber}
        </if>
        <if test="couponCode !=null and couponCode !='' ">
            and couponCode = #{couponCode}
        </if>
        <if test="couponAllocationAmount !=null and couponAllocationAmount !='' ">
            and couponAllocationAmount = #{couponAllocationAmount}
        </if>
        <if test="costRecoveryType !=null and costRecoveryType !='' ">
            and costRecoveryType = #{costRecoveryType}
        </if>
        <if test="rebateUnitPrice !=null and rebateUnitPrice !='' ">
            and rebateUnitPrice = #{rebateUnitPrice}
        </if>
        <if test="rebateAgreementNumber !=null and rebateAgreementNumber !='' ">
            and rebateAgreementNumber = #{rebateAgreementNumber}
        </if>
        <if test="rebateSupplier !=null and rebateSupplier !='' ">
            and rebateSupplier = #{rebateSupplier}
        </if>
        <if test="estimatedCostUnitPrice !=null and estimatedCostUnitPrice !='' ">
            and estimatedCostUnitPrice = #{estimatedCostUnitPrice}
        </if>
        <if test="grossProfitUnitPrice !=null and grossProfitUnitPrice !='' ">
            and grossProfitUnitPrice = #{grossProfitUnitPrice}
        </if>
        <if test="discountAmount !=null and discountAmount !='' ">
            and discountAmount = #{discountAmount}
        </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="singleProductDiscountRemark !=null and singleProductDiscountRemark !='' ">
            and singleProductDiscountRemark = #{singleProductDiscountRemark}
        </if>
        <if test="actualPriceRemark !=null and actualPriceRemark !='' ">
            and actualPriceRemark = #{actualPriceRemark}
        </if>
        <if test="entireOrderDiscountRemark !=null and entireOrderDiscountRemark !='' ">
            and entireOrderDiscountRemark = #{entireOrderDiscountRemark}
        </if>
        <if test="orderRemark !=null and orderRemark !='' ">
            and orderRemark = #{orderRemark}
        </if>
    </select>


    <update id="updateSXsglXsmxSpmxSalesdetailinfo" parameterType="pd" >
        update s_xsgl_xsmx_spmx_salesdetailinfo
        <trim prefix=" SET " suffix="" prefixOverrides="," suffixOverrides=",">
        <if test="productId !=null and productId !='' ">
            productId = #{productId},
        </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="orderStatus !=null and orderStatus !='' ">
            orderStatus = #{orderStatus},
        </if>
        <if test="specification !=null and specification !='' ">
            specification = #{specification},
        </if>
        <if test="marketingCategory !=null and marketingCategory !='' ">
            marketingCategory = #{marketingCategory},
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
            manufacturer = #{manufacturer},
        </if>
        <if test="unit !=null and unit !='' ">
            unit = #{unit},
        </if>
        <if test="dosageForm !=null and dosageForm !='' ">
            dosageForm = #{dosageForm},
        </if>
        <if test="productionBatchNumber !=null and productionBatchNumber !='' ">
            productionBatchNumber = #{productionBatchNumber},
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
            batchNumber = #{batchNumber},
        </if>
        <if test="retailPrice !=null and retailPrice !='' ">
            retailPrice = #{retailPrice},
        </if>
        <if test="actualSalePrice !=null and actualSalePrice !='' ">
            actualSalePrice = #{actualSalePrice},
        </if>
        <if test="quantity !=null and quantity !='' ">
            quantity = #{quantity},
        </if>
        <if test="discountRate !=null and discountRate !='' ">
            discountRate = #{discountRate},
        </if>
        <if test="receivableAmount !=null and receivableAmount !='' ">
            receivableAmount = #{receivableAmount},
        </if>
        <if test="salesperson !=null and salesperson !='' ">
            salesperson = #{salesperson},
        </if>
        <if test="cashier !=null and cashier !='' ">
            cashier = #{cashier},
        </if>
        <if test="authorizer !=null and authorizer !='' ">
            authorizer = #{authorizer},
        </if>
        <if test="saleAttribute !=null and saleAttribute !='' ">
            saleAttribute = #{saleAttribute},
        </if>
        <if test="isGift !=null and isGift !='' ">
            isGift = #{isGift},
        </if>
        <if test="isDispensed !=null and isDispensed !='' ">
            isDispensed = #{isDispensed},
        </if>
        <if test="promotionDocumentNumber !=null and promotionDocumentNumber !='' ">
            promotionDocumentNumber = #{promotionDocumentNumber},
        </if>
        <if test="couponCode !=null and couponCode !='' ">
            couponCode = #{couponCode},
        </if>
        <if test="couponAllocationAmount !=null and couponAllocationAmount !='' ">
            couponAllocationAmount = #{couponAllocationAmount},
        </if>
        <if test="costRecoveryType !=null and costRecoveryType !='' ">
            costRecoveryType = #{costRecoveryType},
        </if>
        <if test="rebateUnitPrice !=null and rebateUnitPrice !='' ">
            rebateUnitPrice = #{rebateUnitPrice},
        </if>
        <if test="rebateAgreementNumber !=null and rebateAgreementNumber !='' ">
            rebateAgreementNumber = #{rebateAgreementNumber},
        </if>
        <if test="rebateSupplier !=null and rebateSupplier !='' ">
            rebateSupplier = #{rebateSupplier},
        </if>
        <if test="estimatedCostUnitPrice !=null and estimatedCostUnitPrice !='' ">
            estimatedCostUnitPrice = #{estimatedCostUnitPrice},
        </if>
        <if test="grossProfitUnitPrice !=null and grossProfitUnitPrice !='' ">
            grossProfitUnitPrice = #{grossProfitUnitPrice},
        </if>
        <if test="discountAmount !=null and discountAmount !='' ">
            discountAmount = #{discountAmount},
        </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="singleProductDiscountRemark !=null and singleProductDiscountRemark !='' ">
            singleProductDiscountRemark = #{singleProductDiscountRemark},
        </if>
        <if test="actualPriceRemark !=null and actualPriceRemark !='' ">
            actualPriceRemark = #{actualPriceRemark},
        </if>
        <if test="entireOrderDiscountRemark !=null and entireOrderDiscountRemark !='' ">
            entireOrderDiscountRemark = #{entireOrderDiscountRemark},
        </if>
        <if test="orderRemark !=null and orderRemark !='' ">
            orderRemark = #{orderRemark},
        </if>
        </trim>
        <if test="up != null and up!=''">
            <if test="id != null and id!=''">
                where id=#{id}
            </if>
        </if>
    </update>

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

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

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

        <if test="productId !=null and productId !='' ">
            productId,
        </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="orderStatus !=null and orderStatus !='' ">
            orderStatus,
        </if>
        <if test="specification !=null and specification !='' ">
            specification,
        </if>
        <if test="marketingCategory !=null and marketingCategory !='' ">
            marketingCategory,
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
            manufacturer,
        </if>
        <if test="unit !=null and unit !='' ">
            unit,
        </if>
        <if test="dosageForm !=null and dosageForm !='' ">
            dosageForm,
        </if>
        <if test="productionBatchNumber !=null and productionBatchNumber !='' ">
            productionBatchNumber,
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
            batchNumber,
        </if>
        <if test="retailPrice !=null and retailPrice !='' ">
            retailPrice,
        </if>
        <if test="actualSalePrice !=null and actualSalePrice !='' ">
            actualSalePrice,
        </if>
        <if test="quantity !=null and quantity !='' ">
            quantity,
        </if>
        <if test="discountRate !=null and discountRate !='' ">
            discountRate,
        </if>
        <if test="receivableAmount !=null and receivableAmount !='' ">
            receivableAmount,
        </if>
        <if test="salesperson !=null and salesperson !='' ">
            salesperson,
        </if>
        <if test="cashier !=null and cashier !='' ">
            cashier,
        </if>
        <if test="authorizer !=null and authorizer !='' ">
            authorizer,
        </if>
        <if test="saleAttribute !=null and saleAttribute !='' ">
            saleAttribute,
        </if>
        <if test="isGift !=null and isGift !='' ">
            isGift,
        </if>
        <if test="isDispensed !=null and isDispensed !='' ">
            isDispensed,
        </if>
        <if test="promotionDocumentNumber !=null and promotionDocumentNumber !='' ">
            promotionDocumentNumber,
        </if>
        <if test="couponCode !=null and couponCode !='' ">
            couponCode,
        </if>
        <if test="couponAllocationAmount !=null and couponAllocationAmount !='' ">
            couponAllocationAmount,
        </if>
        <if test="costRecoveryType !=null and costRecoveryType !='' ">
            costRecoveryType,
        </if>
        <if test="rebateUnitPrice !=null and rebateUnitPrice !='' ">
            rebateUnitPrice,
        </if>
        <if test="rebateAgreementNumber !=null and rebateAgreementNumber !='' ">
            rebateAgreementNumber,
        </if>
        <if test="rebateSupplier !=null and rebateSupplier !='' ">
            rebateSupplier,
        </if>
        <if test="estimatedCostUnitPrice !=null and estimatedCostUnitPrice !='' ">
            estimatedCostUnitPrice,
        </if>
        <if test="grossProfitUnitPrice !=null and grossProfitUnitPrice !='' ">
            grossProfitUnitPrice,
        </if>
        <if test="discountAmount !=null and discountAmount !='' ">
            discountAmount,
        </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="singleProductDiscountRemark !=null and singleProductDiscountRemark !='' ">
            singleProductDiscountRemark,
        </if>
        <if test="actualPriceRemark !=null and actualPriceRemark !='' ">
            actualPriceRemark,
        </if>
        <if test="entireOrderDiscountRemark !=null and entireOrderDiscountRemark !='' ">
            entireOrderDiscountRemark,
        </if>
        <if test="orderRemark !=null and orderRemark !='' ">
            orderRemark,
        </if>
        </trim>
        <trim prefix=" VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
        <if test="productId !=null and productId !='' ">
             #{productId},
        </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="orderStatus !=null and orderStatus !='' ">
             #{orderStatus},
        </if>
        <if test="specification !=null and specification !='' ">
             #{specification},
        </if>
        <if test="marketingCategory !=null and marketingCategory !='' ">
             #{marketingCategory},
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
             #{manufacturer},
        </if>
        <if test="unit !=null and unit !='' ">
             #{unit},
        </if>
        <if test="dosageForm !=null and dosageForm !='' ">
             #{dosageForm},
        </if>
        <if test="productionBatchNumber !=null and productionBatchNumber !='' ">
             #{productionBatchNumber},
        </if>
        <if test="batchNumber !=null and batchNumber !='' ">
             #{batchNumber},
        </if>
        <if test="retailPrice !=null and retailPrice !='' ">
             #{retailPrice},
        </if>
        <if test="actualSalePrice !=null and actualSalePrice !='' ">
             #{actualSalePrice},
        </if>
        <if test="quantity !=null and quantity !='' ">
             #{quantity},
        </if>
        <if test="discountRate !=null and discountRate !='' ">
             #{discountRate},
        </if>
        <if test="receivableAmount !=null and receivableAmount !='' ">
             #{receivableAmount},
        </if>
        <if test="salesperson !=null and salesperson !='' ">
             #{salesperson},
        </if>
        <if test="cashier !=null and cashier !='' ">
             #{cashier},
        </if>
        <if test="authorizer !=null and authorizer !='' ">
             #{authorizer},
        </if>
        <if test="saleAttribute !=null and saleAttribute !='' ">
             #{saleAttribute},
        </if>
        <if test="isGift !=null and isGift !='' ">
             #{isGift},
        </if>
        <if test="isDispensed !=null and isDispensed !='' ">
             #{isDispensed},
        </if>
        <if test="promotionDocumentNumber !=null and promotionDocumentNumber !='' ">
             #{promotionDocumentNumber},
        </if>
        <if test="couponCode !=null and couponCode !='' ">
             #{couponCode},
        </if>
        <if test="couponAllocationAmount !=null and couponAllocationAmount !='' ">
             #{couponAllocationAmount},
        </if>
        <if test="costRecoveryType !=null and costRecoveryType !='' ">
             #{costRecoveryType},
        </if>
        <if test="rebateUnitPrice !=null and rebateUnitPrice !='' ">
             #{rebateUnitPrice},
        </if>
        <if test="rebateAgreementNumber !=null and rebateAgreementNumber !='' ">
             #{rebateAgreementNumber},
        </if>
        <if test="rebateSupplier !=null and rebateSupplier !='' ">
             #{rebateSupplier},
        </if>
        <if test="estimatedCostUnitPrice !=null and estimatedCostUnitPrice !='' ">
             #{estimatedCostUnitPrice},
        </if>
        <if test="grossProfitUnitPrice !=null and grossProfitUnitPrice !='' ">
             #{grossProfitUnitPrice},
        </if>
        <if test="discountAmount !=null and discountAmount !='' ">
             #{discountAmount},
        </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="singleProductDiscountRemark !=null and singleProductDiscountRemark !='' ">
             #{singleProductDiscountRemark},
        </if>
        <if test="actualPriceRemark !=null and actualPriceRemark !='' ">
             #{actualPriceRemark},
        </if>
        <if test="entireOrderDiscountRemark !=null and entireOrderDiscountRemark !='' ">
             #{entireOrderDiscountRemark},
        </if>
        <if test="orderRemark !=null and orderRemark !='' ">
             #{orderRemark},
        </if>
        </trim>

    </insert>

</mapper>
