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
<?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_community.dao.ComActActivityDAO">
 
        <!-- 通用查询映射结果 -->
        <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActActivityDO">
                    <id column="id" property="id" />
                    <result column="activity_name" property="activityName" />
                    <result column="sponsor_id" property="sponsorId" />
                    <result column="activity_addr" property="activityAddr" />
                    <result column="lat" property="lat" />
                    <result column="lng" property="lng" />
                    <result column="status" property="status" />
                    <result column="publish_at" property="publishAt" />
                    <result column="end_at" property="endAt" />
                    <result column="begin_at" property="beginAt" />
                    <result column="sign_up_begin" property="signUpBegin" />
                    <result column="sign_up_end" property="signUpEnd" />
                    <result column="aattend_people" property="aattendPeople" />
                    <result column="volunteer_min" property="volunteerMin" />
                    <result column="volunteer_max" property="volunteerMax" />
                    <result column="participant_min" property="participantMin" />
                    <result column="participant_max" property="participantMax" />
                    <result column="cover" property="cover" />
                    <result column="has_prize" property="hasPrize" />
                    <result column="is_qr_code" property="isQrCode" />
                    <result column="contact_name" property="contactName" />
                    <result column="contact_phone" property="contactPhone" />
                    <result column="is_regist" property="isRegist" />
                    <result column="is_top" property="isTop" />
                    <result column="prize_remark" property="prizeRemark" />
                    <result column="reward_desc" property="rewardDesc" />
                    <result column="content" property="content" />
                    <result column="community_id" property="communityId" />
                    <result column="create_at" property="createAt" />
                    <result column="cancel_reason" property="cancelReason" />
                    <result column="range" property="range" />
                    <result column="have_integral_reward" property="haveIntegralReward" />
                    <result column="participant_reward_way" property="participantRewardWay" />
                    <result column="participant_reward_integral" property="participantRewardIntegral" />
                    <result column="volunteer_reward_way" property="volunteerRewardWay" />
                    <result column="volunteer_reward_integral" property="volunteerRewardIntegral" />
                    <result column="pb_reward_way" property="pbRewardWay" />
                    <result column="pb_reward_integral" property="pbRewardIntegral" />
                    <result column="limit" property="limit" />
                    <result column="can_cancel" property="canCancel" />
                    <result column="cancel_deduct" property="cancelDeduct" />
                    <result column="activity_type" property="activityType" />
        </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, activity_name, sponsor_id, activity_addr, lat, lng, status, publish_at, end_at, begin_at, sign_up_begin, sign_up_end, aattend_people, volunteer_min, volunteer_max, participant_min, participant_max, cover, has_prize, is_qr_code, contact_name, contact_phone, is_regist, is_top, prize_remark, reward_desc, content, community_id, create_at, cancel_reason
    </sql>
    <insert id="addActivityType">
        INSERT INTO com_act_activity_type (id,`name`, `type`, community_id)
        VALUES (#{comActActivityTypeVO.id},#{comActActivityTypeVO.name}, #{comActActivityTypeVO.type}, #{comActActivityTypeVO.communityId})
    </insert>
 
    <select id="activityStatistics" resultType="com.panzhihua.common.model.vos.community.ComActActivityStatisticsVO">
        SELECT IFNULL(volunteer_max,0) + IFNULL(participant_max,0) as signTotal
             ,(SELECT count(id) FROM com_act_act_sign WHERE activity_id = #{activityId} AND `status` = 1) as reallySignTotal
             ,(SELECT count(id) FROM com_act_act_sign WHERE activity_id = #{activityId} AND `status` = 1) as registTotal
             ,(SELECT count(id) FROM com_act_act_regist WHERE activity_id = #{activityId}) as reallyRegistTotal
             ,((SELECT count(id) FROM com_act_act_sign WHERE activity_id = #{activityId} AND `status` = 1) - (SELECT count(id) FROM com_act_act_regist WHERE activity_id = #{activityId})) as noRegistTotal
             ,(SELECT count(id) FROM com_act_act_sign WHERE activity_id = #{activityId} AND `status` = 1) as evaluateTotal
             ,(SELECT count(id) FROM com_act_act_evaluate WHERE activity_id = #{activityId}) as reallyEvaluateTotal
             ,((SELECT count(id) FROM com_act_act_sign WHERE activity_id = #{activityId} AND `status` = 1) - (SELECT count(id) FROM com_act_act_evaluate WHERE activity_id = #{activityId})) as noEvaluateTotal
        FROM com_act_activity where id = #{activityId}
    </select>
    <select id="getIndexTopActivityList" resultMap="BaseResultMap">
        SELECT * FROM `com_act_activity`
        WHERE community_id = ${communityId} and is_top = 1 and sign_up_end &gt;= now()
    </select>
    <select id="pageActivityCommunityBack"
            resultType="com.panzhihua.common.model.vos.community.ComActActivityVO">
        SELECT  a.id, a.activity_name, u.`name` sponsorName, a.activity_addr, a.participant_max, a.contact_name,
        count(IF( s.sign_identity = 1, s.id, NULL )) participant_now,
        count(IF( s.sign_identity = 2, s.id, NULL )) partyMemberNow,
        count(IF( s.sign_identity = 3, s.id, NULL )) volunteer_now, a.volunteer_max, a.`status`, a.publish_at,
        a.is_qr_code, a.begin_at, a.end_at, a.sign_up_begin, a.sign_up_end, a.participant_reward_way,
        a.volunteer_reward_way,a.pb_reward_way,
        a.activity_type, a.have_integral_reward ,a.participant_reward_integral,a.volunteer_reward_integral,a.pb_reward_integral,
        a.party_member_max,a.party_member_min,a.cover,a.type,a.duration<if test='comActActivityVO.type != null and comActActivityVO.type == 4'>,so.socialCount</if>
        FROM  com_act_activity a
        LEFT JOIN sys_user u ON a.sponsor_id=u.user_id
        LEFT JOIN (SELECT * FROM com_act_act_sign WHERE `status` = 1) s ON a.id=s.activity_id
        <if test='comActActivityVO.type != null and comActActivityVO.type == 4'>
            left join  (select count(t.id) as socialCount,activity_id from   com_act_act_regist  t LEFT JOIN sys_user t1 on  t.user_id = t1.user_id LEFT JOIN com_act_social_worker t2 on t1.phone = t2.telephone where t2.id is not null GROUP BY t.activity_id) so on a.id = so.activity_id
        </if>
        WHERE  1=1
        <if test="comActActivityVO.communityIds != null and comActActivityVO.communityIds.size() != 0">
            and a.community_id in
            <foreach collection="comActActivityVO.communityIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test='comActActivityVO.type != null'>
            AND a.type = #{comActActivityVO.type}
        </if>
        <if test='comActActivityVO.activityType != null and comActActivityVO.activityType !=&quot;&quot;'>
            AND a.activity_type = #{comActActivityVO.activityType}
        </if>
        <if test='comActActivityVO.activityName != null and comActActivityVO.activityName !=&quot;&quot;'>
            AND a.activity_name LIKE concat( #{comActActivityVO.activityName}, '%' )
        </if>
        <if test='comActActivityVO.projectId != null'>
            AND a.project_id = #{comActActivityVO.projectId}
        </if>
        <if test='comActActivityVO.status != null and comActActivityVO.status !=0 '>
            AND a.`status` = #{comActActivityVO.status}
        </if>
        <if test='comActActivityVO.beginAt != null '>
            AND a.begin_at <![CDATA[ >= ]]> #{comActActivityVO.beginAt} AND a.end_at <![CDATA[ <= ]]> #{comActActivityVO.endAt}
        </if>
        GROUP BY a.id ORDER BY a.status = 99 desc,a.publish_at DESC
    </select>
    <select id="inforActivity" resultType="com.panzhihua.common.model.vos.community.ComActActivityVO">
        SELECT  u.name sponsorName, ca.name communityName,
        count(IF( s.sign_identity = 1, s.id, NULL )) participant_now,
        count(IF( s.sign_identity = 2, s.id, NULL )) partyMemberNow,
        count(IF( s.sign_identity = 3, s.id, NULL )) volunteer_now, a.*,t1.name as projectName
        FROM  com_act_activity a
        left join sys_user u on a.sponsor_id=u.user_id
        left join (select * from com_act_act_sign where `status` = 1) s on a.id=s.activity_id
        left join com_act ca on a.community_id=ca.community_id  left join com_act_social_project t1 on a.project_id = t1.id where a.id = #{id} group by a.id
 
    </select>
    <select id="listActivityType" resultType="com.panzhihua.common.model.vos.community.ComActActivityTypeVO">
        SELECT * FROM com_act_activity_type WHERE `type` = #{type} AND community_id = ${communityId} ORDER BY id ASC
    </select>
<!--    <select id="selectResidentActHistogramData"-->
<!--            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">-->
<!--        SELECT activity_type AS filed, COUNT(id) AS num-->
<!--        FROM com_act_activity-->
<!--        WHERE community_id = ${communityId} AND `status` IN(2,3,4,5)-->
<!--        <if test="isResidentAct">-->
<!--            AND `type` = 2-->
<!--        </if>-->
<!--        <if test="!isResidentAct">-->
<!--            AND `type` = 1-->
<!--        </if>-->
<!--        GROUP BY filed-->
<!--    </select>-->
 
    <select id="selectResidentActHistogramData"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT activity_type AS filed, COUNT(id) AS num
        FROM com_act_activity
        WHERE community_id = ${communityId} AND `status` IN(2,3,4,5)
        GROUP BY filed
    </select>
 
    <select id="getIndexResidentActBaseData"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT filed, num, IF(total = 0,0,ROUND(num/total,2)) AS percent FROM
        (SELECT t1.activity_type AS filed, COUNT(t2.id) AS num
        FROM com_act_activity t1
        LEFT JOIN (SELECT * FROM com_act_act_sign WHERE `status` = 1) t2 ON t1.id = t2.activity_id
        WHERE t1.community_id = ${communityId}
        <if test="isResidentAct">
            AND t1.`type` = 2
        </if>
        <if test="!isResidentAct">
            AND t1.`type` = 1
        </if>
        GROUP BY filed) temp1,
        (SELECT COUNT(t2.id) AS total
        FROM com_act_activity t1
        LEFT JOIN (SELECT * FROM com_act_act_sign WHERE `status` = 1) t2 ON t1.id = t2.activity_id
        WHERE t1.community_id = ${communityId}
        <if test="isResidentAct">
            AND t1.`type` = 2
        </if>
        <if test="!isResidentAct">
            AND t1.`type` = 1
        </if>
        ) temp2
    </select>
<!--    <select id="getActAddPolylineData" resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">-->
<!--        SELECT filed, SUM(num) AS num FROM (-->
<!--            SELECT DATE_FORMAT( create_at, '%Y-%m' ) AS filed, COUNT(id) AS num-->
<!--            FROM com_act_activity-->
<!--            WHERE community_id = ${communityId} AND `status` IN(2,3,4,5)-->
<!--            <if test="isResidentAct">-->
<!--                AND `type` = 2-->
<!--            </if>-->
<!--            <if test="!isResidentAct">-->
<!--                AND `type` = 1-->
<!--            </if>-->
<!--            AND DATE_FORMAT( create_at, '%Y-%m' ) &gt; DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') GROUP BY filed-->
<!--            UNION ALL SELECT * FROM-->
<!--            (-->
<!--                SELECT DATE_FORMAT(curdate(),'%Y-%m') AS filed, 0 AS num union-->
<!--                SELECT DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') AS filed, 0 AS num union-->
<!--                SELECT DATE_FORMAT(date_sub(curdate(), interval 2 month),'%Y-%m') AS filed, 0 AS num union-->
<!--                SELECT DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AS filed, 0 AS num union-->
<!--                SELECT DATE_FORMAT(date_sub(curdate(), interval 4 month),'%Y-%m') AS filed, 0 AS num union-->
<!--                SELECT DATE_FORMAT(date_sub(curdate(), interval 5 month),'%Y-%m') AS filed, 0 AS num union-->
<!--                SELECT DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AS filed, 0 AS num union-->
<!--                SELECT DATE_FORMAT(date_sub(curdate(), interval 7 month),'%Y-%m') AS filed, 0 AS num union-->
<!--                SELECT DATE_FORMAT(date_sub(curdate(), interval 8 month),'%Y-%m') AS filed, 0 AS num union-->
<!--                SELECT DATE_FORMAT(date_sub(curdate(), interval 9 month),'%Y-%m') AS filed, 0 AS num union-->
<!--                SELECT DATE_FORMAT(date_sub(curdate(), interval 10 month),'%Y-%m') AS filed, 0 AS num union-->
<!--                SELECT DATE_FORMAT(date_sub(curdate(), interval 11 month),'%Y-%m') AS filed, 0 AS num-->
<!--            ) temT-->
<!--        ) temp GROUP BY filed ORDER BY filed ASC-->
<!--    </select>-->
 
 
    <select id="getActAddPolylineData" resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT filed, SUM(num) AS num FROM (
        SELECT DATE_FORMAT( create_at, '%Y-%m' ) AS filed, COUNT(id) AS num
        FROM com_act_activity
        WHERE community_id = ${communityId} AND `status` IN(2,3,4,5)
        AND DATE_FORMAT( create_at, '%Y-%m' ) &gt; DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') GROUP BY filed
        UNION ALL SELECT * FROM
        (
        SELECT DATE_FORMAT(curdate(),'%Y-%m') AS filed, 0 AS num union
        SELECT DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') AS filed, 0 AS num union
        SELECT DATE_FORMAT(date_sub(curdate(), interval 2 month),'%Y-%m') AS filed, 0 AS num union
        SELECT DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AS filed, 0 AS num union
        SELECT DATE_FORMAT(date_sub(curdate(), interval 4 month),'%Y-%m') AS filed, 0 AS num union
        SELECT DATE_FORMAT(date_sub(curdate(), interval 5 month),'%Y-%m') AS filed, 0 AS num union
        SELECT DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AS filed, 0 AS num union
        SELECT DATE_FORMAT(date_sub(curdate(), interval 7 month),'%Y-%m') AS filed, 0 AS num union
        SELECT DATE_FORMAT(date_sub(curdate(), interval 8 month),'%Y-%m') AS filed, 0 AS num union
        SELECT DATE_FORMAT(date_sub(curdate(), interval 9 month),'%Y-%m') AS filed, 0 AS num union
        SELECT DATE_FORMAT(date_sub(curdate(), interval 10 month),'%Y-%m') AS filed, 0 AS num union
        SELECT DATE_FORMAT(date_sub(curdate(), interval 11 month),'%Y-%m') AS filed, 0 AS num
        ) temT
        ) temp GROUP BY filed ORDER BY filed ASC
    </select>
 
 
 
    <select id="getActTotalPolylineData"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT COUNT(id) AS num
        FROM com_act_activity
        WHERE community_id = ${communityId} AND `status` IN(2,3,4,5)
        <if test="isResidentAct">
            AND `type` = 2
        </if>
        <if test="!isResidentAct">
            AND `type` = 1
        </if>
        AND DATE_FORMAT( create_at, '%Y-%m' ) &lt;= #{date}
    </select>
    <select id="indexActList" resultType="com.panzhihua.common.model.vos.community.ComActActivityVO">
        SELECT id, `status`, activity_type, activity_name, cover
        FROM com_act_activity
        WHERE 1=1
        <if test="pageBaseDTO.communityIds != null and pageBaseDTO.communityIds.size > 0">
            AND community_id IN
            <foreach collection="pageBaseDTO.communityIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="pageBaseDTO.communityIds == null">
            AND community_id = ${pageBaseDTO.communityId}
        </if>
        <if test="isResidentAct">
            AND `type` = 2
        </if>
        <if test="!isResidentAct">
            AND `type` = 1
        </if>
        <if test="pageBaseDTO.param2 != null and pageBaseDTO.param2 != &quot;&quot;">
            AND activity_type = #{pageBaseDTO.param2}
        </if>
        ORDER BY id DESC
    </select>
 
    <select id="selectProjectActivity" resultType="com.panzhihua.common.model.vos.community.ComActActivityVO">
        SELECT  a.id, a.activity_name, u.`name` sponsorName, a.activity_addr, a.participant_max, a.contact_name,
                count(IF( s.sign_identity = 1, s.id, NULL )) participant_now,
                count(IF( s.sign_identity = 2, s.id, NULL )) partyMemberNow,
                count(IF( s.sign_identity = 3, s.id, NULL )) volunteer_now, a.volunteer_max,a.`status`, a.publish_at, a.is_qr_code,
                a.begin_at, a.end_at, a.sign_up_begin, a.sign_up_end, a.participant_reward_way,
                a.volunteer_reward_way,a.pb_reward_way, a.activity_type, a.have_integral_reward , a.cover , t1.evaluateLevel
        FROM  com_act_activity a
                  LEFT JOIN sys_user u ON a.sponsor_id=u.user_id
                  LEFT JOIN (SELECT * FROM com_act_act_sign WHERE `status` = 1) s ON a.id=s.activity_id
                  LEFT JOIN (select AVG(star_level) as evaluateLevel,activity_id from com_act_act_evaluate GROUP BY activity_id) t1 on a.id = t1.activity_id
        WHERE   is_project=1 order by t1.evaluateLevel desc
    </select>
 
    <select id="selectActivityBySocialWorker" resultType="com.panzhihua.common.model.vos.community.ComActActivityVO">
        select t.* from com_act_activity t left join com_act_act_regist t1 on t.id=t1.activity_id where t1.user_id =
        (select t1.user_id from com_act_social_worker t LEFT JOIN sys_user t1 on t.telephone = t1.phone where t.id = #{id})
    </select>
 
    <select id="getActBelongRegionCode" resultType="java.lang.String">
        SELECT district_adcode FROM com_mng_struct_area_district WHERE district_adcode = ( SELECT area_code FROM com_street WHERE street_id =( SELECT street_id FROM com_act WHERE community_id = #{communityId} ))
    </select>
 
    <select id="selectActivityStatics" resultType="com.panzhihua.common.model.vos.community.PartyActivityStatics">
        select (select count(*)  from com_act_activity where type = 3
        <if test="communityIds != null and communityIds.size() != 0">
            and community_id in
            <foreach collection="communityIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        ) activityCount,
        (select count(*)  from com_pb_member where audit_result=1
            <if test="communityIds != null and communityIds.size() != 0">
                and community_id in
                <foreach collection="communityIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        ) memberCount
    </select>
 
    <select id="selectActivityChart" resultType="com.panzhihua.common.model.vos.community.PartyActivityTypeChart">
        select count(*) as count,activity_type as name from com_act_activity  where type = 3
        <if test="communityIds != null and communityIds.size() != 0">
            and community_id in
            <foreach collection="communityIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        GROUP BY activity_type
    </select>
 
    <select id="selectActivityLine" resultType="integer">
        select count(*) from com_act_activity where type = 3 and publish_at >= DATE_FORMAT(  CONCAT(#{year},'-',#{date},'-00'), '%Y-%m-00 00:00:00') and DATE_FORMAT( LAST_DAY(CONCAT(#{year},'-',#{date},'-00')), '%Y-%m-%d 23:59:59') >=publish_at
        <if test="communityIds != null and communityIds.size() != 0">
            and community_id in
            <foreach collection="communityIds" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
    </select>
 
    <select id="partyMemberDetail" resultType="com.panzhihua.common.model.vos.community.PartyMemberDetailVO">
        select t.activity_name,t.activity_addr,t.begin_at,t1.position,t1.start_time,t1.end_time,t.duration,t.participant_reward_integral,t.volunteer_reward_integral,t.pb_reward_integral from com_act_activity t LEFT JOIN com_act_act_regist t1 on t.id = t1.activity_id
        where t.type = 3 and t1.user_id = #{commonPage.userId}
        <if test="commonPage.beginTime !=null">
            and t.begin_at between #{commonPage.beginTime} and #{commonPage.endTime}
        </if>
        order by t.begin_at desc
    </select>
 
    <select id="exportPartyMemberDetail" resultType="com.panzhihua.common.model.vos.community.PartyMemberDetailVO">
        select t.activity_name,t.activity_addr,t.begin_at,t1.position,t1.start_time,t1.end_time,t.duration,t.participant_reward_integral,t.volunteer_reward_integral,t.pb_reward_integral from com_act_activity t LEFT JOIN com_act_act_regist t1 on t.id = t1.activity_id
        where t.type = 3 and t1.user_id = #{commonPage.userId}
        <if test="commonPage.beginTime !=null">
            and t.begin_at between #{commonPage.beginTime} and #{commonPage.endTime}
        </if>
        order by t.begin_at desc
    </select>
 
    <select id="selectListByRelationId" resultType="com.panzhihua.common.model.vos.community.ComActActivityVO">
        SELECT  a.id, a.activity_name, u.`name` sponsorName, a.activity_addr, a.participant_max, a.contact_name,
         a.volunteer_max,
         a.`status`, a.publish_at,
        a.is_qr_code, a.begin_at, a.end_at, a.sign_up_begin, a.sign_up_end, a.participant_reward_way,
        a.volunteer_reward_way,a.pb_reward_way, a.activity_type, a.have_integral_reward ,a.participant_reward_integral,a.volunteer_reward_integral,a.pb_reward_integral,a.party_member_max,a.party_member_min,a.cover,a.type,a.duration
        FROM  com_act_activity a
        LEFT JOIN sys_user u ON a.sponsor_id=u.user_id
        LEFT JOIN com_act_act_regist  s ON a.id=s.activity_id
        where s.end_time is not null and  a.check_unit_id = #{relationId} and publish_at between concat(#{date},'-01-01 00:00:00') and concat(#{date},'-12-31 23:59:59') group by a.id
    </select>
 
    <select id="selectListByCommunityId" resultType="com.panzhihua.common.model.vos.community.ComActActivityVO">
        SELECT t.* FROM `com_act_activity` t left join com_act_act_regist t1 on t.id = t1.activity_id left join sys_user t2 on t1.user_id = t2.user_id
        WHERE t1.end_time is not null and  t.community_id = #{communityId} and t.type = 3 and publish_at between concat(#{date},'-01-01 00:00:00') and concat(#{date},'-12-31 23:59:59') group by t.id
    </select>
<!--    <select id="pageProjectActivity" resultType="com.panzhihua.common.model.vos.community.ComActActivityVO">-->
<!--        SELECT-->
<!--            a.id,-->
<!--            a.activity_name,-->
<!--            u.`name` sponsorName,-->
<!--            a.activity_addr,-->
<!--            a.aattend_people,-->
<!--            a.`status`,-->
<!--            a.is_qr_code,-->
<!--            a.publish_at,-->
<!--            a.begin_at,-->
<!--            a.cover,-->
<!--            a.end_at,-->
<!--            a.volunteer_max,-->
<!--            count(IF( s.sign_identity = 1, s.id, NULL )) participant_now,-->
<!--            count(IF( s.sign_identity = 2, s.id, NULL )) partyMemberNow,-->
<!--            count(IF( s.sign_identity = 3, s.id, NULL )) volunteer_now,-->
<!--            a.participant_max,-->
<!--            a.sign_up_begin,-->
<!--            a.sign_up_end,-->
<!--            ca.NAME AS communityName,-->
<!--            a.type,-->
<!--            a.party_member_max,-->
<!--            a.topic_id-->
<!--        FROM-->
<!--            com_act_activity a-->
<!--                LEFT JOIN sys_user u ON a.sponsor_id = u.user_id-->
<!--                LEFT JOIN ( SELECT * FROM com_act_act_sign WHERE `status` = 1 ) s ON a.id = s.activity_id-->
<!--                LEFT JOIN com_act ca ON a.community_id = ca.community_id-->
<!--                JOIN (SELECT * FROM com_act_social_project WHERE (street_id = #{comActActivityVO.streetId} OR community_id = #{comActActivityVO.communityId}) AND `status` =3) t ON a.project_id = t.id-->
<!--        GROUP BY a.id   ORDER BY a.status = 99 desc,a.publish_at DESC-->
<!--    </select>-->
 
 
 
    <select id="pageProjectActivity" resultType="com.panzhihua.common.model.vos.community.ComActActivityVO">
        SELECT
            a.id,
            a.activity_name,
            u.`name` sponsorName,
            a.activity_addr,
            a.aattend_people,
            a.`status`,
            a.is_qr_code,
            a.publish_at,
            a.begin_at,
            a.cover,
            a.end_at,
            a.volunteer_max,
            count(IF( s.sign_identity = 1, s.id, NULL )) participant_now,
            count(IF( s.sign_identity = 2, s.id, NULL )) partyMemberNow,
            count(IF( s.sign_identity = 3, s.id, NULL )) volunteer_now,
            a.participant_max,
            a.sign_up_begin,
            a.sign_up_end,
            ca.NAME AS communityName,
            (SELECT responsibility FROM com_act_social_project casp WHERE    a.project_id = casp.id) AS responsibilityName,
            a.type,
            a.party_member_max,
            a.topic_id,
           a.jinhui_coin_award,
           a.jinhui_coin_punishment
        FROM
            com_act_activity a
                LEFT JOIN sys_user u ON a.sponsor_id = u.user_id
                LEFT JOIN ( SELECT * FROM com_act_act_sign WHERE `status` = 1 ) s ON a.id = s.activity_id
                LEFT JOIN com_act ca ON a.community_id = ca.community_id
                JOIN (SELECT * FROM com_act_social_project WHERE (street_id = #{comActActivityVO.streetId}
                OR community_id = #{comActActivityVO.communityId})) t ON a.project_id = t.id
        <where>
            <if test="comActActivityVO.aattendPeople != null and comActActivityVO.aattendPeople != ''  ">
                a.aattend_people = #{comActActivityVO.aattendPeople}
            </if>
        </where>
        GROUP BY a.id   ORDER BY a.status = 99 desc,a.publish_at DESC
 
    </select>
 
    <select id="pageActivity" resultType="com.panzhihua.common.model.vos.community.ComActActivityVO">
        SELECT
        a.id,
        a.activity_name,
        u.`name` sponsorName,
        a.activity_addr,
        a.aattend_people,
        a.`status`,
        a.is_qr_code,
        a.publish_at,
        a.begin_at,
        a.cover,
        a.end_at,
        a.volunteer_max,
        count(IF( s.sign_identity = 1, s.id, NULL )) participant_now,
        count(IF( s.sign_identity = 2, s.id, NULL )) partyMemberNow,
        count(IF( s.sign_identity = 3, s.id, NULL )) volunteer_now,
        a.participant_max,
        a.sign_up_begin,
        a.sign_up_end,
        ca.NAME AS communityName,
        a.type,
        a.party_member_max,
        a.topic_id,
        a.jinhui_coin_award,
        a.jinhui_coin_punishment
        FROM
        com_act_activity a
        LEFT JOIN sys_user u ON a.sponsor_id = u.user_id
        LEFT JOIN ( SELECT * FROM com_act_act_sign WHERE `status` = 1 ) s ON a.id = s.activity_id
        LEFT JOIN com_act ca ON a.community_id = ca.community_id
        WHERE 1 = 1
        <if test ="comActActivityVO.communityIds != null and comActActivityVO.communityIds.size() != 0">
            <if test="comActActivityVO.checkUnitId != null">
                AND (a.community_id in
                <foreach collection="comActActivityVO.communityIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
                OR a.check_unit_id = #{comActActivityVO.checkUnitId})
            </if>
            <if test="comActActivityVO.checkUnitId == null">
                AND a.community_id in
                <foreach collection="comActActivityVO.communityIds" item="item" open="(" separator="," close=")">
                    #{item}
                </foreach>
                <if test="comActActivityVO.type == null">
                    AND a.`type` != 5
                </if>
            </if>
        </if>
        <if test ="comActActivityVO.phone != null and comActActivityVO.phone != &quot;&quot;">
            AND a.phone = ${comActActivityVO.phone}
        </if>
        <if test ="comActActivityVO.areaCode != null">
            AND ca.area_code = ${comActActivityVO.areaCode}
        </if>
        <if test ="comActActivityVO.checkUnitId != null and comActActivityVO.communityId == null">
            AND a.check_unit_id = #{comActActivityVO.checkUnitId}
        </if>
        <if test="comActActivityVO.activityName != null and comActActivityVO.activityName.trim() != &quot;&quot;">
            AND a.activity_name LIKE concat(#{comActActivityVO.activityName},'%')
        </if>
        <if test="comActActivityVO.status != null and comActActivityVO.status != 0 and comActActivityVO.isIng == null">
            AND a.`status` = #{comActActivityVO.status}
        </if>
        <if test="comActActivityVO.status != null and comActActivityVO.status != 0 and comActActivityVO.isIng != null and comActActivityVO.isIng == 1">
            AND a.`status` IN (3,4)
        </if>
        <if test="comActActivityVO.isApplets != null and comActActivityVO.isApplets == 1">
            AND a.`status` != 1 AND  a.`status` != 6
        </if>
        <if test="comActActivityVO.beginAt != null">
            AND a.begin_at &gt;= #{comActActivityVO.beginAt} AND a.end_at &lt;= #{comActActivityVO.endAt}
        </if>
        <if test="comActActivityVO.type != null">
            AND a.type = #{comActActivityVO.type}
        </if>
        <if test="comActActivityVO.aattendPeople != null and comActActivityVO.aattendPeople != ''  ">
            AND a.aattend_people = #{comActActivityVO.aattendPeople}
        </if>
        GROUP BY a.id
        ORDER BY a.status = 99 DESC,a.publish_at DESC
    </select>
 
    <select id="selectOpenIdByActivityId" resultType="String">
        select distinct openid from com_act_act_sign t LEFT JOIN sys_user t1 on t.user_id = t1.user_id where t.activity_id =#{id} and t.status = 1
    </select>
 
 
    <select id="pageActivityBigScreen"
            resultType="com.panzhihua.common.model.vos.community.ComActActivityBigScreenVO">
        SELECT a.id,a.cover,a.activity_type,a.activity_name,a.`status`,a.begin_at,a.end_at,a.publish_at,
        (SELECT count(1) FROM com_act_act_sign s WHERE s.activity_id = a.id) as person_num
        FROM com_act_activity a
        WHERE a.type = 1 ORDER BY a.create_at desc
    </select>
</mapper>