<?php

namespace Database\Seeders;

use App\Models\Player;
use App\Models\PlayerWallet;
use Illuminate\Database\Seeder;

/**
 * 【本地演示】写入一条玩家 + 彩票钱包（NPR）。
 * 配合 `Bearer dev:{players.id}` 与 `/api/v1/wallet/balance` 调试。
 *
 * fixed site_code + site_player_id 便于之后在 JWT / 脚本里对上号（非生产数据）。
 */
final class DevPlayerAndWalletSeeder extends Seeder
{
    public function run(): void
    {
        $currency = strtoupper(config('lottery.default_currency', 'NPR'));

        $player = Player::query()->updateOrCreate(
            [
                'site_code' => 'demo',
                'site_player_id' => 'demo-player-001',
            ],
            [
                'username' => 'demo_player',
                'nickname' => 'Demo Player',
                'default_currency' => $currency,
                'status' => 0,
            ],
        );

        PlayerWallet::query()->updateOrCreate(
            [
                'player_id' => $player->id,
                'wallet_type' => 'lottery',
                'currency_code' => $currency,
            ],
            [
                /** 最小货币单位整数：示例 125000，仅演示；可由 .env 覆盖 */
                'balance' => (int) env('DEV_SEED_WALLET_BALANCE_MINOR', 125_000),
                'frozen_balance' => (int) env('DEV_SEED_WALLET_FROZEN_MINOR', 0),
                'status' => 0,
                'version' => 0,
            ],
        );
    }
}
