增加系统接入诊断基础能力 #97

Merged
xiaowang merged 2 commits from dev into sit 2026-11-04 14:52:43 +08:00
21 changed files with 1310 additions and 14 deletions
@@ -7,6 +7,7 @@ import com.xiaowang.jayucloud.salon.core.modules.privacy.service.ContentModerati
import com.xiaowang.jayucloud.salon.core.modules.privacy.support.WechatCallbackCrypto;
import com.xiaowang.jayucloud.salon.core.modules.system.secure.ModerationRuntimeConfig;
import com.xiaowang.jayucloud.salon.core.modules.system.service.SecureIntegrationConfigService;
import com.xiaowang.jayucloud.salon.core.modules.system.service.IntegrationProbeService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
@@ -24,6 +25,7 @@ public class WechatContentModerationCallbackController {
private final WechatMiniProperties wechatProperties;
private final WechatCallbackCrypto crypto;
private final ContentModerationService contentModerationService;
private final IntegrationProbeService integrationProbeService;
private final ObjectMapper objectMapper;
@GetMapping("/callback")
@@ -88,7 +90,9 @@ public class WechatContentModerationCallbackController {
extra = firstText(root, "extra", "Extra");
}
if (!StringUtils.hasText(taskId)) throw new IllegalArgumentException("微信审核回调缺少任务标识");
contentModerationService.handleWechatImageResult(taskId, suggest, reason, decodeSourceEnvVersion(extra));
if (!integrationProbeService.handleImageCallback(taskId, suggest, decodeProbeId(extra))) {
contentModerationService.handleWechatImageResult(taskId, suggest, reason, decodeSourceEnvVersion(extra));
}
return "success";
}
@@ -102,6 +106,16 @@ public class WechatContentModerationCallbackController {
}
}
private String decodeProbeId(String extra) {
if (!StringUtils.hasText(extra)) return null;
try {
JsonNode payload = objectMapper.readTree(extra);
return firstText(payload, "probeId", "probe_id");
} catch (Exception ignored) {
return null;
}
}
private String extractEncryptedPayload(String body) throws Exception {
if (!StringUtils.hasText(body)) {
throw new IllegalArgumentException("微信审核回调消息体为空");
@@ -62,6 +62,28 @@ public class WechatContentModerationProvider implements ContentModerationProvide
@Override
public ModerationOutcome submitImage(String contentType, String imageUrl, String openId, String sourceEnvVersion) {
return submitImageWithExtra(contentType, imageUrl, openId, encodeSourceEnvVersion(sourceEnvVersion));
}
public ModerationOutcome submitTestImage(String imageUrl, String openId, String probeId, String sourceEnvVersion) {
Map<String, String> extra = new LinkedHashMap<>();
extra.put("envVersion", normalizeEnvVersion(sourceEnvVersion));
extra.put("probeId", probeId);
try {
return submitImageWithExtra("INTEGRATION_PROBE", imageUrl, openId, objectMapper.writeValueAsString(extra));
} catch (java.io.IOException exception) {
throw new IllegalStateException("无法编码微信审核测试标识", exception);
}
}
private String normalizeEnvVersion(String value) {
if ("developer".equalsIgnoreCase(value) || "develop".equalsIgnoreCase(value)) return "develop";
if ("trial".equalsIgnoreCase(value)) return "trial";
if ("formal".equalsIgnoreCase(value) || "release".equalsIgnoreCase(value)) return "release";
return "UNKNOWN";
}
private ModerationOutcome submitImageWithExtra(String contentType, String imageUrl, String openId, String extra) {
if (!StringUtils.hasText(openId)) return pending("OPENID_REQUIRED", "缺少微信作者身份,转人工复核");
if (!StringUtils.hasText(imageUrl) || !imageUrl.startsWith("https://")) {
return retry("IMAGE_URL_INVALID", "审核图片需要短期有效的 HTTPS 地址");
@@ -72,7 +94,7 @@ public class WechatContentModerationProvider implements ContentModerationProvide
payload.put("version", 2);
payload.put("scene", properties.getScene());
payload.put("openid", openId);
payload.put("extra", encodeSourceEnvVersion(sourceEnvVersion));
payload.put("extra", extra);
return parseResult(post(IMAGE_CHECK_URL, payload), true);
}
@@ -7,7 +7,10 @@ import com.xiaowang.jayucloud.salon.core.modules.security.support.AdminScopeHelp
import com.xiaowang.jayucloud.salon.core.modules.security.support.SecurityAuditActions;
import com.xiaowang.jayucloud.salon.core.modules.security.support.SecurityAuditSupport;
import com.xiaowang.jayucloud.salon.core.modules.system.dto.SecureIntegrationConfigDTO;
import com.xiaowang.jayucloud.salon.core.modules.system.dto.IntegrationProbeRequestDTO;
import com.xiaowang.jayucloud.salon.core.modules.system.service.IntegrationProbeService;
import com.xiaowang.jayucloud.salon.core.modules.system.service.SecureIntegrationConfigService;
import com.xiaowang.jayucloud.salon.core.modules.system.vo.IntegrationProbeResultVO;
import com.xiaowang.jayucloud.salon.core.modules.system.vo.SecureIntegrationConfigVO;
import com.xiaowang.jayucloud.salon.core.modules.user.entity.UserDO;
import lombok.RequiredArgsConstructor;
@@ -20,12 +23,14 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.Map;
import java.util.List;
@RestController
@RequiredArgsConstructor
@RequestMapping("/admin/system-settings/secure-integration")
public class AdminSecureIntegrationConfigController {
private final SecureIntegrationConfigService secureIntegrationConfigService;
private final IntegrationProbeService integrationProbeService;
private final AdminScopeHelper adminScopeHelper;
private final SecurityAuditSupport securityAuditSupport;
@@ -33,7 +38,9 @@ public class AdminSecureIntegrationConfigController {
@RequirePermission("messagehub:config:manage")
public Result<SecureIntegrationConfigVO> getConfig(HttpServletRequest request) {
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
return Result.success(secureIntegrationConfigService.getAdminConfig(currentUser));
SecureIntegrationConfigVO config = secureIntegrationConfigService.getAdminConfig(currentUser);
config.setProbeResults(integrationProbeService.listLatest(currentUser));
return Result.success(config);
}
@GetMapping("/map-runtime")
@@ -74,4 +81,33 @@ public class AdminSecureIntegrationConfigController {
throw exception;
}
}
@GetMapping("/probe-results")
@RequirePermission("messagehub:config:manage")
public Result<List<IntegrationProbeResultVO>> listProbeResults(HttpServletRequest request) {
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
return Result.success(integrationProbeService.listLatest(currentUser));
}
@PostMapping("/probe")
@RequirePermission("messagehub:config:manage")
@OperationGuard(action = "secure-integration-probe", ttlSeconds = 8, message = "接入测试处理中,请勿重复提交")
public Result<IntegrationProbeResultVO> probe(HttpServletRequest request,
@Valid @RequestBody IntegrationProbeRequestDTO dto) {
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
try {
IntegrationProbeResultVO result = integrationProbeService.probe(currentUser, dto);
String auditDetail = "probe=" + dto.getService() + "/" + dto.getOperation() + ",status=" + result.getStatus();
if ("FAIL".equals(result.getStatus())) {
securityAuditSupport.fail(request, SecurityAuditActions.SECURE_CONFIG_UPDATE, auditDetail);
} else {
securityAuditSupport.success(request, SecurityAuditActions.SECURE_CONFIG_UPDATE, auditDetail);
}
return Result.success(result);
} catch (RuntimeException exception) {
securityAuditSupport.fail(request, SecurityAuditActions.SECURE_CONFIG_UPDATE,
"probe=" + dto.getService() + "/" + dto.getOperation());
throw exception;
}
}
}
@@ -0,0 +1,18 @@
package com.xiaowang.jayucloud.salon.core.modules.system.dto;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class IntegrationProbeRequestDTO {
@NotBlank(message = "测试服务不能为空")
private String service;
@NotBlank(message = "测试操作不能为空")
private String operation;
private String mode = "DIAGNOSTIC";
private String targetPhone;
private Boolean confirmed;
}
@@ -0,0 +1,54 @@
package com.xiaowang.jayucloud.salon.core.modules.system.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xiaowang.jayucloud.salon.core.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("t_integration_probe_result")
public class IntegrationProbeResultDO extends BaseEntity {
@TableField("service_code")
private String serviceCode;
@TableField("operation_code")
private String operationCode;
@TableField("mode")
private String mode;
@TableField("provider")
private String provider;
@TableField("status")
private String status;
@TableField("summary")
private String summary;
@TableField("error_code")
private String errorCode;
@TableField("checks_json")
private String checksJson;
@TableField("remote_task_id")
private String remoteTaskId;
@TableField("correlation_key")
private String correlationKey;
@TableField("temporary_object_provider")
private String temporaryObjectProvider;
@TableField("temporary_object_name")
private String temporaryObjectName;
@TableField("expires_at")
private java.time.LocalDateTime expiresAt;
@TableField("checked_at")
private java.time.LocalDateTime checkedAt;
}
@@ -0,0 +1,9 @@
package com.xiaowang.jayucloud.salon.core.modules.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiaowang.jayucloud.salon.core.modules.system.entity.IntegrationProbeResultDO;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface IntegrationProbeResultMapper extends BaseMapper<IntegrationProbeResultDO> {
}
@@ -0,0 +1,15 @@
package com.xiaowang.jayucloud.salon.core.modules.system.service;
import com.xiaowang.jayucloud.salon.core.modules.system.dto.IntegrationProbeRequestDTO;
import com.xiaowang.jayucloud.salon.core.modules.system.vo.IntegrationProbeResultVO;
import com.xiaowang.jayucloud.salon.core.modules.user.entity.UserDO;
import java.util.List;
public interface IntegrationProbeService {
IntegrationProbeResultVO probe(UserDO currentUser, IntegrationProbeRequestDTO request);
List<IntegrationProbeResultVO> listLatest(UserDO currentUser);
boolean handleImageCallback(String taskId, String suggest, String probeId);
}
@@ -0,0 +1,581 @@
package com.xiaowang.jayucloud.salon.core.modules.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.xiaowang.jayucloud.salon.core.config.WechatMiniProperties;
import com.xiaowang.jayucloud.salon.core.modules.file.service.ObjectStorageProvider;
import com.xiaowang.jayucloud.salon.core.modules.integration.entity.WechatMiniBindingDO;
import com.xiaowang.jayucloud.salon.core.modules.integration.mapper.WechatMiniBindingMapper;
import com.xiaowang.jayucloud.salon.core.modules.integration.service.MessageHubClientService;
import com.xiaowang.jayucloud.salon.core.modules.integration.service.MessageHubPushConfigService;
import com.xiaowang.jayucloud.salon.core.modules.integration.service.WechatMiniClientService;
import com.xiaowang.jayucloud.salon.core.modules.integration.service.WechatSubscribeMessageService;
import com.xiaowang.jayucloud.salon.core.modules.privacy.moderation.ModerationOutcome;
import com.xiaowang.jayucloud.salon.core.modules.privacy.moderation.WechatContentModerationProvider;
import com.xiaowang.jayucloud.salon.core.modules.system.dto.IntegrationProbeRequestDTO;
import com.xiaowang.jayucloud.salon.core.modules.system.entity.IntegrationProbeResultDO;
import com.xiaowang.jayucloud.salon.core.modules.system.mapper.IntegrationProbeResultMapper;
import com.xiaowang.jayucloud.salon.core.modules.system.service.IntegrationProbeService;
import com.xiaowang.jayucloud.salon.core.modules.system.service.SecureIntegrationConfigService;
import com.xiaowang.jayucloud.salon.core.modules.system.vo.IntegrationProbeCheckVO;
import com.xiaowang.jayucloud.salon.core.modules.system.vo.IntegrationProbeResultVO;
import com.xiaowang.jayucloud.salon.core.modules.system.vo.SecureIntegrationConfigVO;
import com.xiaowang.jayucloud.salon.core.modules.user.entity.UserDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.core.env.Environment;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
@Slf4j
@Service
public class IntegrationProbeServiceImpl implements IntegrationProbeService {
private static final String[] SERVICES = {"CONTENT_MODERATION", "MAP", "OBJECT_STORAGE", "SMS", "SUBSCRIBE_MESSAGE"};
private static final String TEXT = "CONTENT_MODERATION";
private static final String MAP = "MAP";
private static final String STORAGE = "OBJECT_STORAGE";
private static final String SMS = "SMS";
private static final String SUBSCRIBE = "SUBSCRIBE_MESSAGE";
private final IntegrationProbeResultMapper resultMapper;
private final ObjectMapper objectMapper;
private final SecureIntegrationConfigService secureIntegrationConfigService;
private final WechatMiniProperties wechatMiniProperties;
private final WechatMiniClientService wechatMiniClientService;
private final WechatMiniBindingMapper bindingMapper;
private final WechatContentModerationProvider wechatContentModerationProvider;
private final List<ObjectStorageProvider> storageProviders;
private final MessageHubPushConfigService messageHubPushConfigService;
private final MessageHubClientService messageHubClientService;
private final RestTemplate restTemplate;
private final Environment environment;
public IntegrationProbeServiceImpl(IntegrationProbeResultMapper resultMapper,
ObjectMapper objectMapper,
SecureIntegrationConfigService secureIntegrationConfigService,
WechatMiniProperties wechatMiniProperties,
WechatMiniClientService wechatMiniClientService,
WechatMiniBindingMapper bindingMapper,
WechatContentModerationProvider wechatContentModerationProvider,
List<ObjectStorageProvider> storageProviders,
MessageHubPushConfigService messageHubPushConfigService,
MessageHubClientService messageHubClientService,
@Qualifier("restTemplate") RestTemplate restTemplate,
Environment environment) {
this.resultMapper = resultMapper;
this.objectMapper = objectMapper;
this.secureIntegrationConfigService = secureIntegrationConfigService;
this.wechatMiniProperties = wechatMiniProperties;
this.wechatMiniClientService = wechatMiniClientService;
this.bindingMapper = bindingMapper;
this.wechatContentModerationProvider = wechatContentModerationProvider;
this.storageProviders = storageProviders;
this.messageHubPushConfigService = messageHubPushConfigService;
this.messageHubClientService = messageHubClientService;
this.restTemplate = restTemplate;
this.environment = environment;
}
@Override
public IntegrationProbeResultVO probe(UserDO currentUser, IntegrationProbeRequestDTO request) {
requirePlatformAdmin(currentUser);
String service = normalize(request.getService());
String operation = normalize(request.getOperation());
String mode = normalize(request.getMode());
if (!Arrays.asList(SERVICES).contains(service)) throw new IllegalArgumentException("不支持的测试服务");
if (!"DIAGNOSTIC".equals(mode) && !"REAL".equals(mode)) throw new IllegalArgumentException("不支持的测试模式");
validateOperation(service, operation, mode);
if ("REAL".equals(mode) && (SMS.equals(service) || SUBSCRIBE.equals(service)) && !Boolean.TRUE.equals(request.getConfirmed())) {
throw new IllegalArgumentException("真实发送测试必须先确认可能产生的外部副作用");
}
IntegrationProbeResultVO result;
try {
result = switch (service) {
case TEXT -> probeModeration(currentUser, operation, mode);
case MAP -> probeMap(currentUser, operation);
case STORAGE -> probeStorage(operation);
case SMS -> probeSms(currentUser, operation, mode, request.getTargetPhone());
case SUBSCRIBE -> probeSubscribe(operation, mode);
default -> failure(service, operation, mode, "不支持的测试服务", "UNSUPPORTED");
};
} catch (RuntimeException exception) {
log.warn("系统接入探测失败,service={}, operation={}, mode={}, type={}", service, operation, mode, exception.getClass().getSimpleName());
result = failure(service, operation, mode, safeMessage(exception), "PROBE_FAILURE");
}
save(result);
return result;
}
@Override
public List<IntegrationProbeResultVO> listLatest(UserDO currentUser) {
requirePlatformAdmin(currentUser);
return resultMapper.selectList(new LambdaQueryWrapper<IntegrationProbeResultDO>()
.orderByAsc(IntegrationProbeResultDO::getServiceCode)
.orderByAsc(IntegrationProbeResultDO::getOperationCode))
.stream().map(this::toVO).toList();
}
@Override
public boolean handleImageCallback(String taskId, String suggest, String probeId) {
IntegrationProbeResultDO row = null;
if (StringUtils.hasText(taskId)) {
row = resultMapper.selectOne(new LambdaQueryWrapper<IntegrationProbeResultDO>()
.eq(IntegrationProbeResultDO::getRemoteTaskId, taskId).last("LIMIT 1"));
}
if (row == null && StringUtils.hasText(probeId)) {
row = resultMapper.selectOne(new LambdaQueryWrapper<IntegrationProbeResultDO>()
.eq(IntegrationProbeResultDO::getCorrelationKey, probeId).last("LIMIT 1"));
}
if (row == null) return false;
if (!TEXT.equals(row.getServiceCode()) || !"IMAGE_CALLBACK".equals(row.getOperationCode())) return false;
if (!"PENDING".equals(row.getStatus())) return true;
if (row.getExpiresAt() != null && row.getExpiresAt().isBefore(LocalDateTime.now())) {
row.setStatus("FAIL");
row.setSummary("图片审核回调已超过等待期限");
row.setErrorCode("CALLBACK_TIMEOUT");
row.setCheckedAt(LocalDateTime.now());
deleteTemporaryObject(row);
resultMapper.updateById(row);
return true;
}
String candidateSuggest = StringUtils.hasText(suggest) ? suggest.trim().toLowerCase(Locale.ROOT) : "review";
String normalizedSuggest = List.of("pass", "review", "risky").contains(candidateSuggest) ? candidateSuggest : "unknown";
row.setStatus("pass".equals(normalizedSuggest) ? "PASS" : "review".equals(normalizedSuggest) ? "WARN" : "FAIL");
row.setSummary("微信图片审核回调:" + normalizedSuggest);
row.setCheckedAt(LocalDateTime.now());
try { row.setChecksJson(objectMapper.writeValueAsString(List.of(new IntegrationProbeCheckVO("微信图片审核回调", row.getStatus(), row.getSummary())))); }
catch (Exception ignored) { }
deleteTemporaryObject(row);
resultMapper.updateById(row);
return true;
}
@Scheduled(fixedDelay = 300000)
public void expirePendingImageProbes() {
List<IntegrationProbeResultDO> expired = resultMapper.selectList(new LambdaQueryWrapper<IntegrationProbeResultDO>()
.eq(IntegrationProbeResultDO::getServiceCode, TEXT)
.eq(IntegrationProbeResultDO::getOperationCode, "IMAGE_CALLBACK")
.eq(IntegrationProbeResultDO::getStatus, "PENDING")
.lt(IntegrationProbeResultDO::getExpiresAt, LocalDateTime.now()));
for (IntegrationProbeResultDO row : expired) {
row.setStatus("FAIL");
row.setSummary("图片审核回调超时,请检查微信回调地址和公网可达性");
row.setErrorCode("CALLBACK_TIMEOUT");
row.setCheckedAt(LocalDateTime.now());
deleteTemporaryObject(row);
resultMapper.updateById(row);
}
List<IntegrationProbeResultDO> cleanup = resultMapper.selectList(new LambdaQueryWrapper<IntegrationProbeResultDO>()
.isNotNull(IntegrationProbeResultDO::getTemporaryObjectName)
.lt(IntegrationProbeResultDO::getExpiresAt, LocalDateTime.now()));
for (IntegrationProbeResultDO row : cleanup) {
deleteTemporaryObject(row);
resultMapper.updateById(row);
}
}
private IntegrationProbeResultVO probeModeration(UserDO currentUser, String operation, String mode) {
SecureIntegrationConfigVO config = secureIntegrationConfigService.getAdminConfig(currentUser);
List<IntegrationProbeCheckVO> checks = new ArrayList<>();
String provider = config.getModerationProvider();
if ("WECHAT".equals(provider)) {
checks.add(check("审核 Provider", true, "微信内容安全审核", "未启用"));
checks.add(check("加密主密钥", Boolean.TRUE.equals(config.getEncryptionKeyConfigured()), "已配置", "未配置,安全接入密钥无法读取"));
checks.add(check("小程序凭据", Boolean.TRUE.equals(config.getWechatMiniAppConfigured()), "AppID 与 AppSecret 已配置", "AppID 或 AppSecret 未配置"));
String callbackUrl = config.getModerationCallbackUrl();
boolean callbackUrlValid = false;
try {
java.net.URI callback = java.net.URI.create(callbackUrl == null ? "" : callbackUrl);
callbackUrlValid = "https".equalsIgnoreCase(callback.getScheme())
&& StringUtils.hasText(callback.getHost())
&& (callback.getPort() == -1 || callback.getPort() == 443)
&& callback.getUserInfo() == null && callback.getQuery() == null && callback.getFragment() == null
&& "/api/integration/wechat/content-moderation/callback".equals(callback.getPath());
} catch (IllegalArgumentException ignored) { }
checks.add(check("回调 HTTPS 地址", callbackUrlValid, "公网 HTTPS 回调地址有效", "回调地址缺失或格式不正确"));
checks.add(check("回调 Token", Boolean.TRUE.equals(config.getModerationCallbackTokenConfigured()), "已配置", "未配置"));
checks.add(check("EncodingAESKey", Boolean.TRUE.equals(config.getModerationEncodingAesKeyConfigured()), "已配置", "未配置"));
checks.add(check("回调配置汇总", Boolean.TRUE.equals(config.getModerationCallbackReady()), "回调资料完整", "回调 URL、Token、AESKey、加密主密钥或 App 凭据不完整"));
} else if ("MOCK".equals(provider)) {
boolean mockAllowed = Boolean.TRUE.equals(config.getMockProviderAllowed());
checks.add(new IntegrationProbeCheckVO("审核 Provider", mockAllowed ? "PASS" : "FAIL", mockAllowed ? "本地模拟审核已启用" : "当前环境不允许模拟审核"));
checks.add(new IntegrationProbeCheckVO("真实接口", "WARN", "模拟渠道不会调用微信接口"));
} else {
checks.add(new IntegrationProbeCheckVO("审核 Provider", "WARN", "内容审核未启用,内容保持隔离"));
}
if ("CONFIG".equals(operation)) return result(TEXT, operation, mode, config.getModerationProvider(), statusForChecks(checks), "内容审核配置诊断完成", null, checks);
if ("MOCK".equals(config.getModerationProvider()) && Boolean.TRUE.equals(config.getMockProviderAllowed())) {
checks.add(new IntegrationProbeCheckVO("真实接口", "WARN", "当前使用本地模拟审核,不会调用微信接口"));
return result(TEXT, operation, mode, "MOCK", "WARN", "当前为本地模拟流程", null, checks);
}
if ("MOCK".equals(config.getModerationProvider())) return result(TEXT, operation, mode, "MOCK", "FAIL", "当前环境不允许使用模拟审核", "MOCK_NOT_ALLOWED", checks);
if (!"WECHAT".equals(config.getModerationProvider())) return result(TEXT, operation, mode, config.getModerationProvider(), "FAIL", "微信内容审核未启用", "PROVIDER_DISABLED", checks);
if (!Boolean.TRUE.equals(config.getModerationReady())) return result(TEXT, operation, mode, "WECHAT", "FAIL", "微信审核配置未就绪,未发起接口请求", "MODERATION_NOT_READY", checks);
String openId = findProbeOpenId();
if (!StringUtils.hasText(openId)) {
checks.add(new IntegrationProbeCheckVO("测试账号", "WARN", "当前环境没有可用微信绑定,请先使用体验版登录"));
return result(TEXT, operation, mode, "WECHAT", "WARN", "缺少可用于探测的微信绑定账号", "OPENID_REQUIRED", checks);
}
if ("IMAGE_CALLBACK".equals(operation)) return probeImageCallback(mode, openId, checks);
ModerationOutcome outcome = wechatContentModerationProvider.reviewText("INTEGRATION_PROBE", "Salon 接入测试", openId);
String status = outcome.status() == ModerationOutcome.Status.APPROVED ? "PASS" : outcome.status() == ModerationOutcome.Status.PENDING ? "WARN" : "FAIL";
checks.add(new IntegrationProbeCheckVO("微信文本接口", status, outcome.reason()));
return result(TEXT, "TEXT", mode, "WECHAT", status, status.equals("PASS") ? "微信文本审核接口调用成功" : outcome.reason(), outcome.code(), checks);
}
private IntegrationProbeResultVO probeImageCallback(String mode, String openId, List<IntegrationProbeCheckVO> checks) {
IntegrationProbeResultDO current = findResult(TEXT, "IMAGE_CALLBACK");
if (current != null && "PENDING".equals(current.getStatus()) && current.getExpiresAt() != null && current.getExpiresAt().isAfter(LocalDateTime.now())) {
return result(TEXT, "IMAGE_CALLBACK", mode, "WECHAT", "PENDING", "已有图片测试正在等待微信回调", null,
List.of(new IntegrationProbeCheckVO("微信图片异步接口", "PENDING", "等待上一条测试的微信回调或超时清理")));
}
if (current != null && StringUtils.hasText(current.getTemporaryObjectName())) {
deleteTemporaryObject(current);
resultMapper.updateById(current);
if (StringUtils.hasText(current.getTemporaryObjectName())) {
return result(TEXT, "IMAGE_CALLBACK", mode, "WECHAT", "FAIL", "上一张临时测试图片仍未清理,请稍后重试", "TEMP_CLEANUP_FAILED",
List.of(new IntegrationProbeCheckVO("临时图片清理", "FAIL", "无法确认旧测试文件已删除")));
}
}
String objectName = "integration-probe/" + UUID.randomUUID() + ".png";
String probeId = UUID.randomUUID().toString();
ObjectStorageProvider uploaded = null;
boolean awaitingCallback = false;
boolean pendingSaved = false;
try {
byte[] image = createProbePng();
for (ObjectStorageProvider provider : storageProviders) {
if (provider.isEnabled()) {
uploaded = provider;
provider.uploadStream(new java.io.ByteArrayInputStream(image), image.length, "image/png", objectName);
break;
}
}
if (uploaded == null) return result(TEXT, "IMAGE_CALLBACK", mode, "WECHAT", "FAIL", "没有可用对象存储,无法生成图片审核地址", "STORAGE_UNAVAILABLE", checks);
String url = uploaded.getPresignedUrl(objectName, 5);
if (!StringUtils.hasText(url) || !url.startsWith("https://")) {
checks.add(new IntegrationProbeCheckVO("临时图片地址", "FAIL", "对象存储未提供公网 HTTPS 签名地址"));
return result(TEXT, "IMAGE_CALLBACK", mode, "WECHAT", "FAIL", "对象存储未提供公网 HTTPS 签名地址", "IMAGE_URL_INVALID", checks);
}
savePendingImageProbe(mode, probeId, uploaded.providerCode(), objectName);
pendingSaved = true;
ModerationOutcome outcome = wechatContentModerationProvider.submitTestImage(url, openId, probeId,
wechatMiniProperties.getSubscribeMessageMiniprogramState());
String status = outcome.status() == ModerationOutcome.Status.PENDING ? "PENDING" : outcome.status() == ModerationOutcome.Status.APPROVED ? "PASS" : "FAIL";
checks.add(new IntegrationProbeCheckVO("微信图片异步接口", status, outcome.reason()));
awaitingCallback = "PENDING".equals(status);
updatePendingImageTask(probeId, outcome.remoteTaskId());
return result(TEXT, "IMAGE_CALLBACK", mode, "WECHAT", status, outcome.reason(), outcome.code(), checks);
} catch (Exception exception) {
checks.add(new IntegrationProbeCheckVO("微信图片异步接口", "FAIL", "临时图片上传或审核请求失败"));
return result(TEXT, "IMAGE_CALLBACK", mode, "WECHAT", "FAIL", "微信图片审核探测失败", "IMAGE_PROBE_FAILED", checks);
} finally {
if (uploaded != null && !awaitingCallback && !pendingSaved) try { uploaded.deleteFile(objectName); } catch (Exception ignored) { log.warn("清理接入测试临时图片失败"); }
}
}
private byte[] createProbePng() throws java.io.IOException {
java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(64, 64, java.awt.image.BufferedImage.TYPE_INT_RGB);
java.awt.Graphics2D graphics = image.createGraphics();
try { graphics.setColor(java.awt.Color.WHITE); graphics.fillRect(0, 0, 64, 64); }
finally { graphics.dispose(); }
java.io.ByteArrayOutputStream output = new java.io.ByteArrayOutputStream();
javax.imageio.ImageIO.write(image, "png", output);
return output.toByteArray();
}
private void savePendingImageProbe(String mode, String probeId, String provider, String objectName) throws Exception {
IntegrationProbeResultDO row = findResult(TEXT, "IMAGE_CALLBACK");
if (row == null) { row = new IntegrationProbeResultDO(); row.setServiceCode(TEXT); row.setOperationCode("IMAGE_CALLBACK"); }
row.setMode(mode); row.setProvider("WECHAT"); row.setStatus("PENDING"); row.setSummary("已提交微信图片审核,等待回调"); row.setErrorCode(null);
row.setChecksJson(objectMapper.writeValueAsString(List.of(new IntegrationProbeCheckVO("微信图片异步接口", "PENDING", "等待微信回调"))));
row.setRemoteTaskId(null); row.setCorrelationKey(probeId); row.setTemporaryObjectProvider(provider); row.setTemporaryObjectName(objectName);
row.setExpiresAt(LocalDateTime.now().plusMinutes(5)); row.setCheckedAt(LocalDateTime.now());
if (row.getId() == null) resultMapper.insert(row); else resultMapper.updateById(row);
}
private void updatePendingImageTask(String probeId, String taskId) {
if (!StringUtils.hasText(taskId)) return;
IntegrationProbeResultDO row = resultMapper.selectOne(new LambdaQueryWrapper<IntegrationProbeResultDO>()
.eq(IntegrationProbeResultDO::getCorrelationKey, probeId).last("LIMIT 1"));
if (row != null) { row.setRemoteTaskId(clip(taskId, 128)); resultMapper.updateById(row); }
}
private IntegrationProbeResultDO findResult(String service, String operation) {
return resultMapper.selectOne(new LambdaQueryWrapper<IntegrationProbeResultDO>()
.eq(IntegrationProbeResultDO::getServiceCode, service)
.eq(IntegrationProbeResultDO::getOperationCode, operation).last("LIMIT 1"));
}
private void deleteTemporaryObject(IntegrationProbeResultDO row) {
if (!StringUtils.hasText(row.getTemporaryObjectProvider()) || !StringUtils.hasText(row.getTemporaryObjectName())) return;
ObjectStorageProvider provider = storageProviders.stream()
.filter(item -> item.providerCode().equals(row.getTemporaryObjectProvider())).findFirst().orElse(null);
if (provider == null) return;
try {
provider.deleteFile(row.getTemporaryObjectName());
row.setTemporaryObjectProvider(null);
row.setTemporaryObjectName(null);
} catch (Exception ignored) {
log.warn("清理接入测试临时图片失败,provider={}", provider.providerCode());
}
}
private IntegrationProbeResultVO probeMap(UserDO currentUser, String operation) {
SecureIntegrationConfigVO config = secureIntegrationConfigService.getAdminConfig(currentUser);
List<IntegrationProbeCheckVO> checks = new ArrayList<>();
boolean amapKey = Boolean.TRUE.equals(config.getAmapWebKeyConfigured());
boolean tencentKey = Boolean.TRUE.equals(config.getTencentWebKeyConfigured());
boolean miniKey = Boolean.TRUE.equals(config.getAmapMiniKeyConfigured());
boolean selectedKey = "AMAP".equals(config.getMapProvider()) ? amapKey : tencentKey;
checks.add(check("当前渠道 Web Key", selectedKey, "已配置", "未配置"));
checks.add(new IntegrationProbeCheckVO("高德 Web Key", amapKey ? "PASS" : "WARN", amapKey ? "已配置" : "未配置"));
checks.add(new IntegrationProbeCheckVO("腾讯 Web Key", tencentKey ? "PASS" : "WARN", tencentKey ? "已配置" : "未配置"));
checks.add(new IntegrationProbeCheckVO("高德小程序 Key", miniKey ? "PASS" : "WARN", miniKey ? "已配置" : "未配置,仅影响小程序选点"));
if ("CONFIG".equals(operation)) return result(MAP, operation, "DIAGNOSTIC", config.getMapProvider(), statusForChecks(checks), "地图接入配置诊断完成", null, checks);
if (!selectedKey) return result(MAP, operation, "DIAGNOSTIC", config.getMapProvider(), "FAIL", "当前地图渠道缺少 Web Key", "MAP_KEY_MISSING", checks);
if (!Boolean.TRUE.equals(config.getMapEnabled())) return result(MAP, operation, "DIAGNOSTIC", config.getMapProvider(), "WARN", "地图服务当前已停用,保存并启用后才能测试真实请求", "MAP_DISABLED", checks);
if ("CONFIG".equals(operation)) return result(MAP, operation, "DIAGNOSTIC", config.getMapProvider(), "PASS", "地图 Key 配置诊断完成", null, checks);
Map<String, String> runtime = secureIntegrationConfigService.getMapRuntimeConfig(currentUser);
String key = runtime.get("key");
String url = "AMAP".equals(config.getMapProvider())
? "https://restapi.amap.com/v3/geocode/geo?address=" + java.net.URLEncoder.encode("天安门", StandardCharsets.UTF_8) + "&key=" + key
: "https://apis.map.qq.com/ws/geocoder/v1/?address=" + java.net.URLEncoder.encode("天安门", StandardCharsets.UTF_8) + "&key=" + key;
try {
JsonNode body = objectMapper.readTree(restTemplate.getForObject(url, String.class));
boolean success = "AMAP".equals(config.getMapProvider()) ? body.path("status").asInt(0) == 1 : body.path("status").asInt(-1) == 0;
checks.add(new IntegrationProbeCheckVO("地图 API 请求", success ? "PASS" : "FAIL", success ? "固定地址解析成功" : "地图服务返回失败"));
return result(MAP, operation, "DIAGNOSTIC", config.getMapProvider(), success ? "PASS" : "FAIL", success ? "地图服务调用成功" : "地图服务调用失败", null, checks);
} catch (Exception exception) {
checks.add(new IntegrationProbeCheckVO("地图 API 请求", "FAIL", "地图接口不可达或返回格式异常"));
return result(MAP, operation, "DIAGNOSTIC", config.getMapProvider(), "FAIL", "地图服务调用失败", "MAP_REQUEST_FAILED", checks);
}
}
private IntegrationProbeResultVO probeStorage(String operation) {
List<IntegrationProbeCheckVO> checks = new ArrayList<>();
if ("CONFIG".equals(operation)) {
for (ObjectStorageProvider provider : storageProviders) {
checks.add(new IntegrationProbeCheckVO(provider.providerCode(), provider.isEnabled() ? "PASS" : "WARN", provider.isEnabled() ? "已启用并具备基本配置" : "未启用或配置不完整"));
}
String status = checks.isEmpty() ? "FAIL" : checks.stream().anyMatch(item -> "WARN".equals(item.getStatus())) ? "WARN" : "PASS";
return result(STORAGE, operation, "DIAGNOSTIC", "MULTI", status, status.equals("PASS") ? "对象存储配置完整" : "存在未启用的对象存储渠道", null, checks);
}
byte[] bytes = "salon-integration-probe".getBytes(StandardCharsets.UTF_8);
String objectName = "integration-probe/" + UUID.randomUUID() + ".txt";
int enabled = 0;
try {
for (ObjectStorageProvider provider : storageProviders) {
if (!provider.isEnabled()) {
checks.add(new IntegrationProbeCheckVO(provider.providerCode(), "WARN", "未启用或配置不完整"));
continue;
}
enabled++;
boolean cleanupFailed = false;
try {
provider.uploadStream(new java.io.ByteArrayInputStream(bytes), bytes.length, "text/plain", objectName);
try (InputStream input = provider.downloadFile(objectName)) {
boolean same = java.util.Arrays.equals(bytes, input.readAllBytes());
String signed = provider.getPresignedUrl(objectName, 5);
byte[] signedBytes = StringUtils.hasText(signed) ? restTemplate.getForObject(signed, byte[].class) : null;
boolean signedRead = java.util.Arrays.equals(bytes, signedBytes);
checks.add(new IntegrationProbeCheckVO(provider.providerCode(), same && signedRead ? "PASS" : "FAIL", same && signedRead ? "上传、读取和签名访问成功" : "对象内容或签名读取不一致"));
}
} catch (Exception exception) {
checks.add(new IntegrationProbeCheckVO(provider.providerCode(), "FAIL", "上传或读取失败"));
} finally {
try { provider.deleteFile(objectName); }
catch (Exception ignored) { cleanupFailed = true; log.warn("清理对象存储测试文件失败,provider={}", provider.providerCode()); }
}
if (cleanupFailed) checks.add(new IntegrationProbeCheckVO(provider.providerCode() + " 清理", "FAIL", "临时测试对象未能删除,请检查存储状态"));
}
String status = enabled == 0 ? "FAIL" : checks.stream().anyMatch(item -> "FAIL".equals(item.getStatus())) ? "FAIL" : checks.stream().anyMatch(item -> "WARN".equals(item.getStatus())) ? "WARN" : "PASS";
return result(STORAGE, operation, "DIAGNOSTIC", "MULTI", status, status.equals("PASS") ? "对象存储三副本往返测试成功" : "对象存储存在未就绪渠道", null, checks);
} catch (RuntimeException exception) {
return result(STORAGE, operation, "DIAGNOSTIC", "MULTI", "FAIL", "对象存储测试失败", "STORAGE_PROBE_FAILED", checks);
}
}
private IntegrationProbeResultVO probeSms(UserDO currentUser, String operation, String mode, String phone) {
List<IntegrationProbeCheckVO> checks = new ArrayList<>();
List<com.xiaowang.jayucloud.salon.core.modules.integration.vo.MessageHubPushConfigVO> configs = messageHubPushConfigService.listConfigs(currentUser);
List<String> expectedScenes = 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");
long enabled = expectedScenes.stream().filter(scene -> configs.stream().anyMatch(item -> scene.equals(item.getSceneCode())
&& "SMS".equalsIgnoreCase(item.getPlatform()) && Integer.valueOf(1).equals(item.getEnabled())
&& StringUtils.hasText(item.getSendMethod()) && StringUtils.hasText(item.getQueueName())
&& StringUtils.hasText(item.getTemplateCode()))).count();
checks.add(new IntegrationProbeCheckVO("短信业务场景", enabled == expectedScenes.size() ? "PASS" : "FAIL", enabled + "/" + expectedScenes.size() + " 个场景配置完整并启用"));
String baseUrl = environment.getProperty("messagehub.client.base-url", "http://192.168.10.107:8080");
String accessToken = environment.getProperty("messagehub.client.access-token");
String exchange = environment.getProperty("messagehub.client.ingress-exchange", "messagehub.ingress.exchange");
String routingKey = environment.getProperty("messagehub.client.ingress-routing-key", "message.send");
String smsQueue = environment.getProperty("messagehub.client.sms-queue", "smsQueue");
String sourceSystem = environment.getProperty("messagehub.client.source-system", "jayucloud-salon");
String templateCode = environment.getProperty("messagehub.client.verify-template-code", "SPUG_SMS_VERIFY_1");
String sendMethod = environment.getProperty("messagehub.client.send-method", "SPUG");
boolean endpointConfigured = safeHttpUrl(baseUrl);
checks.add(check("MessageHub 地址", endpointConfigured, "已配置 HTTP(S) 地址", "地址未配置或格式无效"));
checks.add(check("MessageHub 访问凭据", StringUtils.hasText(accessToken), "已配置", "未配置"));
boolean deliveryConfigured = StringUtils.hasText(exchange) && StringUtils.hasText(routingKey)
&& StringUtils.hasText(smsQueue) && StringUtils.hasText(sourceSystem)
&& StringUtils.hasText(templateCode) && StringUtils.hasText(sendMethod);
checks.add(check("短信投递参数", deliveryConfigured, "交换机、路由、队列、来源和模板已配置", "部分投递参数缺失"));
boolean complete = enabled == expectedScenes.size() && endpointConfigured && StringUtils.hasText(accessToken) && deliveryConfigured;
if ("CONFIG".equals(operation) || !"REAL".equals(mode)) return result(SMS, operation, mode, "MESSAGEHUB", complete ? "PASS" : "FAIL", complete ? "短信场景配置完整;未发送真实短信" : "部分短信场景未启用", null, checks);
if (!complete) return result(SMS, operation, mode, "MESSAGEHUB", "FAIL", "短信场景配置不完整,未发送测试短信", "SMS_CONFIG_INCOMPLETE", checks);
if (!StringUtils.hasText(phone) || !phone.matches("^1[3-9]\\d{9}$")) throw new IllegalArgumentException("真实短信测试需要填写有效手机号");
int testCode = java.util.concurrent.ThreadLocalRandom.current().nextInt(100000, 1000000);
messageHubClientService.sendSmsVerificationCode("USER_LOGIN_SMS_CODE", phone, String.valueOf(testCode));
checks.add(new IntegrationProbeCheckVO("真实短信投递", "PASS", "测试短信已提交,手机号 " + maskPhone(phone)));
return result(SMS, "SEND", mode, "MESSAGEHUB", "PASS", "测试短信已提交", null, checks);
}
private IntegrationProbeResultVO probeSubscribe(String operation, String mode) {
List<IntegrationProbeCheckVO> checks = new ArrayList<>();
String provider = StringUtils.hasText(wechatMiniProperties.getSubscribeMessageProvider()) ? wechatMiniProperties.getSubscribeMessageProvider().trim().toLowerCase(Locale.ROOT) : "mock";
boolean enabled = Boolean.TRUE.equals(wechatMiniProperties.getSubscribeMessageEnabled());
boolean liveProvider = "wechat".equals(provider) && enabled;
checks.add(new IntegrationProbeCheckVO("发送渠道", liveProvider ? "PASS" : "WARN", liveProvider ? "微信真实发送已启用" : "当前为 Mock 或已停用"));
if (!liveProvider) {
checks.add(new IntegrationProbeCheckVO("小程序凭据", "WARN", "当前未调用微信接口,因此不校验真实凭据"));
checks.add(new IntegrationProbeCheckVO("固定模板", "PASS", "3 个固定模板 ID 已加载"));
return result(SUBSCRIBE, operation, mode, provider.toUpperCase(Locale.ROOT), "WARN",
"当前为 Mock 或已停用,未调用微信接口", null, checks);
}
boolean credentials = StringUtils.hasText(wechatMiniProperties.getAppId()) && StringUtils.hasText(wechatMiniProperties.getAppSecret());
checks.add(check("小程序凭据", credentials, "已配置", "AppID 或 AppSecret 未配置"));
if (!credentials) return result(SUBSCRIBE, operation, mode, "WECHAT", "FAIL", "订阅消息凭据不完整", "WECHAT_CREDENTIALS_MISSING", checks);
checks.add(check("固定模板", WechatSubscribeMessageService.TEMPLATE_APPOINTMENT.length() > 10
&& WechatSubscribeMessageService.TEMPLATE_CANCELLED.length() > 10
&& WechatSubscribeMessageService.TEMPLATE_SERVICE_START.length() > 10,
"3 个固定模板 ID 已加载", "固定模板 ID 不完整"));
try {
wechatMiniClientService.getAccessTokenForContentModeration();
checks.add(new IntegrationProbeCheckVO("access_token", "PASS", "获取成功"));
if ("SEND".equals(operation) && "REAL".equals(mode)) {
String openId = findProbeOpenId();
checks.add(check("测试账号", StringUtils.hasText(openId), "已找到当前环境绑定账号", "请先使用体验版登录"));
if (!StringUtils.hasText(openId)) return result(SUBSCRIBE, operation, mode, "WECHAT", "WARN", "缺少可用于探测的微信绑定账号", "OPENID_REQUIRED", checks);
WechatMiniClientService.SubscribeMessageResult send = wechatMiniClientService.sendSubscribeMessage(openId, WechatSubscribeMessageService.TEMPLATE_APPOINTMENT,
Map.of("thing1", "接入测试", "time2", "12:00", "thing3", "请忽略此测试消息", "name5", "测试技师", "name6", "测试客户"), wechatMiniProperties.getSubscribeMessagePage(), wechatMiniProperties.getSubscribeMessageMiniprogramState());
String status = send.success() ? "PASS" : "FAIL";
String sendDetail = send.success() ? "测试消息已提交" : subscribeSendError(send.errCode());
checks.add(new IntegrationProbeCheckVO("订阅消息发送", status, sendDetail));
return result(SUBSCRIBE, "SEND", mode, "WECHAT", status, sendDetail, send.success() ? null : String.valueOf(send.errCode()), checks);
}
return checkSubscribeTemplates(operation, mode, checks);
} catch (Exception exception) {
checks.add(new IntegrationProbeCheckVO("access_token", "FAIL", "微信接口不可用"));
return result(SUBSCRIBE, operation, mode, "WECHAT", "FAIL", "订阅消息接口探测失败", "WECHAT_REQUEST_FAILED", checks);
}
}
private IntegrationProbeResultVO checkSubscribeTemplates(String operation, String mode, List<IntegrationProbeCheckVO> checks) throws Exception {
String accessToken = wechatMiniClientService.getAccessTokenForContentModeration();
String url = "https://api.weixin.qq.com/wxaapi/newtmpl/gettemplate?access_token=" + java.net.URLEncoder.encode(accessToken, StandardCharsets.UTF_8);
JsonNode response = objectMapper.readTree(restTemplate.getForObject(url, String.class));
int errorCode = response.path("errcode").asInt(0);
if (errorCode != 0) {
checks.add(new IntegrationProbeCheckVO("微信模板列表", "WARN", "微信未允许读取模板清单,请使用真实发送确认模板状态"));
return result(SUBSCRIBE, operation, mode, "WECHAT", "WARN", "凭据可用,模板状态需真实发送验证", String.valueOf(errorCode), checks);
}
java.util.Set<String> configured = new java.util.HashSet<>();
for (JsonNode item : response.path("data")) {
String templateId = item.path("priTmplId").asText();
if (StringUtils.hasText(templateId)) configured.add(templateId);
}
List<String> required = List.of(WechatSubscribeMessageService.TEMPLATE_APPOINTMENT, WechatSubscribeMessageService.TEMPLATE_CANCELLED, WechatSubscribeMessageService.TEMPLATE_SERVICE_START);
long matched = required.stream().filter(configured::contains).count();
checks.add(new IntegrationProbeCheckVO("固定订阅模板", matched == required.size() ? "PASS" : "FAIL", matched + "/" + required.size() + " 个模板已添加到当前小程序"));
return result(SUBSCRIBE, operation, mode, "WECHAT", matched == required.size() ? "PASS" : "FAIL", matched == required.size() ? "订阅消息凭据与固定模板可用" : "微信后台缺少订阅模板", matched == required.size() ? null : "TEMPLATE_MISSING", checks);
}
private IntegrationProbeResultVO result(String service, String operation, String mode, String provider, String status, String summary, String errorCode, List<IntegrationProbeCheckVO> checks) {
IntegrationProbeResultVO result = new IntegrationProbeResultVO();
result.setService(service); result.setOperation(operation); result.setMode(mode); result.setProvider(provider); result.setStatus(status); result.setSummary(summary); result.setErrorCode(errorCode); result.setCheckedAt(LocalDateTime.now()); result.setChecks(checks);
return result;
}
private IntegrationProbeResultVO failure(String service, String operation, String mode, String summary, String errorCode) {
return result(service, operation, mode, "UNKNOWN", "FAIL", summary, errorCode, new ArrayList<>());
}
private void validateOperation(String service, String operation, String mode) {
boolean valid = switch (service) {
case TEXT -> "DIAGNOSTIC".equals(mode) && List.of("CONFIG", "TEXT", "IMAGE_CALLBACK").contains(operation);
case MAP -> "DIAGNOSTIC".equals(mode) && List.of("CONFIG", "REQUEST").contains(operation);
case STORAGE -> "DIAGNOSTIC".equals(mode) && List.of("CONFIG", "ROUND_TRIP").contains(operation);
case SMS -> ("CONFIG".equals(operation) && "DIAGNOSTIC".equals(mode)) || ("SEND".equals(operation) && "REAL".equals(mode));
case SUBSCRIBE -> ("CONFIG".equals(operation) && "DIAGNOSTIC".equals(mode)) || ("SEND".equals(operation) && "REAL".equals(mode));
default -> false;
};
if (!valid) throw new IllegalArgumentException("服务测试操作与测试模式不匹配");
}
private IntegrationProbeCheckVO check(String name, boolean ok, String pass, String fail) { return new IntegrationProbeCheckVO(name, ok ? "PASS" : "FAIL", ok ? pass : fail); }
private String statusForChecks(List<IntegrationProbeCheckVO> checks) { return checks.stream().anyMatch(item -> "FAIL".equals(item.getStatus())) ? "FAIL" : checks.stream().anyMatch(item -> "WARN".equals(item.getStatus())) ? "WARN" : "PASS"; }
private String findProbeOpenId() {
if (!StringUtils.hasText(wechatMiniProperties.getAppId())) return null;
WechatMiniBindingDO binding = bindingMapper.selectOne(new LambdaQueryWrapper<WechatMiniBindingDO>()
.eq(WechatMiniBindingDO::getAppId, wechatMiniProperties.getAppId())
.eq(WechatMiniBindingDO::getStatus, 1)
.isNotNull(WechatMiniBindingDO::getOpenId)
.last("LIMIT 1"));
return binding == null ? null : binding.getOpenId();
}
private void save(IntegrationProbeResultVO result) {
try {
IntegrationProbeResultDO row = findResult(result.getService(), result.getOperation());
if (row == null) { row = new IntegrationProbeResultDO(); row.setServiceCode(result.getService()); row.setOperationCode(result.getOperation()); }
if ("PENDING".equals(result.getStatus()) && row.getId() != null && !"PENDING".equals(row.getStatus())) return;
row.setMode(result.getMode()); row.setProvider(result.getProvider()); row.setStatus(result.getStatus()); row.setSummary(clip(result.getSummary(), 500)); row.setErrorCode(clip(result.getErrorCode(), 64)); row.setCheckedAt(result.getCheckedAt());
if (!"PENDING".equals(result.getStatus())) deleteTemporaryObject(row);
row.setChecksJson(objectMapper.writeValueAsString(result.getChecks()));
if (row.getId() == null) resultMapper.insert(row); else resultMapper.updateById(row);
} catch (Exception exception) { log.warn("保存接入探测结果失败,service={}, operation={}", result.getService(), result.getOperation()); }
}
private IntegrationProbeResultVO toVO(IntegrationProbeResultDO row) {
IntegrationProbeResultVO result = result(row.getServiceCode(), row.getOperationCode(), row.getMode(), row.getProvider(), row.getStatus(), row.getSummary(), row.getErrorCode(), new ArrayList<>());
result.setCheckedAt(row.getCheckedAt());
try { result.setChecks(objectMapper.readValue(row.getChecksJson(), new TypeReference<List<IntegrationProbeCheckVO>>() {})); } catch (Exception ignored) { }
return result;
}
private String normalize(String value) { return StringUtils.hasText(value) ? value.trim().toUpperCase(Locale.ROOT) : ""; }
private boolean safeHttpUrl(String value) {
if (!StringUtils.hasText(value)) return false;
try {
java.net.URI uri = java.net.URI.create(value.trim());
return ("http".equalsIgnoreCase(uri.getScheme()) || "https".equalsIgnoreCase(uri.getScheme())) && StringUtils.hasText(uri.getHost());
} catch (IllegalArgumentException ignored) { return false; }
}
private String safeMessage(RuntimeException exception) { return "探测请求未完成,请查看脱敏检查项"; }
private String subscribeSendError(int code) {
if (code == 43101) return "当前绑定账号尚未授权此订阅模板";
if (code == 40037 || code == 47003) return "订阅模板无效或模板字段不匹配";
if (code == 40001 || code == 40014) return "微信 access_token 无效或已过期";
return "微信未接受测试消息,请核对模板状态和订阅授权";
}
private String clip(String value, int max) { if (!StringUtils.hasText(value)) return null; String text = value.trim(); return text.length() <= max ? text : text.substring(0, max); }
private String maskPhone(String phone) { return phone.substring(0, 3) + "****" + phone.substring(phone.length() - 4); }
private void requirePlatformAdmin(UserDO user) { if (user == null || !Integer.valueOf(4).equals(user.getType())) throw new RuntimeException("仅平台管理员可以测试系统接入"); }
}
@@ -0,0 +1,14 @@
package com.xiaowang.jayucloud.salon.core.modules.system.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class IntegrationProbeCheckVO {
private String name;
private String status;
private String detail;
}
@@ -0,0 +1,20 @@
package com.xiaowang.jayucloud.salon.core.modules.system.vo;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Data
public class IntegrationProbeResultVO {
private String service;
private String operation;
private String mode;
private String provider;
private String status;
private String summary;
private String errorCode;
private LocalDateTime checkedAt;
private List<IntegrationProbeCheckVO> checks = new ArrayList<>();
}
@@ -3,6 +3,7 @@ package com.xiaowang.jayucloud.salon.core.modules.system.vo;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class SecureIntegrationConfigVO {
@@ -25,4 +26,6 @@ public class SecureIntegrationConfigVO {
private Boolean encryptionKeyConfigured;
private LocalDateTime updatedAt;
/** 最近一次各服务接入探测结果;仅返回脱敏摘要和检查项。 */
private List<IntegrationProbeResultVO> probeResults;
}
@@ -0,0 +1,22 @@
CREATE TABLE IF NOT EXISTS t_integration_probe_result (
id BIGINT NOT NULL,
service_code VARCHAR(64) NOT NULL,
operation_code VARCHAR(64) NOT NULL,
mode VARCHAR(32) NOT NULL,
provider VARCHAR(64) NULL,
status VARCHAR(16) NOT NULL,
summary VARCHAR(500) NULL,
error_code VARCHAR(64) NULL,
checks_json TEXT NULL,
remote_task_id VARCHAR(128) NULL,
correlation_key VARCHAR(128) NULL,
temporary_object_provider VARCHAR(64) NULL,
temporary_object_name VARCHAR(512) NULL,
expires_at DATETIME NULL,
checked_at DATETIME NOT NULL,
create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id),
UNIQUE KEY uk_integration_probe_service_operation (service_code, operation_code),
KEY idx_integration_probe_checked_at (checked_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统接入最近一次诊断结果';
@@ -6,6 +6,7 @@ import com.xiaowang.jayucloud.salon.core.modules.privacy.service.ContentModerati
import com.xiaowang.jayucloud.salon.core.modules.privacy.support.WechatCallbackCrypto;
import com.xiaowang.jayucloud.salon.core.modules.system.secure.ModerationRuntimeConfig;
import com.xiaowang.jayucloud.salon.core.modules.system.service.SecureIntegrationConfigService;
import com.xiaowang.jayucloud.salon.core.modules.system.service.IntegrationProbeService;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@@ -37,6 +38,7 @@ class WechatContentModerationCallbackControllerTest {
wechatProperties,
crypto,
mock(ContentModerationService.class),
mock(IntegrationProbeService.class),
new ObjectMapper());
String result = controller.verifyEndpoint("1000", "nonce", "message-signature", null, "aes", "encrypted-echo");
@@ -58,6 +60,7 @@ class WechatContentModerationCallbackControllerTest {
new WechatMiniProperties(),
crypto,
mock(ContentModerationService.class),
mock(IntegrationProbeService.class),
new ObjectMapper());
assertEquals("echo", controller.verifyEndpoint("1000", "nonce", null, "plain-signature", null, "echo"));
@@ -132,6 +135,6 @@ class WechatContentModerationCallbackControllerTest {
WechatMiniProperties wechatProperties = new WechatMiniProperties();
wechatProperties.setAppId("mini-app-id");
return new WechatContentModerationCallbackController(
secureConfig, wechatProperties, crypto, moderationService, new ObjectMapper());
secureConfig, wechatProperties, crypto, moderationService, mock(IntegrationProbeService.class), new ObjectMapper());
}
}
@@ -0,0 +1,139 @@
package com.xiaowang.jayucloud.salon.core.modules.system.service.impl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xiaowang.jayucloud.salon.core.config.WechatMiniProperties;
import com.xiaowang.jayucloud.salon.core.modules.file.service.ObjectStorageProvider;
import com.xiaowang.jayucloud.salon.core.modules.integration.entity.WechatMiniBindingDO;
import com.xiaowang.jayucloud.salon.core.modules.integration.mapper.WechatMiniBindingMapper;
import com.xiaowang.jayucloud.salon.core.modules.integration.service.MessageHubClientService;
import com.xiaowang.jayucloud.salon.core.modules.integration.service.MessageHubPushConfigService;
import com.xiaowang.jayucloud.salon.core.modules.integration.service.WechatMiniClientService;
import com.xiaowang.jayucloud.salon.core.modules.privacy.moderation.WechatContentModerationProvider;
import com.xiaowang.jayucloud.salon.core.modules.system.dto.IntegrationProbeRequestDTO;
import com.xiaowang.jayucloud.salon.core.modules.system.entity.IntegrationProbeResultDO;
import com.xiaowang.jayucloud.salon.core.modules.system.mapper.IntegrationProbeResultMapper;
import com.xiaowang.jayucloud.salon.core.modules.system.service.SecureIntegrationConfigService;
import com.xiaowang.jayucloud.salon.core.modules.system.vo.SecureIntegrationConfigVO;
import com.xiaowang.jayucloud.salon.core.modules.user.entity.UserDO;
import org.junit.jupiter.api.Test;
import org.springframework.core.env.Environment;
import org.springframework.web.client.RestTemplate;
import java.time.LocalDateTime;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
class IntegrationProbeServiceImplTest {
private final IntegrationProbeResultMapper results = mock(IntegrationProbeResultMapper.class);
private final SecureIntegrationConfigService secureConfig = mock(SecureIntegrationConfigService.class);
private final WechatMiniProperties wechatProperties = new WechatMiniProperties();
private final WechatMiniClientService wechatClient = mock(WechatMiniClientService.class);
private final WechatMiniBindingMapper bindings = mock(WechatMiniBindingMapper.class);
private final WechatContentModerationProvider moderationProvider = mock(WechatContentModerationProvider.class);
private final ObjectStorageProvider storageProvider = mock(ObjectStorageProvider.class);
private final MessageHubPushConfigService smsConfigs = mock(MessageHubPushConfigService.class);
private final MessageHubClientService smsClient = mock(MessageHubClientService.class);
private final RestTemplate restTemplate = mock(RestTemplate.class);
private final Environment environment = mock(Environment.class);
private final IntegrationProbeServiceImpl service = new IntegrationProbeServiceImpl(
results, new ObjectMapper(), secureConfig, wechatProperties, wechatClient, bindings,
moderationProvider, List.of(storageProvider), smsConfigs, smsClient, restTemplate, environment);
@Test
void rejectsNonAdminBeforeAnyProbeSideEffect() {
UserDO manager = new UserDO();
manager.setType(2);
assertThrows(RuntimeException.class, () -> service.probe(manager, request("SMS", "CONFIG", "DIAGNOSTIC", false)));
verify(smsConfigs, never()).listConfigs(any());
}
@Test
void realSmsCannotBeSentWithoutExplicitConfirmation() {
assertThrows(IllegalArgumentException.class,
() -> service.probe(admin(), request("SMS", "SEND", "REAL", false)));
verify(smsClient, never()).sendSmsVerificationCode(any(), any(), any());
}
@Test
void devMockIsNotReportedAsAnAllowedMockWhenEnvironmentDisallowsIt() {
SecureIntegrationConfigVO config = new SecureIntegrationConfigVO();
config.setModerationProvider("MOCK");
config.setMockProviderAllowed(false);
when(secureConfig.getAdminConfig(any())).thenReturn(config);
when(results.selectOne(any())).thenReturn(null);
var result = service.probe(admin(), request("CONTENT_MODERATION", "CONFIG", "DIAGNOSTIC", false));
assertEquals("FAIL", result.getStatus());
verify(moderationProvider, never()).reviewText(any(), any(), any());
}
@Test
void subscribeDiagnosticInMockModeDoesNotFetchTokenOrSendAnything() {
wechatProperties.setAppId("test-app");
wechatProperties.setAppSecret("test-secret");
wechatProperties.setSubscribeMessageEnabled(true);
wechatProperties.setSubscribeMessageProvider("mock");
when(results.selectOne(any())).thenReturn(null);
var result = service.probe(admin(), request("SUBSCRIBE_MESSAGE", "CONFIG", "DIAGNOSTIC", false));
assertEquals("WARN", result.getStatus());
verify(wechatClient, never()).getAccessTokenForContentModeration();
verify(wechatClient, never()).sendSubscribeMessage(any(), any(), any(), any(), any());
}
@Test
void anOutstandingImageProbePreventsAnotherTemporaryUpload() throws Exception {
wechatProperties.setAppId("test-app");
SecureIntegrationConfigVO config = new SecureIntegrationConfigVO();
config.setModerationProvider("WECHAT");
config.setModerationReady(true);
config.setModerationCallbackReady(true);
config.setEncryptionKeyConfigured(true);
config.setWechatMiniAppConfigured(true);
when(secureConfig.getAdminConfig(any())).thenReturn(config);
WechatMiniBindingDO binding = new WechatMiniBindingDO();
binding.setOpenId("private-open-id");
when(bindings.selectOne(any())).thenReturn(binding);
IntegrationProbeResultDO pending = new IntegrationProbeResultDO();
pending.setId(10L);
pending.setServiceCode("CONTENT_MODERATION");
pending.setOperationCode("IMAGE_CALLBACK");
pending.setStatus("PENDING");
pending.setExpiresAt(LocalDateTime.now().plusMinutes(2));
when(results.selectOne(any())).thenReturn(pending);
var result = service.probe(admin(), request("CONTENT_MODERATION", "IMAGE_CALLBACK", "DIAGNOSTIC", false));
assertEquals("PENDING", result.getStatus());
verify(storageProvider, never()).uploadStream(any(), anyLong(), any(), any());
verify(moderationProvider, never()).submitTestImage(any(), any(), any(), any());
}
private UserDO admin() {
UserDO user = new UserDO();
user.setId(1L);
user.setType(4);
return user;
}
private IntegrationProbeRequestDTO request(String service, String operation, String mode, boolean confirmed) {
IntegrationProbeRequestDTO request = new IntegrationProbeRequestDTO();
request.setService(service);
request.setOperation(operation);
request.setMode(mode);
request.setConfirmed(confirmed);
request.setTargetPhone("13800138000");
return request;
}
}
+29
View File
@@ -1596,6 +1596,33 @@ export interface SecureIntegrationConfigVO {
mockProviderAllowed: boolean
encryptionKeyConfigured: boolean
updatedAt?: string
probeResults?: IntegrationProbeResultVO[]
}
export interface IntegrationProbeCheckVO {
name: string
status: 'PASS' | 'WARN' | 'FAIL' | 'PENDING'
detail: string
}
export interface IntegrationProbeResultVO {
service: 'CONTENT_MODERATION' | 'MAP' | 'OBJECT_STORAGE' | 'SMS' | 'SUBSCRIBE_MESSAGE' | string
operation: string
mode: 'DIAGNOSTIC' | 'REAL' | string
provider?: string
status: 'PASS' | 'WARN' | 'FAIL' | 'PENDING' | string
summary: string
errorCode?: string
checkedAt?: string
checks?: IntegrationProbeCheckVO[]
}
export interface IntegrationProbeRequest {
service: string
operation: string
mode?: 'DIAGNOSTIC' | 'REAL'
targetPhone?: string
confirmed?: boolean
}
export interface SecureIntegrationConfigUpdate {
@@ -1633,6 +1660,8 @@ export const adminSystemParameterConfigApi = {
export const adminSecureIntegrationConfigApi = {
getConfig: () => adminApi.get<SecureIntegrationConfigVO>('/system-settings/secure-integration') as unknown as Promise<SecureIntegrationConfigVO>,
listProbeResults: () => adminApi.get<IntegrationProbeResultVO[]>('/system-settings/secure-integration/probe-results') as unknown as Promise<IntegrationProbeResultVO[]>,
probe: (data: IntegrationProbeRequest) => adminApi.post<IntegrationProbeResultVO>('/system-settings/secure-integration/probe', data) as unknown as Promise<IntegrationProbeResultVO>,
getMapRuntimeConfig: () => adminApi.get<{ provider: 'TENCENT' | 'AMAP'; enabled: string; key: string }>('/system-settings/secure-integration/map-runtime') as unknown as Promise<{ provider: 'TENCENT' | 'AMAP'; enabled: string; key: string }>,
saveMapConfig: (data: SecureIntegrationConfigUpdate) => adminApi.post<SecureIntegrationConfigVO>('/system-settings/secure-integration/map', data) as unknown as Promise<SecureIntegrationConfigVO>,
saveModerationConfig: (data: SecureIntegrationConfigUpdate) => adminApi.post<SecureIntegrationConfigVO>('/system-settings/secure-integration/content-moderation', data) as unknown as Promise<SecureIntegrationConfigVO>
@@ -0,0 +1,35 @@
import { describe, expect, it } from 'vitest'
import type { SecureIntegrationConfigVO } from '@/api/admin'
import { buildModerationNotice } from './moderation-status'
function config(overrides: Partial<SecureIntegrationConfigVO> = {}): SecureIntegrationConfigVO {
return {
mapProvider: 'TENCENT', mapEnabled: true, tencentWebKeyConfigured: false, amapWebKeyConfigured: false,
amapMiniKeyConfigured: false, mapLegacyMigrationPending: false, moderationProvider: 'DISABLED',
moderationCallbackUrl: '', moderationCallbackTokenConfigured: false, moderationEncodingAesKeyConfigured: false,
moderationCallbackReady: false, moderationReady: false, wechatMiniAppConfigured: false,
wechatMiniAppId: '', mockProviderAllowed: false, encryptionKeyConfigured: false, ...overrides
}
}
describe('buildModerationNotice', () => {
it('only describes mock behavior when current environment permits it', () => {
expect(buildModerationNotice(config({ moderationProvider: 'MOCK', mockProviderAllowed: true })).title)
.toBe('当前使用本地模拟审核')
expect(buildModerationNotice(config({ moderationProvider: 'MOCK', mockProviderAllowed: false })).title)
.toBe('当前环境不允许模拟审核')
})
it('distinguishes disabled, incomplete and ready WeChat providers', () => {
expect(buildModerationNotice(config()).title).toBe('内容审核未启用')
expect(buildModerationNotice(config({ moderationProvider: 'WECHAT' })).title).toBe('微信内容审核尚未就绪')
expect(buildModerationNotice(config({
moderationProvider: 'WECHAT', moderationReady: true, moderationCallbackReady: true,
wechatMiniAppConfigured: true, encryptionKeyConfigured: true
})).title).toBe('当前使用微信内容安全审核')
})
it('does not claim a provider when configuration cannot be read', () => {
expect(buildModerationNotice(null, true).title).toBe('无法读取内容审核状态')
})
})
@@ -0,0 +1,64 @@
import type { SecureIntegrationConfigVO } from '@/api/admin'
export type ModerationNotice = {
type: 'info' | 'warning' | 'error' | 'success'
title: string
description: string
}
export function buildModerationNotice(config: SecureIntegrationConfigVO | null, statusUnavailable = false): ModerationNotice {
if (statusUnavailable) return {
type: 'error',
title: '无法读取内容审核状态',
description: '状态未知时请勿假设微信审核已生效;可重试加载或前往系统设置检查接入配置。'
}
if (!config) return {
type: 'info',
title: '正在读取内容审核状态',
description: '正在读取当前环境的真实审核渠道和最近探测结果。'
}
const latest = (config.probeResults || [])
.filter(item => item.service === 'CONTENT_MODERATION')
.sort((a, b) => String(b.checkedAt || '').localeCompare(String(a.checkedAt || '')))[0]
if (config.moderationProvider === 'MOCK' && config.mockProviderAllowed) return {
type: 'warning',
title: '当前使用本地模拟审核',
description: '不会调用微信内容安全接口,仅适用于当前允许模拟的开发环境。正式环境请切换为微信内容安全审核。'
}
if (config.moderationProvider === 'MOCK') return {
type: 'error',
title: '当前环境不允许模拟审核',
description: '已保存的模拟渠道不能在当前环境生效,内容仍保持隔离。请切换到微信审核或停用后人工处理。'
}
if (config.moderationProvider === 'DISABLED') return {
type: 'error',
title: '内容审核未启用',
description: '内容会保持隔离,不会自动放行。请在系统设置的服务接入中完成配置。'
}
if (!config.moderationReady) {
const missing = [
!config.encryptionKeyConfigured && '服务端加密主密钥',
!config.wechatMiniAppConfigured && '小程序 AppID/AppSecret',
!config.moderationCallbackTokenConfigured && '回调 Token',
!config.moderationEncodingAesKeyConfigured && 'EncodingAESKey',
!config.moderationCallbackReady && '公网 HTTPS 回调'
].filter(Boolean).join('、')
return {
type: 'warning',
title: '微信内容审核尚未就绪',
description: `当前已选择微信审核,但${missing || '配置校验未通过'}。请先完成配置并运行接入测试。`
}
}
const latestText = latest
? `最近探测:${probeLabel(latest.status)} · ${latest.summary}(${latest.checkedAt ? new Date(latest.checkedAt).toLocaleString('zh-CN', { hour12: false }) : '暂无时间'})`
: '尚未运行接入探测。'
return {
type: 'success',
title: '当前使用微信内容安全审核',
description: `内容须通过微信审核后才会公开展示。${latestText}`
}
}
function probeLabel(status?: string) {
return ({ PASS: '通过', WARN: '需关注', FAIL: '失败', PENDING: '等待回调' } as Record<string, string>)[status || ''] || '未知'
}
@@ -9,11 +9,19 @@
</header>
<a-alert
type="warning"
:type="moderationNotice.type"
show-icon
message="内容审核当前为本地模拟流程,不会调用微信内容安全接口。正式上线前需接入审核服务并复核隐私指引。"
:message="moderationNotice.title"
:description="moderationNotice.description"
class="page-notice"
/>
>
<template #action>
<a-space>
<a-button v-if="integrationStatusError" size="small" @click="loadIntegrationStatus">重试</a-button>
<a-button size="small" @click="openIntegrationSettings">服务接入设置</a-button>
</a-space>
</template>
</a-alert>
<a-tabs v-model:active-key="activeTab" @change="loadActiveTab">
<a-tab-pane key="closures">
@@ -74,7 +82,7 @@
</a-space>
</div>
</template>
<template v-else-if="column.key === 'status'">{{ record.status === 'RETRY' ? '待复核(模拟服务故障)' : '待复核' }}</template>
<template v-else-if="column.key === 'status'">{{ record.status === 'RETRY' ? '待复核(审核服务暂不可用)' : '待复核' }}</template>
<template v-else-if="column.key === 'action'">
<a-space>
<a-button type="link" @click="openModeration(record as ContentModerationRecordVO, true)">通过</a-button>
@@ -122,21 +130,26 @@
<a-modal v-model:open="moderationOpen" :title="moderationApproved ? '通过内容复核' : '拒绝内容'" :confirm-loading="actionLoading" :mask-closable="false" @ok="submitModeration">
<p v-if="moderationTarget">{{ moderationType(moderationTarget.contentType) }}内容,记录号 {{ moderationTarget.id }}</p>
<a-form-item label="复核说明"><a-textarea v-model:value="moderationReason" :rows="3" placeholder="说明本次模拟复核结果" /></a-form-item>
<p class="moderation-provider-context">{{ moderationReviewContext }}</p>
<a-form-item label="复核说明"><a-textarea v-model:value="moderationReason" :rows="3" :placeholder="moderationApproved ? '说明本次复核通过原因' : '说明本次拒绝原因'" /></a-form-item>
</a-modal>
</div>
</template>
<script setup lang="ts">
import { computed, onActivated, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { message, Modal } from 'ant-design-vue'
import { buildModerationNotice } from '@/utils/moderation-status'
import {
adminPrivacyComplianceApi,
type AccountClosureRequestVO,
type ClosureSuccessorManagerVO,
type ContentModerationRecordVO,
type PhoneBackfillReportVO
type PhoneBackfillReportVO,
type SecureIntegrationConfigVO
} from '@/api/admin'
import { adminSecureIntegrationConfigApi } from '@/api/admin'
const activeTab = ref('closures')
const closures = ref<AccountClosureRequestVO[]>([])
@@ -157,6 +170,15 @@ const moderationOpen = ref(false)
const moderationTarget = ref<ContentModerationRecordVO | null>(null)
const moderationApproved = ref(false)
const moderationReason = ref('')
const secureIntegration = ref<SecureIntegrationConfigVO | null>(null)
const integrationStatusError = ref(false)
const router = useRouter()
const moderationNotice = computed(() => buildModerationNotice(secureIntegration.value, integrationStatusError.value))
const moderationReviewContext = computed(() => {
if (secureIntegration.value?.moderationProvider === 'WECHAT' && secureIntegration.value.moderationReady) return '当前环境使用微信内容审核;此处用于处理微信要求人工复核或审核服务异常的记录。'
if (secureIntegration.value?.moderationProvider === 'MOCK' && secureIntegration.value.mockProviderAllowed) return '当前环境允许本地模拟审核;此操作不会调用微信内容安全接口。'
return '请依据内容和平台审核规范填写复核说明;审核渠道不可用时,内容仍保持隔离。'
})
const hasBackfillConflicts = computed(() => Boolean(backfillReport.value?.accountConflictRows || backfillReport.value?.phoneConflictRows))
const successorOptions = computed(() => successorManagers.value.map(manager => ({ label: `${manager.nickname || '店长'}(${manager.id})`, value: manager.id })))
@@ -197,6 +219,16 @@ async function loadModeration() {
finally { moderationLoading.value = false }
}
async function loadIntegrationStatus() {
integrationStatusError.value = false
try { secureIntegration.value = await adminSecureIntegrationConfigApi.getConfig() }
catch (error) { integrationStatusError.value = true; message.error(error instanceof Error ? error.message : '读取内容审核状态失败') }
}
function openIntegrationSettings() {
void router.push({ path: '/admin/settings', query: { section: 'services' } })
}
function loadActiveTab() {
if (activeTab.value === 'closures') void loadClosures()
if (activeTab.value === 'moderation') void loadModeration()
@@ -253,7 +285,9 @@ function confirmArchive() {
function openModeration(record: ContentModerationRecordVO, approved: boolean) {
moderationTarget.value = record
moderationApproved.value = approved
moderationReason.value = approved ? '本地模拟复核通过。' : ''
moderationReason.value = approved
? secureIntegration.value?.moderationProvider === 'MOCK' && secureIntegration.value.mockProviderAllowed ? '本地模拟复核通过。' : '经管理员复核,内容符合平台规范。'
: ''
moderationOpen.value = true
}
@@ -305,6 +339,7 @@ let skipInitialActivationRefresh = true
onMounted(() => {
void loadClosures()
void loadModeration()
void loadIntegrationStatus()
})
onActivated(() => {
if (skipInitialActivationRefresh) {
@@ -313,6 +348,7 @@ onActivated(() => {
}
void loadClosures()
void loadModeration()
void loadIntegrationStatus()
})
</script>
@@ -325,6 +361,7 @@ onActivated(() => {
.payload-preview { max-width: 420px; max-height: 180px; margin: 0; overflow: auto; white-space: pre-wrap; word-break: break-word; font-size: 12px; }
.moderation-content { display: grid; gap: 6px; }
.moderation-author { color: var(--ant-color-text-secondary); font-size: 12px; }
.moderation-provider-context { color: var(--ant-color-text-secondary); font-size: 12px; line-height: 1.55; }
.image-pending { color: var(--ant-color-text-secondary); font-size: 12px; }
.backfill-panel { width: 100%; padding: 8px 0; }
.closure-shops { display: grid; gap: 12px; margin-bottom: 16px; }
@@ -107,6 +107,34 @@
<span />
</div>
<div class="setting-group probe-group">
<div class="setting-group__head setting-group__head--with-action"><strong>接入诊断</strong><span>TEST</span><a-button size="small" :loading="refreshingProbeResults" @click="refreshProbeResults">刷新最近结果</a-button></div>
<div class="probe-list">
<div v-for="card in probeCards" :key="card.service" class="probe-row">
<div class="probe-row__copy">
<strong>{{ card.label }}</strong>
<span>{{ card.description }}</span>
</div>
<div class="probe-actions">
<div v-for="operation in card.operations" :key="operation.code" class="probe-action">
<a-button size="small" :loading="testingProbe === `${card.service}:${operation.code}`" @click="runCardOperation(card.service, operation.code)">{{ operation.label }}</a-button>
<span v-if="probeFor(card.service, operation.code)" :class="['status-pill', `probe-status--${probeFor(card.service, operation.code)?.status.toLowerCase()}`]">{{ probeStatusLabel(probeFor(card.service, operation.code)?.status) }}</span>
<span v-else class="status-pill is-muted">未测试</span>
<small v-if="probeFor(card.service, operation.code)">{{ probeFor(card.service, operation.code)?.summary }} · {{ formatProbeTime(probeFor(card.service, operation.code)?.checkedAt) }}</small>
<a-collapse v-if="probeFor(card.service, operation.code)?.checks?.length" class="probe-details" ghost>
<a-collapse-panel key="checks" header="查看检查项">
<div v-for="check in probeFor(card.service, operation.code)?.checks" :key="`${check.name}-${check.status}`" class="probe-check">
<span>{{ check.name }}</span><em :class="`probe-check--${check.status.toLowerCase()}`">{{ probeStatusLabel(check.status) }}</em><small>{{ check.detail }}</small>
</div>
</a-collapse-panel>
</a-collapse>
</div>
</div>
</div>
</div>
<p class="secure-note">配置保存后再测试。短信和订阅消息默认只诊断,真实发送会产生外部副作用并要求二次确认;对象存储测试文件会自动清理。微信图片测试提交后显示等待回调,不会把异步结果误报为失败。</p>
</div>
<div class="setting-group">
<div class="setting-group__head setting-group__head--with-action"><strong>地图服务</strong><span>安全接入</span><a-button size="small" type="primary" :loading="savingMap || confirmingMap" @click="saveMapConfig">保存地图设置</a-button></div>
<div class="setting-row">
@@ -257,15 +285,27 @@
</section>
</main>
</div>
<a-modal v-model:open="realProbeOpen" title="确认真实接入测试" :confirm-loading="realProbeLoading" :mask-closable="false" ok-text="确认发送" cancel-text="取消" @ok="submitRealProbe">
<template v-if="realProbeService === 'SMS'">
<p>将向指定手机号发送一条真实测试短信,可能产生费用。</p>
<a-input v-model:value="realProbePhone" placeholder="请输入接收手机号" :maxlength="11" />
<a-checkbox v-model:checked="realProbeConfirmed">我确认发送真实测试短信</a-checkbox>
</template>
<template v-else>
<p>将向当前环境已有微信绑定账号发送一条真实订阅消息,可能消耗订阅额度。</p>
<a-checkbox v-model:checked="realProbeConfirmed">我确认发送真实测试消息</a-checkbox>
</template>
</a-modal>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue'
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import { message, Modal } from 'ant-design-vue'
import { ApiOutlined, ArrowDownOutlined, ArrowUpOutlined, CopyOutlined, ExportOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons-vue'
import { adminSecureIntegrationConfigApi, adminSystemParameterConfigApi, type SecureIntegrationConfigVO, type SystemParameterConfigVO } from '@/api/admin'
import { adminSecureIntegrationConfigApi, adminSystemParameterConfigApi, type IntegrationProbeResultVO, type SecureIntegrationConfigVO, type SystemParameterConfigVO } from '@/api/admin'
import { ADMIN_API_BASE_URL } from '@/config/api'
import { loadCachedAdminUserInfo } from '@/utils/admin-session'
@@ -273,8 +313,19 @@ type SettingsSection = 'runtime' | 'services' | 'account'
type MapKey = 'tencentWeb' | 'amapWeb' | 'amapMini'
const route = useRoute()
const activeSection = ref<SettingsSection>(route.query.section === 'account' ? 'account' : 'runtime')
const activeSection = ref<SettingsSection>(route.query.section === 'account' ? 'account' : route.query.section === 'services' ? 'services' : 'runtime')
watch(() => route.query.section, section => {
activeSection.value = section === 'account' || section === 'services' ? section : 'runtime'
})
const loading = ref(false)
const testingProbe = ref('')
const refreshingProbeResults = ref(false)
const probeResults = ref<IntegrationProbeResultVO[]>([])
const realProbeOpen = ref(false)
const realProbeLoading = ref(false)
const realProbeService = ref<'SMS' | 'SUBSCRIBE_MESSAGE'>('SMS')
const realProbePhone = ref('')
const realProbeConfirmed = ref(false)
const savingDefaultPassword = ref(false)
const savingReviewNotice = ref(false)
const savingManagerReviewMode = ref(false)
@@ -342,6 +393,13 @@ const sections = [
{ key: 'services' as const, label: '服务接入', icon: ApiOutlined },
{ key: 'account' as const, label: '当前账号', icon: UserOutlined }
]
const probeCards = [
{ service: 'CONTENT_MODERATION', label: '微信内容审核', description: '检查当前 Provider、凭据和回调;文本使用固定无害内容,图片需等待回调。', operations: [{ code: 'CONFIG', label: '配置诊断' }, { code: 'TEXT', label: '文本接口测试' }, { code: 'IMAGE_CALLBACK', label: '图片回调测试' }] },
{ service: 'MAP', label: '地图服务', description: '同时查看 Web/小程序 Key 状态,并可请求固定地址验证当前 Web Key。', operations: [{ code: 'CONFIG', label: '配置诊断' }, { code: 'REQUEST', label: '真实请求' }] },
{ service: 'OBJECT_STORAGE', label: '对象存储三副本', description: '逐渠道临时上传、读取并访问签名地址,完成后自动清理。', operations: [{ code: 'CONFIG', label: '配置诊断' }, { code: 'ROUND_TRIP', label: '往返测试' }] },
{ service: 'SMS', label: '短信服务', description: '诊断 MessageHub 场景和渠道;真实短信需填写号码并确认。', operations: [{ code: 'CONFIG', label: '配置诊断' }, { code: 'SEND', label: '真实发送', real: true }] },
{ service: 'SUBSCRIBE_MESSAGE', label: '微信订阅消息', description: '检查小程序凭据和固定模板;真实消息会消耗订阅额度。', operations: [{ code: 'CONFIG', label: '配置诊断' }, { code: 'SEND', label: '真实发送', real: true }] }
]
const mapKeyRows: Array<{ key: MapKey; label: string; description: string; placeholder: string; url: string }> = [
{ key: 'tencentWeb', label: '腾讯 Web Key', description: '用于后台腾讯地图选点。', placeholder: '填写腾讯 Web Key;留空保持原值', url: 'https://lbs.qq.com/dev/console/key/manage' },
{ key: 'amapWeb', label: '高德 Web Key', description: '用于后台高德地图选点。', placeholder: '填写高德 Web Key;留空保持原值', url: 'https://console.amap.com/dev/key/app' },
@@ -448,6 +506,7 @@ const load = async () => {
}
}
secureStatus.value = secureConfig
probeResults.value = secureConfig.probeResults || []
mapProvider.value = secureConfig.mapProvider === 'AMAP' ? 'AMAP' : 'TENCENT'
mapEnabled.value = Boolean(secureConfig.mapEnabled)
moderationProvider.value = secureConfig.moderationProvider || 'DISABLED'
@@ -465,6 +524,70 @@ const load = async () => {
}
}
const probeFor = (service: string, operation?: string) => probeResults.value
.filter(item => item.service === service && (!operation || item.operation === operation))
.sort((a, b) => String(b.checkedAt || '').localeCompare(String(a.checkedAt || '')))[0]
const formatProbeTime = (time?: string) => time ? new Date(time).toLocaleString('zh-CN', { hour12: false }) : '暂无时间'
const probeStatusLabel = (status?: string) => ({ PASS: '通过', WARN: '需关注', FAIL: '失败', PENDING: '等待回调' } as Record<string, string>)[status || ''] || '未知'
const runProbe = async (service: string, operation: string) => {
const key = `${service}:${operation}`
testingProbe.value = key
try {
const result = await adminSecureIntegrationConfigApi.probe({ service, operation, mode: 'DIAGNOSTIC' })
probeResults.value = [...probeResults.value.filter(item => !(item.service === result.service && item.operation === result.operation)), result]
message[result.status === 'PASS' ? 'success' : result.status === 'WARN' ? 'warning' : 'error'](result.summary)
} catch (error) { message.error(error instanceof Error ? error.message : '接入测试失败') }
finally { testingProbe.value = '' }
}
const refreshProbeResults = async () => {
refreshingProbeResults.value = true
try {
const config = await adminSecureIntegrationConfigApi.getConfig()
secureStatus.value = config
probeResults.value = config.probeResults || []
message.success('最近接入测试结果已更新')
} catch (error) { message.error(error instanceof Error ? error.message : '刷新接入测试结果失败') }
finally { refreshingProbeResults.value = false }
}
const runCardOperation = (service: string, operation: string) => {
if (operation === 'IMAGE_CALLBACK') return confirmImageProbe()
if (operation === 'SEND') return openRealProbe(service as 'SMS' | 'SUBSCRIBE_MESSAGE')
return runProbe(service, operation)
}
const confirmImageProbe = () => {
Modal.confirm({
title: '确认进行图片回调测试?',
content: '将上传一张临时安全图片并提交微信异步审核,测试文件会自动清理;结果需要等待微信回调。',
okText: '提交测试',
cancelText: '取消',
onOk: () => runProbe('CONTENT_MODERATION', 'IMAGE_CALLBACK')
})
}
const openRealProbe = (service: 'SMS' | 'SUBSCRIBE_MESSAGE') => {
realProbeService.value = service
realProbePhone.value = ''
realProbeConfirmed.value = false
realProbeOpen.value = true
}
const submitRealProbe = async () => {
if (realProbeService.value === 'SMS' && !/^1[3-9]\d{9}$/.test(realProbePhone.value.trim())) { message.warning('请输入有效的接收手机号'); return }
if (!realProbeConfirmed.value) { message.warning('请先确认发送真实测试消息'); return }
realProbeLoading.value = true
try {
const result = await adminSecureIntegrationConfigApi.probe({
service: realProbeService.value,
operation: 'SEND',
mode: 'REAL',
targetPhone: realProbeService.value === 'SMS' ? realProbePhone.value.trim() : undefined,
confirmed: true
})
probeResults.value = [...probeResults.value.filter(item => !(item.service === result.service && item.operation === result.operation)), result]
message[result.status === 'PASS' ? 'success' : result.status === 'WARN' ? 'warning' : 'error'](result.summary)
realProbeOpen.value = false
} catch (error) { message.error(error instanceof Error ? error.message : '真实接入测试失败') }
finally { realProbeLoading.value = false }
}
const validateDefaultPassword = () => {
const password = defaultPasswordForm.configValue.trim()
if (password.length < 8 || password.length > 32) {
@@ -759,6 +882,26 @@ onMounted(() => {
.warning-note { display: inline-flex; align-items: center; gap: 5px; color: #a66d22; font-size: 11px; white-space: nowrap; }
.warning-note::before { content: '!'; display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: #fff3d9; font-size: 10px; font-weight: 800; }
.secure-note { margin: 0; padding: 12px 14px; color: var(--admin-mobile-muted); font-size: 12px; line-height: 1.65; background: color-mix(in srgb, var(--theme-primary) 7%, var(--theme-card-bg)); }
.probe-group { overflow: hidden; }
.probe-list { display: grid; gap: 8px; }
.probe-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px 14px; align-items: center; padding: 11px 14px; border: 1px solid var(--admin-mobile-border); border-radius: 10px; background: color-mix(in srgb, var(--theme-card-bg) 82%, transparent); }
.probe-row__copy { display: grid; gap: 3px; min-width: 0; }
.probe-row__copy strong { font-size: 13px; }
.probe-row__copy span, .probe-row__copy small { color: var(--admin-mobile-muted); font-size: 11px; line-height: 1.4; }
.probe-row__copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.probe-actions { display: grid; gap: 8px; min-width: min(100%, 410px); }
.probe-action { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 5px 9px; align-items: center; padding-top: 7px; border-top: 1px solid var(--admin-mobile-border); }
.probe-action:first-child { padding-top: 0; border-top: 0; }
.probe-action > small { grid-column: 1 / -1; color: var(--admin-mobile-muted); font-size: 10px; line-height: 1.4; overflow-wrap: anywhere; }
.probe-details { grid-column: 1 / -1; margin: -2px 0 -5px; }
.probe-details :deep(.ant-collapse-header) { padding: 4px 0 !important; color: var(--theme-primary-action) !important; font-size: 11px; }
.probe-details :deep(.ant-collapse-content-box) { padding: 4px 0 0 !important; }
.probe-check { display: grid; grid-template-columns: minmax(90px, 150px) 56px minmax(0, 1fr); gap: 8px; align-items: baseline; padding: 4px 0; border-top: 1px dashed var(--admin-mobile-border); font-size: 11px; }
.probe-check em { font-style: normal; font-weight: 700; }
.probe-check small { min-width: 0; color: var(--admin-mobile-muted); overflow-wrap: anywhere; }
.probe-check--pass { color: var(--theme-primary-action); }
.probe-check--warn, .probe-check--pending { color: #a66d22; }
.probe-check--fail { color: var(--ant-color-error); }
.secure-note__warning { display: block; margin-top: 6px; color: #8a4b0d; font-weight: 650; }
.secure-guide { margin: 0 12px 12px; padding: 14px 16px; background: color-mix(in srgb, var(--admin-mobile-accent-soft) 55%, var(--theme-card-bg)); color: var(--admin-mobile-ink); font-size: 12px; line-height: 1.65; }
.secure-guide > strong { font-size: 13px; }
@@ -784,5 +927,9 @@ onMounted(() => {
.setting-control { width: 100%; }
.storage-order-row { grid-template-columns: 1fr; }
.status-pill, .warning-note, .control-note { justify-self: start; }
.probe-row { grid-template-columns: 1fr; }
.probe-actions { min-width: 0; }
.probe-check { grid-template-columns: 1fr auto; }
.probe-check small { grid-column: 1 / -1; }
}
</style>
@@ -0,0 +1,33 @@
# Salon 系统接入诊断与测试说明
更新时间:2026-11-04
后台「系统设置 → 服务接入 → 接入诊断」用于验证当前环境已经保存的接入配置。诊断不会读取页面尚未保存的输入框内容,也不会在短信或订阅消息诊断时发送真实消息。
## 支持范围
| 服务 | 配置诊断 | 实际探测 | 注意事项 |
| --- | --- | --- | --- |
| 微信内容审核 | Provider、加密主密钥、AppID/AppSecret、回调资料 | 固定无害文本、临时安全图片异步审核 | 图片测试需微信回调,状态先显示等待;DEV 允许 Mock 时明确显示模拟状态 |
| 地图 | 高德/腾讯 Web Key、高德小程序 Key 配置状态 | 当前渠道固定地址地理编码 | 不返回或记录 Key |
| 对象存储 | MinIO、七牛云、阿里云 OSS 可用状态 | 各渠道临时对象上传、读取、签名访问和清理 | 不使用正式业务文件;清理失败时保留脱敏任务记录并定时重试 |
| 短信 | MessageHub 地址/凭据、投递参数和六个短信场景 | 用户输入手机号后真实投递 | 必须在确认弹窗中输入号码并勾选确认,可能产生费用 |
| 微信订阅消息 | AppID/AppSecret、Access Token、固定模板 | 使用当前环境已有绑定账号真实发送 | 必须二次确认,可能消耗订阅额度;Mock 或停用时不会访问微信 |
## 接口和结果
- `POST /admin/system-settings/secure-integration/probe` 执行诊断或探测。
- `GET /admin/system-settings/secure-integration/probe-results` 读取最近结果;接入配置读取接口也一并返回 `probeResults`。
- 仅平台管理员可访问。接口通过防重复操作限制并记录审计结果。
- 每种服务和操作只保留最近一次结果。Flyway `V15__系统接入诊断结果_20261104.sql` 创建结果表,不保存密钥、完整 OpenID、完整手机号或完整签名 URL。
- 图片测试回调等待超过 5 分钟标记失败;临时文件由回调清理,或在过期后定时重试清理。
## SIT 手工验收
1. 在「系统设置 → 服务接入」保存微信内容审核配置,再运行配置诊断和无害文本探测。
2. 确认隐私复核页显示实际 Provider、缺失配置和最近探测结果,不应在 WECHAT Provider 下出现本地模拟提示。
3. 明确确认图片回调测试;检查其先显示等待回调、回调完成后刷新状态,并确认临时对象被清理。
4. 对象存储测试后确认三个副本可用;失败时检查具体渠道检查项与临时清理状态。
5. 短信和订阅消息默认只执行配置诊断。真实测试仅使用专门测试号码或测试微信账号,并先确认可能产生的费用或额度消耗。
自动化测试使用 Mock 外部依赖,不消耗真实短信发送或微信订阅额度。
@@ -96,6 +96,7 @@ MessageHub 的地址、交换机、路由和来源系统放在对应环境 `core
- 预约选择客户使用门店范围专用接口返回完整联系电话,普通客户列表仍脱敏;客户预约建档与客户页保持姓名/微信号/手机号三字段完全一致才判重。预约日历以门店运营营业时间生成可选时段;接口无有效营业时间时不生成默认时段,页面明确提示先到店铺设置完成配置。
- 微信订阅消息使用三个固定小程序模板:新建/分配预约发送“预约提醒”,取消发送“预约取消通知”,开始前30分钟发送“服务开始提醒”;只通知当前承接美甲师,未分配不发送。DEV 使用 Mock,SIT/PROD 使用微信 Provider;用户拒绝订阅不影响登录或预约。配置、字段映射和上线检查见 `docs/scripts/Salon微信订阅消息配置说明_20261102.md`,数据库发送日志由 V12 迁移创建。
- Flyway V14 增加微信图片审核任务来源环境版本,并种入 `FILE/IMAGE_READ_PROVIDER_ORDER` 对象存储读取优先级。后台「系统设置 → 服务接入 → 图片读取渠道」仅调整签名访问 URL 和可用副本回退顺序,不改变上传、三副本要求或副本修复读取顺序;Core 最多缓存 30 秒,缺失或非法值回退当前环境 `object-storage.provider-order`。微信异步图片审核将小程序 `develop/trial/release` 写入微信 `extra` 并保存在任务中,重试保持原版本;回调版本缺失或不匹配不改变任务结果。说明见 `docs/scripts/Salon图片读取渠道优先级配置说明_20261103.md`。
- Flyway V15 增加系统接入诊断最近结果表。后台「系统设置 → 服务接入」可检查微信内容审核、地图、对象存储、MessageHub 短信及微信订阅消息;真实短信和订阅消息必须明确确认。诊断仅使用已保存配置,记录脱敏状态,不保存接入密钥、完整 OpenID、手机号或签名 URL。详细验收步骤见 `docs/scripts/Salon系统接入诊断与测试说明_20261104.md`。
## 8. 操作前检查