Files
Mycontent/next-project/scripts/check-withdrawals-data.sql
2026-02-09 14:43:35 +08:00

48 lines
1.4 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 检查提现数据是否存在
-- 1. 检查 withdrawals 表是否存在
SHOW TABLES LIKE 'withdrawals';
-- 2. 查看表结构
DESC withdrawals;
-- 3. 查看所有提现记录
SELECT * FROM withdrawals ORDER BY created_at DESC LIMIT 10;
-- 4. 统计提现记录数量
SELECT
COUNT(*) as ,
SUM(CASE WHEN status = 'pending' THEN 1 ELSE 0 END) as ,
SUM(CASE WHEN status = 'success' THEN 1 ELSE 0 END) as ,
SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) as
FROM withdrawals;
-- 5. 如果没有数据,插入测试数据
-- 注意需要先确认用户ID存在
-- 查看有推荐码的用户
SELECT id, nickname, referral_code, withdrawn_earnings
FROM users
WHERE referral_code IS NOT NULL
LIMIT 5;
-- 查看有推荐订单的用户
SELECT
o.referrer_id,
u.nickname,
u.referral_code,
COUNT(*) as ,
SUM(o.amount) as ,
ROUND(SUM(o.amount) * 0.9, 2) as
FROM orders o
LEFT JOIN users u ON o.referrer_id = u.id
WHERE o.referrer_id IS NOT NULL
AND o.status = 'paid'
GROUP BY o.referrer_id, u.nickname, u.referral_code
LIMIT 5;
-- 插入测试提现记录使用上面查到的用户ID
-- 示例:
-- INSERT INTO withdrawals (id, user_id, amount, status, wechat_openid, created_at)
-- VALUES ('W_TEST_' || UNIX_TIMESTAMP(), '替换为实际用户ID', 50, 'pending', NULL, NOW());