<?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.web.modules.order.mapper.BizOrderLogisticsTraceMapper">

    <resultMap id="BizOrderLogisticsTraceResult" type="com.ruoyi.web.modules.order.domain.BizOrderLogisticsTrace">
        <id property="traceId" column="trace_id"/>
        <result property="orderId" column="order_id"/>
        <result property="traceType" column="trace_type"/>
        <result property="traceTime" column="trace_time"/>
        <result property="content" column="content"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <select id="selectByOrderId" resultMap="BizOrderLogisticsTraceResult">
        select trace_id, order_id, trace_type, trace_time, content, create_by, create_time
        from biz_order_logistics_trace
        where order_id = #{orderId}
        order by trace_time desc, trace_id desc
    </select>

    <select id="selectLatestByOrderId" resultMap="BizOrderLogisticsTraceResult">
        select trace_id, order_id, trace_type, trace_time, content, create_by, create_time
        from biz_order_logistics_trace
        where order_id = #{orderId}
        order by trace_time desc, trace_id desc
        limit 1
    </select>

    <insert id="insertTrace" parameterType="com.ruoyi.web.modules.order.domain.BizOrderLogisticsTrace"
            useGeneratedKeys="true" keyProperty="traceId">
        insert into biz_order_logistics_trace (
            order_id, trace_type, trace_time, content, create_by, create_time
        ) values (
            #{orderId}, #{traceType}, #{traceTime}, #{content}, #{createBy}, now()
        )
    </insert>
</mapper>
