<?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.hotelleaselog.mapper.HotelLeaseLogMapper">


    <select id="myLeaseLogPage" resultType="org.jeecg.modules.hotelleaselog.entity.HotelLeaseLog">
        SELECT a.*,
               (IFNULL(IFNULL(DATEDIFF(NOW(), a.start_time),0)*(SELECT price FROM hotel_goods_sku WHERE id = a.sku_id ),0)) zujin,
               (a.num*(SELECT price FROM hotel_category WHERE id = a.category_id)) wash_price,
               (select id from hotel_order where lease_id = a.id and status in (4,5,6,16)) is_wash
        FROM hotel_lease_log a WHERE a.del_flag = 0 AND a.user_id = #{userId}
        <if test="leaseFlag != null">
            AND lease_flag = #{leaseFlag}
        </if>
        <if test="status != null">
            AND status = #{status}
        </if>
        ORDER BY a.create_time;
    </select>

</mapper>