| 
					
				 | 
			
			
				@ -67,11 +67,14 @@ public class WechatController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String checkmobile(String phone) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            /**modify by linz 2017年2月28日10:11:49 校验手机号码的时候返回使用此号码的所有人员**/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Patient> temp = patientService.findByMobile(phone); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (temp != null&&temp.size()>0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Patient temp = patientService.findByMobile(phone); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (temp != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                // 设置患者标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("code", temp.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                // 设置身份证号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return write(200, "患者信息查询成功!", "data", temp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("idcard", temp.getIdcard()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return write(200, "患者信息查询成功!", "data", json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return error(1, "该手机号未被注册"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -150,9 +153,6 @@ public class WechatController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isEmpty(mobile)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return error(-1, "手机号不允许为空"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (patientService.findByMobile(mobile) != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return error(-1, "该手机号已被注册"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 解密身份证号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            idcard = RSAUtils.getInstance(patientService).decryptString(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            idcard = URLDecoder.decode(idcard, "UTF-8"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -187,7 +187,7 @@ public class WechatController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (patient != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (!StringUtils.isEmpty(patient.getMobile())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return error(-1, "该身份证已被注册"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return error(-2, "该身份证已被注册"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -227,9 +227,6 @@ public class WechatController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isEmpty(mobile)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return error(-1, "手机号不允许为空!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //if (patientService.findByMobile(mobile) != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //    return error(-1, "该手机号已被注册!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 对验证码进行校验 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int res = smsService.check(mobile, 1, captcha); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            switch (res) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -284,7 +281,7 @@ public class WechatController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patient = new Patient(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (!StringUtils.isEmpty(patient.getMobile())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return error(-1, "该身份证已被注册!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return error(-2, "该身份证已被注册!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patient.setName(name); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -348,21 +345,12 @@ public class WechatController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //账号登录 mobile可能是电话号也可能是身份证 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNoneEmpty(mobile) && StringUtils.isNoneEmpty(password) && !org.springframework.util.StringUtils.isEmpty(mobile)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<Patient> patients = patientService.findByMobile(mobile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Patient p =null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (patients == null||patients.size()==0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    p = patientService.findByIdcard(mobile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if(patients.size()==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    p = patients.get(0);//只存在一个用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if(patients.size()>1&&StringUtils.isBlank(patient)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //多个用户返回用户让患者选择 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return write(1, "存在多个用户", "data", patients); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if(patients.size()>1&&StringUtils.isNotBlank(patient)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //传入登入者,一般只有多用户才有此操作 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    p = patientService.findByCode(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Patient patient = patientService.findByMobile(mobile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (patient == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patient = patientService.findByIdcard(mobile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                loginLog.setLoginType("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (p == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (patient == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (mobile.length() == 11) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        errorMessage = "该手机号暂未注册账号,请确认后重新输入!"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -371,7 +359,7 @@ public class WechatController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLog.setErrorMessage(errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLogService.saveLog(loginLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return error(-1, errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else if (p.getStatus() == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else if (patient.getStatus() == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (mobile.length() == 11) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        errorMessage = "该手机号已被禁止使用!"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -380,7 +368,7 @@ public class WechatController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLog.setErrorMessage(errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLogService.saveLog(loginLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return error(-1, errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else if (p.getStatus() == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else if (patient.getStatus() == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    errorMessage = "该账号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLog.setErrorMessage(errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLogService.saveLog(loginLog); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -391,31 +379,31 @@ public class WechatController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLogService.saveLog(loginLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return error(-1, errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                loginLog.setUserCode(p.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                loginLog.setUserCode(patient.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //解密 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                password = RSAUtils.getInstance(patientService).decryptString(password); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                password = StringUtils.reverse(password); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //生成MD5 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String loginPassword = MD5.GetMD5Code(password + p.getSalt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String loginPassword = MD5.GetMD5Code(password + patient.getSalt()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //判断d登录密码是否正确 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (loginPassword.equals(p.getPassword())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (loginPassword.equals(patient.getPassword())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    // 绑定用户手机号和openid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (!StringUtils.equals(p.getOpenid(), openid)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (!StringUtils.equals(patient.getOpenid(), openid)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //patient.setOpenid(openid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        patientService.updatePatient(p, openid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        patientService.updatePatient(patient, openid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    // 用户校验通过,生成token 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Token token = tokenService.newTxToken(p.getCode(), openid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Token token = tokenService.newTxToken(patient.getCode(), openid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Map<Object, Object> map = new HashMap<Object, Object>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("id", p.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("uid", p.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("name", p.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("id", patient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("uid", patient.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("name", patient.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("token", token.getToken()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("photo", p.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("photo", patient.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (StringUtils.isNoneEmpty(openid)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //发送微信模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        familyService.sendWXMessage(p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        familyService.sendWXMessage(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLog.setLoginType("1"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -452,9 +440,9 @@ public class WechatController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        return error(-1, errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<Patient> patients = patientService.findByMobile(mobile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Patient patient = patientService.findByMobile(mobile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                loginLog.setLoginType("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (patient == null||patients.size()==0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (patient == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (mobile.length() == 11) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        errorMessage = "该手机号暂未注册账号,请确认后重新输入!"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -463,57 +451,48 @@ public class WechatController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLog.setErrorMessage(errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLogService.saveLog(loginLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return error(-1, errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if(patients.size()>1&&StringUtils.isBlank(patient)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return write(1, "存在多个用户", "data", patients); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if(patients.size()>1&&StringUtils.isNotBlank(patient)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Patient p = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(patients.size()==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         p  = patients.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else if(StringUtils.isNotBlank(patient)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        p = patientService.findByCode(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (p.getStatus() == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (mobile.length() == 11) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            errorMessage = "该手机号已被禁止使用!"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            errorMessage = "该身份证号已被禁止使用!"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        loginLog.setErrorMessage(errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        loginLogService.saveLog(loginLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        return error(-1, errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else if (p.getStatus() == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        errorMessage = "该账号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        loginLog.setErrorMessage(errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        loginLogService.saveLog(loginLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        return error(-1, errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else if (StringUtils.isEmpty(openid)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        errorMessage = "无效的OpenID!"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        loginLog.setErrorMessage(errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        loginLogService.saveLog(loginLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        return error(-1, errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLog.setUserCode(p.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    // 绑定用户手机号和openid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (!StringUtils.equals(p.getOpenid(), openid)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //patient.setOpenid(openid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        patientService.updatePatient(p, openid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    // 用户校验通过,生成token 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Token token = tokenService.newTxToken(p.getCode(), openid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Map<Object, Object> map = new HashMap<Object, Object>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("id", p.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("uid", p.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("name", p.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("token", token.getToken()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    map.put("photo", p.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (StringUtils.isNoneEmpty(openid)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //发送微信模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        familyService.sendWXMessage(p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else if (patient.getStatus() == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (mobile.length() == 11) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        errorMessage = "该手机号已被禁止使用!"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        errorMessage = "该身份证号已被禁止使用!"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLog.setType("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLog.setErrorMessage(errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLogService.saveLog(loginLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return write(200, "登录成功", "data", map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return error(-1, errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else if (patient.getStatus() == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    errorMessage = "该账号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLog.setErrorMessage(errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLogService.saveLog(loginLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return error(-1, errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } else if (StringUtils.isEmpty(openid)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    errorMessage = "无效的OpenID!"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLog.setErrorMessage(errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    loginLogService.saveLog(loginLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return error(-1, errorMessage); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                loginLog.setUserCode(patient.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                // 绑定用户手机号和openid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (!StringUtils.equals(patient.getOpenid(), openid)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //patient.setOpenid(openid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientService.updatePatient(patient, openid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                // 用户校验通过,生成token 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Token token = tokenService.newTxToken(patient.getCode(), openid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<Object, Object> map = new HashMap<Object, Object>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                map.put("id", patient.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                map.put("uid", patient.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                map.put("name", patient.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                map.put("token", token.getToken()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                map.put("photo", patient.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (StringUtils.isNoneEmpty(openid)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //发送微信模板 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    familyService.sendWXMessage(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                loginLog.setType("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                loginLogService.saveLog(loginLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return write(200, "登录成功", "data", map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return error(-1, "登录失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 |