| | |
| | | import com.pollex.pam.domain.AppointmentCustomerView; |
| | | import com.pollex.pam.domain.Consultant; |
| | | import com.pollex.pam.domain.CustomerFavoriteConsultant; |
| | | import com.pollex.pam.enums.AppointmentStatusEnum; |
| | | import com.pollex.pam.enums.ContactStatusEnum; |
| | | import com.pollex.pam.enums.LoginResult; |
| | | import com.pollex.pam.repository.ConsultantRepository; |
| | |
| | | |
| | | dto.setContactStatus(ContactStatusEnum.PICKED); |
| | | dto.setCreateTime(relation.getCreatedDate()); |
| | | dto.setUpdateTime(relation.getLastModifiedDate()); |
| | | dto.setUpdateTime(relation.getCreatedDate()); |
| | | dto.setCustomerViewTime(relation.getViewTime()); |
| | | |
| | | setAvaliableAppointmentInfo( |
| | | setAvailableAppointmentInfo( |
| | | dto, |
| | | appointmentService.findAvailableByAgentNoAndCustomerId(consultant.getAgentNo(), customerId) |
| | | ); |
| | |
| | | dto.setUpdateTime(latestAppointment.getLastModifiedDate()); |
| | | }); |
| | | |
| | | if(dto.getUpdateTime().isBefore(relation.getCreatedDate())) { |
| | | dto.setUpdateTime(relation.getCreatedDate()); |
| | | } |
| | | |
| | | return dto; |
| | | |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | private void setAvaliableAppointmentInfo(CustomerFavoriteConsultantDTO customerFavoriteConsultantDTO, List<AppointmentCustomerView> appointmentList) { |
| | | private void setAvailableAppointmentInfo(CustomerFavoriteConsultantDTO customerFavoriteConsultantDTO, List<AppointmentCustomerView> appointmentList) { |
| | | List<AppointmentCustomerView> appointments = appointmentList.stream() |
| | | .sorted(Comparator.comparing(AppointmentCustomerView::getAppointmentDate).reversed()) |
| | | .collect(Collectors.toList()); |
| | |
| | | customerFavoriteConsultantDTO.setAppointments(appointmentCustomerViewDTOS); |
| | | |
| | | if (!appointments.isEmpty()) { |
| | | AppointmentCustomerView latestAppointment = appointments.get(0); |
| | | customerFavoriteConsultantDTO.setContactStatus(latestAppointment.getCommunicateStatus()); |
| | | AppointmentCustomerView latestAvailableAppointment = appointments.get(0); |
| | | customerFavoriteConsultantDTO.setContactStatus(latestAvailableAppointment.getCommunicateStatus()); |
| | | } |
| | | } |
| | | |