<?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.TqPriceDetailMapper">

    <resultMap type="TqPriceDetail" id="TqPriceDetailResult">
        <result property="id" column="id"/>
        <result property="specificationId" column="specification_id"/>
        <result property="markupKey" column="markup_key"/>
        <result property="markupName" column="markup_name"/>
        <result property="relatedParaInfo" column="related_para_info"/>
        <result property="quantity" column="quantity"/>
        <result property="unit" column="unit"/>
        <result property="buyerPrice" column="buyer_price"/>
        <result property="floatPercent" column="float_percent"/>
        <result property="treasurerPrice" column="treasurer_price"/>
        <result property="price" column="price"/>
        <result property="total" column="total"/>
        <result property="systemCheckResult" column="system_check_result"/>
        <result property="nonStandardReason" column="non_standard_reason"/>
        <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"/>
        <result property="solution" column="solution"/>
    </resultMap>

    <resultMap type="com.ruoyi.project.business.domain.vo.quotation.PriceDetailVO" id="TqPriceDetailVOResult">
        <result property="id" column="id"/>
        <result property="specificationId" column="specification_id"/>
        <result property="markupKey" column="markup_key"/>
        <result property="markupName" column="markup_name"/>
        <result property="relatedParaInfo" column="related_para_info"/>
        <result property="quantity" column="quantity"/>
        <result property="unit" column="unit"/>
        <result property="buyerPrice" column="buyer_price"/>
        <result property="floatPercent" column="float_percent"/>
        <result property="treasurerPrice" column="treasurer_price"/>
        <result property="price" column="price"/>
        <result property="total" column="total"/>
        <result property="systemCheckResult" column="system_check_result"/>
        <result property="nonStandardReason" column="non_standard_reason"/>
        <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"/>
        <result property="solution" column="solution"/>
    </resultMap>

    <sql id="selectTqPriceDetailVo">
        select id,
               specification_id,
               markup_key,
               markup_name,
               related_para_info,
               quantity,
               unit,
               buyer_price,
               float_percent,
               treasurer_price,
               price,
               total,
               system_check_result,
               non_standard_reason,
               del_flag,
               create_time,
               create_by,
               update_time,
               update_by,
               remark,
               solution
        from tq_price_detail
    </sql>

    <select id="selectTqPriceDetailList" parameterType="TqPriceDetail" resultMap="TqPriceDetailResult">
        <include refid="selectTqPriceDetailVo"/>
        <where>
            <if test="specificationId != null ">and specification_id = #{specificationId}</if>
            <if test="markupKey != null  and markupKey != ''">and markup_key = #{markupKey}</if>
            <if test="markupName != null  and markupName != ''">and markup_name like concat('%', #{markupName}, '%')
            </if>
            <if test="relatedParaInfo != null  and relatedParaInfo != ''">and related_para_info = #{relatedParaInfo}
            </if>
            <if test="quantity != null ">and quantity = #{quantity}</if>
            <if test="unit != null  and unit != ''">and unit = #{unit}</if>
            <if test="buyerPrice != null ">and buyer_price = #{buyerPrice}</if>
            <if test="floatPercent != null ">and float_percent = #{floatPercent}</if>
            <if test="treasurerPrice != null ">and treasurer_price = #{treasurerPrice}</if>
            <if test="price != null ">and price = #{price}</if>
            <if test="total != null ">and total = #{total}</if>
            <if test="systemCheckResult != null  and systemCheckResult != ''">and system_check_result =
                #{systemCheckResult}
            </if>
            <if test="nonStandardReason != null  and nonStandardReason != ''">and non_standard_reason =
                #{nonStandardReason}
            </if>
        </where>
    </select>

    <select id="listAll" parameterType="TqPriceDetail" resultMap="TqPriceDetailVOResult">
        <include refid="selectTqPriceDetailVo"/>
        <where>
            <if test="specificationId != null ">and specification_id = #{specificationId}</if>
            <if test="systemCheckResult != null ">and system_check_result = #{systemCheckResult}</if>
        </where>
    </select>

    <select id="selectTqPriceDetailById" parameterType="Long" resultMap="TqPriceDetailResult">
        <include refid="selectTqPriceDetailVo"/>
        where id = #{id}
    </select>

    <insert id="insertTqPriceDetail" parameterType="TqPriceDetail" useGeneratedKeys="true" keyProperty="id">
        insert into tq_price_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="specificationId != null">specification_id,</if>
            <if test="markupKey != null">markup_key,</if>
            <if test="markupName != null">markup_name,</if>
            <if test="relatedParaInfo != null">related_para_info,</if>
            <if test="quantity != null">quantity,</if>
            <if test="unit != null">unit,</if>
            <if test="buyerPrice != null">buyer_price,</if>
            <if test="floatPercent != null">float_percent,</if>
            <if test="treasurerPrice != null">treasurer_price,</if>
            <if test="price != null">price,</if>
            <if test="total != null">total,</if>
            <if test="systemCheckResult != null">system_check_result,</if>
            <if test="nonStandardReason != null">non_standard_reason,</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="specificationId != null">#{specificationId},</if>
            <if test="markupKey != null">#{markupKey},</if>
            <if test="markupName != null">#{markupName},</if>
            <if test="relatedParaInfo != null">#{relatedParaInfo},</if>
            <if test="quantity != null">#{quantity},</if>
            <if test="unit != null">#{unit},</if>
            <if test="buyerPrice != null">#{buyerPrice},</if>
            <if test="floatPercent != null">#{floatPercent},</if>
            <if test="treasurerPrice != null">#{treasurerPrice},</if>
            <if test="price != null">#{price},</if>
            <if test="total != null">#{total},</if>
            <if test="systemCheckResult != null">#{systemCheckResult},</if>
            <if test="nonStandardReason != null">#{nonStandardReason},</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="updateTqPriceDetail" parameterType="TqPriceDetail">
        update tq_price_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="specificationId != null">specification_id = #{specificationId},</if>
            <if test="markupKey != null">markup_key = #{markupKey},</if>
            <if test="markupName != null">markup_name = #{markupName},</if>
            <if test="relatedParaInfo != null">related_para_info = #{relatedParaInfo},</if>
            <if test="quantity != null">quantity = #{quantity},</if>
            <if test="unit != null">unit = #{unit},</if>
            <if test="buyerPrice != null">buyer_price = #{buyerPrice},</if>
            <if test="floatPercent != null">float_percent = #{floatPercent},</if>
            <if test="treasurerPrice != null">treasurer_price = #{treasurerPrice},</if>
            <if test="price != null">price = #{price},</if>
            <if test="total != null">total = #{total},</if>
            <if test="systemCheckResult != null">system_check_result = #{systemCheckResult},</if>
            <if test="nonStandardReason != null">non_standard_reason = #{nonStandardReason},</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="deleteTqPriceDetailById" parameterType="Long">
        delete
        from tq_price_detail
        where id = #{id}
    </delete>

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