xuhy
2025-04-27 5fa6e6f8410ef9d057174bcff2a3c5038c54a551
ruoyi-system/src/main/resources/mapper/system/TTenantMapper.xml
@@ -9,9 +9,6 @@
        <result column="checkIn_time" property="checkinTime" />
        <result column="tenant_attributes" property="tenantAttributes" />
        <result column="tenant_type" property="tenantType" />
        <result column="tenant_building" property="tenantBuilding" />
        <result column="room_number" property="roomNumber" />
        <result column="building_area" property="buildingArea" />
        <result column="phone" property="phone" />
        <result column="id_card" property="idCard" />
        <result column="email" property="email" />
@@ -28,22 +25,115 @@
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, resident_name, checkIn_time, tenant_attributes, tenant_type, tenant_building, room_number, building_area, phone, id_card, email,
        id, resident_name, checkIn_time, tenant_attributes, tenant_type, phone, id_card, email,
            bank_number, mail_address, create_time, update_time, create_by, update_by, disabled,account,password
    </sql>
    <select id="pageList" resultType="com.ruoyi.system.model.TTenant">
        SELECT <include refid="Base_Column_List"/>
    <select id="pageList" resultType="com.ruoyi.system.vo.TenantVO">
        SELECT id, resident_name, checkIn_time, tenant_attributes, tenant_type, phone, id_card, email,
        bank_number, mail_address, create_time, disabled,account
        FROM t_tenant
        <where>
            <if test="residentName != null and residentName != ''">
                AND resident_name LIKE concat('%',#{residentName},'%')
            <if test="query.residentName != null and query.residentName != ''">
                AND resident_name LIKE concat('%',#{query.residentName},'%')
            </if>
            <if test="phone != null and phone != ''">
                AND phone LIKE concat('%',#{phone},'%')
            <if test="query.phone != null and query.phone != ''">
                AND phone LIKE concat('%',#{query.phone},'%')
            </if>
            AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY create_time DESC
    </select>
    <select id="pageListApplet" resultType="com.ruoyi.system.vo.TenantVO">
        SELECT id, resident_name, checkIn_time, tenant_attributes, tenant_type, phone, id_card, email,
        bank_number, mail_address, create_time, disabled,account
        FROM t_tenant
        <where>
            <if test="query.residentNameOrPhone != null and query.residentNameOrPhone != ''">
                AND (resident_name LIKE concat('%',#{query.residentNameOrPhone},'%')or phone LIKE concat('%',#{query.residentNameOrPhone},'%'))
            </if>
            AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY create_time DESC
    </select>
    <select id="listBill" resultType="com.ruoyi.system.vo.TBillVO">
        select t1.* from
                     t_bill t1
        where 1=1
        <if test="query.payFeesStatus != null and query.payFeesStatus != ''">
          AND t1.pay_fees_status = #{query.payFeesStatus}
        </if>
        <if test="null != query.contractIds and query.contractIds.size() > 0">
            and t1.contract_id in
            <foreach collection="query.contractIds" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        AND t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
    </select>
    <select id="examineList" resultType="com.ruoyi.system.vo.ExamineVO">
        select t1.* from t_contract t1
        <where>
            <if test="query.status == 1">
                AND t1.status = 2
            </if>
            <if test="query.status == 2">
                AND (t1.status !=1 and t1.status !=2)
            </if>
            <if test="query.status == 3">
                AND t1.create_by = #{query.userName}
            </if>
            <if test="query.time != null and query.time != ''">
                <choose>
                    <when test="query.time == 1">
                        AND t1.create_time &gt;= DATE_SUB(NOW(), INTERVAL 1 DAY)
                    </when>
                    <when test="query.time == 2">
                        AND t1.create_time &gt;= DATE_SUB(NOW(), INTERVAL 7 DAY)
                    </when>
                    <when test="query.time == 3">
                        AND t1.create_time &gt;= DATE_SUB(NOW(), INTERVAL 30 DAY)
                    </when>
                </choose>
            </if>
        </where>
        <choose>
            <when test="query.sort != null and query.sort != ''">
                <choose>
                    <when test="query.sort == 1">
                        ORDER BY t1.create_time DESC
                    </when>
                    <when test="query.sort == 2">
                        ORDER BY t1.create_time ASC
                    </when>
                </choose>
            </when>
            <otherwise>
                ORDER BY t1.create_time DESC
            </otherwise>
        </choose>
    </select>
    <select id="pageListByBusinessDeptId" resultType="com.ruoyi.system.vo.TenantVO">
        SELECT * FROM (
        SELECT tt.id, tt.resident_name, tt.checkIn_time, tt.tenant_attributes, tt.tenant_type, tt.phone,
        tt.id_card, tt.email,
        tt.bank_number, tt.mail_address, tt.create_time, tt.disabled,tt.account
        FROM t_tenant tt
        WHERE EXISTS (
        SELECT 1
        FROM t_contract tc
        WHERE tc.tenant_id = tt.id AND tc.business_dept_id = #{query.businessDeptId}
        )
        ) AS te
        <where>
            <if test="query.residentName != null and query.residentName != ''">
                AND te.resident_name LIKE concat('%',#{query.residentName},'%')
            </if>
            <if test="query.phone != null and query.phone != ''">
                AND te.phone LIKE concat('%',#{query.phone},'%')
            </if>
            AND te.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY te.create_time DESC
    </select>
</mapper>