-- 修复余额显示问题

-- 1. 检查now_money字段是否存在
SELECT COLUMN_NAME, DATA_TYPE, COLUMN_DEFAULT, IS_NULLABLE, COLUMN_COMMENT
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'zhibo' 
  AND TABLE_NAME = 'eb_user' 
  AND COLUMN_NAME = 'now_money';

-- 2. 如果字段不存在，添加字段（如果已存在会报错，可以忽略）
-- ALTER TABLE eb_user ADD COLUMN now_money DECIMAL(10,2) DEFAULT 0.00 COMMENT '用户余额';

-- 3. 查看所有测试用户的当前余额
SELECT uid, account, nickname, now_money, integral, create_time
FROM eb_user
WHERE uid IN (43, 44, 45, 46)
ORDER BY uid;

-- 4. 给测试用户添加初始余额（如果当前为0）
UPDATE eb_user 
SET now_money = 1000.00 
WHERE uid = 43 AND now_money = 0;

UPDATE eb_user 
SET now_money = 500.00 
WHERE uid = 44 AND now_money = 0;

UPDATE eb_user 
SET now_money = 800.00 
WHERE uid = 45 AND now_money = 0;

UPDATE eb_user 
SET now_money = 1200.00 
WHERE uid = 46 AND now_money = 0;

-- 5. 验证更新结果
SELECT uid, account, nickname, now_money
FROM eb_user
WHERE uid IN (43, 44, 45, 46)
ORDER BY uid;

-- 6. 查看是否有充值记录表
SELECT COUNT(*) as record_count 
FROM information_schema.tables 
WHERE table_schema = 'zhibo' 
  AND table_name = 'eb_virtual_currency_recharge';

-- 7. 查看是否有交易记录表
SELECT COUNT(*) as record_count 
FROM information_schema.tables 
WHERE table_schema = 'zhibo' 
  AND table_name = 'eb_virtual_currency_transaction';

-- 8. 如果有交易记录，查看最近的记录
-- SELECT * FROM eb_virtual_currency_transaction 
-- WHERE user_id = 43 
-- ORDER BY create_time DESC 
-- LIMIT 10;
