| | |
| | | import org.apache.commons.net.util.Base64; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.crypto.Cipher; |
| | | import javax.crypto.spec.IvParameterSpec; |
| | |
| | | OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto(); |
| | | ownerAppUserDto.setUserId(userDtos.get(0).getUserId()); |
| | | ownerAppUserDto.setLink(userDtos.get(0).getTel()); |
| | | ownerAppUserDto.setState(OwnerAppUserDto.STATE_AUDIT_SUCCESS); |
| | | List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserV1InnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto); |
| | | |
| | | LoginOwnerResDto loginOwnerResDto = new LoginOwnerResDto(); |
| | | if (ListUtil.isNull(ownerAppUserDtos)) { |
| | | autoBindUserToOwner(userDtos.get(0), phoneNumber); |
| | | communityId = smallWeChatDtos.get(0).getObjId(); |
| | |
| | | |
| | | //todo 生成登录token |
| | | String token = generatorLoginToken(tmpUserDto); |
| | | LoginOwnerResDto loginOwnerResDto = new LoginOwnerResDto(); |
| | | |
| | | |
| | | loginOwnerResDto.setCommunityId(communityDtos.get(0).getCommunityId()); |
| | | loginOwnerResDto.setCommunityName(communityDtos.get(0).getName()); |
| | |
| | | loginOwnerResDto.setOwnerTel(tmpUserDto.getTel()); |
| | | loginOwnerResDto.setToken(token); |
| | | loginOwnerResDto.setKey(newKey); |
| | | //查询认证关系 |
| | | OwnerAppUserDto dto = new OwnerAppUserDto(); |
| | | dto.setUserId(userDtos.get(0).getUserId()); |
| | | dto.setLink(userDtos.get(0).getTel()); |
| | | List<OwnerAppUserDto> dtos = ownerAppUserV1InnerServiceSMOImpl.queryOwnerAppUsers(dto); |
| | | if(!CollectionUtils.isEmpty(dtos)){ |
| | | |
| | | } |
| | | context.setResponseEntity(ResultVo.createResponseEntity(loginOwnerResDto)); |
| | | } |
| | | |
| | | private void autoBindUserToOwner(UserDto userDto, String phoneNumber) { |
| | | // todo 查询业主或成员 |
| | | OwnerDto ownerDto = new OwnerDto(); |
| | | ownerDto.setLink(phoneNumber); |
| | | ownerDto.setPage(1); |
| | | ownerDto.setRow(1); |
| | | List<OwnerDto> ownerDtos = ownerV1InnerServiceSMOImpl.queryOwners(ownerDto); |
| | | //查询用户是否已经有认证状态记录 |
| | | //todo 查询业主是否 认证了,如果认证了获取小区ID |
| | | OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto(); |
| | | ownerAppUserDto.setUserId(userDto.getUserId()); |
| | | ownerAppUserDto.setLink(userDto.getTel()); |
| | | List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserV1InnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto); |
| | | if(CollectionUtils.isEmpty(ownerAppUserDtos)){ |
| | | // todo 查询业主或成员 |
| | | OwnerDto ownerDto = new OwnerDto(); |
| | | ownerDto.setLink(phoneNumber); |
| | | ownerDto.setPage(1); |
| | | ownerDto.setRow(1); |
| | | List<OwnerDto> ownerDtos = ownerV1InnerServiceSMOImpl.queryOwners(ownerDto); |
| | | |
| | | // 说明业主不存在 直接返回跑异常 |
| | | if (ListUtil.isNull(ownerDtos)) { |
| | | return; |
| | | } |
| | | CommunityDto communityDto = new CommunityDto(); |
| | | communityDto.setCommunityId(ownerDtos.get(0).getCommunityId()); |
| | | List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto); |
| | | if (ListUtil.isNull(communityDtos)) { |
| | | return; |
| | | } |
| | | CommunityDto tmpCommunityDto = communityDtos.get(0); |
| | | // 说明业主不存在 直接返回跑异常 |
| | | if (ListUtil.isNull(ownerDtos)) { |
| | | return; |
| | | } |
| | | CommunityDto communityDto = new CommunityDto(); |
| | | communityDto.setCommunityId(ownerDtos.get(0).getCommunityId()); |
| | | List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto); |
| | | if (ListUtil.isNull(communityDtos)) { |
| | | return; |
| | | } |
| | | CommunityDto tmpCommunityDto = communityDtos.get(0); |
| | | |
| | | OwnerAppUserPo ownerAppUserPo = new OwnerAppUserPo(); |
| | | //状态类型,10000 审核中,12000 审核成功,13000 审核失败 |
| | | ownerAppUserPo.setState("12000"); |
| | | ownerAppUserPo.setAppTypeCd("10010"); |
| | | ownerAppUserPo.setAppUserId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_appUserId)); |
| | | ownerAppUserPo.setMemberId(ownerDtos.get(0).getMemberId()); |
| | | ownerAppUserPo.setCommunityName(tmpCommunityDto.getName()); |
| | | ownerAppUserPo.setCommunityId(ownerDtos.get(0).getCommunityId()); |
| | | ownerAppUserPo.setAppUserName(ownerDtos.get(0).getName()); |
| | | ownerAppUserPo.setIdCard(ownerDtos.get(0).getIdCard()); |
| | | ownerAppUserPo.setAppType("WECHAT"); |
| | | ownerAppUserPo.setLink(ownerDtos.get(0).getLink()); |
| | | ownerAppUserPo.setUserId(userDto.getUserId()); |
| | | ownerAppUserPo.setOpenId("-1"); |
| | | ownerAppUserV1InnerServiceSMOImpl.saveOwnerAppUser(ownerAppUserPo); |
| | | OwnerAppUserPo ownerAppUserPo = new OwnerAppUserPo(); |
| | | //状态类型,10000 审核中, 11000 待认证 ,12000 审核成功,13000 审核失败 |
| | | ownerAppUserPo.setState(OwnerAppUserDto.STATE_NOT_AUDIT); |
| | | ownerAppUserPo.setAppTypeCd("10010"); |
| | | ownerAppUserPo.setAppUserId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_appUserId)); |
| | | ownerAppUserPo.setMemberId(ownerDtos.get(0).getMemberId()); |
| | | ownerAppUserPo.setCommunityName(tmpCommunityDto.getName()); |
| | | ownerAppUserPo.setCommunityId(ownerDtos.get(0).getCommunityId()); |
| | | ownerAppUserPo.setAppUserName(ownerDtos.get(0).getName()); |
| | | ownerAppUserPo.setIdCard(ownerDtos.get(0).getIdCard()); |
| | | ownerAppUserPo.setAppType("WECHAT"); |
| | | ownerAppUserPo.setLink(ownerDtos.get(0).getLink()); |
| | | ownerAppUserPo.setUserId(userDto.getUserId()); |
| | | ownerAppUserPo.setOpenId("-1"); |
| | | ownerAppUserV1InnerServiceSMOImpl.saveOwnerAppUser(ownerAppUserPo); |
| | | } |
| | | } |
| | | |
| | | private void registerUser(String phoneNumber) { |