[add] 【todo 132301】新增客戶查看顧問清單的時間
¤ñ¹ï·sÀÉ®× |
| | |
| | | ALTER TABLE omo.customer_favorite_consultant ADD view_time timestamp NULL; |
| | |
| | | "contactStatus": "reserved", // å¯é²è¡çæ
ï¼picked (é²è¡é ç´)ãreserved (å·²é ç´)ãcontacted (å·²é£ç¹«) |
| | | "createTime": "2021-12-02T10:55:53.939Z", // å å
¥é¡§åæ¸
宿é |
| | | "updateTime": "2021-12-02T10:56:32.741Z", // æè¿æ´æ°æé |
| | | "customerViewTime": "2021-12-13T02:20:52.932Z", // å®¢æ¶æ¥çæé |
| | | "role": "å¨çä¿éªç¶ç´äºº", |
| | | "seniority": "22 å¹´ 8 æ", |
| | | "appointments": [ // 客æ¶å·²é ç´ç顧忏
å® |
| | |
| | | "consultantReadTime": null, |
| | | "satisfactionScore":3 // null 代表該çé ç´å®å°æªå¡«å¯«æ»¿æåº¦ |
| | | } |
| | | ], |
| | | "new": true |
| | | ] |
| | | }, |
| | | { |
| | | "agentNo": "B282677963", |
| | |
| | | "contactStatus": "reserved", |
| | | "createTime": "2021-12-02T10:55:57.423Z", |
| | | "updateTime": "2021-12-02T10:56:56.946Z", |
| | | "customerViewTime": "2021-12-13T02:20:52.932Z", // å®¢æ¶æ¥çæé |
| | | "role": "é åµä¿éªç¶ç´äºº", |
| | | "seniority": "30 å¹´ 8 æ", |
| | | "appointments": [ |
| | |
| | | "consultantReadTime": null, |
| | | "satisfactionScore":3 // null 代表該çé ç´å®å°æªå¡«å¯«æ»¿æåº¦ |
| | | } |
| | | ], |
| | | "new": true |
| | | ] |
| | | }, |
| | | { |
| | | "agentNo": "R221444250", |
| | |
| | | "contactStatus": "picked", |
| | | "createTime": "2021-12-02T10:56:01.004Z", |
| | | "updateTime": null, |
| | | "customerViewTime": "2021-12-13T02:20:52.932Z", // å®¢æ¶æ¥çæé |
| | | "role": "å°åä¿éªç¶ç´äºº", |
| | | "seniority": "38 å¹´ ", |
| | | "appointments": [], |
| | | "new": true |
| | | "appointments": [] |
| | | }, |
| | | { |
| | | "agentNo": "Z152717443", |
| | |
| | | "contactStatus": "picked", |
| | | "createTime": "2021-12-02T10:56:04.620Z", |
| | | "updateTime": null, |
| | | "customerViewTime": "2021-12-13T02:20:52.932Z", // å®¢æ¶æ¥çæé |
| | | "role": "åæ³°ä¿éªç¶ç´äºº", |
| | | "appointments": [], |
| | | "new": true |
| | | "appointments": [] |
| | | } |
| | | ] |
¤ñ¹ï·sÀÉ®× |
| | |
| | | http post: |
| | | http://localhost:8080/api/consultant/favorite/view |
| | | |
| | | no request body |
| | | |
| | | response body: 204 NO_CONTENT |
| | |
| | | |
| | | import javax.persistence.*; |
| | | import java.io.Serializable; |
| | | import java.time.Instant; |
| | | |
| | | @Entity |
| | | @Table(name = "customer_favorite_consultant") |
| | |
| | | |
| | | @Column(name = "customer_id") |
| | | private Long customerId; |
| | | |
| | | @Column(name = "view_time") |
| | | private Instant viewTime; |
| | | |
| | | public Long getId() { |
| | | return id; |
| | |
| | | this.customerId = customId; |
| | | } |
| | | |
| | | public Instant getViewTime() { |
| | | return viewTime; |
| | | } |
| | | |
| | | public void setViewTime(Instant viewTime) { |
| | | this.viewTime = viewTime; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "CustomerFavoriteConsultant{" + |
| | | "id=" + id + |
| | | ", consultant=" + consultant + |
| | | ", customerId=" + customerId + |
| | | ", viewTime=" + viewTime + |
| | | '}'; |
| | | } |
| | | } |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.Instant; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | |
| | | return customerFavoriteConsultantRepository.findAllByCustomerId(customerId) |
| | | .stream() |
| | | .map(customerFavoriteConsultantRelation -> { |
| | | Consultant consultant = customerFavoriteConsultantRelation.getConsultant(); |
| | | .map(relation -> { |
| | | Consultant consultant = relation.getConsultant(); |
| | | CustomerFavoriteConsultantDTO dto = consultantMapper.toCustomerFavoriteConsultantDto(consultant); |
| | | |
| | | dto.setContactStatus(ContactStatusEnum.PICKED); |
| | | dto.setCreateTime(customerFavoriteConsultantRelation.getCreatedDate()); |
| | | dto.setCreateTime(relation.getCreatedDate()); |
| | | dto.setCustomerViewTime(relation.getViewTime()); |
| | | |
| | | setAppointmentInfo( |
| | | dto, |
| | |
| | | String agentNo = SecurityUtils.getAgentNo(); |
| | | appointmentService.recordAllAppointmentsView(agentNo); |
| | | } |
| | | |
| | | public void recordMyConsultantListView() { |
| | | Long customerId = SecurityUtils.getCustomerDBId(); |
| | | List<CustomerFavoriteConsultant> notViewRelation = customerFavoriteConsultantRepository |
| | | .findAllByCustomerId(customerId) |
| | | .stream() |
| | | .filter(relation -> Objects.isNull(relation.getViewTime())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | notViewRelation.forEach(relation -> { |
| | | relation.setViewTime(Instant.now()); |
| | | }); |
| | | |
| | | customerFavoriteConsultantRepository.saveAll(notViewRelation); |
| | | } |
| | | } |
| | |
| | | |
| | | public class CustomerFavoriteConsultantDTO { |
| | | |
| | | @JsonProperty("new") |
| | | private boolean newConsultant; |
| | | private String agentNo; |
| | | private String name; |
| | | private String img; |
| | |
| | | private ContactStatusEnum contactStatus; |
| | | private Instant createTime; |
| | | private Instant updateTime; |
| | | private Instant customerViewTime; |
| | | private String role; |
| | | private String seniority; |
| | | private List<AppointmentCustomerViewDTO> appointments; |
| | | |
| | | public boolean isNewConsultant() { |
| | | if(createTime != null){ |
| | | Instant nowTimestamp = Instant.now(); |
| | | return ChronoUnit.DAYS.between(createTime, nowTimestamp) < 3; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public String getAgentNo() { |
| | | return agentNo; |
| | |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public Instant getCustomerViewTime() { |
| | | return customerViewTime; |
| | | } |
| | | |
| | | public void setCustomerViewTime(Instant customerViewTime) { |
| | | this.customerViewTime = customerViewTime; |
| | | } |
| | | |
| | | public String getRole() { |
| | | return role; |
| | | } |
| | |
| | | |
| | | public void setSeniority(String seniority) { |
| | | this.seniority = seniority; |
| | | } |
| | | |
| | | public void setNewConsultant(boolean newConsultant) { |
| | | this.newConsultant = newConsultant; |
| | | } |
| | | |
| | | public List<AppointmentCustomerViewDTO> getAppointments() { |
| | |
| | | return new ResponseEntity<>(myConsultants, HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping("/favorite/view") |
| | | public ResponseEntity<Void> recordMyConsultantListView() { |
| | | consultantService.recordMyConsultantListView(); |
| | | return ResponseEntity.noContent().build(); |
| | | } |
| | | |
| | | @GetMapping("/recommend") |
| | | public ResponseEntity<List<ConsultantDTO>> getRecommendConsultantList() { |
| | | List<ConsultantDTO> recommendConsultantList = consultantService.getRecommendConsultantList(); |