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

    <select id="selectSXsglReturnproductinfoList" parameterType="pd" resultType="pd">
        select * from s_xsgl_returnproductinfo where 1=1
        <if test="productCode !=null and productCode !='' ">
            and productCode = #{productCode}
        </if>
        <if test="genericName !=null and genericName !='' ">
            and genericName = #{genericName}
        </if>
        <if test="specification !=null and specification !='' ">
            and specification = #{specification}
        </if>
        <if test="unit !=null and unit !='' ">
            and unit = #{unit}
        </if>
        <if test="salesperson !=null and salesperson !='' ">
            and salesperson = #{salesperson}
        </if>
        <if test="returnQuantity !=null and returnQuantity !='' ">
            and returnQuantity = #{returnQuantity}
        </if>
        <if test="refundAmount !=null and refundAmount !='' ">
            and refundAmount = #{refundAmount}
        </if>
        <if test="productionBatchNumber !=null and productionBatchNumber !='' ">
            and productionBatchNumber = #{productionBatchNumber}
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
            and manufacturer = #{manufacturer}
        </if>
        <if test="origin !=null and origin !='' ">
            and origin = #{origin}
        </if>
    </select>


    <update id="updateSXsglReturnproductinfo" parameterType="pd" >
        update s_xsgl_returnproductinfo
        <trim prefix=" SET " suffix="" prefixOverrides="," suffixOverrides=",">
        <if test="productCode !=null and productCode !='' ">
            productCode = #{productCode},
        </if>
        <if test="genericName !=null and genericName !='' ">
            genericName = #{genericName},
        </if>
        <if test="specification !=null and specification !='' ">
            specification = #{specification},
        </if>
        <if test="unit !=null and unit !='' ">
            unit = #{unit},
        </if>
        <if test="salesperson !=null and salesperson !='' ">
            salesperson = #{salesperson},
        </if>
        <if test="returnQuantity !=null and returnQuantity !='' ">
            returnQuantity = #{returnQuantity},
        </if>
        <if test="refundAmount !=null and refundAmount !='' ">
            refundAmount = #{refundAmount},
        </if>
        <if test="productionBatchNumber !=null and productionBatchNumber !='' ">
            productionBatchNumber = #{productionBatchNumber},
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
            manufacturer = #{manufacturer},
        </if>
        <if test="origin !=null and origin !='' ">
            origin = #{origin},
        </if>
        </trim>
        <if test="up != null and up!=''">
            <if test="id != null and id!=''">
                where id=#{id}
            </if>
        </if>
    </update>

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

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

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

        <if test="productCode !=null and productCode !='' ">
            productCode,
        </if>
        <if test="genericName !=null and genericName !='' ">
            genericName,
        </if>
        <if test="specification !=null and specification !='' ">
            specification,
        </if>
        <if test="unit !=null and unit !='' ">
            unit,
        </if>
        <if test="salesperson !=null and salesperson !='' ">
            salesperson,
        </if>
        <if test="returnQuantity !=null and returnQuantity !='' ">
            returnQuantity,
        </if>
        <if test="refundAmount !=null and refundAmount !='' ">
            refundAmount,
        </if>
        <if test="productionBatchNumber !=null and productionBatchNumber !='' ">
            productionBatchNumber,
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
            manufacturer,
        </if>
        <if test="origin !=null and origin !='' ">
            origin,
        </if>
        </trim>
        <trim prefix=" VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
        <if test="productCode !=null and productCode !='' ">
             #{productCode},
        </if>
        <if test="genericName !=null and genericName !='' ">
             #{genericName},
        </if>
        <if test="specification !=null and specification !='' ">
             #{specification},
        </if>
        <if test="unit !=null and unit !='' ">
             #{unit},
        </if>
        <if test="salesperson !=null and salesperson !='' ">
             #{salesperson},
        </if>
        <if test="returnQuantity !=null and returnQuantity !='' ">
             #{returnQuantity},
        </if>
        <if test="refundAmount !=null and refundAmount !='' ">
             #{refundAmount},
        </if>
        <if test="productionBatchNumber !=null and productionBatchNumber !='' ">
             #{productionBatchNumber},
        </if>
        <if test="manufacturer !=null and manufacturer !='' ">
             #{manufacturer},
        </if>
        <if test="origin !=null and origin !='' ">
             #{origin},
        </if>
        </trim>

    </insert>

</mapper>
