puzhibing
2024-02-05 640ff18d2d7f4be02ddb7f8f75e899f05545eb98
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
<?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.dsh.account.mapper.TAppUserMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.dsh.account.entity.TAppUser">
        <id column="id" property="id"/>
        <result column="code" property="code"/>
        <result column="name" property="name"/>
        <result column="phone" property="phone"/>
        <result column="password" property="password"/>
        <result column="birthday" property="birthday"/>
        <result column="gender" property="gender"/>
        <result column="height" property="height"/>
        <result column="weight" property="weight"/>
        <result column="bmi" property="bmi"/>
        <result column="idCard" property="idCard"/>
        <result column="openid" property="openid"/>
        <result column="province" property="province"/>
        <result column="provinceCode" property="provinceCode"/>
        <result column="city" property="city"/>
        <result column="cityCode" property="cityCode"/>
        <result column="isVip" property="isVip"/>
        <result column="vipEndTime" property="vipEndTime"/>
        <result column="viplevelId" property="viplevelId"/>
        <result column="referralUserId" property="referralUserId"/>
        <result column="salesmanUserId" property="salesmanUserId"/>
        <result column="state" property="state"/>
        <result column="integral" property="integral"/>
        <result column="playPaiCoins" property="playPaiCoins"/>
        <result column="headImg" property="headImg"/>
    </resultMap>
 
 
    <update id="membershipEnd">
        update t_app_user set isVip = 0 where isVip = 1 and now() >= vipEndTime
    </update>
    <update id="changeState">
        update t_app_user set
        state = #{state}
        <where>
            <if test="ids != null and ids.size()>0">
                AND t_app_user.id IN
                <foreach collection="ids" separator="," item="id" open="(" close=")">
                    #{id}
                </foreach>
            </if>
        </where>
    </update>
    <select id="listAll" resultType="com.dsh.account.model.vo.QueryAppUserVO">
        select t1.* from t_app_user t1
        <where>
            <if test="query.city!=null and query.city!= ''">
                and t1.city = #{query.city}
            </if>
            <if test="query.province!=null and query.province!= ''">
                and t1.province = #{query.province}
            </if>
            <if test="query.name!=null and query.name!= ''">
                AND t1.name LIKE concat('%',#{query.name},'%')
            </if>
            <if test="query.phone!=null and query.phone!= ''">
                and t1.phone LIKE concat('%',#{query.phone},'%')
            </if>
            <if test="query.salesmanUser!=null and query.salesmanUser!= ''">
                and t1.salesmanUserId = #{query.salesmanUser}
            </if>
            <if test="query.insertType!=null and query.insertType!= ''">
                and t1.insertType = #{query.insertType}
            </if>
            <if test="query.typeId!=null and query.typeId!= ''">
                and t1.addUserId = #{query.typeId}
            </if>
            and t1.state != 3
        </where>
 
 
    </select>
    <select id="getSelects" resultType="com.dsh.account.dto.SelectDto">
        SELECT ts.id ,ts.`name` as value
        FROM t_student ts
        <where>
            ts.id in
            <foreach collection="studentIds" item="id" index="index" open="(" close=")" separator=",">
                #{id}
            </foreach>
        </where>
    </select>
    <select id="queryAPPUserByNameAndPhone" resultType="com.dsh.account.entity.TAppUser">
        select * from t_app_user t1
        <where>
            <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>
        </where>
    </select>
 
 
    <select id="getYearUserCount" resultType="com.dsh.account.vo.entity.YearData">
        select IFNULL(count(*),0) AS yearCount,DATE_FORMAT(insertTime,'%Y') AS `year` from t_app_user
        <where>
            <if test="dto.cityCode != null and dto.cityCode != ''">
                AND cityCode = #{dto.cityCode}
            </if>
            <if test="dto.isVip != null">
                AND isVip = #{dto.isVip}
            </if>
            <if test="dto.insertType != null and dto.insertType == 2 and dto.operatorId != null">
                AND insertType = 2
                AND addUserId = #{dto.operatorId}
            </if>
            <if test="dto.insertType != null and dto.insertType == 3 and dto.storeId != null">
                AND insertType = 3
                AND addUserId = #{dto.storeId}
            </if>
        </where>
        GROUP BY DATE_FORMAT(insertTime,'%Y')
    </select>
    <select id="getMonthUserCount" resultType="com.dsh.account.vo.entity.MonthData">
        select IFNULL(count(*),0) AS monthCount,DATE_FORMAT(insertTime,'%Y%m') AS `month` from t_app_user
        <where>
            <if test="dto.cityCode != null and dto.cityCode != ''">
                AND cityCode = #{dto.cityCode}
            </if>
            <if test="dto.isVip != null">
                AND isVip = #{dto.isVip}
            </if>
            <if test="dto.insertType != null and dto.insertType == 2 and dto.operatorId != null">
                AND insertType = 2
                AND addUserId = #{dto.operatorId}
            </if>
            <if test="dto.insertType != null and dto.insertType == 3 and dto.storeId != null">
                AND insertType = 3
                AND addUserId = #{dto.storeId}
            </if>
        </where>
        GROUP BY DATE_FORMAT(insertTime,'%Y%m')
    </select>
    <select id="getWeekUserCount4" resultType="com.dsh.account.vo.entity.WeekData">
        select IFNULL(count(*),0) AS weekCount,4 AS `week` from t_app_user
        <where>
            <if test="dto.startTime != null and dto.startTime != '' and dto.endTime != null and dto.endTime != ''">
                AND insertTime between #{dto.startTime} and #{dto.endTime}
            </if>
            <if test="dto.cityCode != null and dto.cityCode != ''">
                AND cityCode = #{dto.cityCode}
            </if>
            <if test="dto.isVip != null">
                AND isVip = #{dto.isVip}
            </if>
            <if test="dto.insertType != null and dto.insertType == 2 and dto.operatorId != null">
                AND insertType = 2
                AND addUserId = #{dto.operatorId}
            </if>
            <if test="dto.insertType != null and dto.insertType == 3 and dto.storeId != null">
                AND insertType = 3
                AND addUserId = #{dto.storeId}
            </if>
        </where>
    </select>
 
    <select id="getWeekUserCount3" resultType="com.dsh.account.vo.entity.WeekData">
        select IFNULL(count(*),0) AS weekCount,3 AS `week` from t_app_user
        <where>
            <if test="dto.startTime != null and dto.startTime != '' and dto.endTime != null and dto.endTime != ''">
                AND insertTime between #{dto.startTime} and #{dto.endTime}
            </if>
            <if test="dto.cityCode != null and dto.cityCode != ''">
                AND cityCode = #{dto.cityCode}
            </if>
            <if test="dto.isVip != null">
                AND isVip = #{dto.isVip}
            </if>
            <if test="dto.insertType != null and dto.insertType == 2 and dto.operatorId != null">
                AND insertType = 2
                AND addUserId = #{dto.operatorId}
            </if>
            <if test="dto.insertType != null and dto.insertType == 3 and dto.storeId != null">
                AND insertType = 3
                AND addUserId = #{dto.storeId}
            </if>
        </where>
    </select>
 
    <select id="getWeekUserCount2" resultType="com.dsh.account.vo.entity.WeekData">
        select IFNULL(count(*),0) AS weekCount,2 AS `week` from t_app_user
        <where>
            <if test="dto.startTime != null and dto.startTime != '' and dto.endTime != null and dto.endTime != ''">
                AND insertTime between #{dto.startTime} and #{dto.endTime}
            </if>
            <if test="dto.cityCode != null and dto.cityCode != ''">
                AND cityCode = #{dto.cityCode}
            </if>
            <if test="dto.isVip != null">
                AND isVip = #{dto.isVip}
            </if>
            <if test="dto.insertType != null and dto.insertType == 2 and dto.operatorId != null">
                AND insertType = 2
                AND addUserId = #{dto.operatorId}
            </if>
            <if test="dto.insertType != null and dto.insertType == 3 and dto.storeId != null">
                AND insertType = 3
                AND addUserId = #{dto.storeId}
            </if>
        </where>
    </select>
 
    <select id="getWeekUserCount1" resultType="com.dsh.account.vo.entity.WeekData">
        select IFNULL(count(*),0) AS weekCount,1 AS `week` from t_app_user
        <where>
            <if test="dto.startTime != null and dto.startTime != '' and dto.endTime != null and dto.endTime != ''">
                AND insertTime between #{dto.startTime} and #{dto.endTime}
            </if>
            <if test="dto.cityCode != null and dto.cityCode != ''">
                AND cityCode = #{dto.cityCode}
            </if>
            <if test="dto.isVip != null">
                AND isVip = #{dto.isVip}
            </if>
            <if test="dto.insertType != null and dto.insertType == 2 and dto.operatorId != null">
                AND insertType = 2
                AND addUserId = #{dto.operatorId}
            </if>
            <if test="dto.insertType != null and dto.insertType == 3 and dto.storeId != null">
                AND insertType = 3
                AND addUserId = #{dto.storeId}
            </if>
        </where>
    </select>
 
    <select id="getDayUserCount" resultType="com.dsh.account.vo.entity.DayData">
        select IFNULL(count(*),0) AS dayCount,DATE_FORMAT(insertTime,'%Y-%m-%d') AS `day` from t_app_user
        <where>
            <if test="dto.startTime != null and dto.startTime != '' and dto.endTime != null and dto.endTime != ''">
                AND insertTime between #{dto.startTime} and #{dto.endTime}
            </if>
            <if test="dto.cityCode != null and dto.cityCode != ''">
                AND cityCode = #{dto.cityCode}
            </if>
            <if test="dto.isVip != null">
                AND isVip = #{dto.isVip}
            </if>
            <if test="dto.insertType != null and dto.insertType == 2 and dto.operatorId != null">
                AND insertType = 2
                AND addUserId = #{dto.operatorId}
            </if>
            <if test="dto.insertType != null and dto.insertType == 3 and dto.storeId != null">
                AND insertType = 3
                AND addUserId = #{dto.storeId}
            </if>
        </where>
        GROUP BY DATE_FORMAT(insertTime,'%Y-%m-%d')
    </select>
    <select id="groupCityInfo" resultType="com.dsh.account.vo.GroupCityInfoVO">
        select IFNULL(count(*),0) AS userCount,cityCode,city from t_app_user
        <where>
            <if test="dto.startTime != null and dto.startTime != '' and dto.endTime != null and dto.endTime != ''">
                AND insertTime between #{dto.startTime} and #{dto.endTime}
            </if>
            <if test="dto.cityCode != null and dto.cityCode != ''">
                AND cityCode = #{dto.cityCode}
            </if>
            <if test="dto.isVip != null">
                AND isVip = #{dto.isVip}
            </if>
            <if test="dto.insertType != null and dto.insertType == 2 and dto.operatorId != null">
                AND insertType = 2
                AND addUserId = #{dto.operatorId}
            </if>
            <if test="dto.insertType != null and dto.insertType == 3 and dto.storeId != null">
                AND insertType = 3
                AND addUserId = #{dto.storeId}
            </if>
        </where>
        GROUP BY cityCode
    </select>
    <select id="listAll1" resultType="com.dsh.account.model.vo.QueryAppUserVO">
        select t2.* from t_app_user t2
        <where>
            <if test="query.userIds != null and query.userIds.size()>0">
                AND t2.id IN
                <foreach collection="query.userIds" separator="," item="id" open="(" close=")">
                    #{id}
                </foreach>
            </if>
            <if test="query.city!=null and query.city!= ''">
                and t2.city = #{query.city}
            </if>
            <if test="query.province!=null and query.province!= ''">
                and t2.province = #{query.province}
            </if>
            <if test="query.name!=null and query.name!= ''">
                AND t2.name LIKE concat('%',#{query.name},'%')
            </if>
            <if test="query.phone!=null and query.phone!= ''">
                and t2.phone LIKE concat('%',#{query.phone},'%')
            </if>
            <if test="query.isVip!=null and query.isVip!= ''">
                and t2.isVip = #{query.isVip}
            </if>
            <if test="query.salesmanUser!=null and query.salesmanUser!= ''">
                and t2.salesmanUserId = #{query.salesmanUser}
            </if>
            and t2.state != 3
        </where>
    </select>
</mapper>