-- 检查微信小程序配置问题
-- 用于排查"租户 10550 的小程序未配置"的问题

-- 1. 查看你提到的配置记录
SELECT
    setting_id,
    setting_key,
    tenant_id,
    content,
    deleted,
    comments
FROM gxwebsoft_core.sys_setting
WHERE setting_id = 292;

-- 2. 查看租户10550的所有配置
SELECT
    setting_id,
    setting_key,
    tenant_id,
    content,
    deleted,
    comments
FROM gxwebsoft_core.sys_setting
WHERE tenant_id = 10550
ORDER BY setting_key;

-- 3. 查看所有mp-weixin相关的配置
SELECT
    setting_id,
    setting_key,
    tenant_id,
    content,
    deleted,
    comments
FROM gxwebsoft_core.sys_setting
WHERE setting_key = 'mp-weixin'
ORDER BY tenant_id;

-- 4. 查看租户10550的mp-weixin配置（这是代码实际查询的条件）
SELECT
    setting_id,
    setting_key,
    tenant_id,
    content,
    deleted,
    comments
FROM gxwebsoft_core.sys_setting
WHERE setting_key = 'mp-weixin'
  AND tenant_id = 10550
  AND deleted = 0;

-- 5. 检查是否有其他租户的mp-weixin配置可以参考
SELECT
    setting_id,
    setting_key,
    tenant_id,
    content,
    deleted,
    comments
FROM gxwebsoft_core.sys_setting
WHERE setting_key = 'mp-weixin'
  AND deleted = 0
ORDER BY tenant_id;

-- 6. 查看所有租户的配置情况
SELECT
    tenant_id,
    COUNT(*) as config_count,
    GROUP_CONCAT(setting_key) as setting_keys
FROM gxwebsoft_core.sys_setting
WHERE deleted = 0
GROUP BY tenant_id
ORDER BY tenant_id;
