[update] 預約單dto加上預約單對應的滿意度分數
預約單至少會對到1至0個滿意度評分
¤ñ¹ï·sÀÉ®× |
| | |
| | | http get : |
| | | |
| | | http://localhost:8080/api/consultant/getMyAppointment |
| | | |
| | | |
| | | |
| | | [ |
| | | { |
| | | "id": 110, |
| | | "phone": "09123456789", |
| | | "email": "", |
| | | "contactType": "mobile", |
| | | "gender": "male", |
| | | "age": "30", |
| | | "job": "å
§å¤", |
| | | "requirement": "å女æè²,è³ç¢è¦å,é²ç«ä¿å®ç¸é", |
| | | "communicateStatus": "contacted", |
| | | "hopeContactTime": "'禮æä¸,禮æäºã12:00~14:00,14:00~18:00'", |
| | | "otherRequirement": null, |
| | | "appointmentDate": "2021-12-02T09:58:58.932Z", |
| | | "lastModifiedDate": "2021-12-02T09:58:58.932Z", |
| | | "agentNo": "AG0109051204", |
| | | "customerId": 70, |
| | | "name": null, |
| | | "consultantViewTime": "2021-12-02T09:58:12.066Z", |
| | | "consultantReadTime": "2021-12-02T09:58:58.930Z", |
| | | "contactTime": "2021-12-02T09:58:58.930Z", |
| | | }, |
| | | { |
| | | "id": 109, |
| | | "phone": "09123456789", |
| | | "email": "", |
| | | "contactType": "mobile", |
| | | "gender": "male", |
| | | "age": "20", |
| | | "job": "å
§å¤", |
| | | "requirement": "å¥åº·èä¿é,å女æè²,ä¿å®å¥æª¢/è¦å,é²ç«ä¿å®ç¸é", |
| | | "communicateStatus": "contacted", |
| | | "hopeContactTime": "'禮æä¸,禮æäº,禮æä¸,禮æå,禮æäº,禮æå
,ç¦®ææ¥ã12:00~14:00,14:00~18:00'", |
| | | "otherRequirement": null, |
| | | "appointmentDate": "2021-12-02T10:12:24.613Z", |
| | | "lastModifiedDate": "2021-12-02T10:12:24.613Z", |
| | | "agentNo": "AG0109051204", |
| | | "customerId": 67, |
| | | "name": null, |
| | | "consultantViewTime": "2021-12-02T09:58:12.066Z", |
| | | "consultantReadTime": "2021-12-02T10:12:24.612Z", |
| | | "contactTime": null |
| | | }, |
| | | { |
| | | "id": 114, |
| | | "phone": "09123456789", |
| | | "email": "", |
| | | "contactType": "mobile", |
| | | "gender": "male", |
| | | "age": "70", |
| | | "job": "å
§å¤", |
| | | "requirement": "å¥åº·èä¿é,å女æè²,è³ç¢è¦å,æ¨æ´»éä¼,é²ç«ä¿å®ç¸é", |
| | | "communicateStatus": "contacted", |
| | | "hopeContactTime": "'禮æä¸,禮æäº,禮æä¸,禮æå,禮æäº,禮æå
,ç¦®ææ¥ã12:00~14:00,14:00~18:00'", |
| | | "otherRequirement": null, |
| | | "appointmentDate": "2021-12-02T09:58:12.248Z", |
| | | "lastModifiedDate": "2021-12-02T09:58:12.248Z", |
| | | "agentNo": "AG0109051204", |
| | | "customerId": 71, |
| | | "name": null, |
| | | "consultantViewTime": "2021-12-02T09:58:12.066Z", |
| | | "consultantReadTime": null, |
| | | "contactTime": null |
| | | }, |
| | | { |
| | | "id": 121, |
| | | "phone": "09123456789", |
| | | "email": "", |
| | | "contactType": "mobile", |
| | | "gender": "male", |
| | | "age": "20", |
| | | "job": "å
§å¤", |
| | | "requirement": "å女æè²", |
| | | "communicateStatus": "contacted", |
| | | "hopeContactTime": "'禮æä¸,禮æäº,禮æä¸,禮æå,禮æäº,禮æå
,ç¦®ææ¥ã9:00~12:00,12:00~14:00,14:00~18:00,18:00~21:00'", |
| | | "otherRequirement": null, |
| | | "appointmentDate": "2021-12-02T09:58:12.248Z", |
| | | "lastModifiedDate": "2021-12-02T09:58:12.248Z", |
| | | "agentNo": "AG0109051204", |
| | | "customerId": 76, |
| | | "name": "æå²ç¶", |
| | | "consultantViewTime": "2021-12-02T09:58:12.066Z", |
| | | "consultantReadTime": "2021-12-02T09:54:20.872Z", |
| | | "contactTime": null |
| | | }, |
| | | { |
| | | "id": 118, |
| | | "phone": "09123456789", |
| | | "email": "", |
| | | "contactType": "mobile", |
| | | "gender": "male", |
| | | "age": "20", |
| | | "job": "å
§å¤", |
| | | "requirement": "å¥åº·èä¿é", |
| | | "communicateStatus": "contacted", |
| | | "hopeContactTime": "'禮æä¸,禮æäº,禮æä¸,禮æå,禮æäº,禮æå
,ç¦®ææ¥ã12:00~14:00,14:00~18:00'", |
| | | "otherRequirement": null, |
| | | "appointmentDate": "2021-12-02T10:02:52.797Z", |
| | | "lastModifiedDate": "2021-12-02T10:02:52.797Z", |
| | | "agentNo": "AG0109051204", |
| | | "customerId": 72, |
| | | "name": null, |
| | | "consultantViewTime": "2021-12-02T09:58:12.066Z", |
| | | "consultantReadTime": "2021-12-02T10:02:52.796Z", |
| | | "contactTime": null |
| | | }, |
| | | { |
| | | "id": 180, |
| | | "phone": "0911111111", |
| | | "email": "", |
| | | "contactType": "phone", |
| | | "gender": "female", |
| | | "age": "31-40", |
| | | "job": "å
§å¤", |
| | | "requirement": "å女æè²,å¥åº·èä¿é", |
| | | "communicateStatus": "contacted", |
| | | "hopeContactTime": "'禮æäº,禮æä¸,禮æå,禮æäº,禮æå
ã9:00~12:00,12:00~14:00,14:00~18:00,18:00~21:00','禮æä¸,禮æäº,禮æä¸,禮æå,禮æäº,ç¦®ææ¥ã12:00~14:00,14:00~18:00,18:00~21:00','禮æä¸,禮æå,禮æå
,ç¦®ææ¥ã14:00~18:00,18:00~21:00'", |
| | | "otherRequirement": null, |
| | | "appointmentDate": "2021-12-02T10:10:53.341Z", |
| | | "lastModifiedDate": "2021-12-03T03:40:16.344Z", |
| | | "agentNo": "AG0109051204", |
| | | "customerId": 77, |
| | | "name": "111", |
| | | "consultantViewTime": "2021-12-02T10:10:46.358Z", |
| | | "consultantReadTime": "2021-12-02T10:10:53.340Z", |
| | | "contactTime": "2021-12-03T03:40:16.215Z" |
| | | } |
| | | ] |
| | |
| | | "updateTime": "2021-12-02T10:56:32.741Z", // æè¿æ´æ°æé |
| | | "role": "å¨çä¿éªç¶ç´äºº", |
| | | "seniority": "22 å¹´ 8 æ", |
| | | "latestAppointmentId": 130, // æå¾ä¸çé ç´å®ID |
| | | "latestAppointmentDate": "2021-12-02T10:56:32.741Z", // æå¾ä¸çé ç´å®é ç´æé |
| | | "latestAppointmentScore": null, // æå¾ä¸çé ç´å®ç忏 (nullçºå°æªè©å) |
| | | "appointments": [ // 客æ¶å·²é ç´ç顧忏
å® |
| | | { |
| | | "id": 130, |
| | |
| | | "customerId": 76, |
| | | "name": "æå²ç¶", |
| | | "consultantViewTime": null, |
| | | "consultantReadTime": null |
| | | "consultantReadTime": null, |
| | | "satisfactionScore":30 // null 代表該çé ç´å®å°æªå¡«å¯«æ»¿æåº¦ |
| | | } |
| | | ], |
| | | "new": true |
| | |
| | | "updateTime": "2021-12-02T10:56:56.946Z", |
| | | "role": "é åµä¿éªç¶ç´äºº", |
| | | "seniority": "30 å¹´ 8 æ", |
| | | "latestAppointmentId": 131, |
| | | "latestAppointmentDate": "2021-12-02T10:56:56.946Z", |
| | | "latestAppointmentScore": null, |
| | | "appointments": [ |
| | | { |
| | | "id": 131, |
| | |
| | | "customerId": 76, |
| | | "name": "æå²ç¶", |
| | | "consultantViewTime": null, |
| | | "consultantReadTime": null |
| | | "consultantReadTime": null, |
| | | "satisfactionScore":30 // null 代表該çé ç´å®å°æªå¡«å¯«æ»¿æåº¦ |
| | | } |
| | | ], |
| | | "new": true |
| | |
| | | "updateTime": null, |
| | | "role": "å°åä¿éªç¶ç´äºº", |
| | | "seniority": "38 å¹´ ", |
| | | "latestAppointmentId": null, |
| | | "latestAppointmentDate": null, |
| | | "latestAppointmentScore": null, |
| | | "appointments": [], |
| | | "new": true |
| | | }, |
| | |
| | | "createTime": "2021-12-02T10:56:04.620Z", |
| | | "updateTime": null, |
| | | "role": "åæ³°ä¿éªç¶ç´äºº", |
| | | "seniority": "17 å¹´ 1 æ", |
| | | "latestAppointmentId": null, |
| | | "latestAppointmentDate": null, |
| | | "latestAppointmentScore": null, // æå¾ä¸çé ç´å®ç忏 (nullçºå°æªè©å) |
| | | "appointments": [], |
| | | "new": true |
| | | } |
| | |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.pollex.pam.domain.Satisfaction; |
| | | import com.pollex.pam.service.dto.AppointmentUpdateDTO; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | public AppointmentCustomerViewDTO getAppointmentDetail(Long appointmentId) { |
| | | AppointmentCustomerView appointment = appointmentCustomerViewRepository.findById(appointmentId) |
| | | .orElseThrow(AppointmentNotFoundException::new); |
| | | return appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointment); |
| | | |
| | | AppointmentCustomerViewDTO dto = appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointment); |
| | | setSatisfactionScore(dto, appointmentId); |
| | | return dto; |
| | | } |
| | | |
| | | public List<AppointmentCustomerViewDTO> getConsultantAvailableAppointments(String agentNo) { |
| | | return appointmentCustomerViewRepository.findByAgentNo(agentNo).stream() |
| | | .filter(appointment -> appointment.getStatus() == AVAILABLE) |
| | | .map(appointmentCustomerView -> { |
| | | AppointmentCustomerViewDTO dto = appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointmentCustomerView); |
| | | setSatisfactionScore(dto, appointmentCustomerView.getId()); |
| | | return dto; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | public void setSatisfactionScore(AppointmentCustomerViewDTO dto, Long appointmentId) { |
| | | satisfactionService.getByAppointmentId(appointmentId).ifPresent(satisfaction -> { |
| | | dto.setSatisfactionScore(satisfaction.getScore()); |
| | | }); |
| | | } |
| | | |
| | | public List<AppointmentCustomerView> findAvailableByAgentNoAndCustomerId(String agentNo, Long customerId) { |
| | | return appointmentCustomerViewRepository.findByAgentNoAndCustomerId(agentNo, customerId) |
| | |
| | | |
| | | consultantNotViewAppointments.forEach(appointment -> appointment.setConsultantViewTime(Instant.now())); |
| | | appointmentRepository.saveAll(consultantNotViewAppointments); |
| | | } |
| | | |
| | | public List<AppointmentCustomerViewDTO> getConsultantAppointments(String agentNo) { |
| | | return appointmentCustomerViewRepository.findByAgentNo(agentNo).stream() |
| | | .filter(appointment -> appointment.getStatus() != DELETED) |
| | | .map(appointmentCustomerViewMapper::toAppointmentCustomerViewDTO) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | } |
| | |
| | | import com.pollex.pam.domain.AppointmentCustomerView; |
| | | import com.pollex.pam.domain.Consultant; |
| | | import com.pollex.pam.domain.CustomerFavoriteConsultant; |
| | | import com.pollex.pam.domain.Satisfaction; |
| | | import com.pollex.pam.enums.ContactStatusEnum; |
| | | import com.pollex.pam.enums.LoginResult; |
| | | import com.pollex.pam.repository.ConsultantRepository; |
| | |
| | | |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | CustomerFavoriteConsultantDTO dto = consultantMapper.toCustomerFavoriteConsultantDto(consultant); |
| | | |
| | | dto.setContactStatus(ContactStatusEnum.PICKED); |
| | | dto.setLatestAppointmentId(null); |
| | | dto.setLatestAppointmentDate(null); |
| | | dto.setLatestAppointmentScore(null); |
| | | dto.setCreateTime(customerFavoriteConsultantRelation.getLastModifiedDate()); |
| | | dto.setCreateTime(customerFavoriteConsultantRelation.getCreatedDate()); |
| | | |
| | | setAppointmentInfo( |
| | | dto, |
| | |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | private void setAppointmentInfo(CustomerFavoriteConsultantDTO dto, List<AppointmentCustomerView> appointmentList) { |
| | | private void setAppointmentInfo(CustomerFavoriteConsultantDTO customerFavoriteConsultantDTO, List<AppointmentCustomerView> appointmentList) { |
| | | List<AppointmentCustomerView> appointments = appointmentList.stream() |
| | | .sorted(Comparator.comparing(AppointmentCustomerView::getAppointmentDate).reversed()) |
| | | .collect(Collectors.toList()); |
| | | |
| | | dto.setAppointments(appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointments)); |
| | | List<AppointmentCustomerViewDTO> appointmentCustomerViewDTOS = appointmentCustomerViewMapper.toAppointmentCustomerViewDTO(appointments); |
| | | appointmentCustomerViewDTOS.forEach(appointmentCustomerViewDTO -> { |
| | | appointmentService.setSatisfactionScore(appointmentCustomerViewDTO, appointmentCustomerViewDTO.getId()); |
| | | }); |
| | | customerFavoriteConsultantDTO.setAppointments(appointmentCustomerViewDTOS); |
| | | |
| | | if (!appointments.isEmpty()) { |
| | | AppointmentCustomerView latestAppointment = appointments.get(0); |
| | | dto.setContactStatus(latestAppointment.getCommunicateStatus()); |
| | | dto.setLatestAppointmentId(latestAppointment.getId()); |
| | | dto.setLatestAppointmentDate(latestAppointment.getAppointmentDate()); |
| | | dto.setUpdateTime(latestAppointment.getLastModifiedDate()); |
| | | |
| | | setLatestAppointmentScore(dto, latestAppointment); |
| | | } |
| | | } |
| | | |
| | | private void setLatestAppointmentScore(CustomerFavoriteConsultantDTO dto, AppointmentCustomerView latestAppointment) { |
| | | Optional<Satisfaction> satisfactionOptional = satisfactionService.getByAppointmentId(latestAppointment.getId()); |
| | | if(satisfactionOptional.isPresent()) { |
| | | Satisfaction satisfaction = satisfactionOptional.get(); |
| | | dto.setLatestAppointmentScore(satisfaction.getScore()); |
| | | } |
| | | else { |
| | | dto.setLatestAppointmentScore(null); |
| | | customerFavoriteConsultantDTO.setContactStatus(latestAppointment.getCommunicateStatus()); |
| | | customerFavoriteConsultantDTO.setUpdateTime(latestAppointment.getLastModifiedDate()); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | public List<AppointmentCustomerViewDTO> getMyAppointment() { |
| | | String agentNo = SecurityUtils.getAgentNo(); |
| | | return appointmentService.getConsultantAppointments(agentNo); |
| | | return appointmentService.getConsultantAvailableAppointments(agentNo); |
| | | } |
| | | |
| | | public void removeConsultantFromCustomList(String agentNo) { |
| | |
| | | private Instant consultantViewTime; |
| | | private Instant consultantReadTime; |
| | | private Instant contactTime; |
| | | private Float satisfactionScore; |
| | | |
| | | public Long getId() { |
| | | return id; |
| | | } |
| | |
| | | public void setContactTime(Instant contactTime) { |
| | | this.contactTime = contactTime; |
| | | } |
| | | public Float getSatisfactionScore() { |
| | | return satisfactionScore; |
| | | } |
| | | public void setSatisfactionScore(Float satisfactionScore) { |
| | | this.satisfactionScore = satisfactionScore; |
| | | } |
| | | } |
| | |
| | | private Instant updateTime; |
| | | private String role; |
| | | private String seniority; |
| | | private Long latestAppointmentId; |
| | | private Instant latestAppointmentDate; |
| | | private Float latestAppointmentScore; |
| | | private List<AppointmentCustomerViewDTO> appointments; |
| | | |
| | | public boolean isNewConsultant() { |
| | |
| | | this.expertise = expertise; |
| | | } |
| | | |
| | | public Float getLatestAppointmentScore() { |
| | | return latestAppointmentScore; |
| | | } |
| | | |
| | | public void setLatestAppointmentScore(Float latestAppointmentScore) { |
| | | this.latestAppointmentScore = latestAppointmentScore; |
| | | } |
| | | |
| | | public Float getAvgScore() { |
| | | return avgScore; |
| | | } |
| | |
| | | |
| | | public void setContactStatus(ContactStatusEnum contactStatus) { |
| | | this.contactStatus = contactStatus; |
| | | } |
| | | |
| | | public Instant getLatestAppointmentDate() { |
| | | return latestAppointmentDate; |
| | | } |
| | | |
| | | public void setLatestAppointmentDate(Instant latestAppointmentDate) { |
| | | this.latestAppointmentDate = latestAppointmentDate; |
| | | } |
| | | |
| | | public Instant getCreateTime() { |
| | |
| | | |
| | | public void setNewConsultant(boolean newConsultant) { |
| | | this.newConsultant = newConsultant; |
| | | } |
| | | |
| | | public Long getLatestAppointmentId() { |
| | | return latestAppointmentId; |
| | | } |
| | | |
| | | public void setLatestAppointmentId(Long latestAppointmentId) { |
| | | this.latestAppointmentId = latestAppointmentId; |
| | | } |
| | | |
| | | public List<AppointmentCustomerViewDTO> getAppointments() { |
| | |
| | | package com.pollex.pam.web.rest; |
| | | |
| | | import com.pollex.pam.service.AppointmentService; |
| | | import com.pollex.pam.service.ConsultantService; |
| | | import com.pollex.pam.service.dto.*; |
| | | import org.apache.commons.compress.utils.IOUtils; |