瀏覽代碼

Merge branch 'dev' of lyr/patient-co-management into dev

lyr 8 年之前
父節點
當前提交
142be816f4

+ 174 - 169
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -28,180 +28,185 @@ import java.util.Date;
/**
 * 患者基本信息类.
 * 
 *
 * @author George
 */
@Component
@Transactional(rollbackFor = Exception.class)
public class PatientService extends TokenService {
	@Autowired
	private SignFamilyDao signFamilyDao;
	@Autowired
	private PatientDao patientDao;
	@Autowired
	private DoctorDao doctorDao;
	@Autowired
	private DoctorPatientDao doctorPatientDao;
	private Clock clock = Clock.DEFAULT;
	public void setClock(Clock clock) {
		this.clock = clock;
	}
	public Patient findByCode(String code) {
		return patientDao.findByCode(code);
	}
	public Patient findByIdcard(String idcard) {
		return patientDao.findByIdcard(idcard);
	}
	public Patient findBySsc(String ssc) {
		return patientDao.findBySsc(ssc);
	}
	public Patient findByMobile(String mobile) {
		return patientDao.findByMobile(mobile);
	}
	public Patient findByOpenid(String openid) {
		return patientDao.findByOpenid(openid);
	}
	public int countByOpenid(String openid) {
		return patientDao.countByOpenid(openid);
	}
	/**
	 * 修改患者密码
	 * @param patient
	 */
	public void updatePatientPwd(Patient patient) {
		patientDao.save(patient);
	}
	public void updatePatientInfo(Patient patient) {
		patientDao.save(patient);
	}
	/**
	 * 修改患者openid
	 * @param patient
	 */
	public void updatePatient(Patient patient) {
		if (StringUtils.isNotEmpty(patient.getOpenid())) {
			patientDao.clearOpenid(patient.getCode(), patient.getOpenid());
		}
		patientDao.save(patient);
		if (StringUtils.isNotEmpty(patient.getOpenid())) {
			signFamilyDao.updateOpenidByPatient(patient.getOpenid(), patient.getCode());
		}
	}
	public void deletePatient(Patient patient) {
		patientDao.delete(patient);
	}
	public void deletePatients(Iterable<Patient> patients) {
		patientDao.delete(patients);
	}
	/**
	 * 患者註冊
	 * @param patient
	 * @return
	 * @throws Exception
	 */
	public JSONObject register(Patient patient, String imei, int platform) throws Exception {
		IdcardInfoExtractor ie = new IdcardInfoExtractor(patient.getIdcard());
		patient.setBirthday(ie.getBirthday());
		patient.setSex(ie.getGender());
		patient.setCode(getCode());
		patient.setStatus(1);
		patient.setCzrq(clock.getCurrentDate());
		patient.setDisease(0);
		patient.setDiseaseCondition(0);
		patient.setRecordAmount(0);
		patient.setPoints(0);
		Patient temp = patientDao.save(patient);
		if (temp != null) {
			// 更新openid
			updatePatient(temp);
			// 生成登录tokey
			Token token = newToken(temp.getCode(), imei, platform);
			if (token != null) {
				// 生成登录信息成功
				JSONObject json = new JSONObject();
				json.put("id", temp.getId());
				json.put("uid", temp.getCode());
				json.put("token", token.getToken());
				json.put("name", temp.getName());
				json.put("photo", temp.getPhoto());
				//new Thread(new SignSsGetTask(patient.getIdcard())).start();
				return json;
			}
		}
		return null;
	}
	/**
	 * 建立三师团队与患者的关系
	 * @param sf
	 * @param patient
	 * @param doctorCode
	 * @param doctorType
	 */
	private void bindDoctorPatient(SignFamily sf, Patient patient, String doctorCode, int doctorType) {
		DoctorPatient dp = doctorPatientDao.findByPatientDoctorTeamType(patient.getCode(), doctorCode, doctorType);
		if (dp == null) {
			Doctor doctor = doctorDao.findByCode(doctorCode);
			dp = new DoctorPatient();
			dp.setBirthday(patient.getBirthday());
			dp.setCzrq(new Date());
			dp.setDoctor(doctor.getCode());
			dp.setDoctorName(doctor.getName());
			// 健康管理师
			dp.setDoctorType(doctorType);
			dp.setPatient(patient.getCode());
			dp.setPatientName(patient.getName());
			dp.setSex(patient.getSex());
			if (sf != null) {
				// 三师和家庭都存在
				dp.setSignType("11");
			} else {
				// 只有家庭签约
				dp.setSignType("01");
			}
			dp.setStatus(1);
			// 设置为三师团队
			dp.setTeamType(1);
			// 保存到数据库
			doctorPatientDao.save(dp);
		}
	}
	/**
	 * 微信端患者註冊
	 * @param patient
	 * @return
	 * @throws Exception
	 */
	public JSONObject register(Patient patient) throws Exception {
		patient.setCode(getCode());
		patient.setCzrq(clock.getCurrentDate());
		EncodesUtil.entryptPassword(patient);
		Patient temp = patientDao.save(patient);
		if (temp != null) {
			JSONObject json = new JSONObject();
			json.put("id", temp.getId());
			json.put("uid", temp.getCode());
			json.put("name", "");
			json.put("openid", temp.getOpenid());
			return json;
		}
		return null;
	}
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private DoctorPatientDao doctorPatientDao;
    private Clock clock = Clock.DEFAULT;
    public void setClock(Clock clock) {
        this.clock = clock;
    }
    public Patient findByCode(String code) {
        return patientDao.findByCode(code);
    }
    public Patient findByIdcard(String idcard) {
        return patientDao.findByIdcard(idcard);
    }
    public Patient findBySsc(String ssc) {
        return patientDao.findBySsc(ssc);
    }
    public Patient findByMobile(String mobile) {
        return patientDao.findByMobile(mobile);
    }
    public Patient findByOpenid(String openid) {
        return patientDao.findByOpenid(openid);
    }
    public int countByOpenid(String openid) {
        return patientDao.countByOpenid(openid);
    }
    /**
     * 修改患者密码
     *
     * @param patient
     */
    public void updatePatientPwd(Patient patient) {
        patientDao.save(patient);
    }
    public void updatePatientInfo(Patient patient) {
        patientDao.save(patient);
    }
    /**
     * 修改患者openid
     *
     * @param patient
     */
    public void updatePatient(Patient patient) {
//		if (StringUtils.isNotEmpty(patient.getOpenid())) {
//			patientDao.clearOpenid(patient.getCode(), patient.getOpenid());
//		}
        patientDao.save(patient);
        if (StringUtils.isNotEmpty(patient.getOpenid())) {
            signFamilyDao.updateOpenidByPatient(patient.getOpenid(), patient.getCode());
        }
    }
    public void deletePatient(Patient patient) {
        patientDao.delete(patient);
    }
    public void deletePatients(Iterable<Patient> patients) {
        patientDao.delete(patients);
    }
    /**
     * 患者註冊
     *
     * @param patient
     * @return
     * @throws Exception
     */
    public JSONObject register(Patient patient, String imei, int platform) throws Exception {
        IdcardInfoExtractor ie = new IdcardInfoExtractor(patient.getIdcard());
        patient.setBirthday(ie.getBirthday());
        patient.setSex(ie.getGender());
        patient.setCode(getCode());
        patient.setStatus(1);
        patient.setCzrq(clock.getCurrentDate());
        patient.setDisease(0);
        patient.setDiseaseCondition(0);
        patient.setRecordAmount(0);
        patient.setPoints(0);
        Patient temp = patientDao.save(patient);
        if (temp != null) {
            // 更新openid
            updatePatient(temp);
            // 生成登录tokey
            Token token = newToken(temp.getCode(), imei, platform);
            if (token != null) {
                // 生成登录信息成功
                JSONObject json = new JSONObject();
                json.put("id", temp.getId());
                json.put("uid", temp.getCode());
                json.put("token", token.getToken());
                json.put("name", temp.getName());
                json.put("photo", temp.getPhoto());
                //new Thread(new SignSsGetTask(patient.getIdcard())).start();
                return json;
            }
        }
        return null;
    }
    /**
     * 建立三师团队与患者的关系
     *
     * @param sf
     * @param patient
     * @param doctorCode
     * @param doctorType
     */
    private void bindDoctorPatient(SignFamily sf, Patient patient, String doctorCode, int doctorType) {
        DoctorPatient dp = doctorPatientDao.findByPatientDoctorTeamType(patient.getCode(), doctorCode, doctorType);
        if (dp == null) {
            Doctor doctor = doctorDao.findByCode(doctorCode);
            dp = new DoctorPatient();
            dp.setBirthday(patient.getBirthday());
            dp.setCzrq(new Date());
            dp.setDoctor(doctor.getCode());
            dp.setDoctorName(doctor.getName());
            // 健康管理师
            dp.setDoctorType(doctorType);
            dp.setPatient(patient.getCode());
            dp.setPatientName(patient.getName());
            dp.setSex(patient.getSex());
            if (sf != null) {
                // 三师和家庭都存在
                dp.setSignType("11");
            } else {
                // 只有家庭签约
                dp.setSignType("01");
            }
            dp.setStatus(1);
            // 设置为三师团队
            dp.setTeamType(1);
            // 保存到数据库
            doctorPatientDao.save(dp);
        }
    }
    /**
     * 微信端患者註冊
     *
     * @param patient
     * @return
     * @throws Exception
     */
    public JSONObject register(Patient patient) throws Exception {
        patient.setCode(getCode());
        patient.setCzrq(clock.getCurrentDate());
        EncodesUtil.entryptPassword(patient);
        Patient temp = patientDao.save(patient);
        if (temp != null) {
            JSONObject json = new JSONObject();
            json.put("id", temp.getId());
            json.put("uid", temp.getCode());
            json.put("name", "");
            json.put("openid", temp.getOpenid());
            return json;
        }
        return null;
    }
}

+ 2 - 23
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/WeixinBaseController.java

@ -76,29 +76,8 @@ public class WeixinBaseController extends BaseController {
			Map<Object, Object> map = new HashMap<Object, Object>();
			if (json.has("openid")) {
				String openid = json.get("openid").toString();
				Patient patient = patientService.findByOpenid(openid);
				if (patient != null) {
					// 返回用户信息
					map.put("id", patient.getId());
					map.put("uid", patient.getCode());
					map.put("name", patient.getName());
					map.put("openid", patient.getOpenid());
					map.put("photo", patient.getPhoto());
					// 查询token
					Token token = SystemData.wxPatientTokens.get(patient.getCode());
					if (token == null) {
						// 从数据库加载
						token = tokenService.findWxToken(patient.getCode());
					}
					if (token == null) {
						// 生成新的token
						token = tokenService.newTxToken(patient.getCode(), openid);
					}
					map.put("token", token.getToken());
					return write(200, "获取成功", "data", map);
				} else {
					return error(100, openid);
				}
				map.put("openid", openid);
				return write(200, "获取成功", "data", map);
			} else {
				return error(Integer.parseInt(json.get("errcode").toString()), "操作失败:" + json.get("errmsg").toString());
			}

+ 98 - 89
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java

@ -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, "查询失败");
        }
    }
}

+ 20 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -1,11 +1,14 @@
package com.yihu.wlyy.web.patient.account;
import com.sun.org.apache.regexp.internal.RE;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.repository.security.TokenDao;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
@ -56,6 +59,8 @@ public class PatientController extends WeixinBaseController {
    private DoctorService doctorService;
    @Autowired
    AdminTeamService teamService;
    @Autowired
    TokenDao tokenDao;
    /**
     * 患者基本信息查询接口
@ -343,10 +348,22 @@ public class PatientController extends WeixinBaseController {
            if (patient == null) {
                return error(-1, "退出失败,用户不存在");
            } else {
                patient.setOpenid("");
                patientInfoService.updateUser(patient);
                //patient.setOpenid("");
                //patientInfoService.updateUser(patient);
                Token token = SystemData.wxPatientTokens.get(getUID());
                if (token == null) {
                    token = tokenDao.findByPatient(getUID(), 3);
                }
                if(token == null){
                    return error(-1,"用户未登录");
                }
                token.setDel("0");
                tokenDao.save(token);
                SystemData.wxPatientTokens.remove(getUID());
                return success("已成功退出!");
            }
            return success("已成功退出!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "操作失败!");