From 07d6fd2c5c6a35a33ad0dd9556b63fd6156d0974 Mon Sep 17 00:00:00 2001
From: KillerADO <wayne8692wayne8692@gmail.com>
Date: 星期四, 23 十二月 2021 16:01:01 +0800
Subject: [PATCH] [fix] 暫時移除客戶預約的業務邏輯,因sit db尚未更新顧問的email

---
 pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java |   19 ++++++++++++++-----
 1 files changed, 14 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..72a1e29 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java
@@ -61,19 +61,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 +95,8 @@
         customerFavoriteConsultantDTO.setAppointments(appointmentCustomerViewDTOS);
 
         if (!appointments.isEmpty()) {
-            AppointmentCustomerView latestAppointment = appointments.get(0);
-            customerFavoriteConsultantDTO.setContactStatus(latestAppointment.getCommunicateStatus());
-            customerFavoriteConsultantDTO.setUpdateTime(latestAppointment.getLastModifiedDate());
+            AppointmentCustomerView latestAvailableAppointment = appointments.get(0);
+            customerFavoriteConsultantDTO.setContactStatus(latestAvailableAppointment.getCommunicateStatus());
         }
     }
 

--
Gitblit v1.8.0