| | |
| | | import com.talentcard.server.common.SensitiveDataCrypto; |
| | | import com.talentcard.server.entity.ChildInformation; |
| | | import com.talentcard.server.entity.ServiceApplication; |
| | | import com.talentcard.server.entity.ServiceApplicationOperationLog; |
| | | import com.talentcard.server.mapper.ChildInformationMapper; |
| | | import com.talentcard.server.mapper.ServiceApplicationMapper; |
| | | import com.talentcard.server.mapper.ServiceApplicationOperationLogMapper; |
| | | import org.springframework.dao.DuplicateKeyException; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | |
| | | private final ServiceApplicationMapper applicationMapper; |
| | | private final ChildInformationMapper childInformationMapper; |
| | | private final ServiceApplicationOperationLogMapper operationLogMapper; |
| | | private final SensitiveDataCrypto sensitiveDataCrypto; |
| | | |
| | | public ServiceAppointmentApplicationService( |
| | | ServiceApplicationMapper applicationMapper, |
| | | ChildInformationMapper childInformationMapper, |
| | | ServiceApplicationOperationLogMapper operationLogMapper, |
| | | SensitiveDataCrypto sensitiveDataCrypto |
| | | ) { |
| | | this.applicationMapper = applicationMapper; |
| | | this.childInformationMapper = childInformationMapper; |
| | | this.operationLogMapper = operationLogMapper; |
| | | this.sensitiveDataCrypto = sensitiveDataCrypto; |
| | | } |
| | | |
| | |
| | | ServiceApplication saved = applicationMapper.selectById(application.getId()); |
| | | if (saved == null) { |
| | | throw new BusinessException(ErrorCode.INTERNAL_ERROR, "预约申请保存失败"); |
| | | } |
| | | ServiceApplicationOperationLog log = new ServiceApplicationOperationLog(); |
| | | log.setApplicationId(saved.getId()); |
| | | log.setApplicationNo(saved.getApplicationNo()); |
| | | log.setOperationType("SUBMIT"); |
| | | log.setAfterStatus(saved.getStatus()); |
| | | log.setOperatorType("TALENT"); |
| | | log.setOperatorId(saved.getTalentId()); |
| | | log.setOperatorName(saved.getTalentName()); |
| | | log.setRemark("提交预约申请"); |
| | | log.setCreatedAt(saved.getSubmittedAt()); |
| | | if (operationLogMapper.insert(log) != 1) { |
| | | throw new BusinessException(ErrorCode.INTERNAL_ERROR, "预约申请操作日志保存失败"); |
| | | } |
| | | return appResult(saved); |
| | | } |
| | |
| | | applyInstitution(application, merchant, request.merchantName(), request.contactMobile(), false); |
| | | application.setApplicantName(first(clean(request.applicantName()), application.getTalentName())); |
| | | application.setApplicantMobile(first(clean(request.applicantMobile()), application.getTalentMobile())); |
| | | application.setGuestCount(request.guestCount()); |
| | | application.setGuestCount(request.guestCount() == null ? 1 : request.guestCount()); |
| | | application.setSubsidy(blankToNull(clean(request.subsidy()))); |
| | | applyHotelProduct(application, request.productId(), request.productName()); |
| | | LocalDate checkIn = date(request.checkInDate(), "入住日期格式不正确", false); |
| | |
| | | if (merchant == null || merchant.isEmpty()) { |
| | | throw new BusinessException(ErrorCode.NOT_FOUND, message); |
| | | } |
| | | if (expectedType != null && !expectedType.equalsIgnoreCase(text(merchant, "merchantType", "merchant_type"))) { |
| | | String actualType = text(merchant, "merchantType", "merchant_type"); |
| | | boolean medicalType = "medical".equalsIgnoreCase(expectedType) |
| | | && ("medical".equalsIgnoreCase(actualType) || "healthCheck".equalsIgnoreCase(actualType) || "免费体检".equals(actualType)); |
| | | boolean hotelType = "hotel".equalsIgnoreCase(expectedType) |
| | | && ("hotel".equalsIgnoreCase(actualType) || "酒店".equals(actualType) || "酒店服务".equals(actualType)); |
| | | if (expectedType != null && !medicalType && !hotelType && !expectedType.equalsIgnoreCase(actualType)) { |
| | | throw new BusinessException(ErrorCode.CONFLICT, message); |
| | | } |
| | | return merchant; |
| | |
| | | private String clean(String value) { |
| | | return value == null ? "" : value.trim(); |
| | | } |
| | | } |
| | | } |