<?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.quotation.mapper.TSeapriceitemMapper">

    <resultMap type="TSeapriceitem" id="TSeapriceitemResult">
        <result property="fId" column="f_id"/>
        <result property="fPid" column="f_pid"/>
        <result property="fFeeid" column="f_feeid"/>
        <result property="fSpecification1" column="f_specification1"/>
        <result property="fSpecification2" column="f_specification2"/>
        <result property="fSpecification3" column="f_specification3"/>
        <result property="fSpecification4" column="f_specification4"/>
        <result property="fSpecification5" column="f_specification5"/>
        <result property="fSpecification6" column="f_specification6"/>
        <result property="fExrate" column="f_exrate"/>
        <result property="fUnitprice" column="f_unitprice"/>
        <result property="fType" column="f_type"/>
        <result property="fBillstatus" column="f_billstatus"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectTSeapriceitemVo">
        select s.f_id,
               s.f_pid,
               s.f_feeid,
               s.f_specification1,
               s.f_specification2,
               s.f_specification3,
               s.f_specification4,
               s.f_specification5,
               s.f_specification6,
               s.f_exrate,
               s.f_unitprice,
               s.f_type,
               s.f_billstatus,
               s.del_flag,
               s.create_by,
               s.create_time,
               s.update_by,
               s.update_time,
               s.remark,
               f.f_name
        from t_seapriceitem s
left join t_fees f on s.f_feeid = f.f_id
    </sql>

    <select id="selectTSeapriceitemList" parameterType="TSeapriceitem" resultMap="TSeapriceitemResult">
        <include refid="selectTSeapriceitemVo"/>
        <where>
            <if test="fPid != null ">and s.f_pid = #{fPid}</if>
            <if test="fFeeid != null ">and s.f_feeid = #{fFeeid}</if>
            <if test="fSpecification1 != null ">and s.f_specification1 = #{fSpecification1}</if>
            <if test="fSpecification2 != null ">and s.f_specification2 = #{fSpecification2}</if>
            <if test="fSpecification3 != null ">and s.f_specification3 = #{fSpecification3}</if>
            <if test="fSpecification4 != null ">and s.f_specification4 = #{fSpecification4}</if>
            <if test="fSpecification5 != null ">and s.f_specification5 = #{fSpecification5}</if>
            <if test="fSpecification6 != null ">and s.f_specification6 = #{fSpecification6}</if>
            <if test="fExrate != null ">and s.f_exrate = #{fExrate}</if>
            <if test="fUnitprice != null ">and s.f_unitprice = #{fUnitprice}</if>
            <if test="fType != null  and fType != ''">and s.f_type = #{fType}</if>
            <if test="fBillstatus != null ">and s.f_billstatus = #{fBillstatus}</if>
        </where>
    </select>

    <select id="selectTSeapriceitemListApp" parameterType="TSeapriceitem" resultMap="TSeapriceitemResult">
        <include refid="selectTSeapriceitemVo"/>
        <where>
            <if test="fPid != null ">and s.f_pid = #{fPid}</if>
            <if test="fFeeid != null ">and s.f_feeid = #{fFeeid}</if>
            <if test="fSpecification1 != null ">and s.f_specification1 = #{fSpecification1}</if>
            <if test="fSpecification2 != null ">and s.f_specification2 = #{fSpecification2}</if>
            <if test="fSpecification3 != null ">and s.f_specification3 = #{fSpecification3}</if>
            <if test="fSpecification4 != null ">and s.f_specification4 = #{fSpecification4}</if>
            <if test="fSpecification5 != null ">and s.f_specification5 = #{fSpecification5}</if>
            <if test="fSpecification6 != null ">and s.f_specification6 = #{fSpecification6}</if>
            <if test="fExrate != null ">and s.f_exrate = #{fExrate}</if>
            <if test="fUnitprice != null ">and s.f_unitprice = #{fUnitprice}</if>
            <if test="fType != null  and fType != ''">and s.f_type = #{fType}</if>
            <if test="fBillstatus != null ">and s.f_billstatus = #{fBillstatus}</if>
            and f.f_name = '海运费'
        </where>
    </select>

    <select id="selectTSeapriceitemById" parameterType="Long" resultMap="TSeapriceitemResult">
        <include refid="selectTSeapriceitemVo"/>
        where s.f_id = #{fId}
    </select>

    <insert id="insertTSeapriceitem" parameterType="TSeapriceitem" useGeneratedKeys="true" keyProperty="fId">
        insert into t_seapriceitem
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fPid != null">f_pid,</if>
            <if test="fFeeid != null">f_feeid,</if>
            <if test="fSpecification1 != null">f_specification1,</if>
            <if test="fSpecification2 != null">f_specification2,</if>
            <if test="fSpecification3 != null">f_specification3,</if>
            <if test="fSpecification4 != null">f_specification4,</if>
            <if test="fSpecification5 != null">f_specification5,</if>
            <if test="fSpecification6 != null">f_specification6,</if>
            <if test="fExrate != null">f_exrate,</if>
            <if test="fUnitprice != null">f_unitprice,</if>
            <if test="fType != null and fType != ''">f_type,</if>
            <if test="fBillstatus != null">f_billstatus,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fPid != null">#{fPid},</if>
            <if test="fFeeid != null">#{fFeeid},</if>
            <if test="fSpecification1 != null">#{fSpecification1},</if>
            <if test="fSpecification2 != null">#{fSpecification2},</if>
            <if test="fSpecification3 != null">#{fSpecification3},</if>
            <if test="fSpecification4 != null">#{fSpecification4},</if>
            <if test="fSpecification5 != null">#{fSpecification5},</if>
            <if test="fSpecification6 != null">#{fSpecification6},</if>
            <if test="fExrate != null">#{fExrate},</if>
            <if test="fUnitprice != null">#{fUnitprice},</if>
            <if test="fType != null and fType != ''">#{fType},</if>
            <if test="fBillstatus != null">#{fBillstatus},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateTSeapriceitem" parameterType="TSeapriceitem">
        update t_seapriceitem
        <trim prefix="SET" suffixOverrides=",">
            <if test="fPid != null">f_pid = #{fPid},</if>
            <if test="fFeeid != null">f_feeid = #{fFeeid},</if>
            <if test="fSpecification1 != null">f_specification1 = #{fSpecification1},</if>
            <if test="fSpecification2 != null">f_specification2 = #{fSpecification2},</if>
            <if test="fSpecification3 != null">f_specification3 = #{fSpecification3},</if>
            <if test="fSpecification4 != null">f_specification4 = #{fSpecification4},</if>
            <if test="fSpecification5 != null">f_specification5 = #{fSpecification5},</if>
            <if test="fSpecification6 != null">f_specification6 = #{fSpecification6},</if>
            <if test="fExrate != null">f_exrate = #{fExrate},</if>
            <if test="fUnitprice != null">f_unitprice = #{fUnitprice},</if>
            <if test="fType != null and fType != ''">f_type = #{fType},</if>
            <if test="fBillstatus != null">f_billstatus = #{fBillstatus},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where f_id = #{fId}
    </update>

    <delete id="deleteTSeapriceitemById" parameterType="Long">
        delete
        from t_seapriceitem
        where f_id = #{fId}
    </delete>

    <delete id="deleteTSeapriceitemByIds" parameterType="String">
        delete from t_seapriceitem where f_id in
        <foreach item="fId" collection="array" open="(" separator="," close=")">
            #{fId}
        </foreach>
    </delete>

    <delete id="deleteTSeapriceitemByfPid" parameterType="Long">
        delete
        from t_seapriceitem
        where f_pid = #{fPid}
    </delete>

</mapper>