<?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.tb.TbRefundDetailDao">
    <resultMap id="ResultMap" type="com.zm.order.tool.server.model.OrderRefundDetails">
		<id column="id" jdbcType="BIGINT" property="id"/>
		<result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
		<result column="refund_no" jdbcType="VARCHAR" property="refundNo"/>
		<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="pay_type" jdbcType="INTEGER" property="payType"/>
		<result column="refund_amount" jdbcType="INTEGER" property="refundAmount"/>
		<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="biz_type" jdbcType="INTEGER" property="bizType"/>
		<result column="features" jdbcType="VARCHAR" property="features"/>
	</resultMap>

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

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

    <sql id="cols_exclude_id">
		order_no,
		refund_no,
		user_id,
		seller_id,
		store_id,
		pay_type,
		refund_amount,
		created_at,
		updated_at,
		is_deleted,
		biz_type,
		features
    </sql>

	<sql id="values">
		#{id,jdbcType=BIGINT},
		#{orderNo,jdbcType=VARCHAR},
		#{refundNo,jdbcType=VARCHAR},
		#{userId,jdbcType=BIGINT},
		#{sellerId,jdbcType=BIGINT},
		#{storeId,jdbcType=BIGINT},
		#{payType,jdbcType=INTEGER},
		#{refundAmount,jdbcType=INTEGER},
		now(),
		now(),
		0,
		#{bizType,jdbcType=INTEGER},
		#{features,jdbcType=VARCHAR}
	</sql>

	<select id="selectId" parameterType="map" resultType="long">
		select
		id
		from
		<include refid="tb"/>
		<where>
			<if test="lastId != null">
				and id > #{lastId}
			</if>
			<if test="maxId != null">
				<![CDATA[ AND id < #{maxId} ]]>
			</if>
			<if test="updatedAtStart != null">
				<![CDATA[ AND updated_at >= #{updatedAtStart} ]]>
			</if>
			<if test="updatedAtEnd != null">
				<![CDATA[ AND updated_at <= #{updatedAtEnd} ]]>
			</if>
		</where>
		order by id
		limit #{size}
	</select>

	<select id="selectById" parameterType="map" resultMap="ResultMap">
		select
		features
		from
		<include refid="tb"/>
		<where>
			id in
			<foreach collection="idList" item="id" index="index" open="(" close=")" separator=",">
				#{id}
			</foreach>
		</where>
	</select>

</mapper>