|
@ -15,14 +15,13 @@ import com.yihu.wlyy.service.common.account.AccessTokenService;
|
|
import com.yihu.wlyy.service.common.account.PatientService;
|
|
import com.yihu.wlyy.service.common.account.PatientService;
|
|
import com.yihu.wlyy.service.common.account.TokenService;
|
|
import com.yihu.wlyy.service.common.account.TokenService;
|
|
import com.yihu.wlyy.service.common.login.LoginLogService;
|
|
import com.yihu.wlyy.service.common.login.LoginLogService;
|
|
|
|
import com.yihu.wlyy.service.third.ylz.YLZUserService;
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
import com.yihu.wlyy.util.HttpUtil;
|
|
|
|
import com.yihu.wlyy.util.IdcardValidator;
|
|
|
|
import com.yihu.wlyy.util.MD5;
|
|
|
|
import com.yihu.wlyy.util.RSAUtils;
|
|
|
|
|
|
import com.yihu.wlyy.util.*;
|
|
import com.yihu.wlyy.web.WeixinBaseController;
|
|
import com.yihu.wlyy.web.WeixinBaseController;
|
|
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
|
|
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
|
|
import com.yihu.wlyy.wechat.util.WeiXinTagUtil;
|
|
import com.yihu.wlyy.wechat.util.WeiXinTagUtil;
|
|
|
|
import com.ylzinfo.ehc.empi.sdk.dto.response.UserInfoResponse;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.json.JSONObject;
|
|
import org.json.JSONObject;
|
|
@ -34,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.net.URLDecoder;
|
|
import java.net.URLDecoder;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@ -73,6 +73,8 @@ public class WechatController extends WeixinBaseController {
|
|
private WeiXinTagUtil weiXinTagUtil;
|
|
private WeiXinTagUtil weiXinTagUtil;
|
|
@Autowired
|
|
@Autowired
|
|
private RSAUtils rsaUtils;
|
|
private RSAUtils rsaUtils;
|
|
|
|
@Autowired
|
|
|
|
private YLZUserService ylzUserService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -132,7 +134,7 @@ public class WechatController extends WeixinBaseController {
|
|
// 解密身份证号
|
|
// 解密身份证号
|
|
//idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
|
|
//idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
|
|
rsaUtils.setBaseService(patientService);
|
|
rsaUtils.setBaseService(patientService);
|
|
idcard =rsaUtils.decryptString(idcard);
|
|
|
|
|
|
idcard = rsaUtils.decryptString(idcard);
|
|
|
|
|
|
idcard = URLDecoder.decode(idcard, "UTF-8");
|
|
idcard = URLDecoder.decode(idcard, "UTF-8");
|
|
idcard = StringUtils.reverse(idcard);
|
|
idcard = StringUtils.reverse(idcard);
|
|
@ -188,7 +190,7 @@ public class WechatController extends WeixinBaseController {
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public String regist(@RequestParam(value = "name", required = true) String name,
|
|
public String regist(@RequestParam(value = "name", required = true) String name,
|
|
@RequestParam(value = "idcard", required = true) String idcard,
|
|
@RequestParam(value = "idcard", required = true) String idcard,
|
|
@RequestParam(value = "ssc", required = false) String ssc,
|
|
|
|
|
|
@RequestParam(value = "ssc", required = true) String ssc,
|
|
@RequestParam(value = "mobile", required = true) String mobile,
|
|
@RequestParam(value = "mobile", required = true) String mobile,
|
|
@RequestParam(value = "captcha", required = true) String captcha,
|
|
@RequestParam(value = "captcha", required = true) String captcha,
|
|
@RequestParam(value = "openid", required = true) String openid,
|
|
@RequestParam(value = "openid", required = true) String openid,
|
|
@ -200,9 +202,9 @@ public class WechatController extends WeixinBaseController {
|
|
if (StringUtils.isEmpty(idcard)) {
|
|
if (StringUtils.isEmpty(idcard)) {
|
|
return error(-1, "身份证号不允许为空!");
|
|
return error(-1, "身份证号不允许为空!");
|
|
}
|
|
}
|
|
// if (StringUtils.isEmpty(ssc)) {
|
|
|
|
// return error(-1, "社保卡号不允许为空!");
|
|
|
|
// }
|
|
|
|
|
|
if (StringUtils.isEmpty(ssc)) {
|
|
|
|
return error(-1, "社保卡号不允许为空!");
|
|
|
|
}
|
|
if (StringUtils.isEmpty(mobile)) {
|
|
if (StringUtils.isEmpty(mobile)) {
|
|
return error(-1, "手机号不允许为空!");
|
|
return error(-1, "手机号不允许为空!");
|
|
}
|
|
}
|
|
@ -240,24 +242,80 @@ public class WechatController extends WeixinBaseController {
|
|
} else {
|
|
} else {
|
|
return error(-1, "请输入正确的身份证号!");
|
|
return error(-1, "请输入正确的身份证号!");
|
|
}
|
|
}
|
|
|
|
|
|
// SocialSecurityInfo socialSecurityInfo = socialSecurityInfoDao.findBySfzh18Max(idcard);
|
|
|
|
|
|
//==========================同步易联众的医保卡号=============================
|
|
|
|
//判断此人有没有厦门社保卡 没有补给注册
|
|
|
|
//判断身份证号与姓名是否一致
|
|
|
|
//判断身份证和社保卡是否一致 统一只存英文字母开头的医保卡
|
|
|
|
|
|
|
|
// if (!org.springframework.util.StringUtils.isEmpty(token)) {
|
|
|
|
// UserInfoResponse userInfoResponse = ylzUserService.getUserByToken(token);
|
|
|
|
// if (userInfoResponse.getCardInfo() != null && userInfoResponse.getCardInfo().size() > 0) {
|
|
|
|
// List<UserInfoResponse.CardInfo> cards = userInfoResponse.getCardInfo();
|
|
|
|
// Boolean hasCard = false;
|
|
|
|
// UserInfoResponse.CardInfo cardInfo = null;
|
|
|
|
// for (UserInfoResponse.CardInfo card : cards) {
|
|
|
|
// //如果患者有正常状态的社保卡
|
|
|
|
// if ("01".equals(card.getCardType()) && "normal".equals("state")) {
|
|
|
|
// hasCard = true;
|
|
|
|
// cardInfo = card;
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
//
|
|
//
|
|
// 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) {
|
|
|
|
|
|
// if (!hasCard) {
|
|
|
|
// return error(-1, "医保卡不存在,必须使用正常状态的厦门医保卡");
|
|
|
|
// }
|
|
|
|
// if (name.compareTo(userInfoResponse.getName() == null ? "" : userInfoResponse.getName()) != 0) {
|
|
|
|
// return error(-1, "身份证号与姓名不一致<br/>请检查后重新输入");
|
|
|
|
// }
|
|
|
|
// if (ssc.compareTo(cardInfo.getCardNo() == null ? "" : cardInfo.getCardNo()) != 0) {
|
|
// return error(-1, "身份证号与医保卡号不一致,请检查后重新输入");
|
|
// return error(-1, "身份证号与医保卡号不一致,请检查后重新输入");
|
|
// } else {
|
|
// } else {
|
|
// ssc = socialSecurityInfo.getCardno();//统一只存英文字母开头的医保卡
|
|
|
|
|
|
// ssc = cardInfo.getCardNo();//统一只存英文字母开头的医保卡
|
|
|
|
// }
|
|
|
|
// SocialSecurityInfo socialSecurityInfo = socialSecurityInfoDao.findBySfzh18Max(idcard);
|
|
|
|
// //如果我们表没有记录那就新增一条记录
|
|
|
|
// if(socialSecurityInfo==null){
|
|
|
|
// socialSecurityInfo=new SocialSecurityInfo();
|
|
|
|
// socialSecurityInfo.setXming0(name);
|
|
|
|
// socialSecurityInfo.setXbie00(IdCardUtil.getSexForIdcard(idcard));
|
|
|
|
// socialSecurityInfo.setCsrqi0(IdCardUtil.getBirthdayForIdcardStr(idcard));
|
|
|
|
// socialSecurityInfo.setSfzh18(idcard);
|
|
|
|
// socialSecurityInfo.setGrsfen("8");
|
|
|
|
// socialSecurityInfo.setId0000(idcard);
|
|
|
|
// socialSecurityInfo.setGzztai("01");
|
|
|
|
// socialSecurityInfo.setCardno(ssc);
|
|
|
|
// socialSecurityInfoDao.save(socialSecurityInfo);
|
|
|
|
// }
|
|
|
|
// //如果医保卡不一致更新{
|
|
|
|
// if(!socialSecurityInfo.getCardno().equals(ssc)){
|
|
|
|
// socialSecurityInfo.setCardno(ssc);
|
|
// }
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
// }
|
|
// }
|
|
// } else {
|
|
|
|
// return error(-1, "对不起,暂不支持16年6月份之后办理的医保卡注册");
|
|
|
|
|
|
//
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
//==============================旧版验证=========================
|
|
|
|
SocialSecurityInfo socialSecurityInfo = socialSecurityInfoDao.findBySfzh18Max(idcard);
|
|
|
|
|
|
|
|
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();//统一只存英文字母开头的医保卡
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return error(-1, "对不起,暂不支持16年6月份之后办理的医保卡注册");
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================旧版验证=============================
|
|
Patient patient = patientDao.findByIdcard(idcard);
|
|
Patient patient = patientDao.findByIdcard(idcard);
|
|
|
|
|
|
if (patient == null) {
|
|
if (patient == null) {
|
|
@ -278,7 +336,7 @@ public class WechatController extends WeixinBaseController {
|
|
password = StringUtils.reverse(password);
|
|
password = StringUtils.reverse(password);
|
|
patient.setPassword(MD5.GetMD5Code(password + salt));
|
|
patient.setPassword(MD5.GetMD5Code(password + salt));
|
|
patient.setSsc(ssc);
|
|
patient.setSsc(ssc);
|
|
if(!"undefined".equals(openid)&&StringUtils.isNotBlank(openid)){
|
|
|
|
|
|
if (!"undefined".equals(openid) && StringUtils.isNotBlank(openid)) {
|
|
patient.setOpenid(openid);
|
|
patient.setOpenid(openid);
|
|
patient.setOpenidTime(new Date());
|
|
patient.setOpenidTime(new Date());
|
|
}
|
|
}
|
|
@ -287,7 +345,7 @@ public class WechatController extends WeixinBaseController {
|
|
// patient.setOpenidTime(new Date());
|
|
// patient.setOpenidTime(new Date());
|
|
// }
|
|
// }
|
|
JSONObject json = patientService.register(idcard, ssc, name, mobile, MD5.GetMD5Code(password + salt)
|
|
JSONObject json = patientService.register(idcard, ssc, name, mobile, MD5.GetMD5Code(password + salt)
|
|
,salt,openid,3);
|
|
|
|
|
|
, salt, openid, 3);
|
|
if (json != null) {
|
|
if (json != null) {
|
|
try {
|
|
try {
|
|
Patient p = patientDao.findByIdcard(idcard);
|
|
Patient p = patientDao.findByIdcard(idcard);
|
|
@ -307,6 +365,7 @@ public class WechatController extends WeixinBaseController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 患者微信登录接口
|
|
* 患者微信登录接口
|
|
*
|
|
*
|
|
@ -384,22 +443,22 @@ public class WechatController extends WeixinBaseController {
|
|
if (StringUtils.isNotBlank(openid) && !"undefined".equals(openid)) {//undefined不更新数据库
|
|
if (StringUtils.isNotBlank(openid) && !"undefined".equals(openid)) {//undefined不更新数据库
|
|
//patient.setOpenid(openid);
|
|
//patient.setOpenid(openid);
|
|
//1.判斷居民OPenid是不是空
|
|
//1.判斷居民OPenid是不是空
|
|
if(StringUtils.isNotBlank(p.getOpenid())){
|
|
|
|
|
|
if (StringUtils.isNotBlank(p.getOpenid())) {
|
|
//如果OPenid与原来用户不相等,则判断登录的openids是否被大于10人登录
|
|
//如果OPenid与原来用户不相等,则判断登录的openids是否被大于10人登录
|
|
if(!p.getOpenid().equals(openid)){
|
|
|
|
|
|
if (!p.getOpenid().equals(openid)) {
|
|
//判断登录的openids是否被大于10人登录
|
|
//判断登录的openids是否被大于10人登录
|
|
if(!patientService.checkOpenidCount(openid)){
|
|
|
|
errorMessage ="您已超过系统允许登录的最大居民账号数量,当前不再允许使用该微信登录新的居民账号,请使用其他微信号进行登录";
|
|
|
|
|
|
if (!patientService.checkOpenidCount(openid)) {
|
|
|
|
errorMessage = "您已超过系统允许登录的最大居民账号数量,当前不再允许使用该微信登录新的居民账号,请使用其他微信号进行登录";
|
|
return error(-2, errorMessage);
|
|
return error(-2, errorMessage);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
patientService.updatePatient(p, openid);
|
|
patientService.updatePatient(p, openid);
|
|
}else{
|
|
|
|
|
|
} else {
|
|
// 判断登录的openids是否被大于10人登录
|
|
// 判断登录的openids是否被大于10人登录
|
|
if(!patientService.checkOpenidCount(openid)){
|
|
|
|
errorMessage ="您已超过系统允许登录的最大居民账号数量,当前不再允许使用该微信登录新的居民账号,请使用其他微信号进行登录";
|
|
|
|
|
|
if (!patientService.checkOpenidCount(openid)) {
|
|
|
|
errorMessage = "您已超过系统允许登录的最大居民账号数量,当前不再允许使用该微信登录新的居民账号,请使用其他微信号进行登录";
|
|
return error(-2, errorMessage);
|
|
return error(-2, errorMessage);
|
|
}else{
|
|
|
|
|
|
} else {
|
|
//未达到上限更新用户openid
|
|
//未达到上限更新用户openid
|
|
patientService.updatePatient(p, openid);
|
|
patientService.updatePatient(p, openid);
|
|
}
|
|
}
|
|
@ -422,7 +481,7 @@ public class WechatController extends WeixinBaseController {
|
|
loginLog.setLoginType("1");
|
|
loginLog.setLoginType("1");
|
|
loginLogService.saveLog(loginLog);
|
|
loginLogService.saveLog(loginLog);
|
|
//判断是否打过标签
|
|
//判断是否打过标签
|
|
//if (!(Patient.isWchatTage.yes.getValue() == p.getIsWxtag())) {
|
|
|
|
|
|
//if (!(Patient.isWchatTage.yes.getValue() == p.getIsWxtag())) {
|
|
|
|
|
|
//清空患者的微信标签
|
|
//清空患者的微信标签
|
|
weiXinTagUtil.deleteTagWithOpenid(p.getOpenid());
|
|
weiXinTagUtil.deleteTagWithOpenid(p.getOpenid());
|
|
@ -510,22 +569,22 @@ public class WechatController extends WeixinBaseController {
|
|
if (StringUtils.isNotBlank(openid) && !"undefined".equals(openid)) {//undefined不更新数据库
|
|
if (StringUtils.isNotBlank(openid) && !"undefined".equals(openid)) {//undefined不更新数据库
|
|
//patient.setOpenid(openid);
|
|
//patient.setOpenid(openid);
|
|
//1.判斷居民OPenid是不是空
|
|
//1.判斷居民OPenid是不是空
|
|
if(StringUtils.isNotBlank(p.getOpenid())){
|
|
|
|
|
|
if (StringUtils.isNotBlank(p.getOpenid())) {
|
|
//如果OPenid与原来用户不相等,则判断登录的openids是否被大于10人登录
|
|
//如果OPenid与原来用户不相等,则判断登录的openids是否被大于10人登录
|
|
if(!p.getOpenid().equals(openid)){
|
|
|
|
|
|
if (!p.getOpenid().equals(openid)) {
|
|
//判断登录的openids是否被大于10人登录
|
|
//判断登录的openids是否被大于10人登录
|
|
if(!patientService.checkOpenidCount(openid)){
|
|
|
|
errorMessage ="您已超过系统允许登录的最大居民账号数量,当前不再允许使用该微信登录新的居民账号,请使用其他微信号进行登录";
|
|
|
|
|
|
if (!patientService.checkOpenidCount(openid)) {
|
|
|
|
errorMessage = "您已超过系统允许登录的最大居民账号数量,当前不再允许使用该微信登录新的居民账号,请使用其他微信号进行登录";
|
|
return error(-2, errorMessage);
|
|
return error(-2, errorMessage);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
patientService.updatePatient(p, openid);
|
|
patientService.updatePatient(p, openid);
|
|
}else{
|
|
|
|
|
|
} else {
|
|
// 判断登录的openids是否被大于10人登录
|
|
// 判断登录的openids是否被大于10人登录
|
|
if(!patientService.checkOpenidCount(openid)){
|
|
|
|
errorMessage ="您已超过系统允许登录的最大居民账号数量,当前不再允许使用该微信登录新的居民账号,请使用其他微信号进行登录";
|
|
|
|
|
|
if (!patientService.checkOpenidCount(openid)) {
|
|
|
|
errorMessage = "您已超过系统允许登录的最大居民账号数量,当前不再允许使用该微信登录新的居民账号,请使用其他微信号进行登录";
|
|
return error(-2, errorMessage);
|
|
return error(-2, errorMessage);
|
|
}else{
|
|
|
|
|
|
} else {
|
|
//未达到上限更新用户openid
|
|
//未达到上限更新用户openid
|
|
patientService.updatePatient(p, openid);
|
|
patientService.updatePatient(p, openid);
|
|
}
|
|
}
|