|  |  | @ -127,17 +127,68 @@ public class LoginServiceImpl implements LoginService { | 
			
		
	
		
			
				
					|  |  |  | 		WxLoginUserInfoFormDTO wxLoginUserInfoFormDTO = new WxLoginUserInfoFormDTO(); | 
			
		
	
		
			
				
					|  |  |  | 		wxLoginUserInfoFormDTO.setApp(formDTO.getApp()); | 
			
		
	
		
			
				
					|  |  |  | 		wxLoginUserInfoFormDTO.setOpenId(wxMaJscode2SessionResult.getOpenid()); | 
			
		
	
		
			
				
					|  |  |  | 		//1、先根据app、client、openId查询
 | 
			
		
	
		
			
				
					|  |  |  | 		Result<String> userResult = epmetUserFeignClient.selecWxLoginUserInfo(wxLoginUserInfoFormDTO); | 
			
		
	
		
			
				
					|  |  |  | 		String userId = ""; | 
			
		
	
		
			
				
					|  |  |  | 		if (!userResult.success()) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new RenException("获取用户信息失败" + userResult.getMsg()); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		userId = (String) userResult.getData(); | 
			
		
	
		
			
				
					|  |  |  | 		if (StringUtils.isBlank(userId) && LoginConstant.APP_GOV.equals(formDTO.getApp())) { | 
			
		
	
		
			
				
					|  |  |  | 		userId = userResult.getData(); | 
			
		
	
		
			
				
					|  |  |  | 		//2、如果已经存在userId,则更新微信信息
 | 
			
		
	
		
			
				
					|  |  |  | 		if (StringUtils.isNotBlank(userId) && StringUtils.isNotBlank(formDTO.getEncryptedData()) && StringUtils.isNotBlank(formDTO.getIv())) { | 
			
		
	
		
			
				
					|  |  |  | 			this.updateWxInfO(userId,formDTO,wxMaJscode2SessionResult); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		//3、数据库不存在此用户则创建此用户
 | 
			
		
	
		
			
				
					|  |  |  | 		if (StringUtils.isBlank(userId)) { | 
			
		
	
		
			
				
					|  |  |  | 			userId = createEpmtUser(formDTO, wxMaJscode2SessionResult); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		return userId; | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * @return com.epmet.commons.tools.utils.Result | 
			
		
	
		
			
				
					|  |  |  | 	 * @param userId | 
			
		
	
		
			
				
					|  |  |  | 	 * @param wxMaJscode2SessionResult | 
			
		
	
		
			
				
					|  |  |  | 	 * @Author yinzuomei | 
			
		
	
		
			
				
					|  |  |  | 	 * @Description 获取用户微信基本信息更新到本地 | 
			
		
	
		
			
				
					|  |  |  | 	 * @Date 2020/3/20 19:51 | 
			
		
	
		
			
				
					|  |  |  | 	 **/ | 
			
		
	
		
			
				
					|  |  |  | 	private Result updateWxInfO(String userId, | 
			
		
	
		
			
				
					|  |  |  | 								LoginByWxCodeFormDTO formDTO, | 
			
		
	
		
			
				
					|  |  |  | 								WxMaJscode2SessionResult wxMaJscode2SessionResult) { | 
			
		
	
		
			
				
					|  |  |  | 		if (LoginConstant.APP_GOV.equals(formDTO.getApp())) { | 
			
		
	
		
			
				
					|  |  |  | 			//查询customer_staff待完善
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 		} else if (LoginConstant.APP_OPER.equals(formDTO.getApp())) { | 
			
		
	
		
			
				
					|  |  |  | 			//查询oper_user待完善
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 		} else if (LoginConstant.APP_RESI.equals(formDTO.getApp())) { | 
			
		
	
		
			
				
					|  |  |  | 			WxMaUserInfo wxMaUserInfo = wxMaServiceUtils.resiWxMaService().getUserService() | 
			
		
	
		
			
				
					|  |  |  | 					.getUserInfo(wxMaJscode2SessionResult.getSessionKey(), | 
			
		
	
		
			
				
					|  |  |  | 							formDTO.getEncryptedData(), | 
			
		
	
		
			
				
					|  |  |  | 							formDTO.getIv()); | 
			
		
	
		
			
				
					|  |  |  | 			CustomerUserDTO customerUserDTO = this.packageCustomerUserDTO(wxMaUserInfo); | 
			
		
	
		
			
				
					|  |  |  | 			customerUserDTO.setId(userId); | 
			
		
	
		
			
				
					|  |  |  | 			epmetUserFeignClient.saveOrUpdateCustomerUser(customerUserDTO); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		return new Result(); | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * @param formDTO | 
			
		
	
		
			
				
					|  |  |  | 	 * @param wxMaJscode2SessionResult | 
			
		
	
		
			
				
					|  |  |  | 	 * @return java.lang.String | 
			
		
	
		
			
				
					|  |  |  | 	 * @Author yinzuomei | 
			
		
	
		
			
				
					|  |  |  | 	 * @Description 陌生人首次授权,创建用户信息 | 
			
		
	
		
			
				
					|  |  |  | 	 * @Date 2020/3/20 19:42 | 
			
		
	
		
			
				
					|  |  |  | 	 **/ | 
			
		
	
		
			
				
					|  |  |  | 	private String createEpmtUser(LoginByWxCodeFormDTO formDTO, WxMaJscode2SessionResult wxMaJscode2SessionResult) { | 
			
		
	
		
			
				
					|  |  |  | 		String userId = ""; | 
			
		
	
		
			
				
					|  |  |  | 		if (LoginConstant.APP_GOV.equals(formDTO.getApp())) { | 
			
		
	
		
			
				
					|  |  |  | 			//查询customer_staff待完善
 | 
			
		
	
		
			
				
					|  |  |  | 		} else if (StringUtils.isBlank(userId) && LoginConstant.APP_OPER.equals(formDTO.getApp())) { | 
			
		
	
		
			
				
					|  |  |  | 		} else if (LoginConstant.APP_OPER.equals(formDTO.getApp())) { | 
			
		
	
		
			
				
					|  |  |  | 			//查询oper_user待完善
 | 
			
		
	
		
			
				
					|  |  |  | 		} else if (StringUtils.isBlank(userId) && LoginConstant.APP_RESI.equals(formDTO.getApp())) { | 
			
		
	
		
			
				
					|  |  |  | 		} else if (LoginConstant.APP_RESI.equals(formDTO.getApp())) { | 
			
		
	
		
			
				
					|  |  |  | 			//查询customer_user
 | 
			
		
	
		
			
				
					|  |  |  | 			CustomerUserDTO customerUserDTO = new CustomerUserDTO(); | 
			
		
	
		
			
				
					|  |  |  | 			if (StringUtils.isNotBlank(formDTO.getIv()) && StringUtils.isNotBlank(formDTO.getEncryptedData())) { | 
			
		
	
	
		
			
				
					|  |  | @ -150,9 +201,9 @@ public class LoginServiceImpl implements LoginService { | 
			
		
	
		
			
				
					|  |  |  | 				customerUserDTO.setWxOpenId(wxMaJscode2SessionResult.getOpenid()); | 
			
		
	
		
			
				
					|  |  |  | 				customerUserDTO.setUnionId(wxMaJscode2SessionResult.getUnionid()); | 
			
		
	
		
			
				
					|  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  | 			Result<String> saveCustomerUserResult = epmetUserFeignClient.saveCustomerUser(customerUserDTO); | 
			
		
	
		
			
				
					|  |  |  | 			Result<String> saveCustomerUserResult = epmetUserFeignClient.saveOrUpdateCustomerUser(customerUserDTO); | 
			
		
	
		
			
				
					|  |  |  | 			if (!saveCustomerUserResult.success()) { | 
			
		
	
		
			
				
					|  |  |  | 				throw new RenException("创建用户失败" + userResult.getMsg()); | 
			
		
	
		
			
				
					|  |  |  | 				throw new RenException("创建用户失败" + saveCustomerUserResult.getMsg()); | 
			
		
	
		
			
				
					|  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  | 			userId = saveCustomerUserResult.getData(); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
	
		
			
				
					|  |  | 
 |