小程序个人中心添加更新签约编号
This commit is contained in:
parent
5adce2514b
commit
366cd7b1e1
@ -103,4 +103,5 @@ public interface ResidentPatientInfoMapper {
|
||||
*@return PatientInfo
|
||||
**/
|
||||
PatientInfo getPatientInfoByPatientCode(String patientCode);
|
||||
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@ -49,6 +50,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
|
||||
private AppletAccessTokenUtils appletAccessTokenUtils;
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
/**
|
||||
* @return com.xinelu.familydoctor.applet.pojo.entity.PatientInfo
|
||||
* @Author mengkuiliang
|
||||
@ -109,27 +111,27 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
|
||||
**/
|
||||
@Override
|
||||
public AppletPhoneVO getPhone(String code) throws Exception {
|
||||
JSONObject result;
|
||||
// 获取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());
|
||||
SslUtils.ignoreSsl();
|
||||
String tokenResult = HttpUtils.sendGet(token_url);
|
||||
if (tokenResult == null) {
|
||||
return null;
|
||||
}
|
||||
result = JSON.parseObject(tokenResult);
|
||||
log.info("获取小程序token : {}", result.toJSONString());
|
||||
String accessToken = result.getString("access_token");
|
||||
if (StringUtils.isEmpty(accessToken)) {
|
||||
return null;
|
||||
}
|
||||
//获取手机号 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;
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("code", code);
|
||||
SslUtils.ignoreSsl();
|
||||
result = httpService.post(url, null, params);
|
||||
return JSON.parseObject(result.toString(), AppletPhoneVO.class);
|
||||
JSONObject result;
|
||||
// 获取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());
|
||||
SslUtils.ignoreSsl();
|
||||
String tokenResult = HttpUtils.sendGet(token_url);
|
||||
if (tokenResult == null) {
|
||||
return null;
|
||||
}
|
||||
result = JSON.parseObject(tokenResult);
|
||||
log.info("获取小程序token : {}", result.toJSONString());
|
||||
String accessToken = result.getString("access_token");
|
||||
if (StringUtils.isEmpty(accessToken)) {
|
||||
return null;
|
||||
}
|
||||
//获取手机号 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;
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("code", code);
|
||||
SslUtils.ignoreSsl();
|
||||
result = httpService.post(url, null, params);
|
||||
return JSON.parseObject(result.toString(), AppletPhoneVO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,7 +156,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
|
||||
public void register(PatientInfoBody body) {
|
||||
if (ObjectUtils.isNotEmpty(body.getCardNo())) {
|
||||
// 修改
|
||||
if(!StringUtils.isBlank(body.getPatientCode())) {
|
||||
if (!StringUtils.isBlank(body.getPatientCode())) {
|
||||
PatientInfo patientInfo = residentPatientInfoMapper.getPatientInfoByPatientCode(body.getPatientCode());
|
||||
if (ObjectUtils.isNotEmpty(patientInfo)) {
|
||||
BeanUtils.copyBeanProp(patientInfo, body);
|
||||
@ -164,7 +166,6 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
|
||||
patientInfo.setDisease("0");
|
||||
}
|
||||
patientInfo.setLoginFlag(Long.valueOf(1));
|
||||
patientInfo.setSignNo(getSignInfo(body.getCityCode(), body.getCardNo()));
|
||||
updatePatientInfo(patientInfo);
|
||||
}
|
||||
// 注册
|
||||
@ -175,7 +176,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
|
||||
if (patientInfo == null) {
|
||||
PatientInfo entity = new PatientInfo();
|
||||
BeanUtils.copyBeanProp(entity, body);
|
||||
if(body.getDiseaseList() != null) {
|
||||
if (body.getDiseaseList() != null) {
|
||||
entity.setDisease(body.getDiseaseList().stream().collect(Collectors.joining(",")));
|
||||
} else {
|
||||
entity.setDisease("0");
|
||||
@ -186,7 +187,6 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
|
||||
entity.setCreateTime(new Date());
|
||||
entity.setCreateBy(body.getCardNo());
|
||||
entity.setLoginFlag(Long.valueOf(1));
|
||||
entity.setSignNo(getSignInfo(body.getCityCode(), body.getCardNo()));
|
||||
residentPatientInfoMapper.insertPatientInfo(entity);
|
||||
} else {
|
||||
if (!StringUtils.isBlank(patientInfo.getOpenid())) {
|
||||
@ -203,12 +203,11 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
|
||||
patientInfo.setHeadPictureUrl(body.getHeadPictureUrl());
|
||||
patientInfo.setDelFlag(0);
|
||||
patientInfo.setLoginFlag(Long.valueOf(1));
|
||||
if(body.getDiseaseList() != null) {
|
||||
if (body.getDiseaseList() != null) {
|
||||
patientInfo.setDisease(body.getDiseaseList().stream().collect(Collectors.joining(",")));
|
||||
} else {
|
||||
patientInfo.setDisease("0");
|
||||
}
|
||||
patientInfo.setSignNo(getSignInfo(body.getCityCode(), body.getCardNo()));
|
||||
residentPatientInfoMapper.updatePatientInfo(patientInfo);
|
||||
}
|
||||
}
|
||||
@ -218,15 +217,15 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
|
||||
|
||||
// 获取签约信息
|
||||
private String getSignInfo(String region, String identity) {
|
||||
if(!StringUtils.isBlank(region)) {
|
||||
if (!StringUtils.isBlank(region)) {
|
||||
try {
|
||||
// 查询签约信息
|
||||
String result = (String) httpService.get(SpringUtils.getFdUrl(region) + "/resident/signinfo/detail/" + identity, null, String.class);
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
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);
|
||||
if(signInfo != null) {
|
||||
if (signInfo != null) {
|
||||
return signInfo.getSignNo();
|
||||
}
|
||||
}
|
||||
@ -278,6 +277,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
|
||||
* @Param [registerCode]
|
||||
**/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public PatientInfo switchResident(String openid, String patientCode) {
|
||||
PatientInfo register = residentPatientInfoMapper.selectPatientInfoByCode(patientCode);
|
||||
if (register == null) {
|
||||
@ -294,6 +294,8 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
|
||||
return residentPatientInfoMapper.selectPatientInfoByCode(patientCode);
|
||||
}
|
||||
|
||||
/** 判断2个参数是否一样 */
|
||||
|
||||
/**
|
||||
* @return java.lang.String
|
||||
* @Author mengkuiliang
|
||||
@ -307,25 +309,27 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
|
||||
if (list == null || list.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
PatientInfo patientInfo = null;
|
||||
// 获取当前选中的
|
||||
List<PatientInfo> currentList = list.stream().filter(p -> p.getIsChecked().equals("1")).collect(Collectors.toList());
|
||||
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(",")));
|
||||
}
|
||||
return currentList.get(0);
|
||||
} else {
|
||||
patientInfo = currentList.get(0);
|
||||
// 没有已选择的,则取最新注册的一条数据
|
||||
} else {
|
||||
|
||||
// 更新选择标识
|
||||
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).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
|
||||
* @Description 是否已注册
|
||||
* @Date 2023-10-11 011 10:46
|
||||
* @Param [code]
|
||||
* @return com.xinelu.familydoctor.applet.pojo.entity.PatientInfo
|
||||
**/
|
||||
/*@Override
|
||||
public PatientInfo isRegistered(String code) {
|
||||
return getCurrentResident(getOpenId(code), null);
|
||||
}*/
|
||||
|
||||
@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<>();
|
||||
try {
|
||||
SslUtils.ignoreSsl();
|
||||
@ -367,7 +370,7 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
|
||||
throw new ServiceException(json.getString("errmsg"));
|
||||
}
|
||||
String openid = json.getString("openid");
|
||||
HashMap.put("openid",openid);
|
||||
HashMap.put("openid", openid);
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
@ -376,17 +379,17 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi
|
||||
String cityCode = "";
|
||||
AppletPhoneVO phone = getPhone(phoneCode);
|
||||
String phoneNumber = phone.getPhoneInfo().getPhoneNumber();
|
||||
HashMap.put("phone",phoneNumber);
|
||||
HashMap.put("phone", 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) {
|
||||
cityCode = patientInfo.getCityCode();
|
||||
}
|
||||
}
|
||||
HashMap.put("code",code);
|
||||
HashMap.put("cityCode",cityCode);
|
||||
HashMap.put("code", code);
|
||||
HashMap.put("cityCode", cityCode);
|
||||
return HashMap;
|
||||
}
|
||||
}
|
||||
|
||||
@ -487,7 +487,6 @@
|
||||
update patient_info set is_checked = #{isChecked} where patient_code = #{patientCode}
|
||||
</update>
|
||||
|
||||
|
||||
<!-- 获取注册详细信息 -->
|
||||
<select id="selectPatientInfoByPhone" parameterType="String" resultMap="PatientInfoResult">
|
||||
<include refid="selectPatientInfoVo"/>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.xinelu.applet.service.nurseapplogin.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.xinelu.applet.dto.appletlogin.StationItemInfoDTO;
|
||||
import com.xinelu.applet.mapper.appletlogin.AppletLoginMapper;
|
||||
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.GooodsOrderStatusEnum;
|
||||
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.mapper.patientinfo.PatientInfoMapper;
|
||||
import com.xinelu.manage.mapper.sysarea.SysAreaMapper;
|
||||
@ -54,7 +57,8 @@ public class NurseAppLoginServiceImpl implements NurseAppLoginService {
|
||||
private SysConfigMapper sysConfigMapper;
|
||||
@Resource
|
||||
private PatientInfoMapper patientInfoMapper;
|
||||
|
||||
@Resource
|
||||
private HttpService httpService;
|
||||
|
||||
/**
|
||||
* 判断用户是否完善信息-微信小程序和APP共用
|
||||
@ -205,9 +209,39 @@ public class NurseAppLoginServiceImpl implements NurseAppLoginService {
|
||||
patientDisease.setWaitReceivedGoodsCount(waitReceivedGoodsCount);
|
||||
patientDisease.setReceivedGoodsCount(receivedGoodsCount);
|
||||
patientDisease.setEvaluatedCount(evaluatedCount);
|
||||
// 更新签约编号
|
||||
setSignInfo(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查询预约服务订单
|
||||
*
|
||||
@ -223,4 +257,4 @@ public class NurseAppLoginServiceImpl implements NurseAppLoginService {
|
||||
}
|
||||
return nurseAppLoginMapper.selectAppointmentOrderDetailsByPatientId(patientId, orderStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,6 +161,7 @@ public class PatientAndDiseaseVO implements Serializable {
|
||||
|
||||
private String disease;
|
||||
private String signNo;
|
||||
private String cityCode;
|
||||
/**
|
||||
* 基础疾病信息
|
||||
*/
|
||||
|
||||
@ -85,6 +85,7 @@
|
||||
pi.patient_code,
|
||||
pi.disease,
|
||||
pi.sign_no,
|
||||
pi.city_code,
|
||||
pdi.id patientDiseaseId,
|
||||
pdi.disease_id,
|
||||
pdi.disease_name,
|
||||
|
||||
@ -141,4 +141,13 @@ public interface PatientInfoMapper {
|
||||
* @return 数量
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
@ -660,4 +660,10 @@
|
||||
update_time = now()
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 更新签约标识 -->
|
||||
<update id="updateSignNo">
|
||||
update patient_info set sign_no = #{signNo} where id = #{patientId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user