From 280ef5100bece9b40ac51736aef037704a52a4ca Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期四, 30 七月 2026 14:58:52 +0800
Subject: [PATCH] update

---
 backend/src/main/java/com/tourguide/integration/sms/AliyunSmsCodeSender.java |   40 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/backend/src/main/java/com/tourguide/integration/sms/AliyunSmsCodeSender.java b/backend/src/main/java/com/tourguide/integration/sms/AliyunSmsCodeSender.java
index f5d77e3..089cdc9 100644
--- a/backend/src/main/java/com/tourguide/integration/sms/AliyunSmsCodeSender.java
+++ b/backend/src/main/java/com/tourguide/integration/sms/AliyunSmsCodeSender.java
@@ -15,6 +15,8 @@
 import org.springframework.util.StringUtils;
 
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
 @Component
 public class AliyunSmsCodeSender implements SmsCodeSender {
@@ -47,6 +49,32 @@
         }
     }
 
+    @Override
+    public void sendGuideAuditResult(String phone, String guideName, boolean approved) {
+        String templateCode = approved
+                ? properties.getGuideAuditApprovedTemplateCode()
+                : properties.getGuideAuditRejectedTemplateCode();
+        if (!hasCommonConfiguration() || !StringUtils.hasText(templateCode)) {
+            LOGGER.warn("导游审核短信模板未配置,跳过发送,手机号:{},审核结果:{}", maskPhone(phone), approved);
+            return;
+        }
+        Map<String, String> parameters = new HashMap<String, String>();
+        parameters.put("name", guideName == null ? "导游" : guideName);
+        try {
+            SendSmsResponse response = createClient().sendSms(new SendSmsRequest()
+                    .setPhoneNumbers(phone)
+                    .setSignName(properties.getSignName())
+                    .setTemplateCode(templateCode)
+                    .setTemplateParam(objectMapper.writeValueAsString(parameters)));
+            ensureSuccess(phone, response == null ? null : response.getBody());
+        } catch (BusinessException exception) {
+            throw exception;
+        } catch (Exception exception) {
+            LOGGER.error("调用阿里云导游审核短信服务失败,手机号:{}", maskPhone(phone), exception);
+            throw new BusinessException(502, "审核短信发送失败");
+        }
+    }
+
     private Client createClient() throws Exception {
         Config config = new Config()
                 .setAccessKeyId(properties.getAccessKeyId())
@@ -71,15 +99,19 @@
     }
 
     private void ensureConfigured() {
-        if (!StringUtils.hasText(properties.getAccessKeyId())
-                || !StringUtils.hasText(properties.getAccessKeySecret())
-                || !StringUtils.hasText(properties.getEndpoint())
-                || !StringUtils.hasText(properties.getSignName())
+        if (!hasCommonConfiguration()
                 || !StringUtils.hasText(properties.getLoginTemplateCode())) {
             throw new BusinessException(503, "阿里云短信配置未完成");
         }
     }
 
+    private boolean hasCommonConfiguration() {
+        return StringUtils.hasText(properties.getAccessKeyId())
+                && StringUtils.hasText(properties.getAccessKeySecret())
+                && StringUtils.hasText(properties.getEndpoint())
+                && StringUtils.hasText(properties.getSignName());
+    }
+
     private String maskPhone(String phone) {
         if (phone == null || phone.length() < 7) {
             return "****";

--
Gitblit v1.7.1