保誠-保戶業務員媒合平台
KillerADO
2021-12-23 07d6fd2c5c6a35a33ad0dd9556b63fd6156d0974
[fix] 暫時移除客戶預約的業務邏輯,因sit db尚未更新顧問的email

修改5個檔案
100 ■■■■■ 已變更過的檔案
pamapi/src/main/java/com/pollex/pam/domain/Consultant.java 12 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java 3 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/service/SendMsgService.java 77 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java 3 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/web/rest/TestSendMsgResource.java 5 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
pamapi/src/main/java/com/pollex/pam/domain/Consultant.java
@@ -71,9 +71,6 @@
    @Column(name = "communication_style")
    private String communicationStyle;
    @Column(name = "email")
    private String email;
    public Long getId() {
        return id;
    }
@@ -233,14 +230,6 @@
        this.communicationStyle = communicationStyle;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    @Override
    public String toString() {
        return "Consultant{" +
@@ -263,7 +252,6 @@
            ", award='" + award + '\'' +
            ", recommend=" + recommend +
            ", communicationStyle='" + communicationStyle + '\'' +
            ", email='" + email + '\'' +
            '}';
    }
}
pamapi/src/main/java/com/pollex/pam/service/AppointmentService.java
@@ -53,12 +53,11 @@
    @Autowired
    SatisfactionService satisfactionService;
    public Appointment customerCreateAppointment(AppointmentCreateDTO appointmentCreateDTO) {
    public void customerCreateAppointment(AppointmentCreateDTO appointmentCreateDTO) {
        Appointment appointment = appointmentDTOMapper.toAppointment(appointmentCreateDTO);
        appointment.setStatus(AVAILABLE);
        appointment.setCustomerId(SecurityUtils.getCustomerDBId());
        appointment.setCommunicateStatus(ContactStatusEnum.RESERVED);
        return appointmentRepository.save(appointment);
    }
    public void updateAppointment(AppointmentUpdateDTO updateAppointmentDTO) {
pamapi/src/main/java/com/pollex/pam/service/SendMsgService.java
@@ -45,83 +45,6 @@
    @Autowired
    SpringTemplateEngine springTemplateEngine;
    public void sendAppointmentNotify(Appointment appointment) {
        Assert.notNull(appointment);
        log.debug("is need sending notify msg = {}", applicationProperties.isSendNotifyMsg());
        if(applicationProperties.isSendNotifyMsg()) {
            log.debug("sending appointment notify, appointmentId = {}", appointment.getId());
            sendAppointmentNotifyBySMS(appointment);
            sendAppointmentNotifyByEmail(appointment);
            // todo 需確認保誠是否有需求使用html mail
            // sendAppointmentNotifyByHtmlEmail(appointment);
        }
    }
    private void sendAppointmentNotifyBySMS(Appointment appointment) throws SendSMSFailException {
        String msg = getAppointmentNotifyWording(appointment);
        String consultantMobile = consultantRepository.findOneByAgentNo(appointment.getAgentNo()).get().getPhoneNumber();
        try {
            sendMsgBySMS(consultantMobile, msg);
        } catch (SendSMSFailException e) {
            log.debug("send sms failed, appointment Id = {}", appointment.getId(), e);
        }
    }
    private void sendAppointmentNotifyByEmail(Appointment appointment) {
        // todo 需得知保誠系統寄件信箱 (並改於設定檔中)
        String senderEmail = applicationProperties.getEmail().getSenderEmail();
        String consultantEmail = consultantRepository.findOneByAgentNo(appointment.getAgentNo()).get().getEmail();
        String content = getAppointmentNotifyWording(appointment);
        try {
            sendMsgByEmail(senderEmail, consultantEmail, EMAIL_SUBJECT, content, false);
        } catch (SendEmailFailException e) {
            log.debug("send email failed, appointment Id = {}", appointment.getId(), e);
        }
    }
    private void sendAppointmentNotifyByHtmlEmail(Appointment appointment) {
        // todo 需得知保誠系統寄件信箱 (並改於設定檔中)
        String senderEmail = applicationProperties.getEmail().getSenderEmail();
        String consultantEmail = consultantRepository.findOneByAgentNo(appointment.getAgentNo()).get().getEmail();
        String customerMobile = appointment.getPhone();
        String normalContent;
        if(StringUtils.hasText(customerMobile)) {
            normalContent = "親愛的顧問您好,您有一筆來自保誠媒合平台的新預約單,該客戶手機號碼為" + customerMobile + "\n";
        }
        else {
            normalContent = "親愛的顧問您好,您有一筆來自保誠媒合平台的新預約單\n";
        }
        Context context = new Context();
        context.setVariable("content", normalContent);
        context.setVariable("urlHint", getAppointmentDetailUrl(appointment.getId()));
        String content = springTemplateEngine.process("mail/appointmentNotifyEmail", context);
        try {
            sendMsgByEmail(senderEmail, consultantEmail, EMAIL_SUBJECT, content, true);
        } catch (SendEmailFailException e) {
            log.debug("send email failed, appointment Id = {}", appointment.getId(), e);
        }
    }
    private String getAppointmentNotifyWording(Appointment appointment) {
        String normalContent;
        if(StringUtils.hasText(appointment.getPhone())) {
            normalContent = "親愛的顧問您好,您有一筆來自保誠媒合平台的新預約單,該客戶手機號碼為" + appointment.getPhone() + "\n";
        }
        else {
            normalContent = "親愛的顧問您好,您有一筆來自保誠媒合平台的新預約單\n";
        }
        String urlContent = "點擊網址:" + getAppointmentDetailUrl(appointment.getId()) + " 開啟媒合平台查看。";
        return normalContent + urlContent;
    }
    public SendSMSResponse sendMsgBySMS(String toMobile, String content) throws SendSMSFailException {
        SMS smsProperties = applicationProperties.getSms();
pamapi/src/main/java/com/pollex/pam/web/rest/AppointmentResource.java
@@ -39,8 +39,7 @@
    @PostMapping("/customer/create")
    public void clientCreateAppointment(@RequestBody AppointmentCreateDTO appointmentCreateDTO) {
        Appointment appointment = appointmentService.customerCreateAppointment(appointmentCreateDTO);
        sendMsgService.sendAppointmentNotify(appointment);
        appointmentService.customerCreateAppointment(appointmentCreateDTO);
    }
    @PostMapping("/markAsContacted/{appointmentId}")
pamapi/src/main/java/com/pollex/pam/web/rest/TestSendMsgResource.java
@@ -41,9 +41,4 @@
    ) {
        return ResponseEntity.ok(sendMsgService.sendMsgByHtmlTestTemplateEmail(from, to));
    }
    @GetMapping("/appointment/{appointmentId}")
    public void sendAppointmentNotify(@PathVariable Long appointmentId) {
        sendMsgService.sendAppointmentNotify(appointmentRepository.findById(appointmentId).get());
    }
}