保誠-保戶業務員媒合平台
wayne
2021-12-13 ee59cafd1de5fe45133e391f3837e8f68e2a6de7
[add] 【todo 132301】新增客戶查看顧問清單的時間

修改5個檔案
新增2個檔案
89 ■■■■ 已變更過的檔案
pamapi/src/doc/sql/20211213_w.sql 1 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
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/service/ConsultantService.java 24 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/dto/CustomerFavoriteConsultantDTO.java 23 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/web/rest/ConsultantResource.java 6 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/doc/sql/20211213_w.sql
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1 @@
ALTER TABLE omo.customer_favorite_consultant ADD view_time timestamp NULL;
pamapi/src/doc/ÅU°ÝAPI/«È¤áªºÅU°Ý²M³æ.txt
@@ -18,6 +18,7 @@
        "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": [       // å®¢æˆ¶å·²é ç´„的顧問清單
@@ -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", // å®¢æˆ¶æŸ¥çœ‹æ™‚é–“
        "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", // å®¢æˆ¶æŸ¥çœ‹æ™‚é–“
        "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", // å®¢æˆ¶æŸ¥çœ‹æ™‚é–“
        "role": "和泰保險經紀人",
        "appointments": [],
        "new": true
        "appointments": []
    }
]
pamapi/src/doc/ÅU°ÝAPI/¬ö¿ý«È¤á¬d¬ÝÅU°Ý²M³æªºview_time API.txt
¤ñ¹ï·sÀÉ®×
@@ -0,0 +1,6 @@
http post:
http://localhost:8080/api/consultant/favorite/view
no request body
response body: 204 NO_CONTENT
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 +
            '}';
    }
}
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);
    }
}
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() {
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();