| | |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.panzhihua.applets.weixin.CheckService; |
| | | import com.panzhihua.applets.model.dtos.ComPbMemberCertificationDTO; |
| | | import com.panzhihua.common.constants.UserConstants; |
| | | import com.panzhihua.common.model.dtos.shop.ExcelShopOrderDTO; |
| | | import com.panzhihua.common.constants.SecurityConstants; |
| | | import com.panzhihua.common.constants.UserConstants; |
| | | import com.panzhihua.common.model.dtos.user.SysUserEditTipsDTO; |
| | | import com.panzhihua.common.model.dtos.user.SysUserFeedbackDTO; |
| | | import com.panzhihua.common.model.vos.community.*; |
| | | import com.panzhihua.common.model.vos.user.ComMngFamilyInfoVO; |
| | | import com.panzhihua.common.model.vos.user.SysUserNoticeVO; |
| | | import com.panzhihua.common.model.vos.user.UserPhoneVO; |
| | | import com.panzhihua.common.model.vos.partybuilding.PartyBuildingMemberVO; |
| | | import com.panzhihua.common.model.vos.user.*; |
| | | 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.controller.BaseController; |
| | | import com.panzhihua.common.exceptions.UnAuthenticationException; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.validated.AddGroup; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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 javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private CommunityService communityService; |
| | | @Resource |
| | | private PartyBuildingService partyBuildingService; |
| | | @Resource |
| | | private CheckService checkService; |
| | | @Resource |
| | | private StringRedisTemplate stringRedisTemplate; |
| | | |
| | | @ApiOperation(value = "当前登录用户信息", response = LoginUserInfoVO.class) |
| | | @GetMapping("info") |
| | |
| | | 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; |
| | | R r1 = communityService.detailHouse(userId); |
| | | if (null!=communityId&&0!=communityId) { |
| | | R r2=communityService.detailCommunity(communityId); |
| | | 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)); |
| | | loginUserInfoVO.setComActVO(JSONObject.parseObject(JSONObject.toJSONString(data1), ComActVO.class)); |
| | | r.setData(loginUserInfoVO); |
| | | } |
| | | } |
| | | } |
| | | if (null!=areaId&&areaId!=0) { |
| | | R r3=communityService.detailArea(areaId); |
| | | 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)); |
| | | loginUserInfoVO.setComMngStructAreaVO(JSONObject.parseObject(JSONObject.toJSONString(data1), ComMngStructAreaVO.class)); |
| | | r.setData(loginUserInfoVO); |
| | | } |
| | | } |
| | |
| | | loginUserInfoVO.setUserId(userId); |
| | | R r = userService.putUserAuthentication(loginUserInfoVO); |
| | | if (R.isOk(r)) { |
| | | //通过不发通知 |
| | | } else { |
| | | SysUserNoticeVO sysUserNoticeVO=new SysUserNoticeVO(); |
| | | //通过发通知 |
| | | SysUserNoticeVO sysUserNoticeVO = new SysUserNoticeVO(); |
| | | sysUserNoticeVO.setUserId(userId); |
| | | sysUserNoticeVO.setType(3); |
| | | sysUserNoticeVO.setTitle("实名制审核未通过"); |
| | | sysUserNoticeVO.setTitle("实名制审核通过"); |
| | | sysUserNoticeVO.setBusinessType(6); |
| | | // sysUserNoticeVO.setBusinessTitle(comActActivityVO.getActivityName()); |
| | | sysUserNoticeVO.setBusinessContent(String.format("驳回原因:%s",r.getMsg())); |
| | | // sysUserNoticeVO.setBusinessId(activityId);R |
| | | sysUserNoticeVO.setBusinessContent("恭喜你,你已经通过了实名制认证"); |
| | | sysUserNoticeVO.setStatus(0); |
| | | sysUserNoticeVO.setBusinessStatus(1); |
| | | 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; |
| | | } |
| | |
| | | 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) |
| | | @ApiImplicitParam(name = "parentCode", value = "父级地址编码", required = false) |
| | | public R listHouses(String parentCode) { |
| | | Long areaId = this.getAreaId(); |
| | | if (ObjectUtils.isEmpty(parentCode)) { |
| | | parentCode=""; |
| | | parentCode = ""; |
| | | } |
| | | return communityService.listHouses(parentCode,areaId); |
| | | return communityService.listHouses(parentCode, areaId); |
| | | } |
| | | |
| | | @ApiOperation(value = "新增房屋") |
| | |
| | | |
| | | @ApiOperation(value = "家庭成员列表") |
| | | @GetMapping("listfamily") |
| | | public R listFamily() { |
| | | public R listFamily(@RequestParam(value = "pageNum") Long pageNum, @RequestParam("pageSize") Long pageSize) { |
| | | Long userId = this.getUserId(); |
| | | return userService.listFamily(userId); |
| | | return userService.listFamily(userId, pageNum, pageSize); |
| | | } |
| | | |
| | | @ApiOperation(value = "新增家庭成员") |
| | |
| | | @PutMapping("putfamily") |
| | | public R putFamily(@RequestBody ComMngFamilyInfoVO comMngFamilyInfoVO) { |
| | | Long id = comMngFamilyInfoVO.getId(); |
| | | if (null==id||0==id) { |
| | | if (null == id || 0 == id) { |
| | | return R.fail("成员主键不能为空"); |
| | | } |
| | | comMngFamilyInfoVO.setUserId(this.getUserId()); |
| | | return userService.putFamily(comMngFamilyInfoVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "我的活动",response =ComActActivityVO.class ) |
| | | @ApiOperation(value = "我的活动", response = ComActActivityVO.class) |
| | | @GetMapping("listactivity") |
| | | public R listActivity() { |
| | | LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); |
| | | Long userId = loginUserInfo.getUserId(); |
| | | Long communityId = loginUserInfo.getCommunityId(); |
| | | List<ComActActivityVO> comActActivityVOS=new ArrayList<>(); |
| | | R r=communityService.listActivity(userId); |
| | | List<ComActActivityVO> comActActivityVOS = new ArrayList<>(); |
| | | R r = communityService.listActivity(userId); |
| | | if (R.isOk(r)) { |
| | | comActActivityVOS =(List<ComActActivityVO>) r.getData(); |
| | | comActActivityVOS = (List<ComActActivityVO>) r.getData(); |
| | | } |
| | | R r1=partyBuildingService.listActivity(userId,communityId); |
| | | R r1 = partyBuildingService.listActivity(userId, communityId); |
| | | if (R.isOk(r1)) { |
| | | 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> 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; |
| | | comActActivityVOS = collect; |
| | | } |
| | | if (!ObjectUtils.isEmpty(comActActivityVOS)) { |
| | | List<ComActActivityVO> collect = comActActivityVOS.stream().sorted(Comparator.comparing(ComActActivityVO::getSingDate).reversed()).collect(Collectors.toList()); |
| | |
| | | return R.ok(comActActivityVOS); |
| | | } |
| | | |
| | | @ApiOperation(value = "分页查询我的随手拍",response = ComActEasyPhotoVO.class ) |
| | | @ApiOperation(value = "分页查询我的随手拍", response = ComActEasyPhotoVO.class) |
| | | @PostMapping("pageeasyphoto") |
| | | public R pageEasyPhoto(@RequestBody ComActEasyPhotoVO comActEasyPhotoVO) { |
| | | Long userId = this.getUserId(); |
| | |
| | | return communityService.pageEasyPhotoApplets(comActEasyPhotoVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "分页查询我的微心愿",response = ComActMicroWishVO.class ) |
| | | @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) { |
| | | if (null != status && status == 1) { |
| | | comActMicroWishVO.setIsPageMyWish(1); |
| | | }else{ |
| | | } else { |
| | | comActMicroWishVO.setIsPageMyWish(null); |
| | | } |
| | | |
| | | return communityService.pageMicroWish(comActMicroWishVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "用户确认心愿" ) |
| | | @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) { |
| | | if (null == id || 0 == id) { |
| | | return R.fail("心愿主键不能为空"); |
| | | } |
| | | String evaluate = comActMicroWishVO.getEvaluate(); |
| | | if (ObjectUtils.isEmpty(evaluate)) { |
| | | return R.fail("用户评价不能为空"); |
| | | } |
| | | Integer score = comActMicroWishVO.getScore(); |
| | | if (null==score||0==score) { |
| | | if (null == score || 0 == score) { |
| | | return R.fail("评分不能为空"); |
| | | } |
| | | comActMicroWishVO.setEvaluateAt(new Date()); |
| | |
| | | return communityService.putMicroWishConfirm(comActMicroWishVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "调试接口--清除昵称、社区、小区" ) |
| | | @ApiOperation(value = "调试接口--清除昵称、社区、小区") |
| | | @DeleteMapping("usertest") |
| | | public R deleteUserTest() { |
| | | Long userId = this.getUserId(); |
| | | return userService.deleteUserTest(userId); |
| | | } |
| | | |
| | | @ApiOperation(value = "意见反馈" ) |
| | | @ApiOperation(value = "意见反馈") |
| | | @PostMapping("feedback") |
| | | public R addFeedback(@RequestBody @Validated(AddGroup.class) SysUserFeedbackDTO sysUserFeedbackDTO) { |
| | | // 微信内容审核 |
| | | String msg = sysUserFeedbackDTO.getContent(); |
| | | if (!checkService.checkMessage(msg)) { |
| | | return R.fail("内容违规"); |
| | | } |
| | | LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); |
| | | Long userId = loginUserInfo.getUserId(); |
| | | Long communityId = loginUserInfo.getCommunityId(); |
| | | Long areaId = loginUserInfo.getAreaId(); |
| | | if (null==communityId||0==communityId) { |
| | | if (null == communityId || 0 == communityId) { |
| | | return R.fail("未绑定社区"); |
| | | } |
| | | sysUserFeedbackDTO.setCommunityId(communityId); |
| | |
| | | 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); |
| | | |
| | | 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()); |
| | | } |
| | | |
| | | 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); |
| | | |
| | | 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(); |
| | | } |
| | | |
| | | |
| | | @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); |
| | | } |
| | | } |