<?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.history.HistoryDataItemBatchingDao">
    <resultMap id="ResultMap" type="com.zm.order.tool.server.model.OrderItemBatching">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="seller_id" jdbcType="BIGINT" property="sellerId"/>
        <result column="store_id" jdbcType="BIGINT" property="storeId"/>
        <result column="user_id" jdbcType="BIGINT" property="userId"/>
        <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
        <result column="batching_id" jdbcType="VARCHAR" property="batchingId"/>
        <result column="batching_name" jdbcType="VARCHAR" property="batchingName"/>
        <result column="code" jdbcType="VARCHAR" property="code"/>
        <result column="num" jdbcType="INTEGER" property="num"/>
        <result column="price" jdbcType="DECIMAL" property="price"/>
        <result column="order_item_id" jdbcType="BIGINT" property="orderItemId"/>
        <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="features" jdbcType="VARCHAR" property="features"/>
    </resultMap>

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

    <sql id="cols_all">
        id
        ,
		seller_id,
		store_id,
		user_id,
		order_no,
		batching_id,
		batching_name,
		code,
		num,
		price,
		order_item_id,
		created_at,
		updated_at,
		is_deleted,
		features
    </sql>

    <select id="selectByOrderNo" parameterType="map" resultMap="ResultMap">
        SELECT
        <include refid="cols_all"/>
        FROM
        <include refid="tb"/>
        <where>
            user_id = #{userId} and order_no = #{orderNo} and is_deleted = 0
        </where>
        limit 100
    </select>


    <select id="selectByOrderNoList" parameterType="map" resultMap="ResultMap">
        SELECT
        <include refid="cols_all"/>
        FROM
        <include refid="tb"/>
        <where>
            user_id = #{userId}
            and order_no in
            <foreach collection="orderNoList" item="orderNo" index="index" open="(" close=")" separator=",">
                #{orderNo}
            </foreach>
            and is_deleted = 0
        </where>
    </select>

</mapper>