From ee59cafd1de5fe45133e391f3837e8f68e2a6de7 Mon Sep 17 00:00:00 2001 From: wayne <wayne8692wayne8692@gmail.com> Date: 星期一, 13 十二月 2021 10:43:29 +0800 Subject: [PATCH] [add] 【todo 132301】新增客戶查看顧問清單的時間 --- pamapi/src/doc/顧問API/客戶的顧問清單.txt | 16 ++++---- pamapi/src/doc/顧問API/紀錄客戶查看顧問清單的view_time API.txt | 6 +++ pamapi/src/main/java/com/pollex/pam/domain/CustomerFavoriteConsultant.java | 13 ++++++ pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java | 6 +++ pamapi/src/main/java/com/pollex/pam/service/dto/CustomerFavoriteConsultantDTO.java | 23 ++++------- pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java | 24 ++++++++++- pamapi/src/doc/sql/20211213_w.sql | 1 7 files changed, 64 insertions(+), 25 deletions(-) diff --git a/pamapi/src/doc/sql/20211213_w.sql b/pamapi/src/doc/sql/20211213_w.sql new file mode 100644 index 0000000..5f011b2 --- /dev/null +++ b/pamapi/src/doc/sql/20211213_w.sql @@ -0,0 +1 @@ +ALTER TABLE omo.customer_favorite_consultant ADD view_time timestamp NULL; diff --git "a/pamapi/src/doc/\351\241\247\345\225\217API/\345\256\242\346\210\266\347\232\204\351\241\247\345\225\217\346\270\205\345\226\256.txt" "b/pamapi/src/doc/\351\241\247\345\225\217API/\345\256\242\346\210\266\347\232\204\351\241\247\345\225\217\346\270\205\345\226\256.txt" index eb81537..b48703c 100644 --- "a/pamapi/src/doc/\351\241\247\345\225\217API/\345\256\242\346\210\266\347\232\204\351\241\247\345\225\217\346\270\205\345\226\256.txt" +++ "b/pamapi/src/doc/\351\241\247\345\225\217API/\345\256\242\346\210\266\347\232\204\351\241\247\345\225\217\346\270\205\345\226\256.txt" @@ -18,6 +18,7 @@ "contactStatus": "reserved", // ��脰�����icked (�脰����)�eserved (撌脤���)�ontacted (撌脤��蝜�) "createTime": "2021-12-02T10:55:53.939Z", // ��憿批������ "updateTime": "2021-12-02T10:56:32.741Z", // ��餈����� + "customerViewTime": "2021-12-13T02:20:52.932Z", // 摰X������ "role": "憡��蝬�鈭�", "seniority": "22 撟� 8 ���", "appointments": [ // 摰X撌脤���“��� @@ -42,8 +43,7 @@ "consultantReadTime": null, "satisfactionScore":3 // null 隞�銵刻府蝑��撠憛怠神皛踵�漲 } - ], - "new": true + ] }, { "agentNo": "B282677963", @@ -61,6 +61,7 @@ "contactStatus": "reserved", "createTime": "2021-12-02T10:55:57.423Z", "updateTime": "2021-12-02T10:56:56.946Z", + "customerViewTime": "2021-12-13T02:20:52.932Z", // 摰X������ "role": "����蝬�鈭�", "seniority": "30 撟� 8 ���", "appointments": [ @@ -85,8 +86,7 @@ "consultantReadTime": null, "satisfactionScore":3 // null 隞�銵刻府蝑��撠憛怠神皛踵�漲 } - ], - "new": true + ] }, { "agentNo": "R221444250", @@ -104,10 +104,10 @@ "contactStatus": "picked", "createTime": "2021-12-02T10:56:01.004Z", "updateTime": null, + "customerViewTime": "2021-12-13T02:20:52.932Z", // 摰X������ "role": "����蝬�鈭�", "seniority": "38 撟� ", - "appointments": [], - "new": true + "appointments": [] }, { "agentNo": "Z152717443", @@ -125,8 +125,8 @@ "contactStatus": "picked", "createTime": "2021-12-02T10:56:04.620Z", "updateTime": null, + "customerViewTime": "2021-12-13T02:20:52.932Z", // 摰X������ "role": "��陸靽蝬�鈭�", - "appointments": [], - "new": true + "appointments": [] } ] diff --git "a/pamapi/src/doc/\351\241\247\345\225\217API/\347\264\200\351\214\204\345\256\242\346\210\266\346\237\245\347\234\213\351\241\247\345\225\217\346\270\205\345\226\256\347\232\204view_time API.txt" "b/pamapi/src/doc/\351\241\247\345\225\217API/\347\264\200\351\214\204\345\256\242\346\210\266\346\237\245\347\234\213\351\241\247\345\225\217\346\270\205\345\226\256\347\232\204view_time API.txt" new file mode 100644 index 0000000..b56821c --- /dev/null +++ "b/pamapi/src/doc/\351\241\247\345\225\217API/\347\264\200\351\214\204\345\256\242\346\210\266\346\237\245\347\234\213\351\241\247\345\225\217\346\270\205\345\226\256\347\232\204view_time API.txt" @@ -0,0 +1,6 @@ +http post: +http://localhost:8080/api/consultant/favorite/view + +no request body + +response body: 204 NO_CONTENT diff --git a/pamapi/src/main/java/com/pollex/pam/domain/CustomerFavoriteConsultant.java b/pamapi/src/main/java/com/pollex/pam/domain/CustomerFavoriteConsultant.java index 4145922..2412924 100644 --- a/pamapi/src/main/java/com/pollex/pam/domain/CustomerFavoriteConsultant.java +++ b/pamapi/src/main/java/com/pollex/pam/domain/CustomerFavoriteConsultant.java @@ -2,6 +2,7 @@ import javax.persistence.*; import java.io.Serializable; +import java.time.Instant; @Entity @Table(name = "customer_favorite_consultant") @@ -20,6 +21,9 @@ @Column(name = "customer_id") private Long customerId; + + @Column(name = "view_time") + private Instant viewTime; public Long getId() { return id; @@ -45,12 +49,21 @@ 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 + '}'; } } 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 adbb6ab..01c179e 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java +++ b/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java @@ -18,8 +18,10 @@ 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 @@ -53,12 +55,13 @@ 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, @@ -164,4 +167,19 @@ 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); + } } diff --git a/pamapi/src/main/java/com/pollex/pam/service/dto/CustomerFavoriteConsultantDTO.java b/pamapi/src/main/java/com/pollex/pam/service/dto/CustomerFavoriteConsultantDTO.java index 3142151..bdcdfd6 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/dto/CustomerFavoriteConsultantDTO.java +++ b/pamapi/src/main/java/com/pollex/pam/service/dto/CustomerFavoriteConsultantDTO.java @@ -9,8 +9,6 @@ public class CustomerFavoriteConsultantDTO { - @JsonProperty("new") - private boolean newConsultant; private String agentNo; private String name; private String img; @@ -19,17 +17,10 @@ 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; @@ -95,6 +86,14 @@ this.updateTime = updateTime; } + public Instant getCustomerViewTime() { + return customerViewTime; + } + + public void setCustomerViewTime(Instant customerViewTime) { + this.customerViewTime = customerViewTime; + } + public String getRole() { return role; } @@ -109,10 +108,6 @@ public void setSeniority(String seniority) { this.seniority = seniority; - } - - public void setNewConsultant(boolean newConsultant) { - this.newConsultant = newConsultant; } public List<AppointmentCustomerViewDTO> getAppointments() { diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java b/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java index 19f5000..e6e74d2 100644 --- a/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java +++ b/pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java @@ -29,6 +29,12 @@ 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(); -- Gitblit v1.8.0