<?php

namespace App\Services\Client;

use App\Models\MemberUser;
use App\Models\WalletTransRecord;
use Illuminate\Support\Facades\Auth;

class WalletService
{
    /**
     * 获取钱包明细
     */
    public function getWalletRecords()
    {
        // 获取当前用户
        $userId = Auth::id();
        $user = MemberUser::findOrFail($userId);
        
        // 检查用户状态
        if ($user->state !== 'enable') {
            throw new \Exception('用户状态异常');
        }

        // 获取钱包交易记录
        $records = WalletTransRecord::where('wallet_id', $user->wallet->id)
            ->where('state', 'enable')
            ->orderBy('created_at', 'desc')
            ->paginate(10);
            
        return $records;
    }
} 