From beeee55db98ec9028a3fcc6a05b844b04ba0c229 Mon Sep 17 00:00:00 2001 From: Jack <jack.su@pollex.com.tw> Date: 星期六, 22 一月 2022 10:39:16 +0800 Subject: [PATCH] [ADD] 新增小鈴鐺通知的紀錄( * 顧問主動發送滿意度給客戶的通知後,系統立即通知客戶需要填寫滿意度通知 * 顧問發送約訪通知後,系統通知客戶有約訪 * 顧問更新個人帳號通知 * 客戶取消預約單通知 * 客戶更新預約單通知 * 客戶進行滿意度評比通知) --- pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java | 98 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 98 insertions(+), 0 deletions(-) diff --git a/pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java b/pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java index 5cf50ae..b6426cd 100644 --- a/pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java +++ b/pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java @@ -6,9 +6,16 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.pollex.pam.domain.Appointment; +import com.pollex.pam.domain.Consultant; +import com.pollex.pam.domain.Customer; import com.pollex.pam.domain.PersonalNotification; +import com.pollex.pam.domain.Satisfaction; +import com.pollex.pam.enums.NotificationTypeEnum; import com.pollex.pam.enums.PersonalNotificationRoleEnum; +import com.pollex.pam.repository.CustomerRepository; import com.pollex.pam.repository.PersonalNotificationRepository; +import com.pollex.pam.service.dto.AppointmentUpdateDTO; @Service @Transactional @@ -16,9 +23,100 @@ @Autowired PersonalNotificationRepository personalNotificationRepository; + + @Autowired + ConsultantService consultantService; + + @Autowired + AppointmentService appointmentService; + + @Autowired + CustomerService customerService; + + @Autowired + CustomerRepository customerRepository; + + @Autowired + SatisfactionService satisfactionService; public List<PersonalNotification> getMyPersonalNotification(Long ownerId, PersonalNotificationRoleEnum role) { return personalNotificationRepository.findAllByOwnerRoleAndOwnerId(role, ownerId); } + public void createSendSatisfactionToClientToCustomer(Appointment appointment) { + PersonalNotification entity = new PersonalNotification(); + Consultant consultant = consultantService.findByAgentNo(appointment.getAgentNo()); + String content = consultant.getName()+"憿批��憛怠神皛踵�漲閰��"; + entity.setContent(content); + entity.setNotificationType(NotificationTypeEnum.ACTIVITY); + entity.setOwnerId(appointment.getCustomerId()); + entity.setOwnerRole(PersonalNotificationRoleEnum.CUSTOMER); + entity.setTitle("憛怠神皛踵�漲"); + personalNotificationRepository.save(entity); + } + + public void createSendNoticeToCustomer(Long appointmentId) { + Appointment appointment = appointmentService.findById(appointmentId); + PersonalNotification entity = new PersonalNotification(); + Consultant consultant = consultantService.findByAgentNo(appointment.getAgentNo()); + String content = "���� "+consultant.getName()+"憿批���赤�"; + entity.setContent(content); + entity.setNotificationType(NotificationTypeEnum.ACTIVITY); + entity.setOwnerId(appointment.getCustomerId()); + entity.setOwnerRole(PersonalNotificationRoleEnum.CUSTOMER); + entity.setTitle("憿批��赤�"); + personalNotificationRepository.save(entity); + } + + public void createEditConsultantToConsultant(Consultant consultant) { + PersonalNotification entity = new PersonalNotification(); + String content = "����犖撣唾�身摰歇�脰��"; + entity.setContent(content); + entity.setNotificationType(NotificationTypeEnum.ACTIVITY); + entity.setOwnerId(consultant.getId()); + entity.setOwnerRole(PersonalNotificationRoleEnum.CONSULTANT); + entity.setTitle("霈撣唾����"); + personalNotificationRepository.save(entity); + } + + public void createMarkAppointmentDeletedToConsultant(Appointment appointment) { + PersonalNotification entity = new PersonalNotification(); + Customer customer = customerRepository.findById(appointment.getCustomerId()).get(); + Consultant consultant = consultantService.findByAgentNo(appointment.getAgentNo()); + String content = customer.getName()+"摰X撌脣�������"; + entity.setContent(content); + entity.setNotificationType(NotificationTypeEnum.ACTIVITY); + entity.setOwnerId(consultant.getId()); + entity.setOwnerRole(PersonalNotificationRoleEnum.CONSULTANT); + entity.setTitle("��������"); + personalNotificationRepository.save(entity); + } + + public void createUpdateAppointmentToConsultant(Appointment appointment) { + PersonalNotification entity = new PersonalNotification(); + Customer customer = customerRepository.findById(appointment.getCustomerId()).get(); + Consultant consultant = consultantService.findByAgentNo(appointment.getAgentNo()); + String content = customer.getName()+"摰X撌脫���������"; + entity.setContent(content); + entity.setNotificationType(NotificationTypeEnum.ACTIVITY); + entity.setOwnerId(consultant.getId()); + entity.setOwnerRole(PersonalNotificationRoleEnum.CONSULTANT); + entity.setTitle("��������"); + personalNotificationRepository.save(entity); + } + + public void createScorefactionToConsultant(Satisfaction satisfaction) { + PersonalNotification entity = new PersonalNotification(); + Appointment appointment = appointmentService.findById(satisfaction.getAppointmentId()); + Customer customer = customerRepository.findById(appointment.getCustomerId()).get(); + Consultant consultant = consultantService.findByAgentNo(appointment.getAgentNo()); + String content = customer.getName()+"摰X撌脣��脰�遛��漲閰��"; + entity.setContent(content); + entity.setNotificationType(NotificationTypeEnum.ACTIVITY); + entity.setOwnerId(consultant.getId()); + entity.setOwnerRole(PersonalNotificationRoleEnum.CONSULTANT); + entity.setTitle("摰X皛踵�漲"); + personalNotificationRepository.save(entity); + } + } -- Gitblit v1.8.0