-- 快速支付配置检查SQL
-- 请在数据库中执行此查询

SELECT 
    '=== 支付配置检查 ===' as title,
    tenant_id as '租户ID',
    CASE 
        WHEN mch_id IS NULL OR mch_id = '' THEN '❌ 未配置'
        ELSE CONCAT('✅ ', mch_id)
    END as '商户号',
    CASE 
        WHEN app_id IS NULL OR app_id = '' THEN '❌ 未配置'
        ELSE CONCAT('✅ ', app_id)
    END as '应用ID',
    CASE 
        WHEN merchant_serial_number IS NULL OR merchant_serial_number = '' THEN '❌ 未配置'
        ELSE '✅ 已配置'
    END as '证书序列号',
    CASE 
        WHEN api_key IS NULL OR api_key = '' THEN '❌ 未配置'
        WHEN LENGTH(api_key) != 32 THEN CONCAT('❌ 长度错误(', LENGTH(api_key), '位)')
        ELSE '✅ 已配置(32位)'
    END as 'API密钥',
    CASE 
        WHEN status = 1 THEN '✅ 已启用'
        ELSE '❌ 未启用'
    END as '状态'
FROM sys_payment 
WHERE type = 0  -- 微信支付
ORDER BY tenant_id;

-- 如果上面的查询没有返回结果，说明没有微信支付配置，请执行：
-- SELECT COUNT(*) as '微信支付配置数量' FROM sys_payment WHERE type = 0;
