mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
<?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"/>
        <result property="plaintextPassword" column="plaintext_password"/>
        <result property="relationName" column="relation_name"/>
        <result property="loveIntegral" column="love_integral"/>
        <result property="playPwd" column="play_pwd"/>
 
    </resultMap>
    <sql id="columns">
        `user_id`,`account`,`password`,`openid`,`session_key`,`unionid`,`phone`,`nick_name`,`name`,play_pwd,
        `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`,love_integral
    </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,love_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.love_integral,
        u.play_pwd,
        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 and u.app_id =#{pageUserAppletsBackstageDTO.appId}
        <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.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 t.type = 1 and t.app_id = #{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 t.app_id = #{areaCode}
            </select>
 
    <select id="selectCommunityUserOrder" resultType="com.panzhihua.service_user.model.dtos.DataKanbanDTO">
        SELECT
            a.`name`,
            COUNT(u.user_id)num,
            t1.dayNum
        FROM
            com_act a
                LEFT JOIN sys_user u ON a.community_id = u.community_id and u.type=1 and a.state=0 and u.app_id=#{areaCode}
                left join (SELECT count( user_id ) dayNum,community_id FROM sys_user WHERE type = 1 and app_id=#{areaCode}
                                                                                       AND last_login_time > DATE_FORMAT( date_sub( SYSDATE(), INTERVAL 0 DAY ), '%Y-%m-%d 00:00:00') GROUP BY community_id) t1 on a.community_id = t1.community_id where a.app_id =#{areaCode} GROUP BY a.community_id
    </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 app_id=#{areaCode}
        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 a.state=0 and u.app_id=#{areaCode} and u.create_at >= DATE_ADD(curdate(),interval -day(curdate())+1 day)
        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.love_integral,
        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>
            u.type=3
            <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.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 t.app_id = #{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 su.app_id = #{areaCode}
    </select>
 
    <select id="selectDailyAdd"  resultType="com.panzhihua.service_user.model.dtos.UsersStatisticsDTO">
        SELECT DATE_FORMAT( u.create_at, '%Y-%m-%d' ) as specificDate,count( u.user_id )  total FROM sys_user u
        LEFT JOIN com_act t1 ON u.community_id = t1.community_id  WHERE u.type = 1 AND u.app_id = #{appId}  AND u.create_at > #{createAt} GROUP BY specificDate;
    </select>
 
    <select id="selectActive"  resultType="com.panzhihua.service_user.model.dtos.UsersStatisticsDTO">
        SELECT DATE_FORMAT( u.last_login_time, '%Y-%m-%d' ) as specificDate,count( u.user_id )  total FROM sys_user u
        LEFT JOIN com_act t1 ON u.community_id = t1.community_id  WHERE u.type = 1 AND u.app_id = #{appId}  AND u.last_login_time > #{lastLoginTime} GROUP BY specificDate;
    </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,
        u.love_integral,
        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 name,community_id,lng,lat,area_code,contacts_phone 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 state = 0 and ca.app_id = #{areaCode}
                AND ca.street_id = cs.street_id
            ) AS userNum
        FROM
            `com_street` AS cs where cs.app_id = #{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 state = 0
            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
        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>
 
    <select id="countSocialWorker" resultType="integer">
        select count(id) from com_act_social_worker where telephone = #{phone} and community_id = #{communityId}
    </select>
 
    <select id="countSocialOrg" resultType="Integer">
        select count(id) from com_act_social_org where user_id = #{userId}
    </select>
 
    <select id="countFmsMember" resultType="integer">
        SELECT COUNT(id) FROM com_fms_team_member
        WHERE phone = #{phone} AND community_id = #{communityId}
    </select>
 
    <select id="selectStreetById" resultType="com.panzhihua.common.model.vos.community.ComStreetVO">
        SELECT street_id, area_code FROM com_street WHERE street_id = #{streetId}
    </select>
 
    <select id="countSocialOrgMember" resultType="integer">
        SELECT COUNT(id) FROM com_act_social_member
        WHERE user_id = #{userId}
    </select>
 
    <select id="countOrgNum" resultType="integer">
        SELECT COUNT(id)
        FROM com_act_social_org
        WHERE contact_phone = #{phone} AND is_society = 1
    </select>
 
    <select id="selectCountDpc" resultType="integer">
        SELECT COUNT(id)
        FROM com_act_dpc
        WHERE phone = #{phone} AND community_id = #{userCommunityId} AND is_del = 0
    </select>
 
    <select id="countEasyPhotoMember" resultType="Integer">
        SELECT COUNT(id) FROM com_act_easy_photo_member
        WHERE phone = #{phone} AND community_id = #{communityId}
    </select>
 
    <select id="selectAcidMemberByPhone" resultType="com.panzhihua.common.model.vos.community.acid.ComActAcidMemberVO">
        SELECT id, relation_name FROM com_act_acid_member WHERE phone = #{phone}
    </select>
 
    <select id="selectAreaTownCommunity" resultType="com.panzhihua.common.model.vos.community.ComAreaTownCommunityVO">
        SELECT * FROM com_area_town_community WHERE community = #{relationName}
    </select>
 
    <select id="selectAreaCodeByStreetId" resultType="String">
        select t.district_name from com_mng_struct_area_district t left join com_street t1 on t.district_adcode  = t1.area_code where t1.street_id =#{streetId}
    </select>
 
    <select id="selectOrgAdmin" resultType="Integer">
        select count(*) from com_pb_check_unit where admin_phone like concat('%',#{phone},'%')
    </select>
 
    <select id="selectOrgAdminId" resultType="Long">
        select id from com_pb_check_unit where admin_phone like concat('%',#{phone},'%')
    </select>
 
    <select id="selectCheckUnitId" resultType="Long">
        select check_unit_id from com_pb_member where phone = #{phone} limit 1
    </select>
    <select id="userAnalysis" resultType="com.panzhihua.common.model.vos.user.UserProportion">
        select cs.area_code,cs.name as streetName,ac.name as communityName,count(su.user_id) as user,su.community_id as communityId from sys_user as su
        left join com_act as ac on su.community_id=ac.community_id
        left join com_street as cs on ac.street_id=cs.street_id
        where su.community_id&lt;>''
        and cs.area_code&lt;>''
        <if test="range != null and range != ''">
            and su.create_at >= #{range}
        </if>
        <if test="appId!=null and appId!=''">
            and su.app_id = #{appId}
        </if>
        <if test="type == 5">
            <if test="areaCode != null">
                and ac.area_code=#{areaCode}
                group by cs.street_id
            </if>
        </if>
        <if test="type == 4">
            <if test="streetId != null">
                and cs.street_id=#{streetId}
                and su.community_id&lt;>11
                group by su.community_id
            </if>
        </if>
        <if test="type == 1">
            group by cs.area_code
        </if>
        <if test="type == 2">
            group by cs.street_id
        </if>
        <if test="type == 3">
            and su.community_id&lt;>11
            group by su.community_id
        </if>
        order by user desc
        limit 10
    </select>
    <select id="realUserCount" resultType="com.panzhihua.common.model.vos.user.RealUser">
        select cs.area_code as areaCode,cs.street_id,ac.name as communityName,su.community_id as communityId,
        cs.name as StreetName,count(su.user_id) as count from sys_user as su
        left join com_act as ac on su.community_id=ac.community_id
        left join com_street as cs on ac.street_id=cs.street_id
        where su.community_id&lt;>''
        and cs.area_code&lt;>''
        and su.id_card&lt;>''
        <if test="range != null and range != ''">
            and su.create_at >= #{range}
        </if>
        <if test="appId!=null and appId!=''">
            and su.app_id = #{appId}
        </if>
        <if test="type == 5">
            <if test="areaCode != null">
                and ac.area_code=#{areaCode}
                group by cs.street_id
            </if>
        </if>
        <if test="type == 4">
            and cs.street_id=#{streetId}
            group by su.community_id
        </if>
        <if test="type == 1">
            group by cs.area_code
        </if>
        <if test="type == 2">
            group by cs.street_id
        </if>
        <if test="type == 3">
            group by su.community_id
        </if>
        order by count desc
        limit 11
    </select>
    <select id="streetUserCount" resultType="Integer">
        select count(user_id) from sys_user as su
        left join com_act as ac on su.community_id=ac.community_id
        left join com_street as cs on ac.street_id=cs.street_id
        where su.community_id&lt;>''
        and cs.area_code&lt;>''
        and cs.street_id=#{id}
        <if test="areaCode != null">
            and ac.area_code=#{areaCode}
        </if>
    </select>
    <select id="dataKanBanStreet" 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 t.type = 1  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
        <if test="streetId != null">
            and t1.street_id=#{streetId}
        </if>
        <if test="areaCode != null">
            and t1.area_code=#{areaCode}
        </if>
        <if test="range != null and range != ''">
            and t.create_at >= #{range}
            and t.community_id&lt;>11
        </if>
    </select>
    <select id="getDailyAddAndActive" resultType="java.util.Map">
        select COUNT(case WHEN DATE_FORMAT(su.last_login_time,'%m-%d-%Y')=DATE_FORMAT(#{date},'%m-%d-%Y') then user_id else null end) as activeUser,
        count(case WHEN DATE_FORMAT(su.create_at,'%m-%d-%Y')=DATE_FORMAT(#{date},'%m-%d-%Y') then user_id else null end ) as addUser
        from sys_user as su
        left join com_act as ac on su.community_id=ac.community_id
        left join com_street as cs on ac.street_id=cs.street_id
        where su.community_id&lt;>''
        and cs.area_code&lt;>''
        and su.type = 1
        <if test="appId != null and appId != &quot;&quot;">
            and su.app_id = #{appId}
        </if>
        <if test="id != null">
            and cs.street_id=#{id}
        </if>
        <if test="areaCode != null">
            and cs.area_code=#{areaCode}
        </if>
    </select>
 
    <select id="getDailyAdd" resultType="com.panzhihua.service_user.model.dtos.UsersStatisticsDTO">
        SELECT DATE_FORMAT( su.create_at, '%Y-%m-%d' ) as specificDate ,count(su.user_id) as total      FROM
        sys_user AS su
        LEFT JOIN com_act AS ac ON su.community_id = ac.community_id
        LEFT JOIN com_street AS cs ON ac.street_id = cs.street_id
        where su.community_id&lt;>''
        and cs.area_code&lt;>''
        and su.type = 1
        <if test="appId != null and appId != &quot;&quot;">
            and su.app_id = #{appId}
        </if>
        <if test="id != null">
            and cs.street_id=#{id}
        </if>
        <if test="areaCode != null">
            and cs.area_code=#{areaCode}
        </if>
        AND su.create_at > #{createAt} GROUP BY specificDate
    </select>
    <select id="getActive" resultType="com.panzhihua.service_user.model.dtos.UsersStatisticsDTO">
        SELECT DATE_FORMAT( su.last_login_time, '%Y-%m-%d' ) as specificDate ,count(su.user_id) as total      FROM
        sys_user AS su
        LEFT JOIN com_act AS ac ON su.community_id = ac.community_id
        LEFT JOIN com_street AS cs ON ac.street_id = cs.street_id
        where su.community_id&lt;>''
        and cs.area_code&lt;>''
        and su.type = 1
        <if test="appId != null and appId != &quot;&quot;">
            and su.app_id = #{appId}
        </if>
        <if test="id != null">
            and cs.street_id=#{id}
        </if>
        <if test="areaCode != null">
            and cs.area_code=#{areaCode}
        </if>
        AND su.last_login_time > #{lastLoginTime} GROUP BY specificDate
    </select>
 
    <select id="selectStreetByAreaCode" resultType="com.panzhihua.common.model.vos.user.StreetVOS">
        select street_id as id,name as name from com_street where area_code=#{code} and app_id ='wx118de8a734d269f0'
    </select>
    <select id="selectStreetsByAreaCode" resultType="com.panzhihua.common.model.vos.user.StreetVO">
        select street_id as id,name as name from com_street where area_code=#{code}
    </select>
    <select id="selectComActAcidCheckRecordById"
            resultType="com.panzhihua.common.model.vos.community.acid.ComActAcidCheckRecordVO">
        select * from com_act_acid_check_record where id = #{id}
    </select>
    <select id="selectComActAcidRecord" resultType="com.panzhihua.common.model.vos.community.acid.ComActAcidRecordVO">
        select * from com_act_acid_record where id = #{id}
    </select>
    <select id="selectComActAcidMember" resultType="com.panzhihua.common.model.vos.community.acid.ComActAcidMemberVO">
        select * from com_act_acid_member where id = #{id}
    </select>
    <select id="getMonthUsers" resultType="java.lang.Integer">
        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 t.community_id is not null
        and t.community_id&lt;>11
        <if test="streetId != null">
            and t1.street_id=#{streetId}
        </if>
        <if test="areaCode != null">
            and t1.area_code=#{areaCode}
        </if>
        <if test="range != null and range != ''">
            and t.create_at >= #{range}
        </if>
        <if test="appId!=null and appId!=''">
            and t.app_id = #{appId}
        </if>
    </select>
    <select id="selectCommunityByStreetId" resultType="com.panzhihua.common.model.vos.user.CommunityVO">
        select community_id as id,name from com_act where street_id =#{id} and app_id = 'wx118de8a734d269f0'
        <if test="type == 1">
            and name like concat('%','社区')
        </if>
        <if test="type == 2">
            and name like concat('%','村')
        </if>
    </select>
 
    <select id="selectIdsByAccount" resultType="java.lang.Integer">
        select user_id from sys_user where account in
        <foreach collection="array" item="name" separator="," open="(" close=")" >
            #{name}
        </foreach>
    </select>
    <select id="selectCommunityByStreetName" resultType="com.panzhihua.common.model.vos.user.CommunityVO">
        select ca.community_id as id,ca.name as name
        from sys_user as su
        left join com_street as cs on cs.name=su.name
        left join com_act as ca on ca.street_id=cs.street_id
        where su.account=#{name}
    </select>
    <select id="selectStreetByName" resultType="com.panzhihua.common.model.vos.user.StreetVOS">
        select cs.street_id as id,cs.name as name
        from sys_user as su
        left join com_street as cs on su.name=cs.name
        where su.account=#{name}
        limit 1
    </select>
    <select id="isExpert" resultType="com.panzhihua.common.model.vos.sanshuo.ComSanshuoExpertVO">
        select * from com_sanshuo_expert where phone=#{phone}
    </select>
 
    <select id="isIndustryCenterAccount" resultType="Integer">
        select count(id) from com_sanshuo_industry_center where account=#{account}
    </select>
 
    <select id="isExpertAccount" resultType="Integer">
        select count(id) from com_sanshuo_expert where account=#{account}
    </select>
 
    <select id="isDpcMember" resultType="Integer">
         select count(id) from com_act_dpc where name =#{name} and phone=#{phone}
    </select>
    <select id="isPropertyAccount" resultType="java.lang.Long">
        select id from com_property where phone=#{phone}
    </select>
    <select id="getCommunityAppId" resultType="java.lang.String">
        select app_id from com_act where community_id=#{communityId}
    </select>
</mapper>