保誠-保戶業務員媒合平台
wayne
2021-12-02 00ac6f95a8cc129ec262f27ce6a162d0713bf002
pamapi/src/main/java/com/pollex/pam/service/mapper/ConsultantMapper.java
@@ -19,9 +19,6 @@
    private static final Character SPLIT_MASK = ',';
    @Autowired
    AppointmentService appointmentService;
    public ConsultantDTO toDto(Consultant source) {
        ConsultantDTO consultantDTO = new ConsultantDTO();
        consultantDTO.setAgentNo(source.getAgentNo());
@@ -37,29 +34,6 @@
        consultantDTO.setLatestAppointmentId(null);
        return consultantDTO;
    }
    public ConsultantDTO toDto(CustomerFavoriteConsultant customerFavoriteConsultant) {
        Consultant consultant = customerFavoriteConsultant.getConsultant();
        ConsultantDTO dto = toDto(consultant);
        final Optional<Appointment> latestAppointmentOptional = appointmentService.findByAgentNoAndCustomerId(consultant.getAgentNo(), customerFavoriteConsultant.getCustomerId())
            .stream()
            .max(Comparator.comparing(Appointment::getAppointmentDate));
        if(latestAppointmentOptional.isPresent()) {
            Appointment latestAppointment = latestAppointmentOptional.get();
            dto.setContactStatus(latestAppointment.getCommunicateStatus());
            dto.setLatestAppointmentId(latestAppointment.getId());
            dto.setUpdateTime(latestAppointment.getAppointmentDate());
        }
        else {
            dto.setContactStatus(ContactStatusEnum.PICKED);
            dto.setLatestAppointmentId(null);
            dto.setUpdateTime(customerFavoriteConsultant.getLastModifiedDate());
        }
        return dto;
    }
    public ConsultantDetailDTO toDetailDto(Consultant source) {