diff --git a/xinelu-common/src/main/java/com/xinelu/common/enums/OrderChannelEnum.java b/xinelu-common/src/main/java/com/xinelu/common/enums/OrderChannelEnum.java new file mode 100644 index 0000000..7550c2f --- /dev/null +++ b/xinelu-common/src/main/java/com/xinelu/common/enums/OrderChannelEnum.java @@ -0,0 +1,35 @@ +package com.xinelu.common.enums; + +import lombok.Getter; + +/** + * @Description 支付渠道枚举 + * @Author 纪寒 + * @Date 2022-10-18 15:23:01 + * @Version 1.0 + */ +@Getter +public enum OrderChannelEnum { + + /** + * 手机App + */ + MOBILE_APP("MOBILE_APP"), + + /** + * 微信小程序 + */ + WECHAT_APPLET("WECHAT_APPLET"), + + /** + * 支付宝小程序 + */ + ALI_PAY_APPLE("ALI_PAY_APPLE"), + ; + + final private String info; + + OrderChannelEnum(String info) { + this.info = info; + } +} \ No newline at end of file diff --git a/xinelu-common/src/main/java/com/xinelu/common/enums/PatientSourceEnum.java b/xinelu-common/src/main/java/com/xinelu/common/enums/PatientSourceEnum.java new file mode 100644 index 0000000..7b92f54 --- /dev/null +++ b/xinelu-common/src/main/java/com/xinelu/common/enums/PatientSourceEnum.java @@ -0,0 +1,29 @@ +package com.xinelu.common.enums; + +import lombok.Getter; + +/** + * @Description 会员信息来源枚举 + * @Author 纪寒 + * @Date 2023-02-24 14:08:25 + * @Version 1.0 + */ +@Getter +public enum PatientSourceEnum { + /** + * 好友邀请 + */ + FRIEND_INVITATION("FRIEND_INVITATION"), + + /** + * 自己搜索注册 + */ + REGISTER_YOURSELF("REGISTER_YOURSELF"), + ; + + final private String info; + + PatientSourceEnum(String info) { + this.info = info; + } +} \ No newline at end of file diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/nurseapplogin/NurseAppLoginController.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/nurseapplogin/NurseAppLoginController.java index d93e663..80e996a 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/nurseapplogin/NurseAppLoginController.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/nurseapplogin/NurseAppLoginController.java @@ -1,5 +1,6 @@ package com.xinelu.applet.controller.nurseapplogin; +import com.xinelu.applet.dto.appletlogin.AppletUserInfoDTO; import com.xinelu.applet.dto.appletlogin.StationItemInfoDTO; import com.xinelu.applet.service.nurseapplogin.NurseAppLoginService; import com.xinelu.applet.vo.nursepersonapplogin.OrderAndItemVO; @@ -7,14 +8,14 @@ import com.xinelu.common.annotation.MobileRequestAuthorization; import com.xinelu.common.core.controller.BaseController; import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.core.page.TableDataInfo; +import com.xinelu.common.custominterface.Insert; import com.xinelu.common.custominterface.Query; import com.xinelu.common.exception.ServiceException; import com.xinelu.common.utils.regex.RegexUtil; +import org.apache.commons.lang3.StringUtils; import org.springframework.validation.BindingResult; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; @@ -36,6 +37,31 @@ public class NurseAppLoginController extends BaseController { @Resource private NurseAppLoginService nurseAppLoginService; + + /** + * 完善用户信息-App和微信小程序共用 + * + * @param appletUserInfoDTO 用户信息 + * @return 结果 + */ + @MobileRequestAuthorization + @PostMapping("/appInformation") + public AjaxResult information(@RequestBody @Validated(Insert.class) AppletUserInfoDTO appletUserInfoDTO, BindingResult bindingResult) { + if (bindingResult.hasErrors()) { + throw new ServiceException(bindingResult.getAllErrors().get(0).getDefaultMessage()); + } + if (Objects.isNull(appletUserInfoDTO.getPatientId())) { + return AjaxResult.error("当前用户信息不存在,无法完善信息!"); + } + if (StringUtils.isBlank(appletUserInfoDTO.getPhone())) { + return AjaxResult.error("请输入手机号!"); + } + if (StringUtils.isBlank(appletUserInfoDTO.getHomeLatitude()) && StringUtils.isBlank(appletUserInfoDTO.getHomeLongitude())) { + return AjaxResult.error("请输入位置信息!"); + } + return nurseAppLoginService.appInformation(appletUserInfoDTO); + } + /** * 查询护理人列表信息(会员小程序和App共用) * diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/mapper/nurseapplogin/NurseAppLoginMapper.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/mapper/nurseapplogin/NurseAppLoginMapper.java index b2c35d8..9697544 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/mapper/nurseapplogin/NurseAppLoginMapper.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/mapper/nurseapplogin/NurseAppLoginMapper.java @@ -15,6 +15,30 @@ import java.util.List; */ public interface NurseAppLoginMapper { + /** + * 根据id查询被护理人疾病 + * + * @param patientId 被护理人id + * @return int + */ + int selectPatientDiseaseInfo(Long patientId); + + /** + * 根据id删除被护理人疾病 + * + * @param patientId 被护理人id + * @return int + */ + long deletePatientDiseaseInfo(Long patientId); + + /** + * 查询身份证数量 + * + * @param cardNo 身份证号 + * @return 数量 + */ + int getCardNoCount(String cardNo); + /** * 个人中心查询 * diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/NurseAppLoginService.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/NurseAppLoginService.java index a0365ac..1c3bfa9 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/NurseAppLoginService.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/NurseAppLoginService.java @@ -1,5 +1,6 @@ package com.xinelu.applet.service.nurseapplogin; +import com.xinelu.applet.dto.appletlogin.AppletUserInfoDTO; import com.xinelu.applet.dto.appletlogin.StationItemInfoDTO; import com.xinelu.applet.vo.nursepersonapplogin.OrderAndItemVO; import com.xinelu.common.core.domain.AjaxResult; @@ -13,6 +14,14 @@ import java.util.List; */ public interface NurseAppLoginService { + /** + * 完善用户信息-App和微信小程序共用 + * + * @param appletUserInfoDTO 信息 + * @return 结果 + */ + AjaxResult appInformation(AppletUserInfoDTO appletUserInfoDTO); + /** * 查询护理人列表信息 * diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/impl/NurseAppLoginServiceImpl.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/impl/NurseAppLoginServiceImpl.java index fb36d7a..abfd9f4 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/impl/NurseAppLoginServiceImpl.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/impl/NurseAppLoginServiceImpl.java @@ -1,8 +1,11 @@ package com.xinelu.applet.service.nurseapplogin.impl; +import com.xinelu.applet.dto.appletlogin.AppletUserInfoDTO; import com.xinelu.applet.dto.appletlogin.StationItemInfoDTO; import com.xinelu.applet.mapper.appletlogin.AppletLoginMapper; import com.xinelu.applet.mapper.nurseapplogin.NurseAppLoginMapper; +import com.xinelu.applet.mapper.patientcenter.PatientCenterMapper; +import com.xinelu.applet.service.messagepush.MessagePushService; import com.xinelu.applet.service.nurseapplogin.NurseAppLoginService; import com.xinelu.applet.utils.AppointmentTimeUtil; import com.xinelu.applet.vo.appletlogin.NurserStationItemConsumableVO; @@ -10,24 +13,55 @@ import com.xinelu.applet.vo.appletlogin.NurserStationItemInfoVO; import com.xinelu.applet.vo.nurseapplogin.PatientAndDiseaseVO; import com.xinelu.applet.vo.nursepersonapplogin.OrderAndItemVO; import com.xinelu.applet.vo.specialdisease.WeekDaysVO; +import com.xinelu.common.config.AppletChatConfig; +import com.xinelu.common.config.XinELuConfig; +import com.xinelu.common.constant.Constants; import com.xinelu.common.core.domain.AjaxResult; -import com.xinelu.common.enums.AppointmentTimeIntervalEnum; -import com.xinelu.common.enums.GooodsOrderStatusEnum; +import com.xinelu.common.enums.*; +import com.xinelu.common.exception.ServiceException; import com.xinelu.common.utils.AgeUtil; +import com.xinelu.common.utils.bean.BeanUtils; +import com.xinelu.common.utils.codes.GenerateSystemCodeUtil; +import com.xinelu.common.utils.regex.RegexUtil; +import com.xinelu.manage.domain.coupon.Coupon; import com.xinelu.manage.domain.goodsOrder.GoodsOrder; +import com.xinelu.manage.domain.patientcouponreceive.PatientCouponReceive; +import com.xinelu.manage.domain.patientdiseaseinfo.PatientDiseaseInfo; +import com.xinelu.manage.domain.patientinfo.PatientInfo; +import com.xinelu.manage.domain.patientintegralchange.PatientIntegralChange; +import com.xinelu.manage.domain.receiveAddressInfo.ReceiveAddressInfo; +import com.xinelu.manage.domain.subscribemessagerecord.SubscribeMessageRecord; +import com.xinelu.manage.domain.systemsettingsinfo.SystemSettingsInfo; +import com.xinelu.manage.mapper.coupon.CouponMapper; +import com.xinelu.manage.mapper.patientcouponreceive.PatientCouponReceiveMapper; +import com.xinelu.manage.mapper.patientdiseaseinfo.PatientDiseaseInfoMapper; +import com.xinelu.manage.mapper.patientinfo.PatientInfoMapper; +import com.xinelu.manage.mapper.patientintegralchange.PatientIntegralChangeMapper; +import com.xinelu.manage.mapper.receiveAddressInfo.ReceiveAddressInfoMapper; +import com.xinelu.manage.mapper.subscribemessagerecord.SubscribeMessageRecordMapper; import com.xinelu.manage.mapper.sysarea.SysAreaMapper; +import com.xinelu.manage.mapper.systemsettingsinfo.SystemSettingsInfoMapper; +import com.xinelu.manage.vo.patientcouponreceive.PatientCouponReceiveInfoVO; +import com.xinelu.manage.vo.patientinfo.PatientInfoVO; import com.xinelu.manage.vo.sysarea.SysAreaVO; import com.xinelu.system.domain.SysConfig; import com.xinelu.system.mapper.SysConfigMapper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.compress.utils.Lists; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.io.File; import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.LocalTime; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** @@ -42,13 +76,97 @@ public class NurseAppLoginServiceImpl implements NurseAppLoginService { @Resource private NurseAppLoginMapper nurseAppLoginMapper; @Resource + private AppletLoginMapper appletLoginMapper; + @Resource + private GenerateSystemCodeUtil generateSystemCodeUtil; + @Resource + private PatientInfoMapper patientInfoMapper; + @Resource + private PatientDiseaseInfoMapper patientDiseaseInfoMapper; + @Resource + private ReceiveAddressInfoMapper receiveAddressInfoMapper; + @Resource + private RegexUtil regexUtil; + @Resource private SysAreaMapper sysAreaMapper; @Resource - private AppletLoginMapper appletLoginMapper; + private AppointmentTimeUtil appointmentTimeUtil; @Resource private SysConfigMapper sysConfigMapper; @Resource - private AppointmentTimeUtil appointmentTimeUtil; + private PatientCouponReceiveMapper patientCouponReceiveMapper; + @Resource + private CouponMapper couponMapper; + @Resource + private SystemSettingsInfoMapper systemSettingsInfoMapper; + @Resource + private PatientIntegralChangeMapper patientIntegralChangeMapper; + @Resource + private PatientCenterMapper patientCenterMapper; + @Resource + private AppletChatConfig appletChatConfig; + @Resource + private SubscribeMessageRecordMapper subscribeMessageRecordMapper; + @Resource + private MessagePushService messagePushService; + + + /** + * 完善用户信息-App和微信小程序共用 + * + * @param appletUserInfoDTO 输入参数 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public AjaxResult appInformation(AppletUserInfoDTO appletUserInfoDTO) { + //校验手机号 + boolean regexPhone = regexUtil.regexPhone(StringUtils.isBlank(appletUserInfoDTO.getPhone()) ? "" : appletUserInfoDTO.getPhone()); + if (BooleanUtils.isFalse(regexPhone)) { + return AjaxResult.error("您输入的手机号不正确,请重新输入!"); + } + //校验身份证号 + boolean cardNo = regexUtil.regexCardNo(StringUtils.isBlank(appletUserInfoDTO.getCardNo()) ? "" : appletUserInfoDTO.getCardNo()); + if (BooleanUtils.isFalse(cardNo)) { + return AjaxResult.error("您输入的身份证号不正确,请重新输入!"); + } + //修改护理人主表信息 + PatientInfo patient = patientInfoMapper.getPatientInfoById(appletUserInfoDTO.getPatientId()); + if (Objects.isNull(patient)) { + return AjaxResult.error("当前用户信息不存在,请先注册或登录!"); + } + if (StringUtils.isBlank(patient.getPatientCode())) { + appletUserInfoDTO.setPatientCode(Constants.PATIENT_PREFIX + generateSystemCodeUtil.generatePatientCode(Constants.PATIENT_PREFIX)); + } + this.updatePatientInfo(appletUserInfoDTO); + //新增会员疾病信息 + this.insertPatientDiseaseInfo(appletUserInfoDTO, appletUserInfoDTO.getPatientId()); + //新增收货人地址信息 + this.insertReceiveAddress(appletUserInfoDTO); + //判断是否是第一次完善,如果是则发放新人优惠券信息 + PatientCouponReceiveInfoVO receiveInfoVO = null; + if (Objects.isNull(patient.getLoginFlag())) { + receiveInfoVO = issueCoupons(patient, appletUserInfoDTO); + } + //删除原有头像信息 + if (StringUtils.isNotBlank(appletUserInfoDTO.getHeadPictureUrl()) && StringUtils.isNotBlank(patient.getHeadPictureUrl()) + && !patient.getHeadPictureUrl().equals(appletUserInfoDTO.getHeadPictureUrl())) { + this.deleteHeadPicture(StringUtils.isBlank(patient.getHeadPictureUrl()) ? "" : patient.getHeadPictureUrl()); + } + if (Objects.isNull(receiveInfoVO) || Objects.isNull(receiveInfoVO.getCouponId())) { + return AjaxResult.success(); + } + //查询微信小程序订阅消息记录表该会员是否已订阅 + SubscribeMessageRecord subscribeMessageRecord = subscribeMessageRecordMapper.selectSubscribeMessageRecordByPatientId(null, patient.getOpenid(), appletChatConfig.getCouponReceiveTemplateId()); + boolean subscribeMessage = Objects.nonNull(subscribeMessageRecord) + && StringUtils.isNotBlank(subscribeMessageRecord.getSubscribeStatus()) + && SubscribeStatusEnum.ACCEPT.getInfo().equals(subscribeMessageRecord.getSubscribeStatus()); + if (BooleanUtils.isTrue(subscribeMessage)) { + //完善用户信息领取优惠券异步发送信息 + messagePushService.messageCouponReceiveThread(subscribeMessageRecord, receiveInfoVO); + } + return AjaxResult.success(); + } /** * 查询护理人列表信息 @@ -194,4 +312,237 @@ public class NurseAppLoginServiceImpl implements NurseAppLoginService { } return nurseAppLoginMapper.selectAppointmentOrderDetailsByPatientId(patientId, orderStatus); } + + /** + * 修改会员信息 + * + * @param appletUserInfoDTO 输入参数 + */ + private void updatePatientInfo(AppletUserInfoDTO appletUserInfoDTO) { + PatientInfo patientInfo = new PatientInfo(); + appletUserInfoDTO.setUpdateTime(LocalDateTime.now()); + BeanUtils.copyProperties(appletUserInfoDTO, patientInfo); + patientInfo.setId(appletUserInfoDTO.getPatientId()); + patientInfo.setLoginFlag(new AtomicInteger(1).intValue()); + patientInfo.setUpdateTime(LocalDateTime.now()); + if (CollectionUtils.isNotEmpty(appletUserInfoDTO.getNurseTypeIdList())) { + String serviceIds = appletUserInfoDTO.getNurseTypeIdList().stream().map(String::valueOf).collect(Collectors.joining(",")); + patientInfo.setServiceIds(serviceIds); + } + //查询省份证号数量,根据数量判断是否为主账号 + int cardNoCount = nurseAppLoginMapper.getCardNoCount(appletUserInfoDTO.getCardNo()); + patientInfo.setPrimaryAccountFlag(cardNoCount == 0 ? 0 : 1); + if (StringUtils.isNotBlank(appletUserInfoDTO.getSource())) { + patientInfo.setSource(appletUserInfoDTO.getSource()); + } + if (Objects.nonNull(appletUserInfoDTO.getInvitationPatientId())) { + patientInfo.setInvitationPatientId(appletUserInfoDTO.getInvitationPatientId()); + } + if (StringUtils.isNotBlank(appletUserInfoDTO.getSex())) { + patientInfo.setSex(appletUserInfoDTO.getSex()); + } + if (Objects.nonNull(appletUserInfoDTO.getBirthDate())) { + patientInfo.setBirthDate(appletUserInfoDTO.getBirthDate()); + } + //修改 + int updatePatientInfoCount = patientInfoMapper.updatePatientInfo(patientInfo); + if (updatePatientInfoCount <= 0) { + throw new ServiceException("完善信息失败,请联系管理员!"); + } + //判断是否是通过邀请好友方式进行完善的,赠送邀请请人积分以及记录积分变更记录 + if (StringUtils.isNotBlank(appletUserInfoDTO.getSource()) && PatientSourceEnum.FRIEND_INVITATION.getInfo().equals(appletUserInfoDTO.getSource())) { + if (Objects.isNull(appletUserInfoDTO.getInvitationPatientId())) { + return; + } + //查询邀请人信息 + PatientInfoVO invitationPatientInfo = patientInfoMapper.getPatientInfoById(appletUserInfoDTO.getInvitationPatientId()); + if (Objects.isNull(invitationPatientInfo)) { + return; + } + SystemSettingsInfo settingsInfo = systemSettingsInfoMapper.getSystemSettingsInfoByType(SettingsTypeEnum.INVITE_FRIENDS.getInfo()); + //赠送积分值 + int changeIntegral = 0; + if (Objects.nonNull(settingsInfo) && Objects.nonNull(settingsInfo.getIntegralCount())) { + changeIntegral = settingsInfo.getIntegralCount(); + } + patientCenterMapper.updatePatientIntegral(invitationPatientInfo.getId(), changeIntegral); + //邀请人账户原始积分值 + int originalIntegral = Objects.isNull(invitationPatientInfo.getIntegral()) ? 0 : invitationPatientInfo.getIntegral(); + this.insertPatientIntegral(invitationPatientInfo.getId(), originalIntegral, changeIntegral); + } + } + + /** + * 新增会员疾病信息 + * + * @param appletUserInfoDTO 输入参数 + * @param patientId 被护理人Id + */ + private void insertPatientDiseaseInfo(AppletUserInfoDTO appletUserInfoDTO, Long patientId) { + //设置护理人疾病关系表信息 + if (CollectionUtils.isNotEmpty(appletUserInfoDTO.getDiseaseInfoList())) { + //剔除疾病名称重复的信息 + List otherDiseaseList = appletUserInfoDTO.getDiseaseInfoList().stream().filter(item -> Objects.isNull(item.getDiseaseId())).collect(Collectors.toList()); + List dictDiseaseList = appletUserInfoDTO.getDiseaseInfoList().stream().filter(item -> Objects.nonNull(item.getDiseaseId())).collect(Collectors.toList()); + List dataListTwo = otherDiseaseList.stream() + .filter(item -> StringUtils.isNotBlank(item.getDiseaseName())) + .filter(otherInfo -> !dictDiseaseList.stream().map(PatientDiseaseInfo::getDiseaseName).filter(StringUtils::isNotBlank).collect(Collectors.toList()).contains(otherInfo.getDiseaseName())).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(dataListTwo)) { + dictDiseaseList.addAll(dataListTwo); + } + //根据id查询疾病信息表 + int diseaseInfoCount = nurseAppLoginMapper.selectPatientDiseaseInfo(patientId); + if (diseaseInfoCount > 0) { + long deletePatientDiseaseCount = nurseAppLoginMapper.deletePatientDiseaseInfo(patientId); + if (deletePatientDiseaseCount <= 0) { + log.warn("删除patient_disease_info信息失败,会员id:[{}]", patientId); + throw new ServiceException("完善信息失败,请联系管理员!"); + } + } + for (PatientDiseaseInfo patientDiseaseInfo : dictDiseaseList) { + patientDiseaseInfo.setPatientId(patientId); + patientDiseaseInfo.setDiseaseId(Objects.isNull(patientDiseaseInfo.getDiseaseId()) ? null : patientDiseaseInfo.getDiseaseId()); + patientDiseaseInfo.setDiseaseName(patientDiseaseInfo.getDiseaseName()); + patientDiseaseInfo.setCreateTime(LocalDateTime.now()); + } + //新增护理人疾病关系表信息 + int insertBatchCount = patientDiseaseInfoMapper.insertBatchPatientDiseaseInfo(dictDiseaseList); + if (insertBatchCount <= 0) { + log.info("新增护理人疾病关系表信息失败,输入参数[{}]", appletUserInfoDTO.getDiseaseInfoList()); + throw new ServiceException("完善信息失败,请联系管理员!"); + } + } + } + + /** + * 新增收货人地址信息 + * + * @param appletUserInfoDTO 输入参数 + */ + private void insertReceiveAddress(AppletUserInfoDTO appletUserInfoDTO) { + //判断当前收货地址信息是否存在 + int receiveCount = receiveAddressInfoMapper.getReceiveAddressInfo(appletUserInfoDTO.getPatientId(), appletUserInfoDTO.getPatientName(), appletUserInfoDTO.getPhone(), appletUserInfoDTO.getAddress()); + if (receiveCount > 0) { + return; + } + //添加收货人地址信息 + ReceiveAddressInfo receiveAddressInfo = new ReceiveAddressInfo(); + receiveAddressInfo.setReceiveAddress(appletUserInfoDTO.getAddress()); + receiveAddressInfo.setReceivePhone(appletUserInfoDTO.getPhone()); + receiveAddressInfo.setAreaCode(appletUserInfoDTO.getAreaCode()); + receiveAddressInfo.setPatientId(appletUserInfoDTO.getPatientId()); + receiveAddressInfo.setReceiveName(appletUserInfoDTO.getPatientName()); + int insertReceiveAddressInfo = receiveAddressInfoMapper.insertReceiveAddressInfo(receiveAddressInfo); + if (insertReceiveAddressInfo <= 0) { + throw new ServiceException("修改收货人地址信息失败,请联系管理员!"); + } + } + + /** + * 发放优惠券方法胡 + * + * @param patient 会员信息 + */ + public PatientCouponReceiveInfoVO issueCoupons(PatientInfo patient, AppletUserInfoDTO appletUserInfoDTO) { + PatientCouponReceiveInfoVO receiveInfoVO = new PatientCouponReceiveInfoVO(); + //查询新人福利的优惠券列表信息 + Coupon coupon = new Coupon(); + Long patientId = patient.getId(); + coupon.setReceiveType(CouponReceiveTypeEnum.NEW_PEOPLE_WELFARE.getInfo()); + List couponList = couponMapper.selectCouponList(coupon); + if (CollectionUtils.isEmpty(couponList)) { + return receiveInfoVO; + } + //组装优惠券信息 + List couponReceiveList = Lists.newArrayList(); + for (Coupon couponInfo : couponList) { + if (Objects.isNull(couponInfo.getId())) { + continue; + } + PatientCouponReceive couponReceive = new PatientCouponReceive(); + couponReceive.setPatientId(patientId); + couponReceive.setCouponId(couponInfo.getId()); + couponReceive.setReceiveSource(CouponReceiveTypeEnum.NEW_PEOPLE_WELFARE.getInfo()); + if (Objects.nonNull(appletUserInfoDTO.getCouponId()) && couponInfo.getId().equals(appletUserInfoDTO.getCouponId())) { + couponReceive.setUseStatus(CouponUseStatusEnum.NOT_USED.getInfo()); + couponReceive.setExpirationStartTime(LocalDateTime.now()); + couponReceive.setExpirationEndTime(LocalDate.now().plusDays(Objects.isNull(couponInfo.getCouponReductionDays()) ? 0 : couponInfo.getCouponReductionDays()).atTime(23, 59, 59)); + couponReceive.setReceiveTime(LocalDateTime.now()); + } else { + couponReceive.setUseStatus(CouponUseStatusEnum.WAIT_RECEIVE.getInfo()); + couponReceive.setExpirationStartTime(null); + couponReceive.setExpirationEndTime(null); + couponReceive.setReceiveTime(null); + } + couponReceive.setCouponReductionDays(Objects.isNull(couponInfo.getCouponReductionDays()) ? 0 : couponInfo.getCouponReductionDays()); + couponReceive.setCreateTime(LocalDateTime.now()); + couponReceive.setCouponTitle(StringUtils.isBlank(couponInfo.getCouponTitle()) ? "" : couponInfo.getCouponTitle()); + couponReceive.setCouponPrice(Objects.isNull(couponInfo.getCouponPrice()) ? BigDecimal.ZERO : couponInfo.getCouponPrice()); + couponReceive.setCouponConsumePrice(Objects.isNull(couponInfo.getCouponConsumePrice()) ? BigDecimal.ZERO : couponInfo.getCouponConsumePrice()); + couponReceive.setCouponDescription(StringUtils.isBlank(couponInfo.getCouponDescription()) ? "" : couponInfo.getCouponDescription()); + couponReceiveList.add(couponReceive); + } + if (CollectionUtils.isNotEmpty(couponReceiveList)) { + int insertCount = patientCouponReceiveMapper.insertBatchPatientReceive(couponReceiveList); + if (insertCount <= 0) { + log.error("完善用户信息接口-新人送券执行失败,输入参数[{}]", couponReceiveList); + throw new ServiceException("完善用户信息失败,请联系管理员!"); + } + } + //把要发放的优惠券数据塞入发送消息实体中 + Coupon couponMessagePush = couponList.stream().filter(Objects::nonNull) + .filter(couponInfo -> (Objects.nonNull(appletUserInfoDTO.getCouponId()) && couponInfo.getId().equals(appletUserInfoDTO.getCouponId()))) + .findFirst().orElse(new Coupon()); + BeanUtils.copyProperties(couponMessagePush, receiveInfoVO); + receiveInfoVO.setReceiveTime(LocalDateTime.now()); + receiveInfoVO.setCouponId(Objects.isNull(couponMessagePush.getId()) ? null : couponMessagePush.getId()); + receiveInfoVO.setCouponType(CouponTypeEnum.FULL_REDUCTION_COUPON.getInfo()); + return receiveInfoVO; + } + + + /** + * 删除个人头像图片 + * + * @param pictureUrl 图片路径 + */ + private void deleteHeadPicture(String pictureUrl) { + if (StringUtils.isBlank(pictureUrl)) { + return; + } + String picture = XinELuConfig.getProfile() + pictureUrl.replaceAll("/profile", ""); + File checkReportNameFile = new File(picture); + if (checkReportNameFile.exists()) { + //文件名称已存在,删除文件 + boolean delete = checkReportNameFile.delete(); + if (BooleanUtils.isFalse(delete)) { + throw new ServiceException("图片文件删除失败!"); + } + } + } + + + /** + * 生成积分积分信息 + * + * @param invitationPatientId 邀请人id + * @param originalIntegral 原始账户积分 + * @param changeIntegral 赠送变更积分 + */ + private void insertPatientIntegral(Long invitationPatientId, int originalIntegral, int changeIntegral) { + PatientIntegralChange integralChange = new PatientIntegralChange(); + integralChange.setPatientId(invitationPatientId); + integralChange.setOriginalIntegral(originalIntegral); + integralChange.setChangeIntegral(changeIntegral); + integralChange.setChangeTime(LocalDateTime.now()); + integralChange.setChangeType(IntegralChangeType.FRIEND_INVITATION.getInfo()); + integralChange.setChangeRemark("邀请好友赠送积分"); + integralChange.setChangeIntegralChannel(OrderChannelEnum.WECHAT_APPLET.getInfo()); + integralChange.setCreateTime(LocalDateTime.now()); + int insertCount = patientIntegralChangeMapper.insertPatientIntegralChange(integralChange); + if (insertCount <= 0) { + log.error("邀请好友-生成积分变更记录表信息失败,积分变更信息:{}", integralChange); + throw new ServiceException("完善用户信息失败,请联系管理员!"); + } + } } \ No newline at end of file diff --git a/xinelu-nurse-applet/src/main/resources/mapper/applet/nurseapplogin/NurseAppLoginMapper.xml b/xinelu-nurse-applet/src/main/resources/mapper/applet/nurseapplogin/NurseAppLoginMapper.xml index 3641690..34607d0 100644 --- a/xinelu-nurse-applet/src/main/resources/mapper/applet/nurseapplogin/NurseAppLoginMapper.xml +++ b/xinelu-nurse-applet/src/main/resources/mapper/applet/nurseapplogin/NurseAppLoginMapper.xml @@ -33,6 +33,35 @@ + + + + delete + from patient_disease_info + where patient_id = #{patientId} + + + + + + + + and order_evaluate_id = #{orderEvaluateId} + + + and evaluate_picture_url = #{evaluatePictureUrl} + + + + + + + + insert into order_evaluate_picture_info + + order_evaluate_id, + + evaluate_picture_url, + + create_by, + + create_time, + + update_by, + + update_time, + + + + #{orderEvaluateId}, + + #{evaluatePictureUrl}, + + #{createBy}, + + #{createTime}, + + #{updateBy}, + + #{updateTime}, + + + + + + update order_evaluate_picture_info + + order_evaluate_id = + #{orderEvaluateId}, + + evaluate_picture_url = + #{evaluatePictureUrl}, + + create_by = + #{createBy}, + + create_time = + #{createTime}, + + update_by = + #{updateBy}, + + update_time = + #{updateTime}, + + + where id = #{id} + + + + delete + from order_evaluate_picture_info + where id = #{id} + + + + delete from order_evaluate_picture_info where id in + + #{id} + + + \ No newline at end of file