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
<?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_dangjian.dao.ComPbCheckUnitMapper">
 
    <resultMap type="com.panzhihua.service_dangjian.entity.ComPbCheckUnit" id="ComPbCheckUnitMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="communityId" column="community_id" jdbcType="INTEGER"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="type" column="type" jdbcType="INTEGER"/>
        <result property="contacts" column="contacts" jdbcType="VARCHAR"/>
        <result property="phone" column="phone" jdbcType="VARCHAR"/>
        <result property="createAt" column="create_at" jdbcType="TIMESTAMP"/>
        <result property="createBy" column="create_by" jdbcType="INTEGER"/>
        <result property="updateAt" column="update_at" jdbcType="TIMESTAMP"/>
        <result property="updateBy" column="update_by" jdbcType="INTEGER"/>
    </resultMap>
 
    <!--查询单个-->
    <select id="queryById" resultType="com.panzhihua.common.model.vos.common.ComPbCheckUnitVo">
        select
        cpcu.*
        ,(select count(id) from com_pb_member where audit_result = 1 and check_unit_id = cpcu.id) as count
        from com_pb_check_unit as cpcu
        where cpcu.id = #{id}
    </select>
 
    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultType="com.panzhihua.common.model.vos.common.ComPbCheckUnitVo">
        select
        cpcu.*
        from com_pb_check_unit as cpcu
        <where>
            <if test="dto.id != null">
                and cpcu.id = #{dto.id}
            </if>
            <if test="dto.type != null">
                and cpcu.`type` = #{dto.type}
            </if>
            <if test="dto.communityIds != null and dto.communityIds.size()>0">
                AND cpcu.community_id IN
                <foreach collection="dto.communityIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="dto.ids != null and dto.ids.length != 0">
                AND cpcu.id IN
                <foreach collection="dto.ids" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="dto.keyWord != null and dto.keyWord != ''">
                and (cpcu.contacts like concat(#{dto.keyWord},'%') or cpcu.`name` like concat('%',#{dto.keyWord},'%') or cpcu.phone like concat(#{dto.keyWord},'%'))
            </if>
            <if test="dto.name != null and dto.name != ''">
                and cpcu.`name` like concat('%',#{dto.name},'%')
            </if>
            <if test="dto.contacts != null and dto.contacts != ''">
                and cpcu.`contacts` like concat(#{dto.contacts},'%')
            </if>
            <if test="dto.specialtyName != null and dto.specialtyName != ''">
                and cpcu.specialty_name like concat('%',#{dto.specialtyName},'%')
            </if>
            <if test="dto.belongTo != null and dto.belongTo != ''">
                and cpcu.belong_to =#{dto.belongTo}
            </if>
            <if test="dto.natureName != null and dto.natureName != ''">
                and cpcu.nature_name = #{dto.natureName}
            </if>
            <if test="dto.orgName != null and dto.orgName !=''">
                and cpcu.org_name like concat('%',#{dto.orgName},'%')
            </if>
        </where>
        order by cpcu.create_at desc
    </select>
 
    <!--查询所有数据-->
    <select id="queryAllByList" resultType="com.panzhihua.common.model.vos.common.ComPbCheckUnitVo">
        select
        cpcu.id, cpcu.`name`, cpcu.`type`, cpcu.contacts, cpcu.phone, cpcu.create_at, cpcu.create_by, cpcu.update_at, cpcu.update_by
        , cpcu.community_id, cpcu.org_name, ca.`name` as communityName, cpcu.`logo`
        from com_pb_check_unit as cpcu
        left join com_act as ca on ca.community_id = cpcu.community_id
        <where>
            <if test="dto.id != null">
                and cpcu.id = #{dto.id}
            </if>
            <if test="dto.name != null and dto.name != ''">
                and cpcu.`name` = #{dto.name}
            </if>
            <if test="dto.type != null">
                and cpcu.`type` = #{dto.type}
            </if>
            <if test="dto.contacts != null and dto.contacts != ''">
                and cpcu.contacts = #{dto.contacts}
            </if>
            <if test="dto.phone != null and dto.phone != ''">
                and cpcu.phone = #{dto.phone}
            </if>
            <if test="dto.communityId != null and dto.communityId !=0">
                and cpcu.community_id = #{dto.communityId}
            </if>
        </where>
        order by cpcu.create_at desc
    </select>
 
    <select id="selectCommunityId" resultType="Long">
        select community_id from com_area_town_community where area=#{area} and town=#{town} and community=#{community}
    </select>
    <select id="unitStatisticsTop"
            resultType="com.panzhihua.common.model.vos.common.PbCheckUnitStatisticsVo">
        SELECT
        (SELECT COUNT( id ) FROM com_pb_check_unit WHERE 1=1
            <if test="communityIds != null and communityIds.size() >0">
                AND community_id IN
                <foreach collection="communityIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="unitIds != null and unitIds.length != 0 ">
                AND id IN
                <foreach collection="unitIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
 
            <if test="belongTo != null and belongTo != ''">
                AND belong_to = #{belongTo}
            </if>
            <if test="choice != null and choice != ''">
                AND belong_to = #{choice}
            </if>
 
        <if test=" null != yearTime and '' != yearTime">
            AND `create_at` &lt;= concat(#{yearTime},'-12-31 59:59:59')
        </if>
 
        ) AS unitTotal,
        (SELECT COUNT( id ) FROM com_pb_check_unit WHERE nature_name = '机关单位'
            <if test="communityIds != null and communityIds.size() >0">
                AND community_id IN
                <foreach collection="communityIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="unitIds != null and unitIds.length != 0 ">
                AND id IN
                <foreach collection="unitIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="belongTo != null and belongTo != ''">
                AND belong_to = #{belongTo}
            </if>
            <if test="choice != null and choice != ''">
                AND belong_to = #{choice}
            </if>
        <if test=" null != yearTime and '' != yearTime">
            AND `create_at` &lt;= concat(#{yearTime},'-12-31 59:59:59')
        </if>
 
        ) AS organTotal,
        (SELECT COUNT( id ) FROM com_pb_check_unit WHERE nature_name = '企事业单位'
            <if test="communityIds != null and communityIds.size() >0">
                AND community_id IN
                <foreach collection="communityIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="unitIds != null and unitIds.length != 0 ">
                AND id IN
                <foreach collection="unitIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="belongTo != null and belongTo != ''">
                AND belong_to = #{belongTo}
            </if>
            <if test="choice != null and choice != ''">
                AND belong_to = #{choice}
            </if>
        <if test=" null != yearTime and '' != yearTime">
            AND `create_at` &lt;= concat(#{yearTime},'-12-31 59:59:59')
        </if>
        ) AS businessTotal,
        (SELECT COUNT( m.id ) FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
            <if test="communityIds != null and communityIds.size() >0">
                AND m.community_id IN
                <foreach collection="communityIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="unitIds != null and unitIds.length != 0 ">
                AND cpcu.id IN
                <foreach collection="unitIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="belongTo != null and belongTo != ''">
                AND cpcu.belong_to = #{belongTo}
            </if>
            <if test="choice != null and choice != ''">
                AND cpcu.belong_to = #{choice}
            </if>
        <if test=" null != yearTime and '' != yearTime">
           AND cpcu.`create_at` &lt;= concat(#{yearTime},'-12-31 59:59:59')
        </if>
        ) AS partyMemberTotal
    </select>
    <select id="unitStatistics" resultType="com.panzhihua.common.model.vos.common.PbCheckUnitStatisticsVo">
        SELECT temp.*,
        (SELECT COUNT( id ) FROM com_pb_check_unit WHERE nature_name = '机关单位'
 
            <if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
                AND community_id IN
                <foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
                AND id IN
                <foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
         AND belong_to = temp.belong_to
            <if test=" null != commonDto.yearTime and '' != commonDto.yearTime">
                AND `create_at` &lt;= concat(#{commonDto.yearTime},'-12-31 59:59:59')
            </if>
        ) AS organTotal,
        (SELECT COUNT( id ) FROM com_pb_check_unit WHERE nature_name = '企事业单位'
            <if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
                AND community_id IN
                <foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
                AND id IN
                <foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        AND belong_to = temp.belong_to
        <if test=" null != commonDto.yearTime and '' != commonDto.yearTime">
            AND `create_at` &lt;= concat(#{commonDto.yearTime},'-12-31 59:59:59')
        </if>
            ) AS businessTotal,
        (SELECT COUNT( m.id ) FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
            <if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
                AND m.community_id IN
                <foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
                AND m.id IN
                <foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
         AND cpcu.belong_to = temp.belong_to
        <if test=" null != commonDto.yearTime and '' != commonDto.yearTime">
           AND cpcu.`create_at` &lt;= concat(#{commonDto.yearTime},'-12-31 59:59:59')
        </if>
            ) AS partyMemberTotal
        FROM (SELECT belong_to,COUNT( id ) AS unitTotal FROM com_pb_check_unit WHERE 1=1
        <if test=" null != commonDto.yearTime and '' != commonDto.yearTime">
            AND `create_at` &lt;= concat(#{commonDto.yearTime},'-12-31 59:59:59')
        </if>
            <if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
                AND community_id IN
                <foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
                AND id IN
                <foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        <if test="commonDto.belongTo != null and commonDto.belongTo != ''">
            AND belong_to = #{commonDto.belongTo}
        </if>
        GROUP BY belong_to) temp
    </select>
    <select id="pbStatisticsTop" resultType="com.panzhihua.common.model.vos.common.PbCheckUnitStatisticsVo">
        SELECT
        (SELECT COUNT( m.id ) FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
        AND cpcu.nature_name = '机关单位'
        <if test="communityIds != null and communityIds.size() >0">
            AND m.community_id IN
            <foreach collection="communityIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="unitIds != null and unitIds.length !=0">
            AND cpcu.id IN
            <foreach collection="unitIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="belongTo != null and belongTo != ''">
            AND cpcu.belong_to = #{belongTo}
        </if>
        <if test="choice != null and choice != ''">
            AND cpcu.belong_to = #{choice}
        </if>
        <if test="checkUnitId != null">
            AND m.check_unit_id = #{checkUnitId}
        </if>
        <if test=" null != yearTime and '' != yearTime">
            AND cpcu.`create_at` &lt;= concat(#{yearTime},'-12-31 59:59:59')
        </if>
        ) AS organTotal,
        (SELECT COUNT( m.id ) FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
        AND cpcu.nature_name = '企事业单位'
        <if test="communityIds != null and communityIds.size() >0">
            AND m.community_id IN
            <foreach collection="communityIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="unitIds != null and unitIds.length !=0">
            AND cpcu.id IN
            <foreach collection="unitIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="belongTo != null and belongTo != ''">
            AND cpcu.belong_to = #{belongTo}
        </if>
        <if test="choice != null and choice != ''">
            AND cpcu.belong_to = #{choice}
        </if>
        <if test="checkUnitId != null">
            AND m.check_unit_id = #{checkUnitId}
        </if>
        <if test=" null != yearTime and '' != yearTime">
            AND cpcu.`create_at` &lt;= concat(#{yearTime},'-12-31 59:59:59')
        </if>
        ) AS businessTotal,
        (SELECT COUNT( m.id ) FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
        <if test="communityIds != null and communityIds.size() >0">
            AND m.community_id IN
            <foreach collection="communityIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="unitIds != null and unitIds.length !=0">
            AND cpcu.id IN
            <foreach collection="unitIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="belongTo != null and belongTo != ''">
            AND cpcu.belong_to = #{belongTo}
        </if>
        <if test="choice != null and choice != ''">
            AND cpcu.belong_to = #{choice}
        </if>
        <if test="checkUnitId != null">
            AND m.check_unit_id = #{checkUnitId}
        </if>
        <if test=" null != yearTime and '' != yearTime">
            AND cpcu.`create_at` &lt;= concat(#{yearTime},'-12-31 59:59:59')
        </if>
        ) AS partyMemberTotal
    </select>
    <select id="pbStatisticsBelong" resultType="com.panzhihua.common.model.vos.common.PbCheckUnitStatisticsVo">
        SELECT temp.*,
        (SELECT COUNT( m.id ) FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
            <if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
                AND m.community_id IN
                <foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
                AND cpcu.id IN
                <foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        <if test=" null != commonDto.yearTime and '' != commonDto.yearTime">
            and  m.`create_at` &lt;= concat(#{commonDto.yearTime},'-12-31 59:59:59')
        </if>
         AND m.check_unit_id is not null AND cpcu.nature_name = '机关单位' AND cpcu.belong_to = temp.belong_to) AS organTotal,
        (SELECT COUNT( m.id ) FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
            <if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
                AND m.community_id IN
                    <foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
                        #{item}
                    </foreach>
                </if>
            <if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
                AND cpcu.id IN
                <foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        <if test=" null != commonDto.yearTime and '' != commonDto.yearTime">
            and  m.`create_at` &lt;= concat(#{commonDto.yearTime},'-12-31 59:59:59')
        </if>
        AND cpcu.nature_name = '企事业单位' AND cpcu.belong_to = temp.belong_to) AS businessTotal
        FROM (SELECT cpcu.belong_to,COUNT( m.id ) AS partyMemberTotal FROM com_pb_member m LEFT JOIN com_pb_check_unit as cpcu ON m.check_unit_id = cpcu.id WHERE m.audit_result = 1
            <if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
                AND m.community_id IN
                <foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
                AND cpcu.id IN
                <foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        <if test="commonDto.belongTo != null and commonDto.belongTo != ''">
            AND cpcu.belong_to = #{commonDto.belongTo}
        </if>
        <if test=" null != commonDto.yearTime and '' != commonDto.yearTime">
            and  m.`create_at` &lt;= concat(#{commonDto.yearTime},'-12-31 59:59:59')
        </if>
        GROUP BY belong_to) temp
    </select>
    <select id="pbStatisticsUnit" resultType="com.panzhihua.common.model.vos.common.ComPbCheckUnitVo">
        SELECT
        cpcu.id,
        cpcu.`name`,
        cpcu.nature_name,
        cpcu.belong_to,
        cpcu.help_community_name,
        cpcu.village_name,
        COUNT( m.id ) AS count
        FROM
        com_pb_member m
        LEFT JOIN com_pb_check_unit AS cpcu ON m.check_unit_id = cpcu.id
        WHERE
        m.audit_result = 1
        <if test="commonDto.communityIds != null and commonDto.communityIds.size() >0">
            AND m.community_id IN
            <foreach collection="commonDto.communityIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="commonDto.unitIds != null and commonDto.unitIds.length !=0">
            AND cpcu.id IN
            <foreach collection="commonDto.unitIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="commonDto.belongTo != null and commonDto.belongTo != ''">
            AND cpcu.belong_to = #{commonDto.belongTo}
        </if>
        GROUP BY
        cpcu.`name`
    </select>
 
    <select id="organSumIntegral" resultType="java.lang.Integer">
        SELECT sum(csr.pb_reward_integral) as organSumIntegral from (
             SELECT cm.user_id , cu.community_id   FROM com_pb_check_unit cu inner JOIN com_pb_member cm on cm.check_unit_id = cu.id
              where
               cm.user_id is not null
                and cu.community_id is not null
        <if test="communityIds != null and communityIds.size() >0">
            AND cu.community_id IN
            <foreach collection="communityIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test=" null != yearTime and '' != yearTime">
           AND cu.`create_at` &lt;= concat(#{yearTime},'-12-31 59:59:59')
        </if>
                   GROUP BY  cm.user_id , cu.community_id
                 ) as cum INNER JOIN (
            SELECT ccc.*  FROM com_act_act_regist as cr INNER JOIN (
                select ca.community_id ,cs.user_id,cs.activity_id,ca.pb_reward_integral
                FROM com_act_activity ca LEFT JOIN com_act_act_sign cs on cs.activity_id = ca.id  WHERE cs.`status` = '1'  and ca.have_integral_reward = '1'
                ORDER BY  cs.user_id DESC
            ) as ccc on cr.activity_id = ccc.activity_id and cr.user_id = ccc.user_id
        ) as csr  on  csr.community_id = cum.community_id and csr.user_id = cum.user_id
 
    </select>
    <select id="pbOrganSumIntegral" resultType="java.lang.Integer">
        SELECT sum(csr.pb_reward_integral) as organSumIntegral from (
        SELECT cm.user_id , cu.community_id   FROM com_pb_check_unit cu inner JOIN com_pb_member cm on cm.check_unit_id = cu.id
        where
        cm.user_id is not null
        and cu.community_id is not null
        <if test="communityIds != null and communityIds.size() >0">
            AND cu.community_id IN
            <foreach collection="communityIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test=" null != yearTime and '' != yearTime">
             AND cm.`create_at` &lt;= concat(#{yearTime},'-12-31 59:59:59')
        </if>
        GROUP BY  cm.user_id , cu.community_id
        ) as cum INNER JOIN (
        SELECT ccc.*  FROM com_act_act_regist as cr INNER JOIN (
        select ca.community_id ,cs.user_id,cs.activity_id,ca.pb_reward_integral
        FROM com_act_activity ca LEFT JOIN com_act_act_sign cs on cs.activity_id = ca.id  WHERE cs.`status` = '1'  and ca.have_integral_reward = '1'
        ORDER BY  cs.user_id DESC
        ) as ccc on cr.activity_id = ccc.activity_id and cr.user_id = ccc.user_id
        ) as csr  on  csr.community_id = cum.community_id and csr.user_id = cum.user_id
 
    </select>
 
 
    <select id="selectOrgAdmin" resultType="Integer">
        select count(*) from com_pb_check_unit where admin_phone like concat('%',#{phone},'%')
    </select>
 
 
 
</mapper>