|
|
@ -154,4 +154,58 @@ public class WechatCertTestController extends BaseController { |
|
|
|
|
|
|
|
return info; |
|
|
|
} |
|
|
|
|
|
|
|
@Operation(summary = "检查商户平台配置状态") |
|
|
|
@PostMapping("/check-merchant-config") |
|
|
|
public ApiResult<Map<String, Object>> checkMerchantConfig( |
|
|
|
@RequestParam String merchantId, |
|
|
|
@RequestParam String privateKeyPath, |
|
|
|
@RequestParam String merchantSerialNumber, |
|
|
|
@RequestParam String apiV3Key) { |
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
|
|
|
try { |
|
|
|
log.info("开始检查商户平台配置状态..."); |
|
|
|
log.info("商户号: {}", merchantId); |
|
|
|
|
|
|
|
// 尝试创建自动证书配置
|
|
|
|
Config config = wechatCertAutoConfig.createAutoConfig( |
|
|
|
merchantId, privateKeyPath, merchantSerialNumber, apiV3Key); |
|
|
|
|
|
|
|
result.put("success", true); |
|
|
|
result.put("configCreated", true); |
|
|
|
result.put("message", "商户平台配置正常,自动证书配置创建成功"); |
|
|
|
result.put("merchantId", merchantId); |
|
|
|
result.put("recommendation", "配置正常,可以正常使用微信支付功能"); |
|
|
|
|
|
|
|
log.info("✅ 商户平台配置检查成功"); |
|
|
|
return success("配置检查成功", result); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
log.error("❌ 商户平台配置检查失败: {}", e.getMessage(), e); |
|
|
|
|
|
|
|
result.put("success", false); |
|
|
|
result.put("configCreated", false); |
|
|
|
result.put("error", e.getMessage()); |
|
|
|
result.put("merchantId", merchantId); |
|
|
|
|
|
|
|
// 分析错误类型并提供解决方案
|
|
|
|
if (e.getMessage().contains("404") || e.getMessage().contains("RESOURCE_NOT_EXISTS")) { |
|
|
|
result.put("errorType", "商户平台配置问题"); |
|
|
|
result.put("solution", "请在微信支付商户平台完成以下配置:\n" + |
|
|
|
"1. 登录商户平台:https://pay.weixin.qq.com/\n" + |
|
|
|
"2. 进入:产品中心 → 开发配置 → API安全\n" + |
|
|
|
"3. 申请API证书\n" + |
|
|
|
"4. 申请使用微信支付公钥\n" + |
|
|
|
"5. 确保API证书和微信支付公钥状态为\"已生效\""); |
|
|
|
result.put("documentUrl", "https://pay.weixin.qq.com/doc/v3/merchant/4012153196"); |
|
|
|
} else { |
|
|
|
result.put("errorType", "其他配置问题"); |
|
|
|
result.put("solution", "请检查商户号、证书序列号、API密钥等配置是否正确"); |
|
|
|
} |
|
|
|
|
|
|
|
return success("配置检查完成(发现问题)", result); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|