<?php

declare(strict_types=1);

namespace Database\Seeders;

use App\Models\PricingTier;
use Illuminate\Database\Seeder;

class PricingTierSeeder extends Seeder
{
    /**
     * 7 ступеней дефолтного тарифа (Plan 4 spec §2.3 — placeholder, ожидает
     * подтверждения заказчика. Открытый вопрос #1).
     */
    public function run(): void
    {
        $tiers = [
            ['tier_no' => 1, 'leads_in_tier' => 100,  'price_per_lead_kopecks' => 50000],
            ['tier_no' => 2, 'leads_in_tier' => 200,  'price_per_lead_kopecks' => 45000],
            ['tier_no' => 3, 'leads_in_tier' => 400,  'price_per_lead_kopecks' => 40000],
            ['tier_no' => 4, 'leads_in_tier' => 800,  'price_per_lead_kopecks' => 35000],
            ['tier_no' => 5, 'leads_in_tier' => 1500, 'price_per_lead_kopecks' => 30000],
            ['tier_no' => 6, 'leads_in_tier' => 3000, 'price_per_lead_kopecks' => 27000],
            ['tier_no' => 7, 'leads_in_tier' => null, 'price_per_lead_kopecks' => 25000],
        ];

        foreach ($tiers as $tier) {
            PricingTier::updateOrCreate(
                ['tier_no' => $tier['tier_no'], 'effective_from' => '1970-01-01'],
                array_merge($tier, ['is_active' => true, 'effective_from' => '1970-01-01']),
            );
        }
    }
}
