<?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.frequency.mallorderstatus.mapper.MallOrderStatusMapper">

    <resultMap type="com.ruoyi.frequency.mallorderstatus.entity.MallOrderStatus" id="MallOrderStatusResult">
        <result property="id"    column="id"    />
        <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="delFlag"    column="del_flag"    />
        <result property="orderId"    column="order_id"    />
        <result property="orderType"    column="order_type"    />
        <result property="status"    column="status"    />
        <result property="name"    column="name"    />
        </resultMap>

    
    
    <sql id="selectMallOrderStatusVo">
        select
            t.id ,
            t.create_by ,
            t.create_time ,
            t.update_by ,
            t.update_time ,
            t.del_flag ,
            t.order_id ,
            t.order_type ,
            t.status ,
            t.name 
        from mall_order_status AS t
                
    </sql>

    <select id="selectMallOrderStatusList" parameterType="com.ruoyi.frequency.mallorderstatus.entity.MallOrderStatus" resultMap="MallOrderStatusResult">
        <include refid="selectMallOrderStatusVo"/>
        <where> AND t.del_flag != 2
            <if test="orderId != null "> and t.order_id = #{orderId}</if>
            <if test="orderType != null "> and t.order_type = #{orderType}</if>
            <if test="status != null "> and t.status = #{status}</if>
            <if test="name != null  and name != ''"> and t.name like concat('%', #{name}, '%')</if>
            <if test="delFlag != null and delFlag != ''"> and t.del_flag = #{delFlag}</if>
        </where>
        order by t.create_time desc
    </select>

    <select id="selectMallOrderStatusById" parameterType="Long" resultMap="MallOrderStatusResult">
        <include refid="selectMallOrderStatusVo"/>
        where t.id = #{id}
    </select>

    <insert id="insertMallOrderStatus" parameterType="com.ruoyi.frequency.mallorderstatus.entity.MallOrderStatus">
        insert into mall_order_status
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</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="delFlag != null">del_flag,</if>
            <if test="orderId != null">order_id,</if>
            <if test="orderType != null">order_type,</if>
            <if test="status != null">status,</if>
            <if test="name != null">name,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</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="delFlag != null">#{delFlag},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="orderType != null">#{orderType},</if>
            <if test="status != null">#{status},</if>
            <if test="name != null">#{name},</if>
        </trim>
    </insert>

    <update id="updateMallOrderStatus" parameterType="com.ruoyi.frequency.mallorderstatus.entity.MallOrderStatus">
        update mall_order_status
        <trim prefix="SET" suffixOverrides=",">
            <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="delFlag != null">del_flag = #{delFlag},</if>
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="orderType != null">order_type = #{orderType},</if>
            <if test="status != null">status = #{status},</if>
            <if test="name != null">name = #{name},</if>
        </trim>
        where id = #{id}
    </update>
                                                                                                                        </mapper>