mitao
2025-02-24 879ce4e66b36daf44f79b17eb02d3578148e4545
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
package com.panzhihua.applets.api;
 
import static java.util.stream.Collectors.toList;
 
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
 
import javax.annotation.Resource;
import javax.validation.Valid;
 
import cn.hutool.core.util.StrUtil;
import com.panzhihua.applets.umf.UmfPayUtil;
import com.panzhihua.common.constants.Constants;
import com.panzhihua.common.constants.HttpStatus;
import com.panzhihua.common.model.dtos.community.social.PageProjectDTO;
import com.panzhihua.common.model.vos.community.rentHouse.WxPayOrderVO;
import com.panzhihua.common.utlis.DateUtils;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.panzhihua.applets.model.dtos.ComPbMemberCertificationDTO;
import com.panzhihua.applets.weixin.CheckService;
import com.panzhihua.common.constants.SecurityConstants;
import com.panzhihua.common.constants.UserConstants;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.dtos.user.SysUserEditTipsDTO;
import com.panzhihua.common.model.dtos.user.SysUserFeedbackDTO;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComActActEvaluateVO;
import com.panzhihua.common.model.vos.community.ComActActRegistVO;
import com.panzhihua.common.model.vos.community.ComActActivityVO;
import com.panzhihua.common.model.vos.community.ComActEasyPhotoVO;
import com.panzhihua.common.model.vos.community.ComActMicroWishVO;
import com.panzhihua.common.model.vos.community.ComActVO;
import com.panzhihua.common.model.vos.community.ComMngStructAreaVO;
import com.panzhihua.common.model.vos.community.ComMngStructHouseVO;
import com.panzhihua.common.model.vos.partybuilding.PartyBuildingMemberVO;
import com.panzhihua.common.model.vos.user.ComMngFamilyInfoVO;
import com.panzhihua.common.model.vos.user.SysUserNoticeVO;
import com.panzhihua.common.model.vos.user.UpdateUserArchivesVO;
import com.panzhihua.common.model.vos.user.UserArchivesVO;
import com.panzhihua.common.model.vos.user.UserPhoneVO;
import com.panzhihua.common.service.community.CommunityService;
import com.panzhihua.common.service.partybuilding.PartyBuildingService;
import com.panzhihua.common.service.user.UserService;
import com.panzhihua.common.validated.AddGroup;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
 
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
 * @description: 用户
 * @author: huang.hongfa weixin hhf9596 qq 959656820
 * @create: 2020-11-24 12:03
 **/
@Slf4j
@RestController
@RequestMapping("/user/")
@Api(tags = {"我的模块"})
public class UserApi extends BaseController {
    @Resource
    private UserService userService;
    @Resource
    private CommunityService communityService;
    @Resource
    private PartyBuildingService partyBuildingService;
    @Resource
    private CheckService checkService;
    @Resource
    private StringRedisTemplate stringRedisTemplate;
 
    @ApiOperation(value = "当前登录用户信息", response = LoginUserInfoVO.class)
    @GetMapping("info")
    public R getUserInfo() {
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        Long communityId = loginUserInfo.getCommunityId();
        Long userId = loginUserInfo.getUserId();
        Long areaId = loginUserInfo.getAreaId();
        R<LoginUserInfoVO> r = userService.getUserInfoByUserId(userId + "");
        String phone = loginUserInfo.getPhone();
        if (R.isOk(r)) {
            Object data = r.getData();
            if (!ObjectUtils.isEmpty(data)) {
                LoginUserInfoVO loginUserInfoVO = (LoginUserInfoVO)data;
                //是否保存unionid
//                if (Objects.isNull(loginUserInfoVO.getUnionid()) || "无".equals(loginUserInfoVO.getUnionid())) {
//                    return R.fail(HttpStatus.UNAUTHORIZED, "token过期");
//                }
                R r1 = communityService.detailHouse(userId);
                if(StringUtils.isNotEmpty(loginUserInfoVO.getIdCard())){
                    //查询实名用户绑定的实有人口地址
                    R r4=communityService.selectByIdCard(loginUserInfoVO.getIdCard());
                    if(R.isOk(r4)){
                        String address= (String) r4.getData();
                        if(StringUtils.isNotEmpty(address)){
                            loginUserInfoVO.setAddress(address);
                            r.setData(loginUserInfoVO);
                        }
                    }
                }
                if (null != communityId && 0 != communityId) {
                    R r2 = communityService.detailCommunity(communityId);
                    if (R.isOk(r2)) {
                        Object data1 = r2.getData();
                        if (!ObjectUtils.isEmpty(data1)) {
                            loginUserInfoVO
                                .setComActVO(JSONObject.parseObject(JSONObject.toJSONString(data1), ComActVO.class));
                            r.setData(loginUserInfoVO);
                        }
                    }
                }
                if (null != areaId && areaId != 0) {
                    R r3 = communityService.detailArea(areaId);
                    if (R.isOk(r3)) {
                        Object data1 = r3.getData();
                        if (!ObjectUtils.isEmpty(data1)) {
                            loginUserInfoVO.setComMngStructAreaVO(
                                JSONObject.parseObject(JSONObject.toJSONString(data1), ComMngStructAreaVO.class));
                            r.setData(loginUserInfoVO);
                        }
                    }
                }
                if (R.isOk(r1)) {
                    Object data1 = r1.getData();
                    if (!ObjectUtils.isEmpty(data1)) {
                        loginUserInfoVO.setComMngStructHouseVOS((List<ComMngStructHouseVO>)data1);
                        r.setData(loginUserInfoVO);
                    }
                }
            }
        }
        return r;
    }
 
    @ApiOperation(value = "用户实名认证")
    @PutMapping("putuserauthentication")
    public R putUserAuthentication(@RequestBody @Validated(AddGroup.class) LoginUserInfoVO loginUserInfoVO) {
        Long userId = this.getUserId();
        loginUserInfoVO.setUserId(userId);
        loginUserInfoVO.setCommunityId(this.getCommunityId());
        R r = userService.putUserAuthentication(loginUserInfoVO);
        if (R.isOk(r)) {
            // 通过发通知
            SysUserNoticeVO sysUserNoticeVO = new SysUserNoticeVO();
            sysUserNoticeVO.setUserId(userId);
            sysUserNoticeVO.setType(3);
            sysUserNoticeVO.setTitle("实名制审核通过");
            sysUserNoticeVO.setBusinessType(6);
            sysUserNoticeVO.setBusinessContent("恭喜你,你已经通过了实名制认证");
            sysUserNoticeVO.setStatus(0);
            sysUserNoticeVO.setBusinessStatus(2);
            R r1 = userService.addNotice(sysUserNoticeVO);
            if (R.isOk(r1)) {
                log.info("新增实名认证未通过通知成功【{}】", JSONObject.toJSONString(sysUserNoticeVO));
            }
            // 清空缓存
            String userRoleKey = UserConstants.LOGIN_USER_INFO + this.getLoginUserInfo().getUserId();
            String userAppletRoleKey = SecurityConstants.ROLE_APPLETS_USER + this.getLoginUserInfo().getUserId();
            stringRedisTemplate.delete(userRoleKey);
            stringRedisTemplate.delete(userAppletRoleKey);
        } else {
            // 未通过发通知
            /**
             * SysUserNoticeVO sysUserNoticeVO=new SysUserNoticeVO(); sysUserNoticeVO.setUserId(userId);
             * sysUserNoticeVO.setType(3); sysUserNoticeVO.setTitle("实名制审核未通过"); sysUserNoticeVO.setBusinessType(6);
             * sysUserNoticeVO.setBusinessContent(String.format("驳回原因:%s",r.getMsg())); sysUserNoticeVO.setStatus(0);
             * sysUserNoticeVO.setBusinessStatus(1); R r1 = userService.addNotice(sysUserNoticeVO); if (R.isOk(r1)) {
             * log.info("新增实名认证未通过通知成功【{}】", JSONObject.toJSONString(sysUserNoticeVO)); }
             */
        }
        return r;
    }
 
    @ApiOperation(value = "修改用户手机号")
    @PutMapping("userphone")
    public R putUserphone(@RequestBody UserPhoneVO userPhoneVO) {
        Long userId = this.getUserId();
        userPhoneVO.setUserId(userId);
        R r = userService.putUserphone(userPhoneVO);
        if (R.isOk(r)) {
            communityService.putVolunteerPhone(userPhoneVO);
        }
        return r;
    }
 
    @ApiOperation(value = "修改用户信息")
    @PutMapping("user")
    public R putUser(@RequestBody LoginUserInfoVO loginUserInfoVO) {
        Long userId = this.getUserId();
        loginUserInfoVO.setUserId(userId);
        return userService.putUser(loginUserInfoVO);
    }
 
    @ApiOperation(value = "修改用户首页活动提示")
    @PostMapping("editUserTips")
    public R putUserTips(@RequestBody SysUserEditTipsDTO userEditTipsDTO) {
        Long userId = this.getUserId();
        if (userId == null) {
            return R.fail("请重新登录");
        }
        userEditTipsDTO.setUserId(userId);
        return userService.editUserTips(userEditTipsDTO);
    }
 
    @ApiOperation(value = "房屋地址下拉列表")
    @GetMapping("listhouse")
    @ApiImplicitParam(name = "parentCode", value = "父级地址编码", required = false)
    public R listHouses(String parentCode) {
        Long areaId = this.getAreaId();
        if (ObjectUtils.isEmpty(parentCode)) {
            parentCode = "";
        }
        return communityService.listHouses(parentCode, areaId);
    }
 
    @ApiOperation(value = "新增房屋")
    @PostMapping("houses")
    public R addHouses(@RequestBody @Validated(AddGroup.class) ComMngStructHouseVO comMngStructHouseVO) {
        String houseCode = comMngStructHouseVO.getHouseCode();
        if (ObjectUtils.isEmpty(houseCode)) {
            return R.fail("房屋地址编码不能为空");
        }
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        comMngStructHouseVO.setUserId(loginUserInfo.getUserId());
        comMngStructHouseVO.setAreaId(loginUserInfo.getAreaId());
        return communityService.addHouses(comMngStructHouseVO);
    }
 
    @ApiOperation(value = "家庭成员列表")
    @GetMapping("listfamily")
    public R listFamily(@RequestParam(value = "pageNum") Long pageNum, @RequestParam("pageSize") Long pageSize) {
        Long userId = this.getUserId();
        return userService.listFamily(userId, pageNum, pageSize);
    }
 
    @ApiOperation(value = "新增家庭成员")
    @PostMapping("addfamily")
    public R addFamily(@RequestBody @Validated(AddGroup.class) ComMngFamilyInfoVO comMngFamilyInfoVO) {
        Long userId = this.getUserId();
        comMngFamilyInfoVO.setUserId(userId);
        return userService.addFamily(comMngFamilyInfoVO);
    }
 
    @ApiOperation(value = "编辑家庭成员")
    @PutMapping("putfamily")
    public R putFamily(@RequestBody ComMngFamilyInfoVO comMngFamilyInfoVO) {
        Long id = comMngFamilyInfoVO.getId();
        if (null == id || 0 == id) {
            return R.fail("成员主键不能为空");
        }
        comMngFamilyInfoVO.setUserId(this.getUserId());
        return userService.putFamily(comMngFamilyInfoVO);
    }
 
    @ApiOperation(value = "我的活动", response = ComActActivityVO.class)
    @GetMapping("listactivity")
    public R listActivity(@RequestParam(value = "status", required = false) Integer status,
                          @RequestParam(value = "type", required = false) Integer type) {
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        Long userId = loginUserInfo.getUserId();
        Long communityId = loginUserInfo.getCommunityId();
        List<ComActActivityVO> comActActivityVOS = new ArrayList<>();
        R r = communityService.listActivity(userId, status,type);
        if (R.isOk(r)&&r.getData()!=null) {
            comActActivityVOS = (List<ComActActivityVO>)r.getData();
        }
//        R r1 = partyBuildingService.listActivity(userId, communityId, status);
//        if (R.isOk(r1)&&r1.getData()!=null) {
//            List<ComActActivityVO> data = (List<ComActActivityVO>)r1.getData();
//            comActActivityVOS.addAll(data);
//        }
        if (!ObjectUtils.isEmpty(comActActivityVOS)) {
            String s = JSONArray.toJSONString(comActActivityVOS);
            List<ComActActivityVO> comActActivityVOS1 = new ArrayList<>();
            comActActivityVOS1 = JSONArray.parseArray(s, ComActActivityVO.class);
            List<ComActActivityVO> collect = comActActivityVOS1.stream()
                .sorted(Comparator.comparing(ComActActivityVO::getBeginAt).reversed()).collect(Collectors.toList());
            comActActivityVOS = collect;
        }
        if (!ObjectUtils.isEmpty(comActActivityVOS)) {
            List<ComActActivityVO> collect = comActActivityVOS.stream()
                .sorted(Comparator.comparing(ComActActivityVO::getSingDate).reversed()).collect(Collectors.toList());
            //当前用户签到记录列表
            R r2 = communityService.listSignInActivity(userId);
            if (R.isOk(r2) && !ObjectUtils.isEmpty(r2.getData())) {
                List<ComActActRegistVO> comActActRegistVOS = JSONArray.parseArray(JSONArray.toJSONString(r2.getData()), ComActActRegistVO.class).stream()
                        .sorted(Comparator.comparing(ComActActRegistVO::getCreateAt).reversed()).collect(toList());
                collect.forEach(comActActivityVO -> {
                    ArrayList<ComActActRegistVO> currentList = new ArrayList<>();
                    comActActRegistVOS.forEach(activitySignInVO -> {
                        if (comActActivityVO.getId().equals(activitySignInVO.getActivityId())) {
                            currentList.add(activitySignInVO);
                            if(activitySignInVO.getEndTime()!=null){
                                comActActivityVO.setIsComment(1);
                                if(comActActivityVO.getTimes()==null){
                                    comActActivityVO.setTimes(1);
                                    comActActivityVO.setAward(activitySignInVO.getAward());
                                }
                                else {
                                    comActActivityVO.setTimes(comActActivityVO.getTimes()+1);
                                    comActActivityVO.setAward(comActActivityVO.getAward() + activitySignInVO.getAward());
                                }
                            }
                        }
                    });
                    if (currentList.size() > 10) {
                        comActActivityVO.setActivitySignInList(currentList.subList(0, 10));
                    } else {
                        comActActivityVO.setActivitySignInList(currentList);
                    }
                    Integer limit = comActActivityVO.getLimit();
                    if(limit != null && limit>0 &&currentList.size()>0){
                        if(limit==currentList.size()&&currentList.get(currentList.size()-1).getEndTime()!=null){
                            comActActivityVO.setIsRegist(1);
                        }
                    }
                });
            }
            //当前用户活动评分
            R r3 = communityService.listEvaluate(userId);
            if (R.isOk(r3) && !ObjectUtils.isEmpty(r3.getData())) {
                List<ComActActEvaluateVO> comActActEvaluateVOS = JSONArray.parseArray(JSONArray.toJSONString(r3.getData()), ComActActEvaluateVO.class);
                collect.forEach(comActActivityVO -> {
                 List<ComActActEvaluateVO> evaluateVOS=comActActEvaluateVOS.stream().filter(comActActEvaluateVO -> comActActEvaluateVO.getActivityId().equals(comActActivityVO.getId())).collect(toList());
                 if(comActActivityVO.getSignCount()<=evaluateVOS.size()){
                     comActActivityVO.setIsComment(0);
                 }
                 comActActivityVO.setComActActEvaluateVOList(evaluateVOS);
                });
            }
            return R.ok(collect);
        }
        return R.ok(comActActivityVOS);
    }
 
    @ApiOperation(value = "分页查询我的随手拍", response = ComActEasyPhotoVO.class)
    @PostMapping("pageeasyphoto")
    public R pageEasyPhoto(@RequestBody ComActEasyPhotoVO comActEasyPhotoVO) {
        Long userId = this.getUserId();
        comActEasyPhotoVO.setSponsorId(userId);
        comActEasyPhotoVO.setCommunityId(null);
        return communityService.pageEasyPhotoApplets(comActEasyPhotoVO);
    }
 
    @ApiOperation(value = "分页查询我的微心愿", response = ComActMicroWishVO.class)
    @PostMapping("pagemicrowish")
    public R pageMicroWish(@RequestBody ComActMicroWishVO comActMicroWishVO) {
        Long userId = this.getUserId();
        comActMicroWishVO.setUserId(userId);
        comActMicroWishVO.setCommunityId(null);
        Integer status = comActMicroWishVO.getStatus();
        if (null != status && status == 1) {
            comActMicroWishVO.setIsPageMyWish(1);
        } else {
            comActMicroWishVO.setIsPageMyWish(null);
        }
 
        return communityService.pageMicroWish(comActMicroWishVO);
    }
 
    @ApiOperation(value = "用户确认心愿")
    @PutMapping("microwishconfirm")
    public R putMicroWishConfirm(@RequestBody ComActMicroWishVO comActMicroWishVO) {
        Long userId = this.getUserId();
        comActMicroWishVO.setUserId(userId);
        comActMicroWishVO.setCommunityId(null);
        Long id = comActMicroWishVO.getId();
        if (null == id || 0 == id) {
            return R.fail("心愿主键不能为空");
        }
        Integer score = comActMicroWishVO.getScore();
        if (null == score || 0 == score) {
            return R.fail("评分不能为空");
        }
        comActMicroWishVO.setEvaluateAt(new Date());
        comActMicroWishVO.setStatus(6);
        return communityService.putMicroWishConfirm(comActMicroWishVO);
    }
 
    @ApiOperation(value = "调试接口--清除昵称、社区、小区")
    @DeleteMapping("usertest")
    public R deleteUserTest() {
        Long userId = this.getUserId();
        return userService.deleteUserTest(userId);
    }
 
    @ApiOperation(value = "意见反馈")
    @PostMapping("feedback")
    public R addFeedback(@RequestBody @Validated(AddGroup.class) SysUserFeedbackDTO sysUserFeedbackDTO) {
        // 微信内容审核
        String msg = sysUserFeedbackDTO.getContent();
        if (StrUtil.isNotBlank(msg)) {
            String result = checkService.checkMessageBy(msg, this.getLoginUserInfo().getOpenid(),this.getAppId());
            if (StrUtil.isNotBlank(result)) {
                return R.fail(501, "填写内容存在 " + result + " 违规信息");
            }
        }
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        Long userId = loginUserInfo.getUserId();
        Long communityId = loginUserInfo.getCommunityId();
        Long areaId = loginUserInfo.getAreaId();
        if (null == communityId || 0 == communityId) {
            return R.fail("未绑定社区");
        }
        sysUserFeedbackDTO.setCommunityId(communityId);
        sysUserFeedbackDTO.setAreaId(areaId);
        sysUserFeedbackDTO.setUserId(userId);
        return userService.addFeedback(sysUserFeedbackDTO);
    }
 
    @ApiOperation(value = "党员认证")
    @PostMapping("partybuildingembercertification")
    public R partybuildingembercertification(
        @RequestBody @Validated(AddGroup.class) ComPbMemberCertificationDTO comPbMemberCertificationDTO) {
        // 党员认证
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        Long userId = loginUserInfo.getUserId();
        Long communityId = loginUserInfo.getCommunityId();
        if (null == communityId || 0 == communityId) {
            return R.fail("未绑定社区");
        }
 
        // 判断用户是否已认证成功
        R certUser = partyBuildingService.userCertification(userId,communityId);
 
        Object certUserInfo = certUser.getData();
        AtomicBoolean userCertified = new AtomicBoolean(false);
        if (R.isOk(certUser) && certUserInfo != null) {
            try {
                List<PartyBuildingMemberVO> partyBuildingMemberVOList =
                    JSONArray.parseArray(JSONArray.toJSONString(certUser.getData()), PartyBuildingMemberVO.class);
                // 已认证党员身份,直接返回
                if (partyBuildingMemberVOList != null && partyBuildingMemberVOList.size() > 0) {
                    partyBuildingMemberVOList.forEach(vo -> {
                        userCertified.set(vo.getAuditResult() == 1);
                    });
                }
            } catch (Exception e) {
            }
        }
        // 匹配手机,验证是否进行自动确认
        if (userCertified.get()) {
            return R.fail("您已审核通过,无需重复提交");
        }
 
        PartyBuildingMemberVO partyBuildingMemberVO = new PartyBuildingMemberVO();
        BeanUtils.copyProperties(comPbMemberCertificationDTO, partyBuildingMemberVO);
        partyBuildingMemberVO.setAuditResult(0);
        partyBuildingMemberVO.setCommunityId(communityId);
 
        // 用户实名认证信息判断
        String idCard = loginUserInfo.getIdCard();
        partyBuildingMemberVO.setUserId(userId);
        if (idCard == null) {
            return R.fail("用户未完成实名认证");
        } else {
            partyBuildingMemberVO.setIdCard(loginUserInfo.getIdCard());
            partyBuildingMemberVO.setName(loginUserInfo.getName());
            partyBuildingMemberVO.setPhone(loginUserInfo.getPhone());
        }
 
        R r = partyBuildingService.addPartyBuildingMember(partyBuildingMemberVO);
        return r;
    }
 
    @ApiOperation(value = "党员认证查询")
    @GetMapping("partybuildingembercertification")
    public R partybuildingembercertification() {
        // 党员认证查询
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        Long userId = loginUserInfo.getUserId();
        R r = partyBuildingService.userCertification(userId,this.getCommunityId());
 
        if (R.isOk(r)) {
            List<PartyBuildingMemberVO> partyBuildingMemberVOList =
                JSONArray.parseArray(JSONArray.toJSONString(r.getData()), PartyBuildingMemberVO.class);
            if (partyBuildingMemberVOList != null && partyBuildingMemberVOList.size() > 0) {
                Optional<PartyBuildingMemberVO> ot = partyBuildingMemberVOList.stream()
                    .filter(partyBuildingMemberVO -> partyBuildingMemberVO.getAuditResult() == 1).findFirst();
                if (ot.isPresent()) {
                    return R.ok(ot.get());
                } else {
                    return R.ok(partyBuildingMemberVOList.get(0));
                }
            }
        }
        return R.ok();
    }
 
    /**
     * 获取动作人员详情
     * @param communityId
     * @param phone
     * @return
     */
    @ApiOperation(value = "社区工做人员详情")
    @GetMapping("/getComPbServiceTeamData")
    public R getComPbServiceTeamData(@RequestParam("communityId") String communityId,
                                     @RequestParam("phone") String phone)
    {
        return partyBuildingService.getComPbServiceTeamData(communityId,phone);
    }
 
 
    @ApiOperation(value = "获取用户电子档案", response = UserArchivesVO.class)
    @PostMapping("getUserArchives")
    public R getUserArchives() {
        Long userId = this.getUserId();
        if (userId == null) {
            return R.fail("请重新登录");
        }
        return userService.getUserArchives(userId);
    }
 
    @ApiOperation(value = "编辑用户电子档案")
    @PostMapping("updateUserArchives")
    public R updateUserArchives(@RequestBody UpdateUserArchivesVO userArchivesVO) {
        Long userId = this.getUserId();
        if (userId == null) {
            return R.fail("请重新登录");
        }
        userArchivesVO.setUserId(userId);
        return userService.updateUserArchives(userArchivesVO);
    }
 
    @ApiOperation(value = "分页查询用户报名的项目")
    @PostMapping("project")
    public R pageProjectWhichIsSignedByUser(@RequestBody @Valid PageProjectDTO pageProjectDTO) {
        pageProjectDTO.setUserId(this.getUserId());
        return communityService.pageProjectWhichIsSignedByUser(pageProjectDTO);
    }
 
    @ApiOperation("获取用户")
    @GetMapping("selectAutomessageSysUserById")
    public R selectAutomessageSysUserById(@RequestParam("id")Long id){
        return communityService.selectAutomessageSysUserById(id);
    }
 
    @ApiOperation("新增投诉建议或问题留言")
    @PostMapping("addFeedBack")
    public R addFeedBack(@RequestBody SysUserFeedbackDTO sysUserFeedbackDTO){
        sysUserFeedbackDTO.setCommunityId(null);
        return userService.addFeedback(sysUserFeedbackDTO);
    }
 
    @ApiOperation("查看自己的投诉建议或问题留言记录")
    @GetMapping("myFeedBack")
    public R myFeedBack(@ApiParam("类型:1问题留言2投诉建议") @RequestParam(value = "type",required = false)Integer type,@RequestParam("propertyId")Long propertyId){
        return userService.myFeedBack(this.getLoginUserInfo().getUserId(),type,propertyId);
    }
 
}