小程序个人中心添加更新签约编号

This commit is contained in:
mengkuiliang 2023-10-24 09:03:00 +08:00
parent 5adce2514b
commit 366cd7b1e1
8 changed files with 101 additions and 47 deletions

View File

@ -103,4 +103,5 @@ public interface ResidentPatientInfoMapper {
*@return PatientInfo *@return PatientInfo
**/ **/
PatientInfo getPatientInfoByPatientCode(String patientCode); PatientInfo getPatientInfoByPatientCode(String patientCode);
} }

View File

@ -26,6 +26,7 @@ import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -49,6 +50,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
private AppletAccessTokenUtils appletAccessTokenUtils; private AppletAccessTokenUtils appletAccessTokenUtils;
@Resource @Resource
private RedisTemplate<String, Object> redisTemplate; private RedisTemplate<String, Object> redisTemplate;
/** /**
* @return com.xinelu.familydoctor.applet.pojo.entity.PatientInfo * @return com.xinelu.familydoctor.applet.pojo.entity.PatientInfo
* @Author mengkuiliang * @Author mengkuiliang
@ -109,27 +111,27 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
**/ **/
@Override @Override
public AppletPhoneVO getPhone(String code) throws Exception { public AppletPhoneVO getPhone(String code) throws Exception {
JSONObject result; JSONObject result;
// 获取token // 获取token
String token_url = String.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s", appletChatConfig.getAppletId(), appletChatConfig.getSecret()); String token_url = String.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s", appletChatConfig.getAppletId(), appletChatConfig.getSecret());
SslUtils.ignoreSsl(); SslUtils.ignoreSsl();
String tokenResult = HttpUtils.sendGet(token_url); String tokenResult = HttpUtils.sendGet(token_url);
if (tokenResult == null) { if (tokenResult == null) {
return null; return null;
} }
result = JSON.parseObject(tokenResult); result = JSON.parseObject(tokenResult);
log.info("获取小程序token : {}", result.toJSONString()); log.info("获取小程序token : {}", result.toJSONString());
String accessToken = result.getString("access_token"); String accessToken = result.getString("access_token");
if (StringUtils.isEmpty(accessToken)) { if (StringUtils.isEmpty(accessToken)) {
return null; return null;
} }
//获取手机号 https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/user-info/phone-number/getPhoneNumber.html //获取手机号 https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/user-info/phone-number/getPhoneNumber.html
String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber" + "?access_token=" + accessToken; String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber" + "?access_token=" + accessToken;
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
params.put("code", code); params.put("code", code);
SslUtils.ignoreSsl(); SslUtils.ignoreSsl();
result = httpService.post(url, null, params); result = httpService.post(url, null, params);
return JSON.parseObject(result.toString(), AppletPhoneVO.class); return JSON.parseObject(result.toString(), AppletPhoneVO.class);
} }
/** /**
@ -154,7 +156,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
public void register(PatientInfoBody body) { public void register(PatientInfoBody body) {
if (ObjectUtils.isNotEmpty(body.getCardNo())) { if (ObjectUtils.isNotEmpty(body.getCardNo())) {
// 修改 // 修改
if(!StringUtils.isBlank(body.getPatientCode())) { if (!StringUtils.isBlank(body.getPatientCode())) {
PatientInfo patientInfo = residentPatientInfoMapper.getPatientInfoByPatientCode(body.getPatientCode()); PatientInfo patientInfo = residentPatientInfoMapper.getPatientInfoByPatientCode(body.getPatientCode());
if (ObjectUtils.isNotEmpty(patientInfo)) { if (ObjectUtils.isNotEmpty(patientInfo)) {
BeanUtils.copyBeanProp(patientInfo, body); BeanUtils.copyBeanProp(patientInfo, body);
@ -164,7 +166,6 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
patientInfo.setDisease("0"); patientInfo.setDisease("0");
} }
patientInfo.setLoginFlag(Long.valueOf(1)); patientInfo.setLoginFlag(Long.valueOf(1));
patientInfo.setSignNo(getSignInfo(body.getCityCode(), body.getCardNo()));
updatePatientInfo(patientInfo); updatePatientInfo(patientInfo);
} }
// 注册 // 注册
@ -175,7 +176,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
if (patientInfo == null) { if (patientInfo == null) {
PatientInfo entity = new PatientInfo(); PatientInfo entity = new PatientInfo();
BeanUtils.copyBeanProp(entity, body); BeanUtils.copyBeanProp(entity, body);
if(body.getDiseaseList() != null) { if (body.getDiseaseList() != null) {
entity.setDisease(body.getDiseaseList().stream().collect(Collectors.joining(","))); entity.setDisease(body.getDiseaseList().stream().collect(Collectors.joining(",")));
} else { } else {
entity.setDisease("0"); entity.setDisease("0");
@ -186,7 +187,6 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
entity.setCreateTime(new Date()); entity.setCreateTime(new Date());
entity.setCreateBy(body.getCardNo()); entity.setCreateBy(body.getCardNo());
entity.setLoginFlag(Long.valueOf(1)); entity.setLoginFlag(Long.valueOf(1));
entity.setSignNo(getSignInfo(body.getCityCode(), body.getCardNo()));
residentPatientInfoMapper.insertPatientInfo(entity); residentPatientInfoMapper.insertPatientInfo(entity);
} else { } else {
if (!StringUtils.isBlank(patientInfo.getOpenid())) { if (!StringUtils.isBlank(patientInfo.getOpenid())) {
@ -203,12 +203,11 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
patientInfo.setHeadPictureUrl(body.getHeadPictureUrl()); patientInfo.setHeadPictureUrl(body.getHeadPictureUrl());
patientInfo.setDelFlag(0); patientInfo.setDelFlag(0);
patientInfo.setLoginFlag(Long.valueOf(1)); patientInfo.setLoginFlag(Long.valueOf(1));
if(body.getDiseaseList() != null) { if (body.getDiseaseList() != null) {
patientInfo.setDisease(body.getDiseaseList().stream().collect(Collectors.joining(","))); patientInfo.setDisease(body.getDiseaseList().stream().collect(Collectors.joining(",")));
} else { } else {
patientInfo.setDisease("0"); patientInfo.setDisease("0");
} }
patientInfo.setSignNo(getSignInfo(body.getCityCode(), body.getCardNo()));
residentPatientInfoMapper.updatePatientInfo(patientInfo); residentPatientInfoMapper.updatePatientInfo(patientInfo);
} }
} }
@ -218,15 +217,15 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
// 获取签约信息 // 获取签约信息
private String getSignInfo(String region, String identity) { private String getSignInfo(String region, String identity) {
if(!StringUtils.isBlank(region)) { if (!StringUtils.isBlank(region)) {
try { try {
// 查询签约信息 // 查询签约信息
String result = (String) httpService.get(SpringUtils.getFdUrl(region) + "/resident/signinfo/detail/" + identity, null, String.class); String result = (String) httpService.get(SpringUtils.getFdUrl(region) + "/resident/signinfo/detail/" + identity, null, String.class);
JSONObject jsonObject = JSONObject.parseObject(result); JSONObject jsonObject = JSONObject.parseObject(result);
if ("1".equals(jsonObject.get("code"))) { if ("1".equals(jsonObject.get("code"))) {
if(jsonObject.getJSONObject("data") != null) { if (jsonObject.getJSONObject("data") != null) {
SignInfoDetailVo signInfo = JSONObject.parseObject(jsonObject.getJSONObject("data").toJSONString(), SignInfoDetailVo.class); SignInfoDetailVo signInfo = JSONObject.parseObject(jsonObject.getJSONObject("data").toJSONString(), SignInfoDetailVo.class);
if(signInfo != null) { if (signInfo != null) {
return signInfo.getSignNo(); return signInfo.getSignNo();
} }
} }
@ -278,6 +277,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
* @Param [registerCode] * @Param [registerCode]
**/ **/
@Override @Override
@Transactional(rollbackFor = Exception.class)
public PatientInfo switchResident(String openid, String patientCode) { public PatientInfo switchResident(String openid, String patientCode) {
PatientInfo register = residentPatientInfoMapper.selectPatientInfoByCode(patientCode); PatientInfo register = residentPatientInfoMapper.selectPatientInfoByCode(patientCode);
if (register == null) { if (register == null) {
@ -294,6 +294,8 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
return residentPatientInfoMapper.selectPatientInfoByCode(patientCode); return residentPatientInfoMapper.selectPatientInfoByCode(patientCode);
} }
/** 判断2个参数是否一样 */
/** /**
* @return java.lang.String * @return java.lang.String
* @Author mengkuiliang * @Author mengkuiliang
@ -307,25 +309,27 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
if (list == null || list.size() == 0) { if (list == null || list.size() == 0) {
return null; return null;
} }
PatientInfo patientInfo = null;
// 获取当前选中的 // 获取当前选中的
List<PatientInfo> currentList = list.stream().filter(p -> p.getIsChecked().equals("1")).collect(Collectors.toList()); List<PatientInfo> currentList = list.stream().filter(p -> p.getIsChecked().equals("1")).collect(Collectors.toList());
if (currentList.size() > 0) { if (currentList.size() > 0) {
if(!StringUtils.isBlank(currentList.get(0).getDisease())) { if (!StringUtils.isBlank(currentList.get(0).getDisease())) {
currentList.get(0).setDiseaseList(Arrays.asList(currentList.get(0).getDisease().split(","))); currentList.get(0).setDiseaseList(Arrays.asList(currentList.get(0).getDisease().split(",")));
} }
return currentList.get(0); patientInfo = currentList.get(0);
} else {
// 没有已选择的则取最新注册的一条数据 // 没有已选择的则取最新注册的一条数据
} else {
// 更新选择标识 // 更新选择标识
residentPatientInfoMapper.updateChecked(list.get(0).getPatientCode(), "1"); residentPatientInfoMapper.updateChecked(list.get(0).getPatientCode(), "1");
if(!StringUtils.isBlank(list.get(0).getDisease())) { if (!StringUtils.isBlank(list.get(0).getDisease())) {
list.get(0).setDiseaseList(Arrays.asList(list.get(0).getDisease().split(","))); list.get(0).setDiseaseList(Arrays.asList(list.get(0).getDisease().split(",")));
} }
list.get(0).setIsChecked("1"); list.get(0).setIsChecked("1");
return list.get(0); patientInfo = list.get(0);
} }
return patientInfo;
} }
/** /**
@ -341,19 +345,18 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
} }
/** /**
* @return com.xinelu.familydoctor.applet.pojo.entity.PatientInfo
* @Author mengkuiliang * @Author mengkuiliang
* @Description 是否已注册 * @Description 是否已注册
* @Date 2023-10-11 011 10:46 * @Date 2023-10-11 011 10:46
* @Param [code] * @Param [code]
* @return com.xinelu.familydoctor.applet.pojo.entity.PatientInfo
**/ **/
/*@Override /*@Override
public PatientInfo isRegistered(String code) { public PatientInfo isRegistered(String code) {
return getCurrentResident(getOpenId(code), null); return getCurrentResident(getOpenId(code), null);
}*/ }*/
@Override @Override
public HashMap<String, String> login(String loginCode,String phoneCode) throws Exception { public HashMap<String, String> login(String loginCode, String phoneCode) throws Exception {
HashMap<String, String> HashMap = new HashMap<>(); HashMap<String, String> HashMap = new HashMap<>();
try { try {
SslUtils.ignoreSsl(); SslUtils.ignoreSsl();
@ -367,7 +370,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
throw new ServiceException(json.getString("errmsg")); throw new ServiceException(json.getString("errmsg"));
} }
String openid = json.getString("openid"); String openid = json.getString("openid");
HashMap.put("openid",openid); HashMap.put("openid", openid);
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException(e.getMessage()); throw new ServiceException(e.getMessage());
} }
@ -376,17 +379,17 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
String cityCode = ""; String cityCode = "";
AppletPhoneVO phone = getPhone(phoneCode); AppletPhoneVO phone = getPhone(phoneCode);
String phoneNumber = phone.getPhoneInfo().getPhoneNumber(); String phoneNumber = phone.getPhoneInfo().getPhoneNumber();
HashMap.put("phone",phoneNumber); HashMap.put("phone", phoneNumber);
List<PatientInfo> infoList = residentPatientInfoMapper.selectPatientInfoByPhone(phoneNumber); List<PatientInfo> infoList = residentPatientInfoMapper.selectPatientInfoByPhone(phoneNumber);
code = infoList.size()== 0 ? "0" : "1"; code = infoList.size() == 0 ? "0" : "1";
//返回绑定城市 //返回绑定城市
if ("1".equals(code)){ if ("1".equals(code)) {
for (PatientInfo patientInfo : infoList) { for (PatientInfo patientInfo : infoList) {
cityCode = patientInfo.getCityCode(); cityCode = patientInfo.getCityCode();
} }
} }
HashMap.put("code",code); HashMap.put("code", code);
HashMap.put("cityCode",cityCode); HashMap.put("cityCode", cityCode);
return HashMap; return HashMap;
} }
} }

View File

@ -487,7 +487,6 @@
update patient_info set is_checked = #{isChecked} where patient_code = #{patientCode} update patient_info set is_checked = #{isChecked} where patient_code = #{patientCode}
</update> </update>
<!-- 获取注册详细信息 --> <!-- 获取注册详细信息 -->
<select id="selectPatientInfoByPhone" parameterType="String" resultMap="PatientInfoResult"> <select id="selectPatientInfoByPhone" parameterType="String" resultMap="PatientInfoResult">
<include refid="selectPatientInfoVo"/> <include refid="selectPatientInfoVo"/>

View File

@ -1,5 +1,6 @@
package com.xinelu.applet.service.nurseapplogin.impl; package com.xinelu.applet.service.nurseapplogin.impl;
import com.alibaba.fastjson2.JSONObject;
import com.xinelu.applet.dto.appletlogin.StationItemInfoDTO; import com.xinelu.applet.dto.appletlogin.StationItemInfoDTO;
import com.xinelu.applet.mapper.appletlogin.AppletLoginMapper; import com.xinelu.applet.mapper.appletlogin.AppletLoginMapper;
import com.xinelu.applet.mapper.nurseapplogin.NurseAppLoginMapper; import com.xinelu.applet.mapper.nurseapplogin.NurseAppLoginMapper;
@ -15,6 +16,8 @@ import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.enums.AppointmentTimeIntervalEnum; import com.xinelu.common.enums.AppointmentTimeIntervalEnum;
import com.xinelu.common.enums.GooodsOrderStatusEnum; import com.xinelu.common.enums.GooodsOrderStatusEnum;
import com.xinelu.common.utils.AgeUtil; import com.xinelu.common.utils.AgeUtil;
import com.xinelu.common.utils.http.HttpService;
import com.xinelu.common.utils.spring.SpringUtils;
import com.xinelu.manage.domain.goodsOrder.GoodsOrder; import com.xinelu.manage.domain.goodsOrder.GoodsOrder;
import com.xinelu.manage.mapper.patientinfo.PatientInfoMapper; import com.xinelu.manage.mapper.patientinfo.PatientInfoMapper;
import com.xinelu.manage.mapper.sysarea.SysAreaMapper; import com.xinelu.manage.mapper.sysarea.SysAreaMapper;
@ -54,7 +57,8 @@ public class NurseAppLoginServiceImpl implements NurseAppLoginService {
private SysConfigMapper sysConfigMapper; private SysConfigMapper sysConfigMapper;
@Resource @Resource
private PatientInfoMapper patientInfoMapper; private PatientInfoMapper patientInfoMapper;
@Resource
private HttpService httpService;
/** /**
* 判断用户是否完善信息-微信小程序和APP共用 * 判断用户是否完善信息-微信小程序和APP共用
@ -205,9 +209,39 @@ public class NurseAppLoginServiceImpl implements NurseAppLoginService {
patientDisease.setWaitReceivedGoodsCount(waitReceivedGoodsCount); patientDisease.setWaitReceivedGoodsCount(waitReceivedGoodsCount);
patientDisease.setReceivedGoodsCount(receivedGoodsCount); patientDisease.setReceivedGoodsCount(receivedGoodsCount);
patientDisease.setEvaluatedCount(evaluatedCount); patientDisease.setEvaluatedCount(evaluatedCount);
// 更新签约编号
setSignInfo(patientDisease);
return AjaxResult.success(patientDisease); return AjaxResult.success(patientDisease);
} }
// 更新签约编号
private void setSignInfo(PatientAndDiseaseVO patientDisease) {
if (!StringUtils.isBlank(patientDisease.getCityCode())) {
try {
String result = (String) httpService.get(SpringUtils.getFdUrl(patientDisease.getCityCode()) + "/resident/signinfo/detail/" + patientDisease.getCardNo(), null, String.class);
JSONObject jsonObject = JSONObject.parseObject(result);
if ("1".equals(jsonObject.get("code"))) {
String signNo = "";
if (jsonObject.getJSONObject("data") != null) {
JSONObject signInfo = jsonObject.getJSONObject("data");
if (signInfo.containsKey("signNo")) {
signNo = signInfo.getString("signNo");
}
} else {
signNo = null;
}
// 不一致才更新签约编号
if(!String.valueOf(signNo).equals(String.valueOf(patientDisease.getSignNo()))) {
patientInfoMapper.updateSignNo(patientDisease.getPatientId(), signNo);
patientDisease.setSignNo(signNo);
}
}
} catch (Exception e) {
log.error("更新签约编号出错:{}", e.getMessage());
}
}
}
/** /**
* App查询预约服务订单 * App查询预约服务订单
* *
@ -223,4 +257,4 @@ public class NurseAppLoginServiceImpl implements NurseAppLoginService {
} }
return nurseAppLoginMapper.selectAppointmentOrderDetailsByPatientId(patientId, orderStatus); return nurseAppLoginMapper.selectAppointmentOrderDetailsByPatientId(patientId, orderStatus);
} }
} }

View File

@ -161,6 +161,7 @@ public class PatientAndDiseaseVO implements Serializable {
private String disease; private String disease;
private String signNo; private String signNo;
private String cityCode;
/** /**
* 基础疾病信息 * 基础疾病信息
*/ */

View File

@ -85,6 +85,7 @@
pi.patient_code, pi.patient_code,
pi.disease, pi.disease,
pi.sign_no, pi.sign_no,
pi.city_code,
pdi.id patientDiseaseId, pdi.id patientDiseaseId,
pdi.disease_id, pdi.disease_id,
pdi.disease_name, pdi.disease_name,

View File

@ -141,4 +141,13 @@ public interface PatientInfoMapper {
* @return 数量 * @return 数量
*/ */
int updatePersonalWeChatCodeUrl(@Param("id") Long id, @Param("personalWeChatCodeUrl") String personalWeChatCodeUrl); int updatePersonalWeChatCodeUrl(@Param("id") Long id, @Param("personalWeChatCodeUrl") String personalWeChatCodeUrl);
/**
* @Author mengkuiliang
* @Description 更新签约标识
* @Date 2023-10-23 023 14:33
* @Param [id, signInfo]
* @return void
**/
void updateSignNo(@Param("patientId") Long patientId, @Param("signNo") String signNo);
} }

View File

@ -660,4 +660,10 @@
update_time = now() update_time = now()
where id = #{id} where id = #{id}
</update> </update>
<!-- 更新签约标识 -->
<update id="updateSignNo">
update patient_info set sign_no = #{signNo} where id = #{patientId}
</update>
</mapper> </mapper>