|  |  | @ -19,6 +19,7 @@ package com.epmet.service.impl; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
			
				
					|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.common.token.util.UserUtil; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.EpmetRoleKeyConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.FieldConstant; | 
			
		
	
	
		
			
				
					|  |  | @ -30,9 +31,11 @@ import com.epmet.commons.tools.utils.Result; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.SmsTemplateConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.UserConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.UserRoleConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.UserCustomerDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.UserResiInfoDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.UserWechatDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.UserResiInfoDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.UserResiRegisterVisitDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.UserRoleDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.result.IssueInitiatorResultDTO; | 
			
		
	
	
		
			
				
					|  |  | @ -82,6 +85,8 @@ public class UserResiInfoServiceImpl extends BaseServiceImpl<UserResiInfoDao, Us | 
			
		
	
		
			
				
					|  |  |  | 	private UserBaseInfoService userBaseInfoService; | 
			
		
	
		
			
				
					|  |  |  | 	@Autowired | 
			
		
	
		
			
				
					|  |  |  | 	private UserWechatDao userWechatService; | 
			
		
	
		
			
				
					|  |  |  | 	@Autowired | 
			
		
	
		
			
				
					|  |  |  | 	private UserCustomerDao userCustomerDao; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	@Override | 
			
		
	
		
			
				
					|  |  |  | 	public PageData<UserResiInfoDTO> page(Map<String, Object> params) { | 
			
		
	
	
		
			
				
					|  |  | @ -164,8 +169,8 @@ public class UserResiInfoServiceImpl extends BaseServiceImpl<UserResiInfoDao, Us | 
			
		
	
		
			
				
					|  |  |  | 			userResiRegisterVisitService.updateResiRegisterVisit(false, userResiInfoDTO); | 
			
		
	
		
			
				
					|  |  |  | 			return new Result().error(EpmetErrorCode.MOBILE_CODE_ERROR.getCode()); | 
			
		
	
		
			
				
					|  |  |  | 		}*/ | 
			
		
	
		
			
				
					|  |  |  | 		//2:再次判断手机号是否可用
 | 
			
		
	
		
			
				
					|  |  |  | 		if (!getResiInfoByMobile(userResiInfoDTO.getRegMobile())) { | 
			
		
	
		
			
				
					|  |  |  | 		//2:再次判断手机号是否在客户下可用
 | 
			
		
	
		
			
				
					|  |  |  | 		if (!getResiInfoByMobile(userResiInfoDTO.getRegMobile(), userResiInfoDTO.getCustomerId())) { | 
			
		
	
		
			
				
					|  |  |  | 			//手机号验证失败则更新行为记录表数据 返回前台结果
 | 
			
		
	
		
			
				
					|  |  |  | 			userResiRegisterVisitService.updateResiRegisterVisit(false, userResiInfoDTO); | 
			
		
	
		
			
				
					|  |  |  | 			return new Result().error(EpmetErrorCode.MOBILE_HAS_BEEN_USED.getCode()); | 
			
		
	
	
		
			
				
					|  |  | @ -221,15 +226,17 @@ public class UserResiInfoServiceImpl extends BaseServiceImpl<UserResiInfoDao, Us | 
			
		
	
		
			
				
					|  |  |  | 		//1:更新居民注册访问记录表数据
 | 
			
		
	
		
			
				
					|  |  |  | 		userResiRegisterVisitService.updateResiVisitOperate(verificationCodeFormDTO); | 
			
		
	
		
			
				
					|  |  |  | 		//2:判断手机号是否可用
 | 
			
		
	
		
			
				
					|  |  |  | 		if (!getResiInfoByMobile(verificationCodeFormDTO.getMobile())) { | 
			
		
	
		
			
				
					|  |  |  | 		//2020-07-29 根据要注册的网格获取客户Id
 | 
			
		
	
		
			
				
					|  |  |  | 		UserResiRegisterVisitDTO registerVisitDTO = userResiRegisterVisitService.get(verificationCodeFormDTO.getResiVisitId()); | 
			
		
	
		
			
				
					|  |  |  | 		if (!getResiInfoByMobile(verificationCodeFormDTO.getMobile(), registerVisitDTO.getCustomerId())) { | 
			
		
	
		
			
				
					|  |  |  | 			return new Result().error(EpmetErrorCode.MOBILE_HAS_BEEN_USED.getCode()); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		//3:调用短信服务 生成验证码发送短信
 | 
			
		
	
		
			
				
					|  |  |  | 		SendVerificationCodeFormDTO sendVerificationCodeFormDTO=new SendVerificationCodeFormDTO(); | 
			
		
	
		
			
				
					|  |  |  | 		SendVerificationCodeFormDTO sendVerificationCodeFormDTO = new SendVerificationCodeFormDTO(); | 
			
		
	
		
			
				
					|  |  |  | 		sendVerificationCodeFormDTO.setMobile(verificationCodeFormDTO.getMobile()); | 
			
		
	
		
			
				
					|  |  |  | 		sendVerificationCodeFormDTO.setAliyunTemplateCode(SmsTemplateConstant.USER_REGISTER); | 
			
		
	
		
			
				
					|  |  |  | 		Result<SendVerificationCodeResultDTO> result = epmetMessageOpenFeignClient.sendVerificationCode(sendVerificationCodeFormDTO); | 
			
		
	
		
			
				
					|  |  |  | 		if(!result.success()||null==result.getData()||StringUtils.isBlank(result.getData().getCode())){ | 
			
		
	
		
			
				
					|  |  |  | 		if (!result.success() || null == result.getData() || StringUtils.isBlank(result.getData().getCode())) { | 
			
		
	
		
			
				
					|  |  |  | 			return new Result().error(EpmetErrorCode.MOBILE_GET_CODE_ERROR.getCode()); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		//4:删除缓存中可能存在的旧验证码
 | 
			
		
	
	
		
			
				
					|  |  | @ -240,11 +247,12 @@ public class UserResiInfoServiceImpl extends BaseServiceImpl<UserResiInfoDao, Us | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	@Override | 
			
		
	
		
			
				
					|  |  |  | 	@Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  | 	public Result saveResiInfo(UserResiInfoDTO userResiInfoDTO) { | 
			
		
	
		
			
				
					|  |  |  | 		Result result = new Result(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 		//判断手机号是否可用
 | 
			
		
	
		
			
				
					|  |  |  | 		if (getResiInfoByMobile(userResiInfoDTO.getRegMobile())) { | 
			
		
	
		
			
				
					|  |  |  | 		if (getResiInfoByMobile(userResiInfoDTO.getRegMobile(), userResiInfoDTO.getCustomerId())) { | 
			
		
	
		
			
				
					|  |  |  | 			//数据存入居民注册表
 | 
			
		
	
		
			
				
					|  |  |  | 			saveUserResiInfo(userResiInfoDTO); | 
			
		
	
		
			
				
					|  |  |  | 			//居民注册关系表新增数据 首次注册数加一 注册数加一 参与数加一
 | 
			
		
	
	
		
			
				
					|  |  | @ -254,6 +262,8 @@ public class UserResiInfoServiceImpl extends BaseServiceImpl<UserResiInfoDao, Us | 
			
		
	
		
			
				
					|  |  |  | 			userRole.setUserId(userResiInfoDTO.getUserId()); | 
			
		
	
		
			
				
					|  |  |  | 			userRole.setRoleKey(UserConstant.ROLE_RESI); | 
			
		
	
		
			
				
					|  |  |  | 			userRoleService.saveUserRole(userRole); | 
			
		
	
		
			
				
					|  |  |  | 			//更新该用户在该客户下的注册状态
 | 
			
		
	
		
			
				
					|  |  |  | 			userCustomerDao.updateRegistered(userResiInfoDTO.getCustomerId(), userResiInfoDTO.getUserId()); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 		return result; | 
			
		
	
	
		
			
				
					|  |  | @ -280,12 +290,17 @@ public class UserResiInfoServiceImpl extends BaseServiceImpl<UserResiInfoDao, Us | 
			
		
	
		
			
				
					|  |  |  | 	 * 判断手机号是否可用-根据手机号查询居民注册信息(user_resi_info)表数据 | 
			
		
	
		
			
				
					|  |  |  | 	 * | 
			
		
	
		
			
				
					|  |  |  | 	 * @param mobile | 
			
		
	
		
			
				
					|  |  |  | 	 * @param customerId | 
			
		
	
		
			
				
					|  |  |  | 	 * @return | 
			
		
	
		
			
				
					|  |  |  | 	 * @Author sun | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	private Boolean getResiInfoByMobile(String mobile) { | 
			
		
	
		
			
				
					|  |  |  | 	private Boolean getResiInfoByMobile(String mobile, String customerId) { | 
			
		
	
		
			
				
					|  |  |  | 		if (StringUtils.isBlank(customerId)) { | 
			
		
	
		
			
				
					|  |  |  | 			customerId = UserUtil.getCurrentUser().getCustomerId(); | 
			
		
	
		
			
				
					|  |  |  | 			log.info("getResiInfoByMobile UserUtil.getCustomerId:{}", customerId); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		Boolean bl = true; | 
			
		
	
		
			
				
					|  |  |  | 		List<UserResiInfoDTO> list = userResiInfoDao.selectResiInfoByMobile(mobile); | 
			
		
	
		
			
				
					|  |  |  | 		List<UserResiInfoDTO> list = userResiInfoDao.selectResiInfoByMobile(mobile, customerId); | 
			
		
	
		
			
				
					|  |  |  | 		if (list.size() > 0) { | 
			
		
	
		
			
				
					|  |  |  | 			bl = false; | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
	
		
			
				
					|  |  | 
 |