liujie
2026-03-12 f5fc754b623007b6d3923b84553714b08003c481
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?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.TAppUserMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.system.model.TAppUser">
        <id column="id" property="id" />
        <result column="nick_name" property="nickName" />
        <result column="avatar" property="avatar" />
        <result column="phone_number" property="phoneNumber" />
        <result column="gender" property="gender" />
        <result column="birth_date" property="birthDate" />
        <result column="status" property="status" />
        <result column="open_id" property="openId" />
        <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, nick_name, avatar, phone_number, gender, birth_date, status, open_id, create_time, update_time, create_by, update_by, disabled
    </sql>
    <select id="pageList" resultType="com.ruoyi.system.model.TAppUser">
        select t1.* from t_app_user t1
        where    t1.status != 3
        <if test="query.nickName != null and query.nickName != ''">
            and t1.name like concat('%',#{query.nickName},'%')
        </if>
 
        <if test="query.phoneNumber != null and query.phoneNumber != ''">
            and t1.phone like concat('%',#{query.phoneNumber},'%')
        </if>
        <if test="query.status != null">
            and t1.status = #{query.status}
        </if>
        <if test="query.promotionStatus != null">
            and t1.promotion_status =1
        </if>
 
        order by t1.create_time desc
    </select>
 
 
    <select id="promotionPageList" resultType="com.ruoyi.system.vo.PromotionPageListVo">
        select * from (
        select t1.id userId,t1.name userName,t1.phone phone,t1.profile_photo avatar,t1.user_type roleName,t1.status
        status,
        t2.id lastUserId,t2.name lastUserName,t2.phone lastPhone,t2.profile_photo lastAvatar,t2.user_type lastRoleName,t1.create_time createTime
        from t_app_user t1
        left join t_app_user t2 on t1.referrer_user_id =t2.id
        where t1.company_id = #{query.companyId} and t1.status !=3 and t1.referrer_user_id is not null
        <if test="query.userName != null and query.userName != ''">
            and t1.name like concat('%',#{query.userName},'%')
        </if>
        <if test="query.phone != null and query.phone != ''">
            and t1.phone like concat('%',#{query.phone},'%')
        </if>
        <if test="query.lastUserName != null and query.lastUserName != ''">
            and t2.name like concat('%',#{query.lastUserName},'%')
        </if>
        <if test="query.lastPhone != null and query.lastPhone != ''">
            and t2.phone like concat('%',#{query.lastPhone},'%')
        </if>
 
        union all
        select t1.id userId,t1.name userName,t1.phone phone,t1.profile_photo avatar,t1.user_type roleName,t1.status
        status,
 
        t2.user_id lastUserId,t2.nick_name lastUserName,t2.phonenumber lastPhone,t2.avatar lastAvatar,
 
        case
        when t2.role_type = 2 then 4
        when t2.role_type = 3 then 5
        end lastRoleName
        ,t1.create_time createTime
 
        from t_app_user t1
        left join sys_user t2 on t1.referrer_sys_user_id =t2.user_id
        where t1.company_id = #{query.companyId} and t1.status !=3 and t1.referrer_user_id is null
        <if test="query.userName != null and query.userName != ''">
            and t1.name like concat('%',#{query.userName},'%')
        </if>
        <if test="query.phone != null and query.phone != ''">
            and t1.phone like concat('%',#{query.phone},'%')
        </if>
        <if test="query.lastUserName != null and query.lastUserName != ''">
            and t2.nick_name like concat('%',#{query.lastUserName},'%')
        </if>
        <if test="query.lastPhone != null and query.lastPhone != ''">
            and t2.phonenumber like concat('%',#{query.lastPhone},'%')
        </if>
 
        ) as t3
        order by t3.createTime desc
    </select>
    <select id="promotionPageListExport" resultType="com.ruoyi.system.vo.PromotionPageListVo">
        select * from (
        select t1.id userId,t1.name userName,t1.phone phone,t1.profile_photo avatar,t1.user_type roleName,t1.status
        status,
        t2.id lastUserId,t2.name lastUserName,t2.phone lastPhone,t2.profile_photo lastAvatar,t2.user_type lastRoleName,t1.create_time createTime
        from t_app_user t1
        left join t_app_user t2 on t1.referrer_user_id =t2.id
        where t1.company_id = #{query.companyId} and t1.status !=3 and t1.referrer_user_id is not null
        <if test="query.userName != null and query.userName != ''">
            and t1.name like concat('%',#{query.userName},'%')
        </if>
        <if test="query.phone != null and query.phone != ''">
            and t1.phone like concat('%',#{query.phone},'%')
        </if>
        <if test="query.lastUserName != null and query.lastUserName != ''">
            and t2.name like concat('%',#{query.lastUserName},'%')
        </if>
        <if test="query.lastPhone != null and query.lastPhone != ''">
            and t2.phone like concat('%',#{query.lastPhone},'%')
        </if>
 
        union all
        select t1.id userId,t1.name userName,t1.phone phone,t1.profile_photo avatar,t1.user_type roleName,t1.status
        status,
 
        t2.user_id lastUserId,t2.nick_name lastUserName,t2.phonenumber lastPhone,t2.avatar lastAvatar,
 
        case
        when t2.role_type = 2 then 4
        when t2.role_type = 3 then 5
        end lastRoleName
        ,t1.create_time createTime
 
        from t_app_user t1
        left join sys_user t2 on t1.referrer_sys_user_id =t2.user_id
        where t1.company_id = #{query.companyId} and t1.status !=3 and t1.referrer_user_id is null
        <if test="query.userName != null and query.userName != ''">
            and t1.name like concat('%',#{query.userName},'%')
        </if>
        <if test="query.phone != null and query.phone != ''">
            and t1.phone like concat('%',#{query.phone},'%')
        </if>
        <if test="query.lastUserName != null and query.lastUserName != ''">
            and t2.nick_name like concat('%',#{query.lastUserName},'%')
        </if>
        <if test="query.lastPhone != null and query.lastPhone != ''">
            and t2.phonenumber like concat('%',#{query.lastPhone},'%')
        </if>
 
        ) as t3
        order by t3.createTime desc
    </select>
    <select id="exportAppUser" resultType="com.ruoyi.system.model.TAppUser">
        select t1.* from t_app_user t1
        where    t1.status != 3
        <if test="query.nickName != null and query.nickName != ''">
            and t1.name like concat('%',#{query.nickName},'%')
        </if>
 
        <if test="query.phoneNumber != null and query.phoneNumber != ''">
            and t1.phone like concat('%',#{query.phoneNumber},'%')
        </if>
        <if test="query.status != null">
            and t1.status = #{query.status}
        </if>
 
        order by t1.create_time desc
    </select>
    <select id="transferPageUserList" resultType="com.ruoyi.system.model.TAppUser">
        select t1.* from t_app_user t1
        where    t1.status != 3
        <if test="query.nickName != null and query.nickName != ''">
            and t1.name like concat('%',#{query.nickName},'%')
        </if>
 
        <if test="query.phoneNumber != null and query.phoneNumber != ''">
            and( t1.phone like concat('%',#{query.phoneNumber},'%') or t1.code like concat('%',#{query.phoneNumber},'%') )
        </if>
        <if test="query.status != null">
            and t1.status = #{query.status}
        </if>
 
        order by t1.create_time desc
    </select>
 
    <select id="userPromotionPageList" resultType="com.ruoyi.system.vo.UserPromotionPageListVo">
        select t1.id userId,t1.name userName,t1.phone phone,t1.gender,t1.profile_photo avatar,t1.user_type roleName,t1.status status
        from t_app_user t1
        where t1.referrer_user_id = #{query.userId} and t1.status !=3 and  t1.referrer_status =2
        <if test="query.userName != null and query.userName != ''">
            and t1.name like concat('%',#{query.userName},'%')
        </if>
        <if test="query.phone != null and query.phone != ''">
            and t1.phone like concat('%',#{query.phone},'%')
        </if>
        order by t1.create_time desc
    </select>
    <select id="userPromotionPageListExport" resultType="com.ruoyi.system.vo.UserPromotionPageListVo">
        select t1.id userId,t1.name userName,t1.phone phone,t1.gender,t1.profile_photo avatar,t1.user_type roleName,t1.status status
        from t_app_user t1
        where t1.referrer_user_id = #{query.userId} and t1.status !=3 and  t1.referrer_status =2
        <if test="query.userName != null and query.userName != ''">
            and t1.name like concat('%',#{query.userName},'%')
        </if>
        <if test="query.phone != null and query.phone != ''">
            and t1.phone like concat('%',#{query.phone},'%')
        </if>
        order by t1.create_time desc
    </select>
 
</mapper>