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