pamapi/src/main/java/com/pollex/pam/domain/Appointment.java | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
pamapi/src/main/java/com/pollex/pam/domain/CustomerFavoriteConsultant.java | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
pamapi/src/main/java/com/pollex/pam/repository/AppointmentRepository.java | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 | |
pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java | ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程 |
pamapi/src/main/java/com/pollex/pam/domain/Appointment.java
@@ -58,11 +58,10 @@ @CreatedDate @Column(name = "appointment_date", updatable = false) private Instant appointmentDate; private Instant appointmentDate = Instant.now(); @LastModifiedDate @Column(name = "last_modified_date") private Instant lastModifiedDate; private Instant lastModifiedDate = Instant.now(); @Column(name = "agent_no") private String agentNo; pamapi/src/main/java/com/pollex/pam/domain/CustomerFavoriteConsultant.java
@@ -1,12 +1,20 @@ package com.pollex.pam.domain; import com.fasterxml.jackson.annotation.JsonIgnore; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedBy; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; import javax.persistence.*; import java.io.Serializable; import java.time.Instant; @EntityListeners(AuditingEntityListener.class) @Entity @Table(name = "customer_favorite_consultant") public class CustomerFavoriteConsultant extends AbstractAuditingEntity implements Serializable { public class CustomerFavoriteConsultant implements Serializable { private static final long serialVersionUID = 1L; @@ -21,6 +29,25 @@ @Column(name = "customer_id") private Long customerId; @CreatedBy @Column(name = "created_by", updatable = false) @JsonIgnore private String createdBy; @CreatedDate @Column(name = "created_date", updatable = false) @JsonIgnore private Instant createdDate = Instant.now(); @LastModifiedBy @Column(name = "last_modified_by") @JsonIgnore private String lastModifiedBy; @Column(name = "last_modified_date") @JsonIgnore private Instant lastModifiedDate = Instant.now(); @Column(name = "view_time") private Instant viewTime; @@ -57,12 +84,48 @@ this.viewTime = viewTime; } public String getCreatedBy() { return createdBy; } public void setCreatedBy(String createdBy) { this.createdBy = createdBy; } public Instant getCreatedDate() { return createdDate; } public void setCreatedDate(Instant createdDate) { this.createdDate = createdDate; } public String getLastModifiedBy() { return lastModifiedBy; } public void setLastModifiedBy(String lastModifiedBy) { this.lastModifiedBy = lastModifiedBy; } public Instant getLastModifiedDate() { return lastModifiedDate; } public void setLastModifiedDate(Instant lastModifiedDate) { this.lastModifiedDate = lastModifiedDate; } @Override public String toString() { return "CustomerFavoriteConsultant{" + "id=" + id + ", consultant=" + consultant + ", customerId=" + customerId + ", createdBy='" + createdBy + '\'' + ", createdDate=" + createdDate + ", lastModifiedBy='" + lastModifiedBy + '\'' + ", lastModifiedDate=" + lastModifiedDate + ", viewTime=" + viewTime + '}'; } pamapi/src/main/java/com/pollex/pam/repository/AppointmentRepository.java
@@ -1,6 +1,7 @@ package com.pollex.pam.repository; import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -13,4 +14,6 @@ List<Appointment> findByAgentNo(String agentNo); List<Appointment> findByAgentNoAndCustomerId(String agentNo, Long customerId); Optional<Appointment> findTopByAgentNoAndCustomerIdOrderByAppointmentDateDesc(String agentNo, Long customerId); } pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
@@ -3,6 +3,7 @@ import java.time.Instant; import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; import com.pollex.pam.domain.Satisfaction; @@ -72,6 +73,7 @@ appointment.setRequirement(updateAppointmentDTO.getRequirement()); appointment.setHopeContactTime(updateAppointmentDTO.getHopeContactTime()); appointment.setOtherRequirement(updateAppointmentDTO.getOtherRequirement()); appointment.setLastModifiedDate(Instant.now()); appointmentRepository.save(appointment); } @@ -79,6 +81,7 @@ public void markAppointmentDeleted(Long appointmentId) { Appointment appointment = appointmentRepository.findById(appointmentId).get(); appointment.setStatus(DELETED); appointment.setLastModifiedDate(Instant.now()); appointmentRepository.save(appointment); } @@ -87,11 +90,11 @@ } public Appointment markAsContacted(Long appointmentId) { Appointment appointment = appointmentRepository.findById(appointmentId).get(); appointment.setCommunicateStatus(ContactStatusEnum.CONTACTED); appointment.setContactTime(Instant.now()); return appointmentRepository.save(appointment); appointment.setLastModifiedDate(Instant.now()); return appointmentRepository.save(appointment); } public AppointmentCustomerViewDTO getAppointmentDetail(Long appointmentId) { @@ -127,6 +130,10 @@ .collect(Collectors.toList()); } public Optional<Appointment> findLatestAppointmentByAgentNoAndCustomerId(String agentNo, Long customerId) { return appointmentRepository.findTopByAgentNoAndCustomerIdOrderByAppointmentDateDesc(agentNo, customerId); } public void recordConsultantReadTime(Long appointmentId) { Appointment appointment = appointmentRepository.findById(appointmentId).get(); pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java
@@ -3,6 +3,7 @@ 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; @@ -61,19 +62,25 @@ dto.setContactStatus(ContactStatusEnum.PICKED); dto.setCreateTime(relation.getCreatedDate()); dto.setUpdateTime(relation.getLastModifiedDate()); dto.setCustomerViewTime(relation.getViewTime()); setAppointmentInfo( setAvaliableAppointmentInfo( dto, appointmentService.findAvailableByAgentNoAndCustomerId(consultant.getAgentNo(), customerId) ); appointmentService.findLatestAppointmentByAgentNoAndCustomerId(consultant.getAgentNo(), customerId) .ifPresent(latestAppointment -> { dto.setUpdateTime(latestAppointment.getLastModifiedDate()); }); return dto; }).collect(Collectors.toList()); } private void setAppointmentInfo(CustomerFavoriteConsultantDTO customerFavoriteConsultantDTO, List<AppointmentCustomerView> appointmentList) { private void setAvaliableAppointmentInfo(CustomerFavoriteConsultantDTO customerFavoriteConsultantDTO, List<AppointmentCustomerView> appointmentList) { List<AppointmentCustomerView> appointments = appointmentList.stream() .sorted(Comparator.comparing(AppointmentCustomerView::getAppointmentDate).reversed()) .collect(Collectors.toList()); @@ -87,7 +94,6 @@ if (!appointments.isEmpty()) { AppointmentCustomerView latestAppointment = appointments.get(0); customerFavoriteConsultantDTO.setContactStatus(latestAppointment.getCommunicateStatus()); customerFavoriteConsultantDTO.setUpdateTime(latestAppointment.getLastModifiedDate()); } }