|
@ -2,16 +2,15 @@ package com.yihu.wlyy.web.common.account;
|
|
|
|
|
|
import java.net.URLDecoder;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
import java.util.*;
|
|
|
|
|
|
import com.yihu.wlyy.entity.login.LoginLog;
|
|
|
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
|
|
|
import com.yihu.wlyy.entity.patient.SocialSecurityInfo;
|
|
|
import com.yihu.wlyy.logs.BusinessLogs;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
|
|
|
import com.yihu.wlyy.service.app.family.FamilyMemberService;
|
|
|
import com.yihu.wlyy.service.app.family.FamilyService;
|
|
|
import com.yihu.wlyy.service.common.login.LoginLogService;
|
|
|
import com.yihu.wlyy.util.HttpUtil;
|
|
@ -59,6 +58,8 @@ public class WechatController extends WeixinBaseController {
|
|
|
private FamilyService familyService;
|
|
|
@Autowired
|
|
|
private LoginLogService loginLogService;
|
|
|
@Autowired
|
|
|
private FamilyMemberService familyMemberService;
|
|
|
|
|
|
/**
|
|
|
* 患者注册-验证手机号
|
|
@ -70,14 +71,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) {
|
|
@ -112,16 +110,16 @@ public class WechatController extends WeixinBaseController {
|
|
|
json.put("idcard", temp.getIdcard());
|
|
|
return write(1, "患者信息查询成功!", "data", json);
|
|
|
} else {
|
|
|
Patient temp1 = patientService.findByMobile(mobile);
|
|
|
if (temp1 != null) {
|
|
|
JSONObject json = new JSONObject();
|
|
|
List<Patient> temp1 = patientService.findByMobile(mobile);
|
|
|
if (temp1 != null&&temp1.size()>0) {
|
|
|
//JSONObject json = new JSONObject();
|
|
|
// 设置患者标识
|
|
|
json.put("code", temp1.getCode());
|
|
|
// 设置手机号码
|
|
|
json.put("mobile", temp1.getMobile());
|
|
|
// 设置身份证号
|
|
|
json.put("idcard", temp1.getIdcard());
|
|
|
return write(2, "患者信息查询成功!", "data", json);
|
|
|
//json.put("code", temp1.getCode());
|
|
|
//// 设置手机号码
|
|
|
//json.put("mobile", temp1.getMobile());
|
|
|
//// 设置身份证号
|
|
|
//json.put("idcard", temp1.getIdcard());
|
|
|
return write(2, "患者信息查询成功!", "data", temp1);
|
|
|
}
|
|
|
}
|
|
|
return success("该身份证和手机号未被注册");
|
|
@ -156,9 +154,9 @@ public class WechatController extends WeixinBaseController {
|
|
|
if (StringUtils.isEmpty(mobile)) {
|
|
|
return error(-1, "手机号不允许为空");
|
|
|
}
|
|
|
if (patientService.findByMobile(mobile) != null) {
|
|
|
return error(-1, "该手机号已被注册");
|
|
|
}
|
|
|
//if (patientService.findByMobile(mobile) != null) {
|
|
|
// return error(-1, "该手机号已被注册");
|
|
|
//}
|
|
|
// 解密身份证号
|
|
|
idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
|
|
|
idcard = URLDecoder.decode(idcard, "UTF-8");
|
|
@ -193,11 +191,11 @@ public class WechatController extends WeixinBaseController {
|
|
|
|
|
|
if (patient != null) {
|
|
|
if (!StringUtils.isEmpty(patient.getMobile())) {
|
|
|
return error(-1, "该身份证已被注册");
|
|
|
return error(-2, "该身份证已被注册");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return write(200, "验证成功");
|
|
|
List<Patient> patients = patientService.findByMobile(mobile);
|
|
|
return write(200, "验证成功","data",patients);
|
|
|
} catch (Exception e) {
|
|
|
return error(-1, "验证失败");
|
|
|
}
|
|
@ -213,13 +211,14 @@ public class WechatController extends WeixinBaseController {
|
|
|
*/
|
|
|
@RequestMapping(value = "regist")
|
|
|
@ResponseBody
|
|
|
public String regist(String name,
|
|
|
String idcard,
|
|
|
String ssc,
|
|
|
String mobile,
|
|
|
String captcha,
|
|
|
String openid,
|
|
|
String password) {
|
|
|
public String regist(@RequestParam(value="name",required = true) String name,
|
|
|
@RequestParam(value="idcard",required = true) String idcard,
|
|
|
@RequestParam(value="ssc",required = true) String ssc,
|
|
|
@RequestParam(value="mobile",required = true) String mobile,
|
|
|
@RequestParam(value="captcha",required = true) String captcha,
|
|
|
@RequestParam(value="openid",required = true) String openid,
|
|
|
@RequestParam(value="password",required = true) String password,
|
|
|
@RequestParam(value="home",required = true) String home) {
|
|
|
try {
|
|
|
if (StringUtils.isEmpty(name)) {
|
|
|
return error(-1, "姓名不允许为空!");
|
|
@ -233,9 +232,9 @@ public class WechatController extends WeixinBaseController {
|
|
|
if (StringUtils.isEmpty(mobile)) {
|
|
|
return error(-1, "手机号不允许为空!");
|
|
|
}
|
|
|
if (patientService.findByMobile(mobile) != null) {
|
|
|
return error(-1, "该手机号已被注册!");
|
|
|
}
|
|
|
//if (patientService.findByMobile(mobile) != null) {
|
|
|
// return error(-1, "该手机号已被注册!");
|
|
|
//}
|
|
|
// 对验证码进行校验
|
|
|
int res = smsService.check(mobile, 1, captcha);
|
|
|
switch (res) {
|
|
@ -290,7 +289,7 @@ public class WechatController extends WeixinBaseController {
|
|
|
patient = new Patient();
|
|
|
} else {
|
|
|
if (!StringUtils.isEmpty(patient.getMobile())) {
|
|
|
return error(-1, "该身份证已被注册!");
|
|
|
return error(-2, "该身份证已被注册!");
|
|
|
}
|
|
|
}
|
|
|
patient.setName(name);
|
|
@ -313,6 +312,12 @@ public class WechatController extends WeixinBaseController {
|
|
|
try {
|
|
|
Patient p = patientDao.findByIdcard(idcard);
|
|
|
BusinessLogs.info(BusinessLogs.BusinessType.register, p.getCode(), p.getCode(), new JSONObject(p));
|
|
|
if("1".equals(home)){
|
|
|
List<Patient> patients = patientService.findByMobile(mobile);
|
|
|
for(Patient patient1 :patients){
|
|
|
familyMemberService.addMember(p,patient1.getCode());
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@ -342,6 +347,7 @@ public class WechatController extends WeixinBaseController {
|
|
|
@RequestParam(required = false) String mobile,
|
|
|
@RequestParam(required = false) String captcha,
|
|
|
@RequestParam(required = false) String password,
|
|
|
@RequestParam(required = false) String patient,
|
|
|
String openid) {
|
|
|
System.out.println("login openid : " + openid);
|
|
|
String errorMessage;
|
|
@ -353,12 +359,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 {
|
|
@ -367,7 +382,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 {
|
|
@ -376,7 +391,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);
|
|
@ -387,31 +402,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");
|
|
@ -448,9 +463,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 (patients == null||patients.size()==0) {
|
|
|
if (mobile.length() == 11) {
|
|
|
errorMessage = "该手机号暂未注册账号,请确认后重新输入!";
|
|
|
} else {
|
|
@ -459,48 +474,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) {
|