<?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.jarvis.mapper.ErpGoofishOrderEventLogMapper">

    <resultMap id="ErpGoofishOrderEventLogResult" type="com.ruoyi.jarvis.domain.ErpGoofishOrderEventLog">
        <id property="id" column="id"/>
        <result property="orderId" column="order_id"/>
        <result property="appKey" column="app_key"/>
        <result property="orderNo" column="order_no"/>
        <result property="eventType" column="event_type"/>
        <result property="source" column="source"/>
        <result property="message" column="message"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <insert id="insert" parameterType="com.ruoyi.jarvis.domain.ErpGoofishOrderEventLog" useGeneratedKeys="true" keyProperty="id">
        insert into erp_goofish_order_event_log
        (order_id, app_key, order_no, event_type, source, message, create_time)
        values
        (#{orderId}, #{appKey}, #{orderNo}, #{eventType}, #{source}, #{message}, #{createTime})
    </insert>

    <select id="selectByOrderId" resultMap="ErpGoofishOrderEventLogResult">
        select id, order_id, app_key, order_no, event_type, source, message, create_time
        from erp_goofish_order_event_log
        where order_id = #{orderId}
        order by id desc
    </select>

    <select id="selectLogList" parameterType="com.ruoyi.jarvis.domain.ErpGoofishOrderEventLogQuery" resultMap="ErpGoofishOrderEventLogResult">
        select id, order_id, app_key, order_no, event_type, source, message, create_time
        from erp_goofish_order_event_log
        <where>
            <if test="orderId != null">and order_id = #{orderId}</if>
            <if test="appKey != null and appKey != ''">and app_key = #{appKey}</if>
            <if test="orderNo != null and orderNo != ''">and order_no like concat('%', #{orderNo}, '%')</if>
            <if test="eventType != null and eventType != ''">and event_type = #{eventType}</if>
            <if test="source != null and source != ''">and source like concat('%', #{source}, '%')</if>
            <if test="messageKeyword != null and messageKeyword != ''">and message like concat('%', #{messageKeyword}, '%')</if>
            <if test="params != null and params.beginTime != null and params.beginTime != ''">
                and create_time &gt;= concat(#{params.beginTime}, ' 00:00:00')
            </if>
            <if test="params != null and params.endTime != null and params.endTime != ''">
                and create_time &lt;= concat(#{params.endTime}, ' 23:59:59')
            </if>
        </where>
        order by id desc
    </select>
</mapper>
