删除多余代码
This commit is contained in:
parent
b2451f91e9
commit
9247d993a9
@ -32,36 +32,9 @@ import java.util.Objects;
|
||||
@RequestMapping("/nurseApp/login")
|
||||
public class NurseAppLoginController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private RegexUtil regexUtil;
|
||||
@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共用)
|
||||
*
|
||||
|
||||
@ -14,14 +14,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface NurseAppLoginService {
|
||||
|
||||
/**
|
||||
* 完善用户信息-App和微信小程序共用
|
||||
*
|
||||
* @param appletUserInfoDTO 信息
|
||||
* @return 结果
|
||||
*/
|
||||
AjaxResult appInformation(AppletUserInfoDTO appletUserInfoDTO);
|
||||
|
||||
/**
|
||||
* 查询护理人列表信息
|
||||
*
|
||||
|
||||
@ -78,95 +78,11 @@ public class NurseAppLoginServiceImpl implements NurseAppLoginService {
|
||||
@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 AppointmentTimeUtil appointmentTimeUtil;
|
||||
@Resource
|
||||
private SysConfigMapper sysConfigMapper;
|
||||
@Resource
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询护理人列表信息
|
||||
@ -312,237 +228,4 @@ 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<PatientDiseaseInfo> otherDiseaseList = appletUserInfoDTO.getDiseaseInfoList().stream().filter(item -> Objects.isNull(item.getDiseaseId())).collect(Collectors.toList());
|
||||
List<PatientDiseaseInfo> dictDiseaseList = appletUserInfoDTO.getDiseaseInfoList().stream().filter(item -> Objects.nonNull(item.getDiseaseId())).collect(Collectors.toList());
|
||||
List<PatientDiseaseInfo> 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<Coupon> couponList = couponMapper.selectCouponList(coupon);
|
||||
if (CollectionUtils.isEmpty(couponList)) {
|
||||
return receiveInfoVO;
|
||||
}
|
||||
//组装优惠券信息
|
||||
List<PatientCouponReceive> 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("完善用户信息失败,请联系管理员!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user