<?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.gxwebsoft.house.mapper.ReservationMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM house_reservation a
        <where>
            <if test="param.logId != null">
                AND a.log_id = #{param.logId}
            </if>
            <if test="param.logNo != null">
                AND a.log_no LIKE CONCAT('%', #{param.logNo}, '%')
            </if>
            <if test="param.type != null">
                AND a.type = #{param.type}
            </if>
            <if test="param.money != null">
                AND a.money = #{param.money}
            </if>
            <if test="param.payPrice != null">
                AND a.pay_price = #{param.payPrice}
            </if>
            <if test="param.houseId != null">
                AND a.house_id = #{param.houseId}
            </if>
            <if test="param.priceId != null">
                AND a.price_id = #{param.priceId}
            </if>
            <if test="param.gradeId != null">
                AND a.grade_id = #{param.gradeId}
            </if>
            <if test="param.priceName != null">
                AND a.price_name LIKE CONCAT('%', #{param.priceName}, '%')
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.realName != null">
                AND a.real_name LIKE CONCAT('%', #{param.realName}, '%')
            </if>
            <if test="param.phone != null">
                AND a.phone LIKE CONCAT('%', #{param.phone}, '%')
            </if>
            <if test="param.payTime != null">
                AND a.pay_time LIKE CONCAT('%', #{param.payTime}, '%')
            </if>
            <if test="param.payStatus != null">
                AND a.pay_status = #{param.payStatus}
            </if>
            <if test="param.expirationTime != null">
                AND a.expiration_time LIKE CONCAT('%', #{param.expirationTime}, '%')
            </if>
            <if test="param.province != null">
                AND a.province LIKE CONCAT('%', #{param.province}, '%')
            </if>
            <if test="param.city != null">
                AND a.city LIKE CONCAT('%', #{param.city}, '%')
            </if>
            <if test="param.region != null">
                AND a.region LIKE CONCAT('%', #{param.region}, '%')
            </if>
            <if test="param.area != null">
                AND a.area LIKE CONCAT('%', #{param.area}, '%')
            </if>
            <if test="param.address != null">
                AND a.address LIKE CONCAT('%', #{param.address}, '%')
            </if>
            <if test="param.merchantId != null">
                AND a.merchant_id = #{param.merchantId}
            </if>
            <if test="param.merchantName != null">
                AND a.merchant_name LIKE CONCAT('%', #{param.merchantName}, '%')
            </if>
            <if test="param.merchantCode != null">
                AND a.merchant_code LIKE CONCAT('%', #{param.merchantCode}, '%')
            </if>
            <if test="param.isSettled != null">
                AND a.is_settled = #{param.isSettled}
            </if>
            <if test="param.sortNumber != null">
                AND a.sort_number = #{param.sortNumber}
            </if>
            <if test="param.comments != null">
                AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </if>
            <if test="param.deleted != null">
                AND a.deleted = #{param.deleted}
            </if>
            <if test="param.deleted == null">
                AND a.deleted = 0
            </if>
            <if test="param.createTimeStart != null">
                AND a.create_time &gt;= #{param.createTimeStart}
            </if>
            <if test="param.createTimeEnd != null">
                AND a.create_time &lt;= #{param.createTimeEnd}
            </if>
        </where>
    </sql>

    <!-- 分页查询 -->
    <select id="selectPageRel" resultType="com.gxwebsoft.house.entity.Reservation">
        <include refid="selectSql"></include>
    </select>

    <!-- 查询全部 -->
    <select id="selectListRel" resultType="com.gxwebsoft.house.entity.Reservation">
        <include refid="selectSql"></include>
    </select>

</mapper>
