From 296632415043a56e27da67f23e9d801e2afe5ec6 Mon Sep 17 00:00:00 2001 From: wayne <wayne8692wayne8692@gmail.com> Date: 星期三, 29 十二月 2021 13:58:05 +0800 Subject: [PATCH] [fix] 微調訊息文案的換行處理 --- pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java | 29 ++++++++++++++++++++++++----- 1 files changed, 24 insertions(+), 5 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 01c179e..5f8232c 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java +++ b/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java @@ -24,6 +24,8 @@ import java.util.Objects; import java.util.stream.Collectors; +import static com.pollex.pam.enums.ContactStatusEnum.*; + @Service public class ConsultantService { @@ -61,19 +63,29 @@ dto.setContactStatus(ContactStatusEnum.PICKED); dto.setCreateTime(relation.getCreatedDate()); + dto.setUpdateTime(relation.getCreatedDate()); dto.setCustomerViewTime(relation.getViewTime()); - setAppointmentInfo( + setAvailableAppointmentInfo( 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()); + } return dto; }).collect(Collectors.toList()); } - private void setAppointmentInfo(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()); @@ -85,9 +97,12 @@ customerFavoriteConsultantDTO.setAppointments(appointmentCustomerViewDTOS); if (!appointments.isEmpty()) { - AppointmentCustomerView latestAppointment = appointments.get(0); - customerFavoriteConsultantDTO.setContactStatus(latestAppointment.getCommunicateStatus()); - customerFavoriteConsultantDTO.setUpdateTime(latestAppointment.getLastModifiedDate()); + AppointmentCustomerView latestAvailableAppointment = appointments.get(0); + + if(latestAvailableAppointment.getCommunicateStatus() == RESERVED) + customerFavoriteConsultantDTO.setContactStatus(RESERVED); + else + customerFavoriteConsultantDTO.setContactStatus(PICKED); } } @@ -182,4 +197,8 @@ customerFavoriteConsultantRepository.saveAll(notViewRelation); } + + public Consultant findByAgentNo(String agentNo) { + return consultantRepository.findOneByAgentNo(agentNo).get(); + } } -- Gitblit v1.8.0