| | |
| | | import com.pollex.pam.enums.AppointmentStatusEnum; |
| | | import com.pollex.pam.enums.ContactStatusEnum; |
| | | import com.pollex.pam.enums.SatisfactionStatusEnum; |
| | | import com.pollex.pam.enums.SatisfactionTypeEnum; |
| | | import com.pollex.pam.repository.AppointmentCustomerViewRepository; |
| | | import com.pollex.pam.repository.AppointmentExpiringNotifyRecordRepository; |
| | | import org.slf4j.Logger; |
| | |
| | | consultantWithPendingAppointments.forEach((agentNo, pendingAppointments) -> { |
| | | int pendingAppointmentsSum = pendingAppointments.size(); |
| | | Consultant consultant = consultantService.findByAgentNo(agentNo); |
| | | String consultantPhoneNumber = consultant.getPhoneNumber(); |
| | | String consultantEmail = consultant.getEmail(); |
| | | Optional<String> optionalPhone = Optional.ofNullable(consultant.getPhoneNumber()).filter(StringUtils::hasText); |
| | | Optional<String> optionalEmail = Optional.ofNullable(consultant.getEmail()).filter(StringUtils::hasText); |
| | | |
| | | String emailContent = getAppointmentPendingNotifyEmailContent(pendingAppointmentsSum); |
| | | |
| | | sendMsgService.sendMsgBySMS(consultantPhoneNumber, String.format("您有%s則預約單未進行聯繫,請盡速處理", pendingAppointmentsSum)); |
| | | sendMsgService.sendMsgByEmail(consultantEmail, NOT_CONTACTED_NOTIFY_SUBJECT, emailContent, true); |
| | | optionalPhone.ifPresent(phone -> { |
| | | sendMsgService.sendMsgBySMS(phone, String.format("您有%s則預約單未進行聯繫,請盡速處理", pendingAppointmentsSum)); |
| | | }); |
| | | optionalEmail.ifPresent(email -> { |
| | | sendMsgService.sendMsgByEmail(email, NOT_CONTACTED_NOTIFY_SUBJECT, emailContent, true); |
| | | }); |
| | | }); |
| | | |
| | | log.info("Sending appointment pending notify to consultant finish"); |
| | |
| | | .filter(appointment -> |
| | | appointmentService.isAppointmentDateNotInIntervalFromNow(appointment, Constants.APPOINTMENT_EXPIRING_PHONE_INTERVAL, Constants.APPOINTMENT_EXPIRING_EMAIL_INTERVAL) |
| | | ) |
| | | .filter(this::isAppointmentNotifyNotOnLimit) |
| | | .filter(this::isAppointmentExpiringNotifyNotOnLimit) |
| | | .collect(Collectors.toList()); |
| | | |
| | | allByCommunicateStatus.forEach(appointment -> { |
| | |
| | | |
| | | optionalPhone.ifPresent(phone -> |
| | | sendMsgService.sendMsgBySMS(phone, String.format("很抱歉!您預約%s顧問正忙碌中,請您取消預約並改選其他顧問,請點擊網址:%s" |
| | | , consultant.getName(), getAppointmentUrl(appointment.getId()))) |
| | | , consultant.getName(), getAppointmentExpiringNotifyUrl(appointment.getId()))) |
| | | ); |
| | | optionalEmail.ifPresent(email -> |
| | | sendMsgService.sendMsgByEmail(email, NOT_CONTACTED_NOTIFY_SUBJECT, getAppointmentExpiringNotifyEmail(consultant.getName(), getAppointmentUrl(appointment.getId())), true) |
| | | sendMsgService.sendMsgByEmail(email, NOT_CONTACTED_NOTIFY_SUBJECT, getAppointmentExpiringNotifyEmail(consultant.getName(), getAppointmentExpiringNotifyUrl(appointment.getId())), true) |
| | | ); |
| | | |
| | | AppointmentExpiringNotifyRecord record = new AppointmentExpiringNotifyRecord(); |
| | |
| | | } |
| | | |
| | | // todo 需確認該時間, otis todo=134497 |
| | | @Scheduled(cron = "0 0 9 * * *") |
| | | public void sendNotFillSatisfactionToPersonalNotification() { |
| | | Map<Long, List<Satisfaction>> customerNotFillSatisfactions = satisfactionService.getByStatus(SatisfactionStatusEnum.UNFILLED) |
| | | @Scheduled(cron = "0 30 8 * * *") |
| | | public void sendNotFillAppointmentSatisfactionToPersonalNotification() { |
| | | Map<Long, List<Satisfaction>> customerNotFillSatisfactions = |
| | | satisfactionService.getByStatusAndType(SatisfactionStatusEnum.UNFILLED, SatisfactionTypeEnum.APPOINTMENT) |
| | | .stream() |
| | | .collect(Collectors.groupingBy(Satisfaction::getCustomerId)); |
| | | |
| | | customerNotFillSatisfactions.forEach((customerId, notFillSatisfactions) -> |
| | | personalNotificationService.createNotFillSatisfactionSumToCustomer(customerId, notFillSatisfactions.size()) |
| | | personalNotificationService.createNotFillAppointmentSatisfactionNumberToCustomer(customerId, notFillSatisfactions.size()) |
| | | ); |
| | | } |
| | | |
| | | private boolean isAppointmentNotifyNotOnLimit(AppointmentCustomerView appointment) { |
| | | private boolean isAppointmentExpiringNotifyNotOnLimit(AppointmentCustomerView appointment) { |
| | | int sendNotifyToCustomerRecordSum = |
| | | appointmentExpiringNotifyRecordRepository.findAllByAppointmentId(appointment.getId()).size(); |
| | | |
| | | return sendNotifyToCustomerRecordSum < Constants.SEND_EXPIRING_NOTIFY_LIMIT; |
| | | } |
| | | |
| | | private String getAppointmentUrl(Long appointmentId) { |
| | | private String getAppointmentExpiringNotifyUrl(Long appointmentId) { |
| | | return applicationProperties.getFrontEndDomain() + "?notContactAppointmentId=" + appointmentId; |
| | | } |
| | | |