<?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.logistics.mapper.BizFinancialFeeItemsMapper">
    
    <resultMap type="com.ruoyi.logistics.domain.BizFinancialFeeItems" id="BizFinancialFeeItemsResult">
        <result property="feeItemId"    column="fee_item_id"    />
        <result property="feeItemCode"    column="fee_item_code"    />
        <result property="feeItemName"    column="fee_item_name"    />
        <result property="feeItemCategory"    column="fee_item_category"    />
        <result property="extFeeCode"    column="ext_fee_code"    />
        <result property="extFeeName"    column="ext_fee_name"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="deptId"    column="dept_id"    />
        <result property="userId"    column="user_id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>

    <sql id="selectBizFinancialFeeItemsVo">
        select fee_item_id, fee_item_code, fee_item_name, fee_item_category, ext_fee_code, ext_fee_name, create_time, update_time, remark, dept_id, user_id, del_flag, create_by, update_by from biz_financial_fee_items
    </sql>

    <select id="selectBizFinancialFeeItemsList" parameterType="com.ruoyi.logistics.domain.BizFinancialFeeItems" resultMap="BizFinancialFeeItemsResult">
        <include refid="selectBizFinancialFeeItemsVo"/>
        <where>  
            <if test="feeItemCode != null  and feeItemCode != ''"> and fee_item_code = #{feeItemCode}</if>
            <if test="feeItemName != null  and feeItemName != ''"> and fee_item_name like concat('%', #{feeItemName}, '%')</if>
            <if test="feeItemCategory != null  and feeItemCategory != ''"> and fee_item_category = #{feeItemCategory}</if>
            <if test="extFeeCode != null  and extFeeCode != ''"> and ext_fee_code = #{extFeeCode}</if>
            <if test="extFeeName != null  and extFeeName != ''"> and ext_fee_name like concat('%', #{extFeeName}, '%')</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
        </where>
         order by create_time desc
    </select>
    
    <select id="selectBizFinancialFeeItemsByFeeItemId" parameterType="Long" resultMap="BizFinancialFeeItemsResult">
        <include refid="selectBizFinancialFeeItemsVo"/>
        where fee_item_id = #{feeItemId}
    </select>

    <insert id="insertBizFinancialFeeItems" parameterType="com.ruoyi.logistics.domain.BizFinancialFeeItems" useGeneratedKeys="true" keyProperty="feeItemId">
        insert into biz_financial_fee_items
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="feeItemCode != null">fee_item_code,</if>
            <if test="feeItemName != null">fee_item_name,</if>
            <if test="feeItemCategory != null">fee_item_category,</if>
            <if test="extFeeCode != null">ext_fee_code,</if>
            <if test="extFeeName != null">ext_fee_name,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="feeItemCode != null">#{feeItemCode},</if>
            <if test="feeItemName != null">#{feeItemName},</if>
            <if test="feeItemCategory != null">#{feeItemCategory},</if>
            <if test="extFeeCode != null">#{extFeeCode},</if>
            <if test="extFeeName != null">#{extFeeName},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
         </trim>
    </insert>

    <update id="updateBizFinancialFeeItems" parameterType="com.ruoyi.logistics.domain.BizFinancialFeeItems">
        update biz_financial_fee_items
        <trim prefix="SET" suffixOverrides=",">
            <if test="feeItemCode != null">fee_item_code = #{feeItemCode},</if>
            <if test="feeItemName != null">fee_item_name = #{feeItemName},</if>
            <if test="feeItemCategory != null">fee_item_category = #{feeItemCategory},</if>
            <if test="extFeeCode != null">ext_fee_code = #{extFeeCode},</if>
            <if test="extFeeName != null">ext_fee_name = #{extFeeName},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where fee_item_id = #{feeItemId}
    </update>

    <delete id="deleteBizFinancialFeeItemsByFeeItemId" parameterType="Long">
        delete from biz_financial_fee_items where fee_item_id = #{feeItemId}
    </delete>

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