<?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.fjs.scenic.mapper.order.OrdersMapper">
	<resultMap id="BaseResultMap" type="com.fjs.scenic.entity.order.Orders">
			<id property="id" column="id" javaType="java.lang.Integer" jdbcType="INTEGER" />
			<result property="orderNo" column="order_no" javaType="java.lang.String" jdbcType="VARCHAR" />
			<result property="orderName" column="order_name" javaType="java.lang.String" jdbcType="VARCHAR" />
			<result property="totelPrice" column="totel_price" javaType="java.lang.Integer" jdbcType="INTEGER" />
			<result property="status" column="status" javaType="java.lang.String" jdbcType="VARCHAR" />
			<result property="orderTime" column="order_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
			<result property="userId" column="user_id" javaType="java.lang.Integer" jdbcType="INTEGER" />
			<result property="payTime" column="pay_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
			<result property="playTime" column="play_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
			<result property="refundTime" column="refund_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
			<result property="refundPrice" column="refund_price" javaType="java.lang.Integer" jdbcType="INTEGER" />
			<result property="distOrderNo" column="dist_order_no" javaType="java.lang.String" jdbcType="VARCHAR" />
			<result property="verifyCode" column="verify_code" javaType="java.lang.String" jdbcType="VARCHAR" />
			<result property="buyUserName" column="buy_user_name" javaType="java.lang.String" jdbcType="VARCHAR" />
			<result property="buyIdCard" column="buy_id_card" javaType="java.lang.String" jdbcType="VARCHAR" />
			<result property="buyPhone" column="buy_phone" javaType="java.lang.String" jdbcType="VARCHAR" />
			<result property="distTimeId" column="dist_time_id" javaType="java.lang.Integer" jdbcType="INTEGER" />
			<result property="parkingTime" column="parking_time" javaType="java.lang.String" jdbcType="VARCHAR" />
			<result property="qrcode" column="qrcode" javaType="java.lang.String" jdbcType="VARCHAR" />
	</resultMap>
	<sql id="Base_Column_List">
		id, order_no, order_name, totel_price, status, order_time, user_id, pay_time, play_time,
		refund_time, refund_price, dist_order_no, verify_code, buy_user_name, buy_id_card,
		buy_phone,dist_time_id,parking_time,qrcode
	</sql>
	<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
		select
		<include refid="Base_Column_List" />
		from orders
		where id = #{id,jdbcType=INTEGER}
	</select>
	
	<select id="getOrderByOrderNo" resultMap="BaseResultMap">
		select
		<include refid="Base_Column_List" />
		from orders
		where order_no = #{orderNo}
	</select>
	
	<select id="getCytOrderByOrderNo" resultMap="BaseResultMap">
		select
		<include refid="Base_Column_List" />
		from orders
		where dist_order_no = #{cytOrderNo}
	</select>
	
	<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
		delete from orders
		where id = #{id,jdbcType=INTEGER}
	</delete>
	<insert id="insert" parameterType="com.fjs.scenic.entity.order.Orders">
		insert into orders (id, order_no, order_name,
		totel_price, status, order_time,
		user_id, pay_time, play_time,
		refund_time, refund_price, dist_order_no,
		verify_code, buy_user_name, buy_id_card,
		buy_phone,dist_time_id,parking_time)
		values (#{id,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{orderName,jdbcType=VARCHAR},
		#{totelPrice,jdbcType=INTEGER}, #{status,jdbcType=VARCHAR}, #{orderTime,jdbcType=TIMESTAMP},
		#{userId,jdbcType=INTEGER}, #{payTime,jdbcType=TIMESTAMP}, #{playTime,jdbcType=TIMESTAMP},
		#{refundTime,jdbcType=TIMESTAMP}, #{refundPrice,jdbcType=INTEGER}, #{distOrderNo,jdbcType=VARCHAR},
		#{verifyCode,jdbcType=VARCHAR}, #{buyUserName,jdbcType=VARCHAR}, #{buyIdCard,jdbcType=VARCHAR},
		#{buyPhone,jdbcType=VARCHAR}, #{distTimeId,jdbcType=INTEGER}, #{parkingTime,jdbcType=INTEGER})
	</insert>
	<insert id="insertSelective" parameterType="com.fjs.scenic.entity.order.Orders" useGeneratedKeys="true" keyProperty="id">
		insert into orders
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="id != null">
				id,
			</if>
			<if test="orderNo != null">
				order_no,
			</if>
			<if test="orderName != null">
				order_name,
			</if>
			<if test="totelPrice != null">
				totel_price,
			</if>
			<if test="status != null">
				status,
			</if>
			<if test="orderTime != null">
				order_time,
			</if>
			<if test="userId != null">
				user_id,
			</if>
			<if test="payTime != null">
				pay_time,
			</if>
			<if test="playTime != null">
				play_time,
			</if>
			<if test="refundTime != null">
				refund_time,
			</if>
			<if test="refundPrice != null">
				refund_price,
			</if>
			<if test="distOrderNo != null">
				dist_order_no,
			</if>
			<if test="verifyCode != null">
				verify_code,
			</if>
			<if test="buyUserName != null">
				buy_user_name,
			</if>
			<if test="buyIdCard != null">
				buy_id_card,
			</if>
			<if test="buyPhone != null">
				buy_phone,
			</if>
			<if test="buyPhone != null">
				dist_time_id,
			</if>
			<if test="parkingTime != null">
				parking_time,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="id != null">
				#{id,jdbcType=INTEGER},
			</if>
			<if test="orderNo != null">
				#{orderNo,jdbcType=VARCHAR},
			</if>
			<if test="orderName != null">
				#{orderName,jdbcType=VARCHAR},
			</if>
			<if test="totelPrice != null">
				#{totelPrice,jdbcType=INTEGER},
			</if>
			<if test="status != null">
				#{status,jdbcType=VARCHAR},
			</if>
			<if test="orderTime != null">
				#{orderTime,jdbcType=TIMESTAMP},
			</if>
			<if test="userId != null">
				#{userId,jdbcType=INTEGER},
			</if>
			<if test="payTime != null">
				#{payTime,jdbcType=TIMESTAMP},
			</if>
			<if test="playTime != null">
				#{playTime,jdbcType=TIMESTAMP},
			</if>
			<if test="refundTime != null">
				#{refundTime,jdbcType=TIMESTAMP},
			</if>
			<if test="refundPrice != null">
				#{refundPrice,jdbcType=INTEGER},
			</if>
			<if test="distOrderNo != null">
				#{distOrderNo,jdbcType=VARCHAR},
			</if>
			<if test="verifyCode != null">
				#{verifyCode,jdbcType=VARCHAR},
			</if>
			<if test="buyUserName != null">
				#{buyUserName,jdbcType=VARCHAR},
			</if>
			<if test="buyIdCard != null">
				#{buyIdCard,jdbcType=VARCHAR},
			</if>
			<if test="buyPhone != null">
				#{buyPhone,jdbcType=VARCHAR},
			</if>
			<if test="buyPhone != null">
				#{distTimeId,jdbcType=INTEGER},
			</if>
			<if test="parkingTime != null">
				#{parkingTime,jdbcType=INTEGER},
			</if>
		</trim>
	</insert>
	<update id="updateByPrimaryKeySelective" parameterType="com.fjs.scenic.entity.order.Orders">
		update orders
		<set>
			<if test="orderNo != null">
				order_no = #{orderNo,jdbcType=VARCHAR},
			</if>
			<if test="orderName != null">
				order_name = #{orderName,jdbcType=VARCHAR},
			</if>
			<if test="totelPrice != null">
				totel_price = #{totelPrice,jdbcType=INTEGER},
			</if>
			<if test="status != null">
				status = #{status,jdbcType=VARCHAR},
			</if>
			<if test="orderTime != null">
				order_time = #{orderTime,jdbcType=TIMESTAMP},
			</if>
			<if test="userId != null">
				user_id = #{userId,jdbcType=INTEGER},
			</if>
			<if test="payTime != null">
				pay_time = #{payTime,jdbcType=TIMESTAMP},
			</if>
			<if test="playTime != null">
				play_time = #{playTime,jdbcType=TIMESTAMP},
			</if>
			<if test="refundTime != null">
				refund_time = #{refundTime,jdbcType=TIMESTAMP},
			</if>
			<if test="refundPrice != null">
				refund_price = #{refundPrice,jdbcType=INTEGER},
			</if>
			<if test="distOrderNo != null">
				dist_order_no = #{distOrderNo,jdbcType=VARCHAR},
			</if>
			<if test="verifyCode != null">
				verify_code = #{verifyCode,jdbcType=VARCHAR},
			</if>
			<if test="buyUserName != null">
				buy_user_name = #{buyUserName,jdbcType=VARCHAR},
			</if>
			<if test="buyIdCard != null">
				buy_id_card = #{buyIdCard,jdbcType=VARCHAR},
			</if>
			<if test="buyPhone != null">
				buy_phone = #{buyPhone,jdbcType=VARCHAR},
			</if>
			<if test="distTimeId != null">
				dist_time_id = #{distTimeId,jdbcType=INTEGER},
			</if>
			<if test="parkingTime != null">
				parking_time = #{parkingTime,jdbcType=INTEGER},
			</if>
		</set>
		where id = #{id,jdbcType=INTEGER}
	</update>
	<update id="updateByPrimaryKey" parameterType="com.fjs.scenic.entity.order.Orders">
		update orders
		set order_no = #{orderNo,jdbcType=VARCHAR},
		order_name = #{orderName,jdbcType=VARCHAR},
		totel_price = #{totelPrice,jdbcType=INTEGER},
		status = #{status,jdbcType=VARCHAR},
		order_time = #{orderTime,jdbcType=TIMESTAMP},
		user_id = #{userId,jdbcType=INTEGER},
		pay_time = #{payTime,jdbcType=TIMESTAMP},
		play_time = #{playTime,jdbcType=TIMESTAMP},
		refund_time = #{refundTime,jdbcType=TIMESTAMP},
		refund_price = #{refundPrice,jdbcType=INTEGER},
		dist_order_no = #{distOrderNo,jdbcType=VARCHAR},
		verify_code = #{verifyCode,jdbcType=VARCHAR},
		buy_user_name = #{buyUserName,jdbcType=VARCHAR},
		buy_id_card = #{buyIdCard,jdbcType=VARCHAR},
		buy_phone = #{buyPhone,jdbcType=VARCHAR},
		dist_time_id = #{distTimeId,jdbcType=INTEGER},
		parking_time = #{parkingTime,jdbcType=INTEGER}
		where id = #{id,jdbcType=INTEGER}
	</update>



	<!--自定义-->
	<update id="update" parameterType="com.fjs.scenic.entity.order.Orders">
		update orders
		<set>
			<if test="orderNo != null">
				order_no = #{orderNo,jdbcType=VARCHAR},
			</if>
			<if test="orderName != null">
				order_name = #{orderName,jdbcType=VARCHAR},
			</if>
			<if test="totelPrice != null">
				totel_price = #{totelPrice,jdbcType=INTEGER},
			</if>
			<if test="status != null">
				status = #{status,jdbcType=TINYINT},
			</if>
			<if test="orderTime != null">
				order_time = #{orderTime,jdbcType=TIMESTAMP},
			</if>
			<if test="userId != null">
				user_id = #{userId,jdbcType=INTEGER},
			</if>
			<if test="payTime != null">
				pay_time = #{payTime,jdbcType=TIMESTAMP},
			</if>
			<if test="playTime != null">
				play_time = #{playTime,jdbcType=TIMESTAMP},
			</if>
			<if test="refundTime != null">
				refund_time = #{refundTime,jdbcType=TIMESTAMP},
			</if>
			<if test="refundPrice != null">
				refund_price = #{refundPrice,jdbcType=INTEGER},
			</if>
			<if test="distOrderNo != null">
				dist_order_no = #{distOrderNo,jdbcType=VARCHAR},
			</if>
			<if test="parkingTime != null">
				parking_time = #{parkingTime,jdbcType=VARCHAR},
			</if>
			<if test="qrcode != null">
				qrcode = #{qrcode,jdbcType=VARCHAR},
			</if>
		</set>
		where id = #{id,jdbcType=INTEGER}
	</update>

	<delete id="delete" parameterType="com.fjs.scenic.entity.order.Orders">
		delete from orders where 1=1
		<if test="id != null"> and id = #{id}</if>
		<if test="orderNo != null">
			and order_no = #{orderNo,jdbcType=VARCHAR}
		</if>
		<if test="orderName != null">
			and order_name = #{orderName,jdbcType=VARCHAR}
		</if>
		<if test="totelPrice != null">
			and totel_price = #{totelPrice,jdbcType=INTEGER}
		</if>
		<if test="status != null">
			and status = #{status,jdbcType=TINYINT}
		</if>
		<if test="orderTime != null">
			and order_time = #{orderTime,jdbcType=TIMESTAMP}
		</if>
		<if test="userId != null">
			and user_id = #{userId,jdbcType=INTEGER}
		</if>
		<if test="payTime != null">
			and pay_time = #{payTime,jdbcType=TIMESTAMP}
		</if>
		<if test="playTime != null">
			and play_time = #{playTime,jdbcType=TIMESTAMP}
		</if>
		<if test="refundTime != null">
			and refund_time = #{refundTime,jdbcType=TIMESTAMP}
		</if>
		<if test="refundPrice != null">
			and refund_price = #{refundPrice,jdbcType=INTEGER}
		</if>
		<if test="distOrderNo != null">
			and dist_order_no = #{distOrderNo,jdbcType=VARCHAR}
		</if>
		<if test="parkingTime != null">
			and parking_time = #{parkingTime,jdbcType=INTEGER},
		</if>
	</delete>

	<select id="select" resultType="com.fjs.scenic.entity.order.Orders"
		parameterType="com.fjs.scenic.entity.order.Orders">
		select
		<if test="field != null and field != ''"> ${field}</if>
		<if test="field == null or field == ''"> * </if>
		from
		<if test="param != null and param != ''"> ${param}</if>
		<if test="param == null or param == ''"> orders </if>
		where 1 = 1
		<if test="id != null"> and o.id = #{id}</if>
		<if test="orderNo != null">
			and o.order_no = #{orderNo,jdbcType=VARCHAR}
		</if>
		<if test="orderName != null">
			and o.order_name = #{orderName,jdbcType=VARCHAR}
		</if>
		<if test="totelPrice != null">
			and o.totel_price = #{totelPrice,jdbcType=INTEGER}
		</if>
		<if test="status != null and status != ''">
			and o.status = #{status,jdbcType=TINYINT}
		</if>
		<if test="orderTime != null">
			and o.order_time = #{orderTime,jdbcType=TIMESTAMP}
		</if>
		<if test="userId != null">
			and o.user_id = #{userId,jdbcType=INTEGER}
		</if>
		<if test="payTime != null">
			and o.pay_time = #{payTime,jdbcType=TIMESTAMP}
		</if>
		<if test="playTime != null">
			and o.play_time = #{playTime,jdbcType=TIMESTAMP}
		</if>
		<if test="refundTime != null">
			and o.refund_time = #{refundTime,jdbcType=TIMESTAMP}
		</if>
		<if test="refundPrice != null">
			and o.refund_price = #{refundPrice,jdbcType=INTEGER}
		</if>
		<if test="distOrderNo != null">
			and o.dist_order_no = #{distOrderNo,jdbcType=VARCHAR}
		</if>
		 GROUP BY o.order_no order by order_time desc 
	</select>

	<select id="selectByParam" resultMap="BaseResultMap"
		parameterType="java.util.Map">
		select
		<if test="field != null and field != ''"> ${field}</if>
		<if test="field == null or field == ''"> * </if>
		from orders
		<if test="param != null and param != ''">where ${param}</if>
	</select>
	
	<select id="selectByCount" resultType="com.fjs.scenic.entity.order.OrderNum"
		parameterType="java.util.Map">
		select
		<if test="field != null and field != ''"> ${field}</if>
		from orders
		<if test="param != null and param != ''">where ${param}</if>
	</select>

	<select id="selectByJoin" resultType="com.fjs.scenic.entity.order.Orders"
		parameterType="java.util.Map">
		select
		<if test="field != null and field != ''"> ${field}</if>
		<if test="field == null or field == ''"> * </if>
		from orders
		<if test="param != null and param != ''"> ${param}</if>
	</select>
	
	<select id="selectByOption" resultType="map" parameterType="com.fjs.scenic.dto.OrdersDto">
		SELECT o.id,o.order_no,o.order_name,o.dist_order_no,o.play_time,o.totel_price/100 totel_price,
		u.nick_name,od.num,od.price/100 price,o.order_time,o.`status`,o.pay_time,o.buy_id_card card,o.buy_phone,o.buy_user_name
		 FROM orders o LEFT JOIN order_details od ON o.id=od.order_id INNER JOIN `user` u ON u.id=o.user_id
		 <where>
		 	<if test="status != null and status!='' ">
				and o.`status` = #{status}
			</if>
			<if test="startTime != null ">
				and o.order_time &gt; #{startTime,jdbcType=TIMESTAMP}
			</if>
			<if test="endTime != null ">
				and o.order_time &lt; #{endTime,jdbcType=TIMESTAMP}
			</if>
			<if test="playTimeStartTime != null ">
				and o.play_time &gt; #{playTimeStartTime,jdbcType=TIMESTAMP}
			</if>
			 <if test="playTimeEndTime != null ">
				 and o.play_time &lt; #{playTimeEndTime,jdbcType=TIMESTAMP}
			 </if>
			 <if test="orderNo != null and orderNo!='' ">
				 and o.order_no = #{orderNo,jdbcType=VARCHAR}
			 </if>
			 <if test="distOrderNo != null and distOrderNo!='' ">
				 and o.dist_order_no like concat(concat('%',#{distOrderNo}),'%')
			 </if>
			 <if test="buyIdCard != null and buyIdCard!='' ">
				 and o.buy_id_card like concat(concat('%',#{buyIdCard}),'%')
			 </if>
			 <if test="buyPhone != null and buyPhone!='' ">
				 and o.buy_phone like concat(concat('%',#{buyPhone}),'%')
			 </if>
			 <if test="buyUserName != null and buyUserName!='' ">
				 and o.buy_user_name like concat(concat('%',#{buyUserName}),'%')
			 </if>
			 <if test="startTime != null ">
				 and o.order_time &gt; #{startTime,jdbcType=TIMESTAMP}
			 </if>
			 <if test="endTime != null ">
				 and o.order_time &lt; #{endTime,jdbcType=TIMESTAMP}
			 </if>
		 </where>
       ORDER BY id DESC
	</select>

	<delete id="deleteByParam" parameterType="java.util.Map">
		delete from orders
		<if test="param != null and param != ''">where ${param}</if>
	</delete>

	<update id="updateByParam" parameterType="java.util.Map">
		<if test="param != null and param !=''">update orders set ${param}</if>
	</update>

	<select id="selectByStatus" resultType="com.fjs.scenic.entity.order.Orders">
		SELECT <include refid="Base_Column_List" /> FROM orders
		<where>
			<if test="userId!=null and userId != ''">and user_id = #{userId,jdbcType=INTEGER}</if>
			<if test='type!=null and type == "D"'>and status = 1</if>
			<if test='type!=null and type == "Y"'>and status in (2,3)</if>
			<if test='type!=null and type == "S"'>and status in (9,8)</if>
			<if test='type!=null and type == "T"'>and status in (6,7)</if>
			<if test='type==null or type == ""'>and `status` != 0</if>
			<if test='type!=null and type == "Q"'>and `status` != 0</if>
		</where>
		order by order_time desc
	</select>


	<resultMap id="DetailMap" type="com.fjs.scenic.dto.OrderDetailModel">
		<id property="id" column="id" jdbcType="INTEGER" javaType="java.lang.Integer" />
		<result property="orderNo" column="order_no" jdbcType="VARCHAR" javaType="java.lang.String" />
		<result property="distOrderNo" column="dist_order_no" jdbcType="VARCHAR" javaType="java.lang.String" />
		<result property="payTime" column="pay_time" jdbcType="TIMESTAMP" javaType="java.util.Date"  />
		<result property="orderTime" column="order_time" jdbcType="TIMESTAMP" javaType="java.util.Date"  />
		<result property="playTime" column="play_time" jdbcType="TIMESTAMP" javaType="java.util.Date"  />
		<result property="status" column="status" jdbcType="VARCHAR" javaType="java.lang.String" />
		<result property="totelPrice" column="totel_price" jdbcType="INTEGER" javaType="java.lang.Integer" />
		<result property="buyPhone" column="buy_phone" jdbcType="VARCHAR" javaType="java.lang.String" />
		<result property="goodsName" column="goodName" jdbcType="VARCHAR" javaType="java.lang.String" />
		<result property="price" column="goodPrice" jdbcType="INTEGER" javaType="java.lang.Integer" />
		<result property="num" column="num" jdbcType="INTEGER" javaType="java.lang.Integer" />
		<result property="scenicName" column="scenicName" jdbcType="VARCHAR" javaType="java.lang.String" />
		<result property="addr" column="addr" jdbcType="VARCHAR" javaType="java.lang.String" />
		<result property="parkingTime" column="parking_time" jdbcType="VARCHAR" javaType="java.lang.String" />
		<result property="qrcode" column="qrcode" jdbcType="VARCHAR" javaType="java.lang.String" />
		<collection property="playManList" ofType="com.fjs.scenic.entity.order.PlayMan">
			<id property="id" column="playId" jdbcType="INTEGER" javaType="java.lang.Integer" />
			<result property="name" column="playName" jdbcType="VARCHAR" javaType="java.lang.String" />
			<result property="idCard" column="id_card" jdbcType="VARCHAR" javaType="java.lang.String" />
		</collection>
	</resultMap>

	<select id="selectOrderDetail" resultMap="DetailMap">
		SELECT o.id,o.order_no,o.pay_time,o.play_time,o.status,o.totel_price,o.buy_phone,o.pay_time,o.dist_order_no,o.qrcode,
		g.name goodName,od.price goodPrice,od.num,s.name scenicName,s.addr,o.parking_time,o.order_time,
		p.id playId,p.name playName,p.id_card
		FROM orders o
		LEFT JOIN order_details od ON
		o.id=od.order_id LEFT JOIN goods g
		on od.goods_id=g.resourceId LEFT JOIN scenic s
		on s.id=g.scenic_id LEFT JOIN play_man p
		on p.order_id=o.id
		WHERE o.id=#{id,jdbcType=INTEGER} AND o.user_id=#{userID,jdbcType=INTEGER}
	</select>
	
	<delete id="deleteExpireOrder">
	DELETE FROM orders WHERE order_time &lt; #{orderTime,jdbcType=TIMESTAMP} AND `status`=1
	</delete>
	
	<update id="updateOrderByExpire">
	UPDATE orders SET `status` = '8' WHERE `status` = '3' AND play_time &lt; NOW()
	</update>
	
	<update id="updateOrderByCancel">
	UPDATE orders SET `status`=0 WHERE `status`=1 AND order_time &lt; (now() - interval 25 minute)
	</update>

	<select id="selectByOrderNo" parameterType="java.lang.String" resultMap="BaseResultMap">
		select
		<include refid="Base_Column_List" />
		from orders
		where order_no = #{orderNo}
	</select>

	<!--根据条件查询id集合（分页）-->
	<select id="selectIdsPage" resultType="java.lang.String" parameterType="com.fjs.scenic.dto.OrdersDto">
		SELECT o.id FROM orders o
		<where>
			<if test="status != null and status!='' ">
				and o.`status` = #{status}
			</if>
			<if test="startTime != null ">
				and o.order_time &gt;= #{startTime,jdbcType=TIMESTAMP}
			</if>
			<if test="endTime != null ">
				and o.order_time &lt; #{endTime,jdbcType=TIMESTAMP}
			</if>
			<if test="playTimeStartTime != null and status!='' ">
				and o.play_time &gt;= #{playTimeStartTime,jdbcType=TIMESTAMP}
			</if>
			<if test="playTimeEndTime != null and status!='' ">
				and o.play_time &lt; #{playTimeEndTime,jdbcType=TIMESTAMP}
			</if>
			<if test="orderNo != null and orderNo!='' ">
				and o.order_no = #{orderNo,jdbcType=VARCHAR}
			</if>
			<if test="distOrderNo != null and distOrderNo!='' ">
				and o.dist_order_no like concat(concat('%',#{distOrderNo}),'%')
			</if>
			<if test="buyIdCard != null and buyIdCard!='' ">
				and o.buy_id_card like concat(concat('%',#{buyIdCard}),'%')
			</if>
			<if test="buyPhone != null and buyPhone!='' ">
				and o.buy_phone like concat(concat('%',#{buyPhone}),'%')
			</if>
			<if test="buyUserName != null and buyUserName!='' ">
				and o.buy_user_name like concat(concat('%',#{buyUserName}),'%')
			</if>
		</where>
		ORDER BY id DESC
	</select>

	<!--通过id集合获取订单信息-->
	<select id="selectByIds" resultType="map">
		SELECT o.id,o.order_no,o.order_name,o.dist_order_no,o.play_time,o.totel_price/100 totel_price,
		u.nick_name,od.num,od.price/100 price,o.order_time,o.`status`,IFNULL(o.pay_time, '') pay_time ,o.buy_id_card card,o.buy_phone,o.buy_user_name
		FROM orders o LEFT JOIN order_details od ON o.id=od.order_id INNER JOIN `user` u ON u.id=o.user_id
		WHERE o.id IN
		<foreach collection="list" index="index" item="oid" open="(" separator="," close=")">
			#{oid}
		</foreach>
		ORDER BY o.id DESC
	</select>
	
	<select id="select30MinuteOrder" resultMap="BaseResultMap">
	SELECT <include refid="Base_Column_List" /> FROM orders WHERE `status`=1 AND order_time &lt; (now() - interval 5 minute) 
	</select>
	
	<select id="getPhoneByOrdersNo" resultType="map">
	SELECT buy_phone,dist_order_no FROM orders WHERE order_no=#{ordersNo}
	</select>
	
</mapper>