diff --git a/xinelu-familydoctor/pom.xml b/xinelu-familydoctor/pom.xml index 84cb4ac..d7a4b4c 100644 --- a/xinelu-familydoctor/pom.xml +++ b/xinelu-familydoctor/pom.xml @@ -39,5 +39,9 @@ com.xinelu xinelu-nurse-manage + + com.xinelu + xinelu-nurse-applet + 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 9128d8c..ffcee50 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 @@ -1,10 +1,12 @@ package com.xinelu.familydoctor.applet.service.impl; +import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; +import com.xinelu.applet.dto.appletlogin.AppletUserInfoDTO; import com.xinelu.common.config.AppletChatConfig; import com.xinelu.common.entity.AppletPhoneVO; import com.xinelu.common.exception.ServiceException; @@ -18,11 +20,14 @@ import com.xinelu.familydoctor.applet.pojo.body.PatientInfoBody; import com.xinelu.familydoctor.applet.pojo.entity.PatientInfo; import com.xinelu.familydoctor.applet.service.IResidentPatientInfoService; import com.xinelu.familydoctor.applet.utils.AppletAccessTokenUtils; +import com.xinelu.manage.domain.receiveAddressInfo.ReceiveAddressInfo; +import com.xinelu.manage.mapper.receiveAddressInfo.ReceiveAddressInfoMapper; import lombok.extern.slf4j.Slf4j; 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; @@ -46,6 +51,9 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi private AppletAccessTokenUtils appletAccessTokenUtils; @Resource private RedisTemplate redisTemplate; + @Resource + private ReceiveAddressInfoMapper receiveAddressInfoMapper; + /** * @return com.xinelu.familydoctor.applet.pojo.entity.PatientInfo * @Author mengkuiliang @@ -148,11 +156,13 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi * @Param [body] **/ @Override + @Transactional(rollbackFor = Exception.class) public void register(PatientInfoBody body) { if (ObjectUtils.isNotEmpty(body.getCardNo())) { + PatientInfo patientInfo; // 修改 if(!StringUtils.isBlank(body.getPatientCode())) { - PatientInfo patientInfo = residentPatientInfoMapper.getPatientInfoByPatientCode(body.getPatientCode()); + patientInfo = residentPatientInfoMapper.getPatientInfoByPatientCode(body.getPatientCode()); if (ObjectUtils.isNotEmpty(patientInfo)) { BeanUtils.copyBeanProp(patientInfo, body); if (body.getDiseaseList() != null) { @@ -160,12 +170,12 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi } patientInfo.setLoginFlag(Long.valueOf(1)); updatePatientInfo(patientInfo); - // 注册 } + // 注册 } else { // 获取当前微信绑定的居民 List list = residentPatientInfoMapper.getList(body.getOpenid(), body.getCityCode()); - PatientInfo patientInfo = residentPatientInfoMapper.isRegisterByCardNo(body.getCardNo()); + patientInfo = residentPatientInfoMapper.isRegisterByCardNo(body.getCardNo()); if (patientInfo == null) { PatientInfo entity = new PatientInfo(); BeanUtils.copyBeanProp(entity, body); @@ -179,6 +189,10 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi entity.setCreateBy(body.getCardNo()); entity.setLoginFlag(Long.valueOf(1)); residentPatientInfoMapper.insertPatientInfo(entity); + + // 新增的话重新查询居民信息获取patientId + patientInfo = residentPatientInfoMapper.getPatientInfoByPatientCode(entity.getPatientCode()); + } else { if (!StringUtils.isBlank(patientInfo.getOpenid())) { throw new ServiceException("该身份证号已被注册"); @@ -200,6 +214,34 @@ public class ResidentPatientInfoServiceImpl implements IResidentPatientInfoServi residentPatientInfoMapper.updatePatientInfo(patientInfo); } } + if(patientInfo != null) { + // 记录收货地址信息 + this.insertReceiveAddress(patientInfo); + } + } + } + + /** 新增收货人地址信息 */ + private void insertReceiveAddress(PatientInfo patientInfo) { + //判断当前收货地址信息是否存在 + int receiveCount = receiveAddressInfoMapper.getReceiveAddressInfo(patientInfo.getId(), patientInfo.getPatientName(), patientInfo.getPhone(), patientInfo.getAddress()); + if (receiveCount > 0) { + return; + } + //添加收货人地址信息 + ReceiveAddressInfo receiveAddressInfo = new ReceiveAddressInfo(); + receiveAddressInfo.setReceiveAddress(patientInfo.getAddress()); + receiveAddressInfo.setReceivePhone(patientInfo.getPhone()); + receiveAddressInfo.setAreaCode(patientInfo.getAreaCode()); + receiveAddressInfo.setPatientId(patientInfo.getId()); + receiveAddressInfo.setReceiveName(patientInfo.getPatientName()); + receiveAddressInfo.setOpenid(patientInfo.getOpenid()); + receiveAddressInfo.setUnionid(patientInfo.getUnionid()); + receiveAddressInfo.setCreateTime(LocalDateTime.now()); + receiveAddressInfo.setCreateBy(patientInfo.getCardNo()); + int insertReceiveAddressInfo = receiveAddressInfoMapper.insertReceiveAddressInfo(receiveAddressInfo); + if (insertReceiveAddressInfo <= 0) { + throw new ServiceException("修改收货人地址信息失败,请联系管理员!"); } }