From 7c43ab636abd3818816b96301b43a5c0812d5d84 Mon Sep 17 00:00:00 2001 From: xiaowang <2161656029@qq.com> Date: Sun, 6 Sep 2026 18:18:45 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Salon=E7=9F=AD=E4=BF=A1?= =?UTF-8?q?=E9=98=BF=E9=87=8C=E4=BA=91=E9=80=9A=E9=81=93=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../短信模板编码映射调整_20260906.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/scripts/sql/短信模板编码映射调整_20260906/短信模板编码映射调整_20260906.sql b/docs/scripts/sql/短信模板编码映射调整_20260906/短信模板编码映射调整_20260906.sql index 98f542e4..6e411e8b 100644 --- a/docs/scripts/sql/短信模板编码映射调整_20260906/短信模板编码映射调整_20260906.sql +++ b/docs/scripts/sql/短信模板编码映射调整_20260906/短信模板编码映射调整_20260906.sql @@ -1,6 +1,7 @@ -- Salon 短信验证码模板编码映射调整 -- 版本:0.0.1 -- 说明:MessageHub 已配置阿里云 100001-100005 与 Spug SPUG_SMS_VERIFY_1-4 模板。 +-- 阿里云短信认证通道 ID:314055468907909120。 START TRANSACTION; @@ -13,6 +14,7 @@ SET template_code = CASE scene_code WHEN 'USER_CHANGE_PHONE_SMS_CODE' THEN '100002' WHEN 'USER_CHANGE_PASSWORD_SMS_CODE' THEN '100003' END, + channel_id = 314055468907909120, send_method = 'ALIYUN_SMS_VERIFY', update_time = NOW() WHERE platform = 'SMS' @@ -29,7 +31,7 @@ WHERE platform = 'SMS' COMMIT; -SELECT scene_code, template_code, send_method +SELECT scene_code, template_code, channel_id, send_method FROM t_messagehub_push_config WHERE platform = 'SMS' AND source_system = 'jayucloud-salon' -- 2.54.0 From dc46ff359b02d44869a8518031eb346d45313df8 Mon Sep 17 00:00:00 2001 From: xiaowang <2161656029@qq.com> Date: Sun, 6 Sep 2026 20:50:19 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=88=87=E6=8D=A2Salon=E7=9F=AD=E4=BF=A1?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E4=B8=BASpug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../短信模板编码映射调整_20260906.sql | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/scripts/sql/短信模板编码映射调整_20260906/短信模板编码映射调整_20260906.sql b/docs/scripts/sql/短信模板编码映射调整_20260906/短信模板编码映射调整_20260906.sql index 6e411e8b..4920d9c6 100644 --- a/docs/scripts/sql/短信模板编码映射调整_20260906/短信模板编码映射调整_20260906.sql +++ b/docs/scripts/sql/短信模板编码映射调整_20260906/短信模板编码映射调整_20260906.sql @@ -1,21 +1,20 @@ -- Salon 短信验证码模板编码映射调整 -- 版本:0.0.1 --- 说明:MessageHub 已配置阿里云 100001-100005 与 Spug SPUG_SMS_VERIFY_1-4 模板。 --- 阿里云短信认证通道 ID:314055468907909120。 +-- 说明:当前 Salon 使用 Spug 短信,模板 SPUG_SMS_VERIFY_1 支持 name、code、number 参数。 START TRANSACTION; UPDATE t_messagehub_push_config SET template_code = CASE scene_code - WHEN 'USER_REGISTER_SMS_CODE' THEN '100001' - WHEN 'USER_LOGIN_SMS_CODE' THEN '100001' - WHEN 'USER_RESET_PASSWORD_SMS_CODE' THEN '100003' - WHEN 'USER_BIND_PHONE_SMS_CODE' THEN '100004' - WHEN 'USER_CHANGE_PHONE_SMS_CODE' THEN '100002' - WHEN 'USER_CHANGE_PASSWORD_SMS_CODE' THEN '100003' + WHEN 'USER_REGISTER_SMS_CODE' THEN 'SPUG_SMS_VERIFY_1' + WHEN 'USER_LOGIN_SMS_CODE' THEN 'SPUG_SMS_VERIFY_1' + WHEN 'USER_RESET_PASSWORD_SMS_CODE' THEN 'SPUG_SMS_VERIFY_1' + WHEN 'USER_BIND_PHONE_SMS_CODE' THEN 'SPUG_SMS_VERIFY_1' + WHEN 'USER_CHANGE_PHONE_SMS_CODE' THEN 'SPUG_SMS_VERIFY_1' + WHEN 'USER_CHANGE_PASSWORD_SMS_CODE' THEN 'SPUG_SMS_VERIFY_1' END, - channel_id = 314055468907909120, - send_method = 'ALIYUN_SMS_VERIFY', + channel_id = NULL, + send_method = 'SPUG', update_time = NOW() WHERE platform = 'SMS' AND source_system = 'jayucloud-salon' -- 2.54.0 From 3401c2f5e560c46d01d799b60d2da05184390136 Mon Sep 17 00:00:00 2001 From: xiaowang <2161656029@qq.com> Date: Sun, 6 Sep 2026 21:41:09 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Salon=E7=9F=AD=E4=BF=A1?= =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E5=85=A8=E5=B1=80=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/MessageHubPushConfigService.java | 2 + .../impl/MessageHubPushConfigServiceImpl.java | 48 +++++++++++++++ .../SystemParameterConfigServiceImpl.java | 5 ++ .../src/views/admin/SystemSettingsView.vue | 38 +++++++++++- .../短信供应商全局切换_20260906.sql | 14 +++++ ...-09-06-salon-sms-provider-switch-design.md | 59 +++++++++++++++++++ 6 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 docs/scripts/sql/短信供应商全局切换_20260906/短信供应商全局切换_20260906.sql create mode 100644 docs/superpowers/specs/2026-09-06-salon-sms-provider-switch-design.md diff --git a/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/integration/service/MessageHubPushConfigService.java b/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/integration/service/MessageHubPushConfigService.java index 65994c02..9a25aa3b 100644 --- a/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/integration/service/MessageHubPushConfigService.java +++ b/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/integration/service/MessageHubPushConfigService.java @@ -68,4 +68,6 @@ public interface MessageHubPushConfigService { * @return MessageHubPushConfigDO result consumed by the caller or returned to the frontend */ MessageHubPushConfigDO getEnabledConfig(String sceneCode); + + void switchSmsProvider(UserDO currentUser, String provider); } diff --git a/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/integration/service/impl/MessageHubPushConfigServiceImpl.java b/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/integration/service/impl/MessageHubPushConfigServiceImpl.java index 05ae64d9..381d7755 100644 --- a/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/integration/service/impl/MessageHubPushConfigServiceImpl.java +++ b/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/integration/service/impl/MessageHubPushConfigServiceImpl.java @@ -26,6 +26,12 @@ import java.util.stream.Collectors; * Beginner guide: follow the call chain Controller -> Service -> ServiceImpl -> Mapper/support class. */ public class MessageHubPushConfigServiceImpl implements MessageHubPushConfigService { + private static final String SPUG_PROVIDER = "SPUG"; + private static final String ALIYUN_PROVIDER = "ALIYUN_SMS_VERIFY"; + private static final long ALIYUN_CHANNEL_ID = 314055468907909120L; + private static final List SMS_SCENES = List.of( + "USER_REGISTER_SMS_CODE", "USER_LOGIN_SMS_CODE", "USER_RESET_PASSWORD_SMS_CODE", + "USER_BIND_PHONE_SMS_CODE", "USER_CHANGE_PHONE_SMS_CODE", "USER_CHANGE_PASSWORD_SMS_CODE"); /** * Variable `configMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls. */ @@ -214,6 +220,48 @@ public class MessageHubPushConfigServiceImpl implements MessageHubPushConfigServ .last("LIMIT 1")); } + @Override + @Transactional(rollbackFor = Exception.class) + public void switchSmsProvider(UserDO currentUser, String provider) { + ensurePlatformAdmin(currentUser); + String normalizedProvider = normalizeSmsProvider(provider); + String templateCode = SPUG_PROVIDER.equals(normalizedProvider) ? "SPUG_SMS_VERIFY_1" : null; + String sendMethod = normalizedProvider; + Long channelId = SPUG_PROVIDER.equals(normalizedProvider) ? null : ALIYUN_CHANNEL_ID; + List configs = configMapper.selectList(new LambdaQueryWrapper() + .in(MessageHubPushConfigDO::getSceneCode, SMS_SCENES) + .eq(MessageHubPushConfigDO::getPlatform, "SMS") + .eq(MessageHubPushConfigDO::getIsDelete, 0)); + if (configs.size() != SMS_SCENES.size()) { + throw new IllegalStateException("短信场景配置不完整,无法切换供应商"); + } + for (MessageHubPushConfigDO config : configs) { + String sceneTemplate = templateCode == null ? aliyunTemplate(config.getSceneCode()) : templateCode; + config.setTemplateCode(sceneTemplate); + config.setChannelId(channelId); + config.setSendMethod(sendMethod); + configMapper.updateById(config); + } + } + + private String normalizeSmsProvider(String provider) { + String value = normalizeUpper(provider, ""); + if (!SPUG_PROVIDER.equals(value) && !ALIYUN_PROVIDER.equals(value)) { + throw new IllegalArgumentException("短信供应商仅支持 SPUG 或 ALIYUN_SMS_VERIFY"); + } + return value; + } + + private String aliyunTemplate(String sceneCode) { + return switch (sceneCode) { + case "USER_REGISTER_SMS_CODE", "USER_LOGIN_SMS_CODE" -> "100001"; + case "USER_CHANGE_PHONE_SMS_CODE" -> "100002"; + case "USER_RESET_PASSWORD_SMS_CODE", "USER_CHANGE_PASSWORD_SMS_CODE" -> "100003"; + case "USER_BIND_PHONE_SMS_CODE" -> "100004"; + default -> throw new IllegalArgumentException("不支持的短信场景: " + sceneCode); + }; + } + /** * Run business method `apply`. * Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result. diff --git a/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/system/service/impl/SystemParameterConfigServiceImpl.java b/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/system/service/impl/SystemParameterConfigServiceImpl.java index b4b82638..5a939579 100644 --- a/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/system/service/impl/SystemParameterConfigServiceImpl.java +++ b/JC-Salon-Core/src/main/java/com/xiaowang/jacyucloudsalon/core/modules/system/service/impl/SystemParameterConfigServiceImpl.java @@ -8,6 +8,7 @@ import com.xiaowang.jacyucloudsalon.core.modules.system.mapper.SystemParameterCo import com.xiaowang.jacyucloudsalon.core.modules.system.service.SystemParameterConfigService; import com.xiaowang.jacyucloudsalon.core.modules.system.support.AdminDefaultPasswordSupport; import com.xiaowang.jacyucloudsalon.core.modules.system.vo.SystemParameterConfigVO; +import com.xiaowang.jacyucloudsalon.core.modules.integration.service.MessageHubPushConfigService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -30,6 +31,7 @@ public class SystemParameterConfigServiceImpl implements SystemParameterConfigSe * Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state. */ private final SystemParameterConfigMapper configMapper; + private final MessageHubPushConfigService messageHubPushConfigService; @Override /** @@ -81,6 +83,9 @@ public class SystemParameterConfigServiceImpl implements SystemParameterConfigSe } else { configMapper.updateById(config); } + if ("SMS".equals(group) && "SMS_PROVIDER".equals(key)) { + messageHubPushConfigService.switchSmsProvider(currentUser, config.getConfigValue()); + } return true; } diff --git a/JC-Salon-Frontend/src/views/admin/SystemSettingsView.vue b/JC-Salon-Frontend/src/views/admin/SystemSettingsView.vue index 396f9bc7..e0aebab3 100644 --- a/JC-Salon-Frontend/src/views/admin/SystemSettingsView.vue +++ b/JC-Salon-Frontend/src/views/admin/SystemSettingsView.vue @@ -1,6 +1,15 @@