<?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="com.ruoyi.project.business.mapper.quotation.TqSalespersonSetPriceMapper">

    <resultMap type="TqSalespersonSetPrice" id="TqSalespersonSetPriceResult">
        <result property="id" column="id"/>
        <result property="bargainId" column="bargain_id"/>
        <result property="specificationId" column="specification_id"/>
        <result property="basicPrice" column="basic_price"/>
        <result property="optionalPrice" column="optional_price"/>
        <result property="discountRate" column="discount_rate"/>
        <result property="discountbasicPrice" column="discountbasic_price"/>
        <result property="discountPrice" column="discount_price"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createTime" column="create_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectTqSalespersonSetPriceVo">
        select id,
               bargin_id,
               specification_id,
               basic_price,
               optional_price,
               discount_rate,
               discountbasic_price,
               discount_price,
               del_flag,
               create_time,
               create_by,
               update_time,
               update_by,
               remark
        from tq_salesperson_set_price
    </sql>

    <select id="selectTqSalespersonSetPriceList" parameterType="TqSalespersonSetPrice"
        resultMap="TqSalespersonSetPriceResult">
        <include refid="selectTqSalespersonSetPriceVo"/>
        <where>
            <if test="bargainId != null ">and bargin_id = #{bargainId}</if>
            <if test="specificationId != null ">and specification_id = #{specificationId}</if>
            <if test="basicPrice != null ">and basic_price = #{basicPrice}</if>
            <if test="optionalPrice != null ">and optional_price = #{optionalPrice}</if>
            <if test="discountRate != null ">and discount_rate = #{discountRate}</if>
            <if test="discountbasicPrice != null ">and discountbasic_price = #{discountbasicPrice}</if>
            <if test="discountPrice != null ">and discount_price = #{discountPrice}</if>
        </where>
    </select>

    <select id="selectTqSalespersonSetPriceById" parameterType="Long" resultMap="TqSalespersonSetPriceResult">
        <include refid="selectTqSalespersonSetPriceVo"/>
        where id = #{id}
    </select>

    <insert id="insertTqSalespersonSetPrice" parameterType="TqSalespersonSetPrice" useGeneratedKeys="true"
        keyProperty="id">
        insert into tq_salesperson_set_price
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="bargainId != null">bargain_id,</if>
            <if test="specificationId != null">specification_id,</if>
            <if test="basicPrice != null">basic_price,</if>
            <if test="optionalPrice != null">optional_price,</if>
            <if test="discountRate != null">discount_rate,</if>
            <if test="discountbasicPrice != null">discountbasic_price,</if>
            <if test="discountPrice != null">discount_price,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="bargainId != null">#{bargainId},</if>
            <if test="specificationId != null">#{specificationId},</if>
            <if test="basicPrice != null">#{basicPrice},</if>
            <if test="optionalPrice != null">#{optionalPrice},</if>
            <if test="discountRate != null">#{discountRate},</if>
            <if test="discountbasicPrice != null">#{discountbasicPrice},</if>
            <if test="discountPrice != null">#{discountPrice},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateTqSalespersonSetPrice" parameterType="TqSalespersonSetPrice">
        update tq_salesperson_set_price
        <trim prefix="SET" suffixOverrides=",">
            <if test="bargainId != null">bargin_id = #{bargainId},</if>
            <if test="specificationId != null">specification_id = #{specificationId},</if>
            <if test="basicPrice != null">basic_price = #{basicPrice},</if>
            <if test="optionalPrice != null">optional_price = #{optionalPrice},</if>
            <if test="discountRate != null">discount_rate = #{discountRate},</if>
            <if test="discountbasicPrice != null">discountbasic_price = #{discountbasicPrice},</if>
            <if test="discountPrice != null">discount_price = #{discountPrice},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTqSalespersonSetPriceById" parameterType="Long">
        delete
        from tq_salesperson_set_price
        where id = #{id}
    </delete>

    <delete id="deleteTqSalespersonSetPriceByIds" parameterType="String">
        delete from tq_salesperson_set_price where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>