<?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.zm.order.tool.server.tempdb.OrderLogsDao">

    <resultMap id="OrderItemMap" type="com.zm.order.tool.server.model.OrderLogs">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <id column="order_no" jdbcType="VARCHAR" property="orderNo"/>
        <id column="updated_at" jdbcType="TIMESTAMP" property="updatedAt"/>
        <id column="order_at" jdbcType="TIMESTAMP" property="orderAt"/>
        <id column="store_id" jdbcType="INTEGER" property="storeId"/>
        <id column="features" jdbcType="VARCHAR" property="features"/>
        <id column="old_features" jdbcType="VARCHAR" property="oldFeatures"/>
        <id column="seller_id" jdbcType="VARCHAR" property="sellerId"/>
        <id column="status" jdbcType="INTEGER" property="status"/>
    </resultMap>

    <sql id="tb">
        order_20230419
    </sql>

    <sql id="cols_all">
        id,
        order_no,
        seller_id,
        updated_at,
        order_at,
        store_id,
        features,
        status,
        old_features
    </sql>

    <select id="selectList" parameterType="map" resultMap="OrderItemMap">
        select
        <include refid="cols_all"/>
        from
        <include refid="tb"/>
        <where>
            <if test="lastId != null">
                id > #{lastId}
            </if>
        </where>
            order by id asc
    </select>

    <select id="selectByOrderNo" parameterType="map" resultMap="OrderItemMap">
        select
        <include refid="cols_all"/>
        from
        <include refid="tb"/>
        <where>
            order_no = #{orderNo}
        </where>
            order by updated_at asc
    </select>


    <update id="update" parameterType="map">
        update
        <include refid="tb"/>
        <set>
            status = #{status}
        </set>
        where order_no = #{orderNo}
    </update>
</mapper>