| | |
| | | |
| | | public Satisfaction save(Satisfaction satisfaction) { |
| | | satisfaction = satisfactionRepository.save(satisfaction); |
| | | consultantService.setConsultantAvgScore(satisfaction); |
| | | if(satisfaction.getType() == SatisfactionTypeEnum.APPOINTMENT) { |
| | | consultantService.setConsultantAvgScore(satisfaction); |
| | | } |
| | | return satisfaction; |
| | | } |
| | | |
| | | public Satisfaction scorefaction(SatisfactionCustomerScoreDTO scoreDTO) { |
| | | Optional<Satisfaction> satisfactionOP = getByAppointmentIdAndType(scoreDTO.getAppointmentId(), SatisfactionTypeEnum.APPOINTMENT); |
| | | Optional<Satisfaction> satisfactionOP = satisfactionRepository.findById(scoreDTO.getSatisfactionId()); |
| | | Satisfaction satisfaction = satisfactionOP.orElseThrow(SatisfactionNotFoundException::new); |
| | | satisfaction.setScore(scoreDTO.getScore()); |
| | | satisfaction.setStatus(SatisfactionStatusEnum.FILLED); |
| | | satisfaction.setType(SatisfactionTypeEnum.APPOINTMENT); |
| | | save(satisfaction); |
| | | personalNotificationService.createScorefactionToConsultant(satisfaction); |
| | | return satisfaction; |
| | | |
| | | if(satisfaction.getType() == SatisfactionTypeEnum.APPOINTMENT) { |
| | | personalNotificationService.createScorefactionToConsultant(satisfaction); |
| | | } |
| | | return satisfaction; |
| | | } |
| | | |
| | | public Satisfaction createAppointmentSatisfaction(Appointment appointment) { |
| | |
| | | Optional<Satisfaction> systemSatisfactionOptional = |
| | | satisfactionRepository.findOneByAppointmentIdAndType(scoreDTO.getAppointmentId(), SatisfactionTypeEnum.SYSTEM); |
| | | |
| | | if(systemSatisfactionOptional.isPresent()) { |
| | | Satisfaction satisfaction = systemSatisfactionOptional.get(); |
| | | satisfaction.setStatus(SatisfactionStatusEnum.FILLED); |
| | | satisfaction.setScore(scoreDTO.getScore()); |
| | | return satisfactionRepository.save(satisfaction); |
| | | } |
| | | else { |
| | | log.warn("not found the satisfaction record, so can't fill system satisfaction"); |
| | | return null; |
| | | } |
| | | Satisfaction satisfaction = systemSatisfactionOptional.orElseThrow(SatisfactionNotFoundException::new); |
| | | satisfaction.setStatus(SatisfactionStatusEnum.FILLED); |
| | | satisfaction.setScore(scoreDTO.getScore()); |
| | | return satisfactionRepository.save(satisfaction); |
| | | } |
| | | } |