|
@ -133,16 +133,16 @@ public class WechatController extends WeixinBaseController {
|
|
|
/**
|
|
|
* 注册信息验证
|
|
|
*
|
|
|
* @param name 姓名
|
|
|
* @param name 姓名
|
|
|
* @param idcard 身份证号
|
|
|
* @param ssc 社保卡号
|
|
|
* @param ssc 社保卡号
|
|
|
* @param mobile 手机号
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/check_regist_info")
|
|
|
@ResponseBody
|
|
|
public String checkRegistInfo(String name,String idcard,String ssc,String mobile){
|
|
|
try{
|
|
|
public String checkRegistInfo(String name, String idcard, String ssc, String mobile) {
|
|
|
try {
|
|
|
if (StringUtils.isEmpty(name)) {
|
|
|
return error(-1, "姓名不允许为空");
|
|
|
}
|
|
@ -177,38 +177,38 @@ public class WechatController extends WeixinBaseController {
|
|
|
|
|
|
SocialSecurityInfo socialSecurityInfo = socialSecurityInfoDao.findBySfzh18Max(idcard);
|
|
|
|
|
|
if(socialSecurityInfo != null){
|
|
|
if(name.compareTo(socialSecurityInfo.getXming0() == null ? "" : socialSecurityInfo.getXming0()) != 0){
|
|
|
return error(-1,"身份证号与姓名不一致,请检查后重新输入");
|
|
|
if (socialSecurityInfo != null) {
|
|
|
if (name.compareTo(socialSecurityInfo.getXming0() == null ? "" : socialSecurityInfo.getXming0()) != 0) {
|
|
|
return error(-1, "身份证号与姓名不一致,请检查后重新输入");
|
|
|
}
|
|
|
if(ssc.compareTo(socialSecurityInfo.getCardno() == null ? "" : socialSecurityInfo.getCardno()) != 0&&ssc.compareTo(socialSecurityInfo.getCard16() == null ? "" : socialSecurityInfo.getCard16()) != 0){
|
|
|
return error(-1,"身份证号与医保卡号不一致,请检查后重新输入");
|
|
|
if (ssc.compareTo(socialSecurityInfo.getCardno() == null ? "" : socialSecurityInfo.getCardno()) != 0 && ssc.compareTo(socialSecurityInfo.getCard16() == null ? "" : socialSecurityInfo.getCard16()) != 0) {
|
|
|
return error(-1, "身份证号与医保卡号不一致,请检查后重新输入");
|
|
|
}
|
|
|
}else{
|
|
|
return error(-1,"对不起,暂不支持16年6月份之后办理的医保卡注册");
|
|
|
} else {
|
|
|
return error(-1, "对不起,暂不支持16年6月份之后办理的医保卡注册");
|
|
|
}
|
|
|
|
|
|
Patient patient = patientDao.findByIdcard(idcard);
|
|
|
|
|
|
if(patient != null){
|
|
|
if (patient != null) {
|
|
|
if (!StringUtils.isEmpty(patient.getMobile())) {
|
|
|
return error(-1, "该身份证已被注册");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return write(200,"验证成功");
|
|
|
}catch(Exception e){
|
|
|
return write(200, "验证成功");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"验证失败");
|
|
|
return error(-1, "验证失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 患者注册
|
|
|
*
|
|
|
* @param idcard 身份證號
|
|
|
* @param mobile 登录手机号
|
|
|
* @param captcha 手机验证码
|
|
|
* @param idcard 身份證號
|
|
|
* @param mobile 登录手机号
|
|
|
* @param captcha 手机验证码
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "regist")
|
|
@ -227,9 +227,9 @@ public class WechatController extends WeixinBaseController {
|
|
|
if (StringUtils.isEmpty(idcard)) {
|
|
|
return error(-1, "身份证号不允许为空!");
|
|
|
}
|
|
|
if (StringUtils.isEmpty(ssc)) {
|
|
|
return error(-1, "社保卡号不允许为空!");
|
|
|
}
|
|
|
if (StringUtils.isEmpty(ssc)) {
|
|
|
return error(-1, "社保卡号不允许为空!");
|
|
|
}
|
|
|
if (StringUtils.isEmpty(mobile)) {
|
|
|
return error(-1, "手机号不允许为空!");
|
|
|
}
|
|
@ -269,26 +269,26 @@ public class WechatController extends WeixinBaseController {
|
|
|
|
|
|
SocialSecurityInfo socialSecurityInfo = socialSecurityInfoDao.findBySfzh18Max(idcard);
|
|
|
|
|
|
if(socialSecurityInfo != null){
|
|
|
if(name.compareTo(socialSecurityInfo.getXming0() == null ? "" : socialSecurityInfo.getXming0()) != 0){
|
|
|
return error(-1,"身份证号与姓名不一致<br/>请检查后重新输入");
|
|
|
if (socialSecurityInfo != null) {
|
|
|
if (name.compareTo(socialSecurityInfo.getXming0() == null ? "" : socialSecurityInfo.getXming0()) != 0) {
|
|
|
return error(-1, "身份证号与姓名不一致<br/>请检查后重新输入");
|
|
|
}
|
|
|
if(ssc.compareTo(socialSecurityInfo.getCardno() == null ? "" : socialSecurityInfo.getCardno()) != 0){
|
|
|
if(ssc.compareTo(socialSecurityInfo.getCard16() == null ? "" : socialSecurityInfo.getCard16()) != 0){
|
|
|
return error(-1,"身份证号与医保卡号不一致,请检查后重新输入");
|
|
|
}else{
|
|
|
ssc= socialSecurityInfo.getCardno();//统一只存英文字母开头的医保卡
|
|
|
if (ssc.compareTo(socialSecurityInfo.getCardno() == null ? "" : socialSecurityInfo.getCardno()) != 0) {
|
|
|
if (ssc.compareTo(socialSecurityInfo.getCard16() == null ? "" : socialSecurityInfo.getCard16()) != 0) {
|
|
|
return error(-1, "身份证号与医保卡号不一致,请检查后重新输入");
|
|
|
} else {
|
|
|
ssc = socialSecurityInfo.getCardno();//统一只存英文字母开头的医保卡
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
return error(-1,"对不起,暂不支持16年6月份之后办理的医保卡注册");
|
|
|
} else {
|
|
|
return error(-1, "对不起,暂不支持16年6月份之后办理的医保卡注册");
|
|
|
}
|
|
|
|
|
|
Patient patient = patientDao.findByIdcard(idcard);
|
|
|
|
|
|
if(patient == null){
|
|
|
if (patient == null) {
|
|
|
patient = new Patient();
|
|
|
}else{
|
|
|
} else {
|
|
|
if (!StringUtils.isEmpty(patient.getMobile())) {
|
|
|
return error(-1, "该身份证已被注册!");
|
|
|
}
|
|
@ -297,13 +297,13 @@ public class WechatController extends WeixinBaseController {
|
|
|
patient.setIdcard(idcard);
|
|
|
patient.setMobile(mobile);
|
|
|
//增加密码
|
|
|
String salt= UUID.randomUUID().toString().replace("-","");
|
|
|
String salt = UUID.randomUUID().toString().replace("-", "");
|
|
|
patient.setSalt(salt);
|
|
|
password = RSAUtils.getInstance(patientService).decryptString(password);
|
|
|
password=StringUtils.reverse(password);
|
|
|
patient.setPassword(MD5.GetMD5Code(password+salt));
|
|
|
password = StringUtils.reverse(password);
|
|
|
patient.setPassword(MD5.GetMD5Code(password + salt));
|
|
|
|
|
|
patient.setSsc(ssc);
|
|
|
patient.setSsc(ssc);
|
|
|
patient.setOpenid(openid);
|
|
|
JSONObject json = patientService.register(patient, openid, 3);
|
|
|
if (json != null) {
|
|
@ -322,7 +322,7 @@ public class WechatController extends WeixinBaseController {
|
|
|
/**
|
|
|
* 患者微信登录接口
|
|
|
*
|
|
|
* @param captcha 短信号
|
|
|
* @param captcha 短信号
|
|
|
* @param mobile 电话号码
|
|
|
* @param password 登录密码
|
|
|
* @return
|
|
@ -335,58 +335,61 @@ public class WechatController extends WeixinBaseController {
|
|
|
@RequestParam(required = false) String password,
|
|
|
String openid) {
|
|
|
String errorMessage;
|
|
|
LoginLog loginLog=new LoginLog();
|
|
|
LoginLog loginLog = new LoginLog();
|
|
|
loginLog.setCreateTime(new Date());
|
|
|
loginLog.setPhone(mobile);
|
|
|
loginLog.setType("2");
|
|
|
loginLog.setUserType("1");
|
|
|
try {
|
|
|
//账号登录 mobile可能是电话号也可能是身份证
|
|
|
if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(password)&&!org.springframework.util.StringUtils.isEmpty(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);
|
|
|
if (patient == null) {
|
|
|
patient = patientService.findByIdcard(mobile);
|
|
|
}
|
|
|
loginLog.setLoginType("2");
|
|
|
if (patient == null) {
|
|
|
if(mobile.length()==11){
|
|
|
errorMessage="该手机号暂未注册账号,请确认后重新输入!";
|
|
|
}else{
|
|
|
errorMessage="该身份证号暂未注册账号,请确认后重新输入!";
|
|
|
if (mobile.length() == 11) {
|
|
|
errorMessage = "该手机号暂未注册账号,请确认后重新输入!";
|
|
|
} else {
|
|
|
errorMessage = "该身份证号暂未注册账号,请确认后重新输入!";
|
|
|
}
|
|
|
loginLog.setErrorMessage(errorMessage);
|
|
|
loginLogService.saveLog(loginLog);
|
|
|
return error(-1, errorMessage);
|
|
|
} else if (patient.getStatus() == 0) {
|
|
|
if(mobile.length()==11){
|
|
|
errorMessage="该手机号已被禁止使用!";
|
|
|
}else{
|
|
|
errorMessage="该身份证号已被禁止使用!";
|
|
|
if (mobile.length() == 11) {
|
|
|
errorMessage = "该手机号已被禁止使用!";
|
|
|
} else {
|
|
|
errorMessage = "该身份证号已被禁止使用!";
|
|
|
}
|
|
|
loginLog.setErrorMessage(errorMessage);
|
|
|
loginLogService.saveLog(loginLog);
|
|
|
return error(-1,errorMessage );
|
|
|
return error(-1, errorMessage);
|
|
|
} else if (patient.getStatus() == 2) {
|
|
|
errorMessage="该账号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”";
|
|
|
errorMessage = "该账号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”";
|
|
|
loginLog.setErrorMessage(errorMessage);
|
|
|
loginLogService.saveLog(loginLog);
|
|
|
return error(-1, errorMessage);
|
|
|
} else if (StringUtils.isEmpty(openid)) {
|
|
|
errorMessage="无效的OpenID!";
|
|
|
errorMessage = "无效的OpenID!";
|
|
|
loginLog.setErrorMessage(errorMessage);
|
|
|
loginLogService.saveLog(loginLog);
|
|
|
return error(-1,errorMessage);
|
|
|
return error(-1, errorMessage);
|
|
|
}
|
|
|
loginLog.setUserCode(patient.getCode());
|
|
|
//解密
|
|
|
password = RSAUtils.getInstance(patientService).decryptString(password);
|
|
|
password=StringUtils.reverse(password);
|
|
|
password = StringUtils.reverse(password);
|
|
|
//生成MD5
|
|
|
String loginPassword= MD5.GetMD5Code(password+patient.getSalt());
|
|
|
String loginPassword = MD5.GetMD5Code(password + patient.getSalt());
|
|
|
//判断d登录密码是否正确
|
|
|
if(loginPassword.equals(patient.getPassword())){
|
|
|
if (loginPassword.equals(patient.getPassword())) {
|
|
|
// 绑定用户手机号和openid
|
|
|
if (!StringUtils.equals(patient.getOpenid(), openid)) {
|
|
|
if (patientService.countByOpenid(openid) >= 11) {
|
|
|
return error(-1,"该微信号已绑定11人,无法再绑定");
|
|
|
}
|
|
|
patient.setOpenid(openid);
|
|
|
patientService.updatePatient(patient);
|
|
|
}
|
|
@ -399,7 +402,7 @@ public class WechatController extends WeixinBaseController {
|
|
|
map.put("name", patient.getName());
|
|
|
map.put("token", token.getToken());
|
|
|
map.put("photo", patient.getPhoto());
|
|
|
if(StringUtils.isNoneEmpty(openid)){
|
|
|
if (StringUtils.isNoneEmpty(openid)) {
|
|
|
//发送微信模板
|
|
|
familyService.sendWXMessage(patient);
|
|
|
}
|
|
@ -407,61 +410,64 @@ public class WechatController extends WeixinBaseController {
|
|
|
loginLog.setLoginType("1");
|
|
|
loginLogService.saveLog(loginLog);
|
|
|
return write(200, "登录成功", "data", map);
|
|
|
}else{
|
|
|
errorMessage="密码错误,登录失败";
|
|
|
} else {
|
|
|
errorMessage = "密码错误,登录失败";
|
|
|
loginLog.setErrorMessage(errorMessage);
|
|
|
loginLogService.saveLog(loginLog);
|
|
|
return error(-1, errorMessage);
|
|
|
}
|
|
|
}
|
|
|
//短信登录
|
|
|
if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(captcha)){
|
|
|
if (StringUtils.isNoneEmpty(mobile) && StringUtils.isNoneEmpty(captcha)) {
|
|
|
// 对验证码进行校验
|
|
|
int res = smsService.check(mobile, 4, captcha);
|
|
|
switch (res) {
|
|
|
case -2:{
|
|
|
errorMessage="验证码已过期!";
|
|
|
case -2: {
|
|
|
errorMessage = "验证码已过期!";
|
|
|
loginLog.setErrorMessage(errorMessage);
|
|
|
loginLogService.saveLog(loginLog);
|
|
|
return error(-1, errorMessage);}
|
|
|
case -1:{
|
|
|
errorMessage="请输入正确的验证码!";
|
|
|
return error(-1, errorMessage);
|
|
|
}
|
|
|
case -1: {
|
|
|
errorMessage = "请输入正确的验证码!";
|
|
|
loginLog.setErrorMessage(errorMessage);
|
|
|
loginLogService.saveLog(loginLog);
|
|
|
return error(-1, errorMessage);}
|
|
|
case 0:{
|
|
|
errorMessage="验证码无效!";
|
|
|
return error(-1, errorMessage);
|
|
|
}
|
|
|
case 0: {
|
|
|
errorMessage = "验证码无效!";
|
|
|
loginLog.setErrorMessage(errorMessage);
|
|
|
loginLogService.saveLog(loginLog);
|
|
|
return error(-1, errorMessage);}
|
|
|
return error(-1, errorMessage);
|
|
|
}
|
|
|
}
|
|
|
Patient patient = patientService.findByMobile(mobile);
|
|
|
loginLog.setLoginType("1");
|
|
|
if (patient == null) {
|
|
|
if(mobile.length()==11){
|
|
|
errorMessage="该手机号暂未注册账号,请确认后重新输入!";
|
|
|
}else{
|
|
|
errorMessage="该身份证号暂未注册账号,请确认后重新输入!";
|
|
|
if (mobile.length() == 11) {
|
|
|
errorMessage = "该手机号暂未注册账号,请确认后重新输入!";
|
|
|
} else {
|
|
|
errorMessage = "该身份证号暂未注册账号,请确认后重新输入!";
|
|
|
}
|
|
|
loginLog.setErrorMessage(errorMessage);
|
|
|
loginLogService.saveLog(loginLog);
|
|
|
return error(-1, errorMessage);
|
|
|
} else if (patient.getStatus() == 0) {
|
|
|
if(mobile.length()==11){
|
|
|
errorMessage="该手机号已被禁止使用!";
|
|
|
}else{
|
|
|
errorMessage="该身份证号已被禁止使用!";
|
|
|
if (mobile.length() == 11) {
|
|
|
errorMessage = "该手机号已被禁止使用!";
|
|
|
} else {
|
|
|
errorMessage = "该身份证号已被禁止使用!";
|
|
|
}
|
|
|
loginLog.setErrorMessage(errorMessage);
|
|
|
loginLogService.saveLog(loginLog);
|
|
|
return error(-1, errorMessage);
|
|
|
} else if (patient.getStatus() == 2) {
|
|
|
errorMessage="该账号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”";
|
|
|
errorMessage = "该账号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”";
|
|
|
loginLog.setErrorMessage(errorMessage);
|
|
|
loginLogService.saveLog(loginLog);
|
|
|
return error(-1, errorMessage);
|
|
|
} else if (StringUtils.isEmpty(openid)) {
|
|
|
errorMessage="无效的OpenID!";
|
|
|
errorMessage = "无效的OpenID!";
|
|
|
loginLog.setErrorMessage(errorMessage);
|
|
|
loginLogService.saveLog(loginLog);
|
|
|
return error(-1, errorMessage);
|
|
@ -469,6 +475,9 @@ public class WechatController extends WeixinBaseController {
|
|
|
loginLog.setUserCode(patient.getCode());
|
|
|
// 绑定用户手机号和openid
|
|
|
if (!StringUtils.equals(patient.getOpenid(), openid)) {
|
|
|
if (patientService.countByOpenid(openid) >= 11) {
|
|
|
return error(-1,"该微信号已绑定11人,无法再绑定");
|
|
|
}
|
|
|
patient.setOpenid(openid);
|
|
|
patientService.updatePatient(patient);
|
|
|
}
|
|
@ -481,7 +490,7 @@ public class WechatController extends WeixinBaseController {
|
|
|
map.put("name", patient.getName());
|
|
|
map.put("token", token.getToken());
|
|
|
map.put("photo", patient.getPhoto());
|
|
|
if(StringUtils.isNoneEmpty(openid)){
|
|
|
if (StringUtils.isNoneEmpty(openid)) {
|
|
|
//发送微信模板
|
|
|
familyService.sendWXMessage(patient);
|
|
|
}
|
|
@ -492,7 +501,7 @@ public class WechatController extends WeixinBaseController {
|
|
|
return error(-1, "登录失败");
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
errorMessage="系统异常,登录失败";
|
|
|
errorMessage = "系统异常,登录失败";
|
|
|
loginLog.setErrorMessage(errorMessage);
|
|
|
loginLogService.saveLog(loginLog);
|
|
|
error(e);
|
|
@ -641,20 +650,20 @@ public class WechatController extends WeixinBaseController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/is_subscribe")
|
|
|
@ResponseBody
|
|
|
public String getIsSubscribe(String openid){
|
|
|
try{
|
|
|
String userInfo_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token="+ getAccessToken()+ "&openid=" + openid + "&lang=zh_CN";
|
|
|
public String getIsSubscribe(String openid) {
|
|
|
try {
|
|
|
String userInfo_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + getAccessToken() + "&openid=" + openid + "&lang=zh_CN";
|
|
|
String params = "";
|
|
|
String result = HttpUtil.sendGet(userInfo_url, params);
|
|
|
JSONObject json = new JSONObject(result);
|
|
|
if (json.has("subscribe")) {
|
|
|
return write(200,"查询成功","subsribe",json.get("subscribe").toString());
|
|
|
return write(200, "查询成功", "subsribe", json.get("subscribe").toString());
|
|
|
} else {
|
|
|
return error(-1,json.getString("errmsg"));
|
|
|
return error(-1, json.getString("errmsg"));
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1,"查询失败");
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
}
|
|
|
}
|