xuhy
2025-04-27 5fa6e6f8410ef9d057174bcff2a3c5038c54a551
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?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.TTenantMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.system.model.TTenant">
        <id column="id" property="id" />
        <result column="resident_name" property="residentName" />
        <result column="checkIn_time" property="checkinTime" />
        <result column="tenant_attributes" property="tenantAttributes" />
        <result column="tenant_type" property="tenantType" />
        <result column="phone" property="phone" />
        <result column="id_card" property="idCard" />
        <result column="email" property="email" />
        <result column="bank_number" property="bankNumber" />
        <result column="mail_address" property="mailAddress" />
        <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" />
        <result column="account" property="account" />
        <result column="password" property="password" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        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.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.residentName != null and query.residentName != ''">
                AND resident_name LIKE concat('%',#{query.residentName},'%')
            </if>
            <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>