<?php

namespace Database\Seeders\Dummy;

use App\Models\Orders\ClientGroup;
use Database\Seeders\DummyDataSeeder;
use Illuminate\Database\Seeder;

class DummyClientGroupSeeder extends Seeder
{
    public function run(): void
    {
        $tenantId = DummyDataSeeder::TENANT_ID;
        $userId = DummyDataSeeder::USER_ID;

        // 기존 데이터 있으면 스킵
        $existing = ClientGroup::where('tenant_id', $tenantId)->count();
        if ($existing > 0) {
            $this->command->info('   ⚠ client_groups: 이미 '.$existing.'개 존재 (스킵)');

            return;
        }

        $groups = [
            ['group_code' => 'VIP',    'group_name' => 'VIP 고객',   'price_rate' => 0.95],
            ['group_code' => 'GOLD',   'group_name' => '골드 고객',  'price_rate' => 0.97],
            ['group_code' => 'SILVER', 'group_name' => '실버 고객',  'price_rate' => 0.98],
            ['group_code' => 'NORMAL', 'group_name' => '일반 고객',  'price_rate' => 1.00],
            ['group_code' => 'NEW',    'group_name' => '신규 고객',  'price_rate' => 1.00],
        ];

        foreach ($groups as $group) {
            ClientGroup::create([
                'tenant_id' => $tenantId,
                'group_code' => $group['group_code'],
                'group_name' => $group['group_name'],
                'price_rate' => $group['price_rate'],
                'is_active' => true,
                'created_by' => $userId,
            ]);
        }

        $this->command->info('   ✓ client_groups: '.count($groups).'건 생성');
    }
}
