| | |
| | | import com.pollex.pam.domain.Consultant; |
| | | import com.pollex.pam.domain.CustomerFavoriteConsultant; |
| | | import com.pollex.pam.domain.Satisfaction; |
| | | import com.pollex.pam.enums.ConsultantStatusEnum; |
| | | import com.pollex.pam.enums.ContactStatusEnum; |
| | | import com.pollex.pam.enums.LoginResult; |
| | | import com.pollex.pam.repository.ConsultantRepository; |
| | |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.pollex.pam.consts.SeniorityQueryConst.*; |
| | |
| | | |
| | | @Autowired |
| | | AppointmentService appointmentService; |
| | | |
| | | @Autowired |
| | | LoginRecordService loginRecordService; |
| | | |
| | | @Autowired |
| | | AppointmentCustomerViewMapper appointmentCustomerViewMapper; |
| | |
| | | public List<ConsultantDTO> getRecommendConsultantList() { |
| | | return consultantRepository.findAllByRecommendIsTrue() |
| | | .stream() |
| | | .filter(consultant -> consultant.getStatus() == ConsultantStatusEnum.AVAILABLE) |
| | | .map(consultantMapper::toDto) |
| | | .collect(Collectors.toList()); |
| | | } |
| | |
| | | |
| | | public ConsultantDetailDTO getConsultantDetail(String agentNo) { |
| | | Consultant consultant = consultantRepository.findOneByAgentNo(agentNo).orElseThrow(ConsultantNotFoundException::new); |
| | | ConsultantDetailDTO consultantDetailDTO = consultantMapper.toDetailDto(consultant); |
| | | |
| | | loginRecordService.findLatestLoginRecord(agentNo, LoginResult.SUCCESS) |
| | | .ifPresent(loginRecord -> consultantDetailDTO.setLatestLoginTime(loginRecord.getLoginDate())); |
| | | |
| | | return consultantDetailDTO; |
| | | return consultantMapper.toDetailDto(consultant); |
| | | } |
| | | |
| | | @Transactional |
| | |
| | | } |
| | | |
| | | public void setConsultantAvgScore(Satisfaction satisfaction) { |
| | | float avgScore = getAgentAvgScore(satisfaction.getAgentNo()); |
| | | Consultant consultant = consultantRepository.findOneByAgentNo(satisfaction.getAgentNo()) |
| | | .get(); |
| | | consultant.setAvgScore(avgScore); |
| | | consultantRepository.save(consultant); |
| | | Optional<Float> avgScore = getAgentAvgScore(satisfaction.getAgentNo()); |
| | | |
| | | if(avgScore.isPresent()) { |
| | | BigDecimal bigDecimal = BigDecimal.valueOf(avgScore.get()); |
| | | |
| | | Consultant consultant = consultantRepository.findOneByAgentNo(satisfaction.getAgentNo()).get(); |
| | | consultant.setAvgScore(bigDecimal.setScale(1, BigDecimal.ROUND_HALF_UP).floatValue()); |
| | | consultantRepository.save(consultant); |
| | | } |
| | | } |
| | | |
| | | public float getAgentAvgScore(String agentNo) { |
| | | Float avgScore = satisfactionRepository.getAgentScoreAvg(agentNo); |
| | | if(avgScore==null)return 0; |
| | | BigDecimal bigDecimal = new BigDecimal(avgScore); |
| | | return avgScore = bigDecimal.setScale(1,BigDecimal.ROUND_HALF_UP).floatValue(); |
| | | public Optional<Float> getAgentAvgScore(String agentNo) { |
| | | return satisfactionRepository.getAgentScoreAvg(agentNo); |
| | | } |
| | | } |