101captain
2022-01-14 dad5e5fd2abbf5d77d23f1b9a4500a9ae9bf274d
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
<?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.panzhihua.service_user.dao.UserDao">
    <resultMap id="baseResult" type="com.panzhihua.service_user.model.dos.SysUserDO">
        <id property="userId" column="user_id"/>
        <result property="account" column="account"/>
        <result property="password" column="password"/>
        <result property="openid" column="openid"/>
        <result property="sessionKey" column="session_key"/>
        <result property="unionid" column="unionid"/>
        <result property="phone" column="phone"/>
        <result property="nickName" column="nick_name"/>
        <result property="name" column="name"/>
        <result property="communityId" column="community_id"/>
        <result property="sex" column="sex"/>
        <result property="idCard" column="id_card"/>
        <result property="birthday" column="birthday"/>
        <result property="imageUrl" column="image_url"/>
        <result property="type" column="type"/>
        <result property="job" column="job"/>
        <result property="isVolunteer" column="is_volunteer"/>
        <result property="isPartymember" column="is_partymember"/>
        <result property="status" column="status"/>
        <result property="createAt" column="create_at"/>
        <result property="lastLoginTime" column="last_login_time"/>
        <result property="tags" column="tags"/>
        <result property="familyId" column="family_id"/>
        <result property="faceUrl" column="face_url"/>
        <result property="faceState" column="face_state"/>
        <result property="rejectReson" column="reject_reson"/>
        <result property="areaId" column="area_id"/>
        <result property="cardPhotoFront" column="card_photo_front"/>
        <result property="cardPhotoBack" column="card_photo_back"/>
        <result property="familyBook" column="family_book"/>
        <result property="continuousLandingDays" column="continuous_landing_days"/>
        <result property="isTips" column="is_tips"/>
        <result property="workStatus" column="work_status"/>
        <result property="workStartTime" column="work_start_time"/>
        <result property="workEndTime" column="work_end_time"/>
        <result property="bigAgeTips" column="big_age_tips"/>
 
    </resultMap>
    <sql id="columns">
        `user_id`,`account`,`password`,`openid`,`session_key`,`unionid`,`phone`,`nick_name`,`name`,`community_id`,`sex`,`id_card`,`birthday`,`image_url`,`type`,`job`,`is_volunteer`,`is_partymember`,`status`,`create_at`,`last_login_time`,`tags`,`family_id`,`face_url`,`face_state`,`reject_reson`,`area_id`,`card_photo_front`,`card_photo_back`,`family_book`,`continuous_landing_days`,`is_tips`,`work_status`,`work_start_time`,`work_end_time`,`big_age_tips`
    </sql>
 
 
    <select id="indexDataCommunityBackstage" resultType="com.panzhihua.common.model.vos.IndexDataVO">
        SELECT
        COUNT(DISTINCT u.user_id)allUser,
        (select COUNT(m.id) from com_mng_volunteer_mng m where m.community_id = #{communityId} and m.`state`=2)volunteerUser,
         (select count(id) from com_pb_member cpm where cpm.audit_result = 1 and cpm.community_id = #{communityId}) partymemberUser,
        COUNT(h.id)house
        FROM
        sys_user u
        JOIN com_act c ON u.community_id = c.community_id
        LEFT JOIN com_mng_struct_house_user h on u.user_id=h.user_id
        WHERE u.community_id = #{communityId} and u.type=1
    </select>
 
    <update id="timedTaskContinuousLandingDays">
        UPDATE sys_user u
        SET u.continuous_landing_days =
        IF
        (
        DATE_FORMAT( u.last_login_time, '%m-%d-%Y' )= DATE_FORMAT( SYSDATE(), '%m-%d-%Y' ),
        u.continuous_landing_days + 1,
        0)
    </update>
 
    <select id="selectVolunteerMngByPhone" resultType="com.panzhihua.common.model.vos.community.ComMngVolunteerMngVO">
        select id,create_at,state,name,phone,photo_path,political_face,reject_reson,apply_reson,address,age,job,integral,community_id,submit_user_id  from com_mng_volunteer_mng where phone=#{phone} order by create_at desc limit 1
    </select>
 
    <select id="selectCountMemberRole" resultType="java.lang.Integer">
        SELECT
             COUNT(a.id)
        FROM
             com_pb_member_role a
        WHERE
             a.phone = #{phone} and community_id = #{userCommunityId}
    </select>
 
    <select id="pageUserAppletsBackstage" resultType="com.panzhihua.common.model.vos.user.SysUserVO">
        select
        u.user_id,
        u.phone,
        u.nick_name,
        u.name,
        u.tags,
        a.name communityName,
        u.status,
        u.create_at,
        u.last_login_time
        from sys_user u
        left join com_act a on u.community_id=a.community_id
        where
        u.type=1 and u.community_id is not null
        <if test='pageUserAppletsBackstageDTO.phone != null and pageUserAppletsBackstageDTO.phone.trim() != &quot;&quot;'>
            and u.phone=#{pageUserAppletsBackstageDTO.phone}
        </if>
        <if test='pageUserAppletsBackstageDTO.communityId != null and pageUserAppletsBackstageDTO.communityId != 0'>and
            u.community_id = #{pageUserAppletsBackstageDTO.communityId}
        </if>
        <if test='pageUserAppletsBackstageDTO.areaCode != null'>and
            a.area_code = #{pageUserAppletsBackstageDTO.areaCode}
        </if>
        <if test='pageUserAppletsBackstageDTO.status != null and pageUserAppletsBackstageDTO.status != 0'>and
            u.status=#{pageUserAppletsBackstageDTO.status}
        </if>
        <if test='pageUserAppletsBackstageDTO.createAtBegin != null '>and u.create_at between
            #{pageUserAppletsBackstageDTO.createAtBegin} and #{pageUserAppletsBackstageDTO.createAtEnd}
        </if>
        <if test='pageUserAppletsBackstageDTO.lastLoginTimeBegin != null '>and u.last_login_time between
            #{pageUserAppletsBackstageDTO.lastLoginTimeBegin} and #{pageUserAppletsBackstageDTO.lastLoginTimeEnd}
        </if>
        order by u.create_at desc
 
    </select>
 
    <select id="selectIndexDataKanban" resultType="com.panzhihua.common.model.vos.IndexDataKanbanVO">
        SELECT
        COUNT(user_id)allUser,
        COUNT(case WHEN DATE_FORMAT(t.create_at,'%m-%d-%Y')=DATE_FORMAT(SYSDATE(),'%m-%d-%Y') then user_id else null end )addUser,
        COUNT(case WHEN DATE_FORMAT(last_login_time,'%m-%d-%Y')=DATE_FORMAT(SYSDATE(),'%m-%d-%Y') then user_id else null end )activeDayUser,
        (SELECT count(user_id) FROM sys_user t left join com_act t1 on t.community_id = t1.community_id WHERE type = 1 and t1.area_code = #{areaCode} AND last_login_time > date_sub(SYSDATE(), INTERVAL 7 DAY))activeWeekUser
        FROM
        sys_user t LEFT JOIN com_act t1 on t.community_id = t1.community_id
        where t.type=1 and t.community_id is not null and t1.area_code = #{areaCode}
            </select>
 
    <select id="selectCommunityUserOrder" resultType="com.panzhihua.service_user.model.dtos.DataKanbanDTO">
        select t.* from (
        SELECT
        a.`name`,
        COUNT(u.user_id)num,
        (SELECT count( user_id ) FROM sys_user WHERE type = 1 and community_id = a.community_id
        AND last_login_time > DATE_FORMAT( date_sub( SYSDATE(), INTERVAL 0 DAY ), '%Y-%m-%d 00:00:00')) as dayNum
        FROM
        com_act a
        LEFT JOIN sys_user u ON a.community_id = u.community_id and u.type=1 where a.area_code = #{areaCode}
        GROUP BY a.community_id)t ORDER BY t.num desc
    </select>
 
    <select id="selectCommunityUserOrderMonth" resultType="com.panzhihua.service_user.model.dtos.DataKanbanDTO">
        select t.* from (
        SELECT
        a.`name`,
        COUNT(u.user_id)num,
        (SELECT count( user_id ) FROM sys_user WHERE type = 1 and community_id = a.community_id
        AND last_login_time > DATE_FORMAT( date_sub( SYSDATE(), INTERVAL 0 DAY ), '%Y-%m-%d 00:00:00')) as dayNum
        FROM
        com_act a
        LEFT JOIN sys_user u ON a.community_id = u.community_id
        and u.type=1 and u.create_at >= DATE_ADD(curdate(),interval -day(curdate())+1 day) where a.area_code = #{areaCode}
        GROUP BY a.community_id)t ORDER BY t.num desc
    </select>
 
    <select id="pageUserBackstage" resultType="com.panzhihua.common.model.vos.user.AdministratorsUserVO">
        SELECT
        u.user_id,
        u.account,
        u.`name`,
        u.`password`,
        u.phone,
        e.role_name,
        e.role_id ,
        u.`status`,
        u.create_at,
        u.last_login_time
        FROM
        sys_user u
        JOIN sys_user_role r ON u.user_id = r.user_id
        JOIN sys_role e ON r.role_id = e.role_id
        left join com_act ca on u.community_id = ca.community_id
        <if test='administratorsUserVO.roleId != null and administratorsUserVO.roleId!=0'>and
            e.role_id=#{administratorsUserVO.roleId}
        </if>
        <where>
            <if test='administratorsUserVO.communityId != null '>AND u.community_id =
                #{administratorsUserVO.communityId}
            </if>
            <if test='administratorsUserVO.name != null and administratorsUserVO.name.trim() != &quot;&quot;'>AND u.name
                like concat (#{administratorsUserVO.name},'%')
            </if>
            <if test='administratorsUserVO.phone != null and administratorsUserVO.phone.trim() != &quot;&quot;'>AND
                u.phone like concat(#{administratorsUserVO.phone},'%')
            </if>
            <if test='administratorsUserVO.areaCode != null '>
                AND ca.area_code = #{administratorsUserVO.areaCode}
            </if>
            <if test='administratorsUserVO.account != null and administratorsUserVO.account.trim() != &quot;&quot;'>AND
                u.account like concat(#{administratorsUserVO.account},'%')
            </if>
        </where>
        order by u.create_at desc
    </select>
 
    <select id="selectCommunityActiveUserOrder" resultType="com.panzhihua.service_user.model.dtos.DataKanbanDTO">
        SELECT
            COUNT( a.id ) num
        FROM
            com_act_activity a
        WHERE
            DATE_FORMAT( #{date1}, '%Y-%m-%d' )= DATE_FORMAT( a.create_at,'%Y-%m-%d')
    </select>
 
    <select id="selectCommunityAddUserOrder" resultType="com.panzhihua.service_user.model.dtos.DataKanbanDTO">
        select count(user_id) as num,
        (SELECT count( user_id ) FROM sys_user t LEFT JOIN com_act t1 on t.community_id=t1.community_id WHERE t.type = 1 and t1.area_code = #{areaCode}
        AND last_login_time <![CDATA[ >= ]]> DATE_FORMAT( #{date1}, '%Y-%m-%d 00:00:00')
        AND last_login_time <![CDATA[ <= ]]> DATE_FORMAT( #{date1}, '%Y-%m-%d 23:59:59')) as dayNum from sys_user as su LEFT JOIN com_act t1 on su.community_id = t1.community_id
        where su.create_at <![CDATA[ >= ]]> DATE_SUB(DATE_FORMAT(#{date1},'%Y-%m-%d 00:00:00'),INTERVAL 0 DAY)
        and su.create_at <![CDATA[ <= ]]> DATE_SUB(DATE_FORMAT(#{date1},'%Y-%m-%d 23:59:59'),INTERVAL 0 DAY)
        and su.type = 1 and t1.area_code=#{areaCode}
    </select>
 
    <update id="gridMemberEditStatus">
        update sys_user set status = #{gridMemberEditDTO.status} where user_id in
        <foreach item="item" collection="gridMemberEditDTO.ids" separator="," open="(" close=")" index="">
            #{item}
        </foreach>
 
    </update>
 
    <select id="getGridMemberList" resultType="com.panzhihua.common.model.vos.grid.GridMemberVO">
        select su.user_id,su.image_url,su.nick_name,su.account,su.phone,su.work_status,su.`status`,ca.name as
        communityName,su.work_start_time,su.work_end_time from sys_user su left join com_act as ca on ca.community_id =
        su.community_id where su.type = 6
        <if test='memberRelationDTO.status != null'>AND su.status =
            #{memberRelationDTO.status}
        </if>
        <if test='memberRelationDTO.gridCommunityId != null'>AND ca.community_id =
            #{memberRelationDTO.gridCommunityId}
        </if>
        <if test='memberRelationDTO.gridStreetId != null'>AND ca.street_id = #{memberRelationDTO.gridStreetId}</if>
        <if test='memberRelationDTO.workStatus != null'>AND su.work_status = #{memberRelationDTO.workStatus}</if>
        <if test='memberRelationDTO.keyWord != null and memberRelationDTO.keyWord != &quot;&quot;'>and (su.nick_name
            like concat(#{memberRelationDTO.keyWord},'%') OR su.user_id = #{memberRelationDTO.keyWord} OR su.account
            like concat(#{memberRelationDTO.keyWord},'%') OR su.phone like concat(#{memberRelationDTO.keyWord},'%'))
        </if>
        order by su.create_at desc
    </select>
 
    <update id="updateServiceTeam">
        update com_pb_service_team u set u.phone=#{newphone},is_reg=1 where u.phone=#{oldphone}
    </update>
 
    <delete id="deleteStoreByPhoneAndStatus">
         delete from com_shop_store where delete_status = 1 and phone = #{phone}
    </delete>
 
    <select id="getPartyBuildingByIdCard" resultType="java.lang.Long">
           select id from com_pb_member where audit_result = 1 and id_card = #{idCard}
    </select>
 
    <select id="getGridsMemberList"
            resultType="com.panzhihua.common.model.vos.community.screen.event.EventGridMemberVO">
        select user_id,nick_name,phone from sys_user where type = 6 and community_id = #{communityId} limit 3
    </select>
 
    <update id="updateUserArchives">
        update sys_user set card_photo_front = #{userArchivesVO.cardPhotoFront}
        , card_photo_back = #{userArchivesVO.cardPhotoBack}
        ,family_book = #{userArchivesVO.familyBook}
        ,job = #{userArchivesVO.job}
         where user_id = #{userArchivesVO.userId}
    </update>
 
    <select id="selectCountSysUser" resultType="java.lang.Integer">
        SELECT
             COUNT(ur.role_id)
        FROM
             sys_user u LEFT JOIN sys_user_role ur ON u.user_id = ur.user_id
             LEFT JOIN sys_role r ON ur.role_id = r.role_id
        WHERE ur.role_id IS  NOT NULL AND  u.phone = #{phone}  and r.community_id = #{userCommunityId}
    </select>
 
    <delete id="delGridMemberRelation">
       delete from event_grid_member_building_relation where grid_member_id = #{gridMemberId}
    </delete>
 
    <update id="updateStoreByPhone">
       update com_shop_store set sys_user_id = #{sysUserId} where phone = #{phone}
    </update>
 
    <update id="updateComPbMemberUserId">
        update com_pb_member set user_id = #{userId} where audit_result = 1 and id_card = #{idCard}
    </update>
 
    <select id="getServiceTeamList" resultType="com.panzhihua.common.model.vos.partybuilding.ComPbServiceTeamWishVO">
        select id as managerId,`name` from com_pb_service_team where community_id = #{communityId}
        <if test='param != null and param != &quot;&quot;'>AND `name` like concat(#{param},'%')</if>
    </select>
 
    <select id="getUserListByCommunityId" resultType="com.panzhihua.common.model.vos.user.SysUserVO">
        select user_id,`name` from sys_user as su where type = 3 and community_id = #{communityId}
    </select>
 
    <select id="pageUserFace" resultType="com.panzhihua.common.model.vos.LoginUserInfoVO">
        SELECT
        u.user_id,
        u.face_url,
        u.nick_name,
        u.`name`,
        u.phone,
        u.id_card,
        u.face_state,
        c.area_name communityName,
        u.create_at
        FROM
        sys_user u
        JOIN com_mng_struct_area c ON u.area_id = c.id
        <if test='loginUserInfoVO.communityName != null and loginUserInfoVO.communityName.trim() != &quot;&quot;'>
            AND c.`area_name` like concat(#{loginUserInfoVO.communityName},'%')
        </if>
        where u.face_state is not null and u.type=1 and u.community_id = #{loginUserInfoVO.communityId}
        <if test='loginUserInfoVO.name != null and loginUserInfoVO.name.trim() != &quot;&quot;'>
            and u.`name` like concat(#{loginUserInfoVO.name},'%')
        </if>
        <if test='loginUserInfoVO.phone != null and loginUserInfoVO.phone.trim() != &quot;&quot;'>
            AND u.phone like concat(#{loginUserInfoVO.phone},'%')
        </if>
        order by u.face_state asc,u.create_at asc
    </select>
 
    <update id="putUserTag">
      update sys_user set tags = #{sysUserDO.tags}  where user_id = #{sysUserDO.userId}
    </update>
 
    <update id="updateMemberRole">
      update com_pb_member_role u set u.phone=#{newphone},is_reg=1 where u.phone=#{oldphone}
    </update>
 
    <select id="selectCountTeam" resultType="java.lang.Integer">
        SELECT
             COUNT(a.id)
        FROM
             com_pb_service_team a
        WHERE
             a.phone = #{phone} and community_id = #{userCommunityId}
    </select>
 
    <select id="selectExport" resultType="com.panzhihua.common.model.dtos.user.EexcelUserDTO">
        SELECT
        u.user_id 'order',
        h.house_name doorNumber,
        if(h.state=2,'租住','自主')isRent,
        u.`name`,
        '汉' nation,
        if(u.is_partymember=1,'党员','群众')politicalOutlook,
        '未知' maritalStatus,
        u.phone,
        '未知' education,
        u.id_card,
        '未知' company,
        '未知' residence,
        '未知' isPanZhiHua,
        '未知' situation,
        '未知' isContact,
        '未知' major,
        '未知' soldier,
        '未知' disability,
        '未知' lowIncomeHouseholds,
        '未知' lowIncomePeople,
        '未知' oldPeople,
        '未知' specialServiceFamily,
        '未知' keyPersonnel
        FROM
        sys_user u
        left join com_mng_struct_house_user hu on hu.user_id=u.user_id
        left join com_mng_struct_house h on hu.house_code=h.house_code
        <if test='exportUserDTO.areaName != null and exportUserDTO.areaName.trim() != &quot;&quot;'>JOIN
            com_mng_struct_area c ON u.area_id = c.id
        </if>
        <if test='exportUserDTO.areaName == null or exportUserDTO.areaName.trim() == &quot;&quot;'>LEFT JOIN
            com_mng_struct_area c ON u.area_id = c.id
        </if>
        <if test='exportUserDTO.areaName != null and exportUserDTO.areaName.trim() != &quot;&quot;'>AND c.`area_name`
            like concat(#{exportUserDTO.areaName},'%')
        </if>
        where u.community_id = #{exportUserDTO.communityId} and u.type=1
        <if
                test='exportUserDTO.name != null and exportUserDTO.name.trim() != &quot;&quot;'>and u.`name` like
            concat(#{exportUserDTO.name},'%')
        </if>
        <if test='exportUserDTO.phone != null and exportUserDTO.phone.trim() != &quot;&quot;'>AND u.phone like
            concat(#{exportUserDTO.phone},'%')
        </if>
        group by u.user_id
    </select>
 
    <select id="pageNotice" resultType="com.panzhihua.common.model.vos.user.SysUserNoticeVO">
        select * from
        sys_user_notice
        where
        user_id=#{pageDTO.userId}
        <if test='pageDTO.type != null and pageDTO.type != 0'>and type=#{pageDTO.type}
        </if>
        order by create_at desc
 
    </select>
 
    <select id="selectCountHouse" resultType="java.lang.Integer">
        SELECT
            COUNT(h.id)
        FROM
            com_mng_struct_area a
            LEFT JOIN com_mng_struct_house h on  h.parent_code=a.area_code
        WHERE
            a.area_name = #{areaName}
    </select>
 
    <update id="passResetUser">
        update sys_user set password = #{gridMemberDTO.password} where user_id in
        <foreach item="item" collection="gridMemberDTO.ids" separator="," open="(" close=")" index="">
            #{item}
        </foreach>
 
    </update>
 
    <update id="deleteUserTest">
     update sys_user set nick_name=null ,community_id=null,area_id=null where user_id=#{userId}
    </update>
 
    <select id="selectCountArea" resultType="java.lang.Integer">
    select COUNT(a.id) from com_mng_struct_area a where a.area_name=#{areaName}
    </select>
 
    <update id="addLcMember">
     update lc_compare_code_member set local_grid_member_id = #{userId},grid_member_name = #{userName} where id = #{lcMemberId}
    </update>
 
    <update id="updateFaceState">
      update sys_user set face_state=null where user_id=#{userId}
    </update>
 
    <select id="selectCommunity" resultType="com.panzhihua.common.model.vos.community.ComActVO">
       select * from com_act where community_id = #{communityId}
    </select>
 
    <delete id="delLcMember">
         delete from lc_compare_code_member where local_grid_member_id = #{gridMemberId}
    </delete>
 
    <select id="getBuilding" resultType="java.util.Map">
       select id,village_id,act_id from com_mng_building where id = #{buildingId}
    </select>
 
    <select id="getLcMemberId" resultType="java.util.Map">
        select lc_grid_member_id,lc_grid_member_name,lc_bind_user_id from lc_compare_code_member where local_grid_member_id = #{gridMemberId}
    </select>
 
    <select id="getGridIsOk" resultType="java.lang.Integer">
          select count(id) from event_grid_member_relation where grid_member_id = #{userId}
    </select>
 
    <update id="judgeCommunityTeam">
        update com_pb_service_team set is_reg = 1 where phone = #{phone}
    </update>
 
    <select id="getCommunityTeamCount" resultType="integer">
        select count(id) from com_pb_service_team where is_reg = 2 and phone = #{phone}
    </select>
 
    <select id="getUserStreetList" resultType="com.panzhihua.common.model.vos.community.IndexUserStreetVo">
        SELECT
            street_id,
            `name`,(
            SELECT
                count( user_id )
            FROM
                sys_user AS su
                LEFT JOIN com_act AS ca ON ca.community_id = su.community_id
            WHERE
                type = 1
                AND ca.street_id = cs.street_id
            ) AS userNum
        FROM
            `com_street` AS cs where area_code=#{areaCode}
            order by userNum desc
    </select>
 
    <select id="getUserCommunityList" resultType="com.panzhihua.common.model.vos.community.IndexUserCommunityVo">
        SELECT
            ca.community_id,
            ca.`name`,
            count( user_id ) as userNum
        FROM
            sys_user as su
            left join com_act as ca on ca.community_id = su.community_id
        WHERE
            type = 1
            AND ca.street_id = #{streetId}
            group by ca.community_id
            order by userNum desc
    </select>
 
    <select id="getUserCommunityExcelExport" resultType="com.panzhihua.common.model.vos.community.IndexUserStreetExcelExportVo">
        SELECT
            cs.`name` AS streetName,
            ca.`name` AS communityName,
            (
            SELECT
                count( user_id )
            FROM
                sys_user AS su1
                LEFT JOIN com_act AS ca1 ON ca1.community_id = su1.community_id
            WHERE
                su1.type = 1
                AND su1.community_id IS NOT NULL
                AND ca1.street_id = ca.street_id
            ) AS streetNum,
            count( user_id ) AS userNum
        FROM
            sys_user AS su
            LEFT JOIN com_act AS ca ON ca.community_id = su.community_id
            LEFT JOIN com_street AS cs ON cs.street_id = ca.street_id
        WHERE
            su.type = 1
            AND su.community_id IS NOT NULL and ca.area_code = #{areaCode}
        GROUP BY
            ca.community_id
        ORDER BY
            ca.street_id DESC,
            userNum DESC
    </select>
 
    <select id="countPropertyWorker" resultType="integer">
        SELECT COUNT(id) FROM com_property
        WHERE user_id = #{userId} AND community_id = #{communityId}
    </select>
 
</mapper>