保誠-保戶業務員媒合平台
[ADD] 新增小鈴鐺通知的紀錄(
* 顧問主動發送滿意度給客戶的通知後,系統立即通知客戶需要填寫滿意度通知
* 顧問發送約訪通知後,系統通知客戶有約訪
* 顧問更新個人帳號通知
* 客戶取消預約單通知
* 客戶更新預約單通知
* 客戶進行滿意度評比通知)
修改6個檔案
139 ■■■■■ 已變更過的檔案
pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java 11 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java 9 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/NoticeService.java 5 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/PersonalNotificationService.java 98 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/SatisfactionService.java 7 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java 9 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
@@ -83,6 +83,9 @@
    
    @Autowired
    AppointmentProcess abstractAppointmentProcess;
    @Autowired
    PersonalNotificationService personalNotificationService;
    public Appointment customerCreateAppointment(AppointmentCreateDTO appointmentCreateDTO) {
        Appointment appointment = appointmentDTOMapper.toAppointment(appointmentCreateDTO);
@@ -92,9 +95,9 @@
        return appointmentRepository.save(appointment);
    }
    public void updateAppointment(AppointmentUpdateDTO updateAppointmentDTO) {
    public Appointment updateAppointment(AppointmentUpdateDTO updateAppointmentDTO) {
        Appointment appointment = appointmentRepository.findById(updateAppointmentDTO.getId()).get();
        BeanUtils.copyProperties(updateAppointmentDTO, appointment);
        appointment.setPhone(updateAppointmentDTO.getPhone());
        appointment.setEmail(updateAppointmentDTO.getEmail());
        appointment.setContactType(updateAppointmentDTO.getContactType());
@@ -106,7 +109,7 @@
        appointment.setOtherRequirement(updateAppointmentDTO.getOtherRequirement());
        appointment.setLastModifiedDate(Instant.now());
        appointmentRepository.save(appointment);
        return appointmentRepository.save(appointment);
    }
    public void markAppointmentDeleted(Long appointmentId) {
@@ -115,6 +118,8 @@
        appointment.setLastModifiedDate(Instant.now());
        appointment.setCommunicateStatus(ContactStatusEnum.CANCEL);
        appointmentRepository.save(appointment);
        personalNotificationService.createMarkAppointmentDeletedToConsultant(appointment);
    }
    public List<Appointment> findByAgentNo(String agentNo) {
pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java
@@ -88,6 +88,9 @@
    
    @Autowired
    SatisfactionRepository satisfactionRepository;
    @Autowired
    PersonalNotificationService personalNotificationService;
    public List<CustomerFavoriteConsultantDTO> getMyConsultantList() {
        Long customerId = SecurityUtils.getCustomerDBId();
@@ -248,7 +251,9 @@
                .orElseThrow(ConsultantNotFoundException::new);
        consultantDTOMapper.copyToConsultant(editDTO, consultant);
        FileUtil.base64ToFile(editDTO.getPhotoBase64(), editDTO.getPhotoFileName(), applicationProperty.getFileFolderPath());
        return consultantRepository.save(consultant);
        consultantRepository.save(consultant);
        personalNotificationService.createEditConsultantToConsultant(consultant);
        return consultant;
    }
    public InputStream getAvatarImage(String agentNo) {
@@ -275,6 +280,8 @@
            String content = genSendSatisfactionSMSContent(appointment);
            sendMsgService.sendMsgBySMS(appointment.getPhone(), content);
        }
        personalNotificationService.createSendSatisfactionToClientToCustomer(appointment);
    }
    
    private String genSendSatisfactionSMSContent(Appointment appointment) {
pamapi/src/main/java/com/pollex/pam/service/NoticeService.java
@@ -29,6 +29,9 @@
    @Autowired
    AppointmentRepository appointmentRepository;
    
    @Autowired
    PersonalNotificationService personalNotificationService;
    public void sendNotice(AppointmentNoticeSendDTO dto) {
        String subject = "保誠媒合平台系統通知:預約通知";
@@ -38,6 +41,7 @@
        }if(StringUtils.hasText(dto.getPhone())) {
            sendMsgService.sendMsgBySMS(dto.getPhone(), dto.getMessage());
        }
        List<AppointmentNoticeLog> noticeLogs = 
                appointmentNoticeLogService.findByAppointmentId(dto.getAppointmentId());
        if(noticeLogs.size()==0) {
@@ -47,6 +51,7 @@
        }
        
        appointmentNoticeLogService.create(dto);
        personalNotificationService.createSendNoticeToCustomer(dto.getAppointmentId());
    }
}
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()+"客戶已取消您的預約";
        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()+"客戶已更新您的預約資訊";
        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()+"客戶已對您進行滿意度評比";
        entity.setContent(content);
        entity.setNotificationType(NotificationTypeEnum.ACTIVITY);
        entity.setOwnerId(consultant.getId());
        entity.setOwnerRole(PersonalNotificationRoleEnum.CONSULTANT);
        entity.setTitle("客戶滿意度");
        personalNotificationRepository.save(entity);
    }
}
pamapi/src/main/java/com/pollex/pam/service/SatisfactionService.java
@@ -46,6 +46,9 @@
    
    @Autowired
    ConsultantService consultantService;
    @Autowired
    PersonalNotificationService personalNotificationService;
    public Satisfaction save(Satisfaction satisfaction) {
        satisfaction = satisfactionRepository.save(satisfaction);
@@ -58,7 +61,9 @@
        Satisfaction satisfaction = satisfactionOP.orElseThrow(SatisfactionNotFoundException::new);
        satisfaction.setScore(scoreDTO.getScore());
        satisfaction.setStatus(SatisfactionStatusEnum.FILLED);
        return save(satisfaction);
        save(satisfaction);
        personalNotificationService.createScorefactionToConsultant(satisfaction);
        return satisfaction;
    }
    
    public Satisfaction createSatisfaction(Appointment appointment) {
pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java
@@ -15,6 +15,7 @@
import org.springframework.web.bind.annotation.*;
import com.pollex.pam.service.AppointmentService;
import com.pollex.pam.service.PersonalNotificationService;
import com.pollex.pam.service.SatisfactionService;
import com.pollex.pam.service.dto.AppointmentCloseDTO;
import com.pollex.pam.service.dto.AppointmentCreateDTO;
@@ -35,10 +36,14 @@
    
    @Autowired
    AppointmentProcess abstractAppointmentProcess;
    @Autowired
    PersonalNotificationService personalNotificationService;
    @PutMapping("")
    public ResponseEntity<Void> updateAppointment(@RequestBody AppointmentUpdateDTO appointment) {
        appointmentService.updateAppointment(appointment);
    public ResponseEntity<Void> updateAppointment(@RequestBody AppointmentUpdateDTO dto) {
        Appointment appointment = appointmentService.updateAppointment(dto);
        personalNotificationService.createUpdateAppointmentToConsultant(appointment);
        return ResponseEntity.noContent().build();
    }