From bc6c7eb6d2c2bff68f2decfbd3a800140b79dd88 Mon Sep 17 00:00:00 2001 From: wayne <wayne8692wayne8692@gmail.com> Date: 星期三, 29 十二月 2021 12:55:46 +0800 Subject: [PATCH] [update] 暫時將測試顧問資料改成Charles指定的手機與email,以便測試 --- pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java | 25 +++++++++++++++++++------ 1 files changed, 19 insertions(+), 6 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 da2ee4f..5f8232c 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java +++ b/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java @@ -3,7 +3,6 @@ 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; @@ -24,6 +23,8 @@ import java.util.List; import java.util.Objects; import java.util.stream.Collectors; + +import static com.pollex.pam.enums.ContactStatusEnum.*; @Service public class ConsultantService { @@ -62,10 +63,10 @@ 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) ); @@ -75,12 +76,16 @@ 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()); @@ -92,8 +97,12 @@ customerFavoriteConsultantDTO.setAppointments(appointmentCustomerViewDTOS); if (!appointments.isEmpty()) { - AppointmentCustomerView latestAppointment = appointments.get(0); - customerFavoriteConsultantDTO.setContactStatus(latestAppointment.getCommunicateStatus()); + AppointmentCustomerView latestAvailableAppointment = appointments.get(0); + + if(latestAvailableAppointment.getCommunicateStatus() == RESERVED) + customerFavoriteConsultantDTO.setContactStatus(RESERVED); + else + customerFavoriteConsultantDTO.setContactStatus(PICKED); } } @@ -188,4 +197,8 @@ customerFavoriteConsultantRepository.saveAll(notViewRelation); } + + public Consultant findByAgentNo(String agentNo) { + return consultantRepository.findOneByAgentNo(agentNo).get(); + } } -- Gitblit v1.8.0