<?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.ruoyi.system.mapper.THouseMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ruoyi.system.model.THouse">
|
<id column="id" property="id" />
|
<result column="house_picture" property="housePicture" />
|
<result column="house_name" property="houseName" />
|
<result column="house_address" property="houseAddress" />
|
<result column="house_area" property="houseArea" />
|
<result column="house_type" property="houseType" />
|
<result column="business_attributes" property="businessAttributes" />
|
<result column="product_type" property="productType" />
|
<result column="property_right_person" property="propertyRightPerson" />
|
<result column="property_right_number" property="propertyRightNumber" />
|
<result column="property_right_start_time" property="propertyRightStartTime" />
|
<result column="property_right_duration" property="propertyRightDuration" />
|
<result column="lease_status" property="leaseStatus" />
|
<result column="create_time" property="createTime" />
|
<result column="update_time" property="updateTime" />
|
<result column="create_by" property="createBy" />
|
<result column="update_by" property="updateBy" />
|
<result column="disabled" property="disabled" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, house_picture, house_name, house_address, house_area, house_type, business_attributes, product_type, property_right_person, property_right_number, property_right_start_time, property_right_duration, lease_status, create_time, update_time, create_by, update_by, disabled
|
</sql>
|
<select id="houseList" resultType="com.ruoyi.system.model.THouse">
|
select t1.*,t2.start_time as startTime
|
from t_house t1
|
left join t_contract t2
|
on (t2.house_id = t1.id
|
and t2.status != 1
|
and t2.status != 2
|
and t2.status != 3
|
and t2.status != 5
|
and t2.status != 8
|
and NOW() between t2.start_time and t2.end_time)
|
<where>
|
<if test="req.houseName != null and req.houseName != ''">
|
and t1.house_name like concat('%', #{req.houseName}, '%')
|
</if>
|
<if test="req.propertyRightPerson != null and req.propertyRightPerson != ''">
|
and t1.property_right_person like concat('%', #{req.propertyRightPerson}, '%')
|
</if>
|
<if test="req.leaseStatus == 3">
|
and t1.lease_status = #{req.leaseStatus}
|
</if>
|
<if test="req.leaseStatus == 2">
|
and (t2.start_time is not null)
|
</if>
|
<if test="req.leaseStatus == 1">
|
and (t2.start_time is null) and t1.lease_status = 1
|
</if>
|
<if test="req.businessDeptId != null and req.businessDeptId != '' and req.businessDeptId!=0">
|
and t1.business_dept_id = #{req.businessDeptId}
|
</if>
|
AND t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
|
</where>
|
order by t1.create_time desc
|
</select>
|
<select id="userHistoryList" resultType="com.ruoyi.system.vo.HouseVO">
|
select
|
t2.resident_name as residentName,
|
t2.phone as phone,
|
t3.business_attributes as businessAttributes,
|
t3.product_type as productType,
|
t1.start_time as startTime,
|
t3.building as building,
|
t3.room_number as roomNumber,
|
t3.house_area as houseArea,
|
t2.phone as loginAccount,
|
t2.tenant_type as tenantType,
|
t2.id as tenantId,
|
t2.id_card as idCard,
|
t2.bank_number as bankNumber,
|
t2.mail_address as mailAddress,
|
t2.tenant_attributes as tenantAttributes
|
from t_contract t1
|
left join t_tenant t2 on t1.tenant_id = t2.id
|
LEFT JOIN t_house t3 on t3.id = t1.house_id
|
where t1.house_id = #{req.id}
|
AND t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
|
|
</select>
|
<select id="getRentedArea" resultType="java.lang.Double">
|
SELECT COALESCE(SUM(t1.house_area),0) FROM t_house t1
|
LEFT JOIN t_contract t2 ON t1.id = t2.house_id AND t2.status = 4 AND t2.pay_type = 2
|
<where>
|
t1.lease_status != 1
|
<if test="businessDeptId!=0">
|
AND t1.business_dept_id = #{businessDeptId}
|
</if>
|
AND t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
|
</where>
|
</select>
|
|
</mapper>
|