xuhy
2025-04-27 5fa6e6f8410ef9d057174bcff2a3c5038c54a551
ruoyi-system/src/main/resources/mapper/system/TTenantMapper.xml
@@ -30,7 +30,7 @@
    </sql>
    <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,
        bank_number, mail_address, create_time, disabled,account
        FROM t_tenant
        <where>
            <if test="query.residentName != null and query.residentName != ''">
@@ -43,5 +43,97 @@
        </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>