From 633a43b1bc57187983d8bbe85f2e835026cc37b6 Mon Sep 17 00:00:00 2001 From: Mila <Mila@pollex.com.tw> Date: 星期五, 21 一月 2022 17:05:24 +0800 Subject: [PATCH] Merge branch 'Phase3' of https://192.168.0.10:8443/r/pcalife/PAM into Phase3 --- pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java | 42 +++++++++++++++++++++++------------------- 1 files changed, 23 insertions(+), 19 deletions(-) diff --git a/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java b/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java index 4706c99..91e1ba3 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java +++ b/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java @@ -97,49 +97,53 @@ .map(relation -> { Consultant consultant = relation.getConsultant(); CustomerFavoriteConsultantDTO dto = consultantMapper.toCustomerFavoriteConsultantDto(consultant); - - dto.setContactStatus(ContactStatusEnum.PICKED); dto.setCreateTime(relation.getCreatedDate()); dto.setUpdateTime(relation.getCreatedDate()); dto.setCustomerViewTime(relation.getViewTime()); - setAvailableAppointmentInfo( + setInfoByAvailableAppointment( dto, appointmentService.findAvailableByAgentNoAndCustomerId(consultant.getAgentNo(), customerId) ); - - appointmentService.findLatestAppointmentByAgentNoAndCustomerId(consultant.getAgentNo(), customerId) - .ifPresent(latestAppointment -> { - dto.setUpdateTime(latestAppointment.getLastModifiedDate()); - }); - - if(dto.getUpdateTime().isBefore(relation.getCreatedDate())) { - dto.setUpdateTime(relation.getCreatedDate()); - } + + setFavoriteConsultantUpdatedTime(relation, dto); return dto; }).collect(Collectors.toList()); } - private void setAvailableAppointmentInfo(CustomerFavoriteConsultantDTO customerFavoriteConsultantDTO, List<AppointmentCustomerView> appointmentList) { + public void setFavoriteConsultantUpdatedTime(CustomerFavoriteConsultant relation, + CustomerFavoriteConsultantDTO dto) { + Consultant consultant = relation.getConsultant(); + appointmentService.findLatestAppointmentByAgentNoAndCustomerId(consultant.getAgentNo(), relation.getCustomerId()) + .ifPresent(latestAppointment -> { + dto.setUpdateTime(latestAppointment.getLastModifiedDate()); + }); + + if(dto.getUpdateTime().isBefore(relation.getCreatedDate())) { + dto.setUpdateTime(relation.getCreatedDate()); + } + } + + private void setInfoByAvailableAppointment(CustomerFavoriteConsultantDTO customerFavoriteConsultantDTO, List<AppointmentCustomerView> appointmentList) { List<AppointmentCustomerView> appointments = appointmentList.stream() .sorted(Comparator.comparing(AppointmentCustomerView::getAppointmentDate).reversed()) .collect(Collectors.toList()); List<AppointmentCustomerViewDTO> appointmentCustomerViewDTOS = appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointments); - appointmentCustomerViewDTOS.forEach(appointmentCustomerViewDTO -> { - appointmentService.setSatisfactionScore(appointmentCustomerViewDTO, appointmentCustomerViewDTO.getId()); - }); customerFavoriteConsultantDTO.setAppointments(appointmentCustomerViewDTOS); if (!appointments.isEmpty()) { AppointmentCustomerView latestAvailableAppointment = appointments.get(0); - - if(latestAvailableAppointment.getCommunicateStatus() == RESERVED) - customerFavoriteConsultantDTO.setContactStatus(RESERVED); + ContactStatusEnum latestStatus = latestAvailableAppointment.getCommunicateStatus(); + if( latestStatus != ContactStatusEnum.DONE + || latestStatus != ContactStatusEnum.CLOSED) + customerFavoriteConsultantDTO.setContactStatus(latestStatus); else customerFavoriteConsultantDTO.setContactStatus(PICKED); + }else { + customerFavoriteConsultantDTO.setContactStatus(PICKED); } } -- Gitblit v1.8.0