From a3716f72066d25d745f4d5103ff23a553c3e102b Mon Sep 17 00:00:00 2001
From: wayne <wayne8692wayne8692@gmail.com>
Date: 星期四, 17 二月 2022 11:41:19 +0800
Subject: [PATCH] Merge branch 'sit' into uat

---
 pamapi/src/main/java/com/pollex/pam/service/ScheduleTaskService.java |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/pamapi/src/main/java/com/pollex/pam/service/ScheduleTaskService.java b/pamapi/src/main/java/com/pollex/pam/service/ScheduleTaskService.java
index 4cf9cc4..627aeb4 100644
--- a/pamapi/src/main/java/com/pollex/pam/service/ScheduleTaskService.java
+++ b/pamapi/src/main/java/com/pollex/pam/service/ScheduleTaskService.java
@@ -6,6 +6,7 @@
 import com.pollex.pam.enums.AppointmentStatusEnum;
 import com.pollex.pam.enums.ContactStatusEnum;
 import com.pollex.pam.enums.SatisfactionStatusEnum;
+import com.pollex.pam.enums.SatisfactionTypeEnum;
 import com.pollex.pam.repository.AppointmentCustomerViewRepository;
 import com.pollex.pam.repository.AppointmentExpiringNotifyRecordRepository;
 import org.slf4j.Logger;
@@ -73,12 +74,17 @@
         consultantWithPendingAppointments.forEach((agentNo, pendingAppointments) -> {
             int pendingAppointmentsSum = pendingAppointments.size();
             Consultant consultant = consultantService.findByAgentNo(agentNo);
-            String consultantPhoneNumber = consultant.getPhoneNumber();
-            String consultantEmail = consultant.getEmail();
+            Optional<String> optionalPhone = Optional.ofNullable(consultant.getPhoneNumber()).filter(StringUtils::hasText);
+            Optional<String> optionalEmail = Optional.ofNullable(consultant.getEmail()).filter(StringUtils::hasText);
+
             String emailContent = getAppointmentPendingNotifyEmailContent(pendingAppointmentsSum);
 
-            sendMsgService.sendMsgBySMS(consultantPhoneNumber, String.format("����%s������脰�蝜恬������", pendingAppointmentsSum));
-            sendMsgService.sendMsgByEmail(consultantEmail, NOT_CONTACTED_NOTIFY_SUBJECT, emailContent, true);
+            optionalPhone.ifPresent(phone -> {
+                sendMsgService.sendMsgBySMS(phone, String.format("����%s������脰�蝜恬������", pendingAppointmentsSum));
+            });
+            optionalEmail.ifPresent(email -> {
+                sendMsgService.sendMsgByEmail(email, NOT_CONTACTED_NOTIFY_SUBJECT, emailContent, true);
+            });
         });
 
         log.info("Sending appointment pending notify to consultant finish");
@@ -122,13 +128,14 @@
 
     // todo ��蝣箄�府����, otis todo=134497
     @Scheduled(cron = "0 30 8 * * *")
-    public void sendNotFillSatisfactionToPersonalNotification() {
-        Map<Long, List<Satisfaction>> customerNotFillSatisfactions = satisfactionService.getByStatus(SatisfactionStatusEnum.UNFILLED)
+    public void sendNotFillAppointmentSatisfactionToPersonalNotification() {
+        Map<Long, List<Satisfaction>> customerNotFillSatisfactions =
+            satisfactionService.getByStatusAndType(SatisfactionStatusEnum.UNFILLED, SatisfactionTypeEnum.APPOINTMENT)
                 .stream()
                 .collect(Collectors.groupingBy(Satisfaction::getCustomerId));
 
         customerNotFillSatisfactions.forEach((customerId, notFillSatisfactions) ->
-            personalNotificationService.createNotFillSatisfactionSumToCustomer(customerId, notFillSatisfactions.size())
+            personalNotificationService.createNotFillAppointmentSatisfactionNumberToCustomer(customerId, notFillSatisfactions.size())
         );
     }
 

--
Gitblit v1.8.0