From 34b07249c7e7a9f487a6bc08f022db6bcb925d42 Mon Sep 17 00:00:00 2001 From: Jack <jack.su@pollex.com.tw> Date: 星期四, 20 一月 2022 14:46:35 +0800 Subject: [PATCH] [UPDATE] 調整客戶填寫滿意度的API [UPDATE] 調整產生滿意度調查資料的時機點,改為每次進到結案狀態就新增滿意度資料 [UPDATE] 調整結案API,新增和修改都使用同一支API由後端判斷為新增或修改 [BUG] 當沒有任何一筆滿意度的時候取得顧問平均分數會發生錯誤的問題修正 --- pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) 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 2efd89f..4706c99 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java +++ b/pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java @@ -5,10 +5,12 @@ 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 com.pollex.pam.repository.CustomerFavoriteConsultantRepository; +import com.pollex.pam.repository.SatisfactionRepository; import com.pollex.pam.security.SecurityUtils; import com.pollex.pam.service.dto.*; import com.pollex.pam.service.mapper.AppointmentCustomerViewMapper; @@ -30,6 +32,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.math.BigDecimal; import java.time.Instant; import java.util.Comparator; import java.util.List; @@ -82,6 +85,9 @@ @Autowired ConsultantService consultantService; + + @Autowired + SatisfactionRepository satisfactionRepository; public List<CustomerFavoriteConsultantDTO> getMyConsultantList() { Long customerId = SecurityUtils.getCustomerDBId(); @@ -288,4 +294,19 @@ public String getSendSatisfactionToClientUrl(Long appointmentId) { return applicationProperties.getFrontEndDomain() + "/?appointmentId=" + appointmentId; } + + public void setConsultantAvgScore(Satisfaction satisfaction) { + float avgScore = getAgentAvgScore(satisfaction.getAgentNo()); + Consultant consultant = consultantRepository.findOneByAgentNo(satisfaction.getAgentNo()) + .get(); + consultant.setAvgScore(avgScore); + consultantRepository.save(consultant); + } + + public float getAgentAvgScore(String agentNo) { + Float avgScore = satisfactionRepository.getAgentScoreAvg(agentNo); + if(avgScore==null)return 0; + BigDecimal bigDecimal = new BigDecimal(avgScore); + return avgScore = bigDecimal.setScale(1,BigDecimal.ROUND_HALF_UP).floatValue(); + } } -- Gitblit v1.8.0