-- 导出 COMBMY01 成功调用记录（含解密密钥）
-- 用法（MySQL 命令行导出 CSV）:
--   mysql -h <host> -u <user> -p --default-character-set=utf8mb4 <database> < export_combmy01_api_calls.sql > combmy01_calls.csv
--
-- 或在 Navicat / DBeaver 中执行本 SQL，再「导出结果为 CSV」。
-- 若 JOIN 报错表不存在，把 product 改成 products 试一下。

SELECT
    ac.id,
    ac.transaction_id,
    ac.access_id,
    ac.user_id,
    p.code          AS product_code,
    ac.request_params,
    au.secret_key,
    ac.status,
    ac.cost,
    ac.start_at,
    ac.end_at,
    ac.created_at
FROM api_calls ac
INNER JOIN product p ON ac.product_id = p.id
INNER JOIN api_users au ON ac.user_id = au.user_id
WHERE ac.user_id = '2acfef92-0700-4638-b386-bd03a8ad09c3'
  AND p.code = 'COMBMY01'
  AND ac.status = 'success'
ORDER BY ac.created_at DESC;
