-- 为指定用户插入测试数据：余额 8888.88，积分 5000

DO $$
DECLARE
    -- 这里直接硬编码目标用户ID
    target_user_id uuid := 'b653fded-7d5e-4950-aa0d-725595543e3c';
BEGIN
    RAISE NOTICE '开始为用户 % 插入数据...', target_user_id;

    -- 2. 插入或更新钱包余额 (设置余额为 8888.88)
    INSERT INTO public.ml_user_wallets (user_id, balance, frozen_balance, status, currency)
    VALUES (target_user_id, 8888.88, 0.00, 1, 'CNY')
    ON CONFLICT (user_id) 
    DO UPDATE SET 
        balance = 8888.88,
        updated_at = now();

    -- 3. 插入一条钱包充值记录
    INSERT INTO public.ml_wallet_transactions (user_id, amount, balance_after, type, description)
    VALUES (target_user_id, 8888.88, 8888.88, 'recharge', '系统测试赠送资金');

    -- 4. 插入或更新积分 (设置积分为 5000)
    INSERT INTO public.ml_user_points (user_id, points, total_earned)
    VALUES (target_user_id, 5000, 5000)
        ON CONFLICT (user_id) 
        DO UPDATE SET 
            points = 5000,
            updated_at = now();

        -- 5. 插入一条积分获取记录
        INSERT INTO public.ml_point_records (user_id, points, type, description)
        VALUES (target_user_id, 5000, 'admin', '系统测试赠送积分');
        
        RAISE NOTICE '测试数据插入完成。';
END $$;
