<?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.TempOrderOperationDao">

    <resultMap id="OrderOperationMap" type="com.zm.order.tool.server.model.TempOrderOperation">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="user_id" jdbcType="BIGINT" property="userId"/>
        <result column="seller_id" jdbcType="BIGINT" property="sellerId"/>
        <result column="store_id" jdbcType="BIGINT" property="storeId"/>
        <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
        <result column="role" jdbcType="INTEGER" property="role"/>
        <result column="operator" jdbcType="BIGINT" property="operator"/>
        <result column="before_status" jdbcType="INTEGER" property="beforeStatus"/>
        <result column="operation" jdbcType="VARCHAR" property="operation"/>
        <result column="after_status" jdbcType="INTEGER" property="afterStatus"/>
        <result column="operate_at" jdbcType="TIMESTAMP" property="operateAt"/>
        <result column="features" jdbcType="VARCHAR" property="features"/>
        <result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
        <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt"/>
        <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
        <result column="data_source_type" jdbcType="INTEGER" property="dataSourceType"/>
    </resultMap>


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

    <sql id="cols_all">
        id,
        <include refid="cols_exclude_id"/>
    </sql>

    <sql id="cols_exclude_id">
       user_id, order_no, role, operator, before_status, operation, after_status, operate_at,
        features, created_at, updated_at, is_deleted, data_source_type, seller_id, store_id
    </sql>

    <sql id="values">
        #{id}, #{userId}, #{orderNo}, #{role}, #{operator},
        #{beforeStatus}, #{operation}, #{afterStatus}, #{operateAt},
        #{features}, now(), now(), 0, #{dataSourceType}, #{sellerId}, #{storeId}
  </sql>


    <insert id="insertList" parameterType="list" >
        insert into
        <include refid="tb"/>
        (<include refid="cols_all"/>)
        values
        <foreach collection="list" item="record" index="index" separator=",">
            (
            #{record.id}, #{record.userId}, #{record.orderNo}, #{record.role}, #{record.operator},
            #{record.beforeStatus}, #{record.operation}, #{record.afterStatus}, #{record.operateAt},
            #{record.features}, now(), now(), 0, #{record.dataSourceType}, #{record.sellerId}, #{record.storeId}
            )
        </foreach>
    </insert>
</mapper>