diff --git a/xinelu-admin/src/main/java/com/xinelu/web/controller/applet/ResidentPatientInfoController.java b/xinelu-admin/src/main/java/com/xinelu/web/controller/applet/ResidentPatientInfoController.java index e57d9bf..f6968df 100644 --- a/xinelu-admin/src/main/java/com/xinelu/web/controller/applet/ResidentPatientInfoController.java +++ b/xinelu-admin/src/main/java/com/xinelu/web/controller/applet/ResidentPatientInfoController.java @@ -102,12 +102,9 @@ public class ResidentPatientInfoController extends BaseController { } @ApiOperation("获取当前注册居民") - @GetMapping(value = "/getCurrentResident/{openid}/{cityCode}") - public R getCurrentResident(@PathVariable("openid") String openid, @PathVariable("cityCode") String cityCode) { - if(StringUtils.isBlank(cityCode) || cityCode.equals("null")) { - R.fail("绑定城市编码不能为空"); - } - return R.ok(residentPatientInfoService.getCurrentResident(openid, cityCode)); + @GetMapping(value = "/getCurrentResident/{openid}") + public R getCurrentResident(@PathVariable("openid") String openid) { + return R.ok(residentPatientInfoService.getCurrentResident(openid, null)); } /*@ApiOperation("是否已注册") diff --git a/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/service/impl/ResidentPatientInfoServiceImpl.java b/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/service/impl/ResidentPatientInfoServiceImpl.java index bb5a5f9..0a20303 100644 --- a/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/service/impl/ResidentPatientInfoServiceImpl.java +++ b/xinelu-familydoctor/src/main/java/com/xinelu/familydoctor/applet/service/impl/ResidentPatientInfoServiceImpl.java @@ -102,11 +102,11 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi try { SslUtils.ignoreSsl(); String params = "appid=" + appletChatConfig.getAppletId() + "&secret=" + appletChatConfig.getSecret() + "&js_code=" + code + "&grant_type=" + appletChatConfig.getGrantType(); - log.info("获取openID请求参数{}", params); +// log.info("获取openID请求参数{}", params); String result = HttpUtils.sendPost("https://api.weixin.qq.com/sns/jscode2session", params); JSONObject json = JSONObject.parseObject(result); // {"errcode":40029,"errmsg":"invalid code, rid: 650bf9c3-31a6c960-2b437029"} - log.info("获取openID响应结果{}", json.toJSONString()); +// log.info("获取openID响应结果{}", json.toJSONString()); if (!json.containsKey("openid")) { throw new ServiceException(json.getString("errmsg")); } @@ -135,7 +135,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi return null; } result = JSON.parseObject(tokenResult); - log.info("获取小程序token : {}", result.toJSONString()); +// log.info("获取小程序token : {}", result.toJSONString()); String accessToken = result.getString("access_token"); if (StringUtils.isEmpty(accessToken)) { return null; @@ -434,40 +434,43 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi }*/ @Override public HashMap login(String loginCode, String phoneCode) throws Exception { - HashMap HashMap = new HashMap<>(); + HashMap resultMap = new HashMap<>(); try { SslUtils.ignoreSsl(); String params = "appid=" + appletChatConfig.getAppletId() + "&secret=" + appletChatConfig.getSecret() + "&js_code=" + loginCode + "&grant_type=" + appletChatConfig.getGrantType(); - log.info("获取openID请求参数{}", params); +// log.info("获取openID请求参数{}", params); String result = HttpUtils.sendPost("https://api.weixin.qq.com/sns/jscode2session", params); JSONObject json = JSONObject.parseObject(result); // {"errcode":40029,"errmsg":"invalid code, rid: 650bf9c3-31a6c960-2b437029"} - log.info("获取openID响应结果{}", json.toJSONString()); +// log.info("获取openID响应结果{}", json.toJSONString()); if (!json.containsKey("openid")) { throw new ServiceException(json.getString("errmsg")); } String openid = json.getString("openid"); - HashMap.put("openid", openid); + resultMap.put("openid", openid); + + //获取手机号 + AppletPhoneVO phone = getPhone(phoneCode); + String phoneNumber = phone.getPhoneInfo().getPhoneNumber(); + resultMap.put("phone", phoneNumber); + List infoList = residentPatientInfoMapper.selectPatientInfoByPhone(phoneNumber); + if(infoList != null && infoList.size() > 0) { + if(!infoList.get(0).getBindOpenid().equals(openid)) { + resultMap.put("code", "2"); + resultMap.put("info", "已被其他人注册"); + return resultMap; + } else { + resultMap.put("code", "1"); + resultMap.put("info", "已注册"); + return resultMap; + } + } + resultMap.put("code", "0"); + resultMap.put("info", "未注册"); + return resultMap; } catch (Exception e) { throw new ServiceException(e.getMessage()); } - //获取手机号 - String code; - String cityCode = ""; - AppletPhoneVO phone = getPhone(phoneCode); - String phoneNumber = phone.getPhoneInfo().getPhoneNumber(); - HashMap.put("phone", phoneNumber); - List infoList = residentPatientInfoMapper.selectPatientInfoByPhone(phoneNumber); - code = infoList.size() == 0 ? "0" : "1"; - //返回绑定城市 - if ("1".equals(code)) { - for (PatientInfo patientInfo : infoList) { - cityCode = patientInfo.getCityCode(); - } - } - HashMap.put("code", code); - HashMap.put("cityCode", cityCode); - return HashMap; } /** diff --git a/xinelu-familydoctor/src/main/resources/mapper/sign/ResidentServiceApplyMapper.xml b/xinelu-familydoctor/src/main/resources/mapper/sign/ResidentServiceApplyMapper.xml index 31515e7..b11c86f 100644 --- a/xinelu-familydoctor/src/main/resources/mapper/sign/ResidentServiceApplyMapper.xml +++ b/xinelu-familydoctor/src/main/resources/mapper/sign/ResidentServiceApplyMapper.xml @@ -292,11 +292,11 @@ - and (s.booking_status = '1' or s.approval_status in ('1','2')) + and s.booking_status = '1' - and (s.booking_status = '0' and s.approval_status = '0') + and s.booking_status != '1' diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/appletlogin/impl/AppletLoginServiceImpl.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/appletlogin/impl/AppletLoginServiceImpl.java index d1ce709..fbed907 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/appletlogin/impl/AppletLoginServiceImpl.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/appletlogin/impl/AppletLoginServiceImpl.java @@ -303,7 +303,7 @@ public class AppletLoginServiceImpl implements AppletLoginService { @Override public AjaxResult existPatientInfo(String openId) { PatientInfo patientInfo = appletLoginMapper.getPatientInfoByOpenId(openId); - if (Objects.nonNull(patientInfo) && StringUtils.isNotBlank(patientInfo.getOpenid())) { + if (Objects.nonNull(patientInfo) && StringUtils.isNotBlank(patientInfo.getBindOpenid())) { return AjaxResult.success("LOGIN"); } return AjaxResult.success("NOT_LOGIN"); diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/PatientAndDiseaseVO.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/PatientAndDiseaseVO.java index aa51bbb..842b79d 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/PatientAndDiseaseVO.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/PatientAndDiseaseVO.java @@ -176,6 +176,6 @@ public class PatientAndDiseaseVO implements Serializable { /** * 居民健康行为积分-总分 */ - private String score; + private String score = "0"; } diff --git a/xinelu-nurse-applet/src/main/resources/mapper/applet/appletlogin/AppletLoginMapper.xml b/xinelu-nurse-applet/src/main/resources/mapper/applet/appletlogin/AppletLoginMapper.xml index ddb9d76..f70c0bc 100644 --- a/xinelu-nurse-applet/src/main/resources/mapper/applet/appletlogin/AppletLoginMapper.xml +++ b/xinelu-nurse-applet/src/main/resources/mapper/applet/appletlogin/AppletLoginMapper.xml @@ -75,13 +75,14 @@ community_alias_name, home_longitude, home_latitude, - head_picture_url + head_picture_url, + bind_openid FROM patient_info del_flag = 0 - and openid = #{openId} + and bind_openid = #{openId} limit 1