<?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="org.jeecg.modules.hotelorderlog.mapper.HotelOrderLogMapper">
    
    <resultMap id="orderLogPageResp" type="org.jeecg.modules.hotelorderlog.entity.HotelOrderLog">
        <id property="id" column="id"  />
        <result property="orderPay" column="order_pay" />
        <result property="isPay" column="is_pay" />
        <result property="delFlag" column="del_flag" />
        <result property="createTime" column="create_time" />
        <result property="updateTime" column="update_time" />
        <result property="userId" column="user_id" />
        <result property="discountOrderPay" column="discount_order_pay" />
        <result property="type" column="type" />
        <result property="shopId" column="shop_id" />
        <collection property="details" ofType="org.jeecg.modules.hotelorder.entity.HotelOrder"
                    column="id"
                    select="org.jeecg.modules.hotelorder.mapper.HotelOrderMapper.getOrderPage">

        </collection>
    </resultMap>

    <resultMap id="orderLogOneResp" type="org.jeecg.modules.hotelorderlog.entity.HotelOrderLog">
        <id property="id" column="id"  />
        <result property="orderPay" column="order_pay" />
        <result property="isPay" column="is_pay" />
        <result property="delFlag" column="del_flag" />
        <result property="createTime" column="create_time" />
        <result property="updateTime" column="update_time" />
        <result property="userId" column="user_id" />
        <result property="discountOrderPay" column="discount_order_pay" />
        <result property="type" column="type" />
        <result property="shopId" column="shop_id" />
        <collection property="details" ofType="org.jeecg.modules.hotelorder.entity.HotelOrder"
                    column="id"
                    select="org.jeecg.modules.hotelorder.mapper.HotelOrderMapper.getOrderPage">
        </collection>
        <collection property="hotelOrderFlows" ofType="org.jeecg.modules.hotelorderflow.entity.HotelOrderFlow"
                    column="type"
                    select="org.jeecg.modules.hotelorderflow.mapper.HotelOrderFlowMapper.getOrderFlowList">
        </collection>
    </resultMap>

    <select id="getOrderLogPage" resultMap="orderLogPageResp">
        select a.* from hotel_order_log a    where del_flag = 0
        <if test="type != null">
            AND a.type = #{type}
        </if>
        <if test="uid == null">
            AND (a.user_id = #{userId} or a.shop_id = #{userId})
        </if>
        <if test="uid != null">
            AND a.user_id = #{uid}
        </if>

        order by a.create_time desc
    </select>


    <select id="getOrderLogOne" resultMap="orderLogOneResp">
        SELECT * FROM hotel_order_log where del_flag = 0
        <if test="userId != null">
            AND user_id = #{userId}
        </if>
        <if test="id != null">
            AND id = #{id}
        </if>

    </select>



</mapper>