Entscheidung 13.07.: verkauft wird nur, was sichtbar ist — max. 5 gleichzeitige Boosts je Startseite, 3 je Branchenseite (= die sichtbaren Plaetze; Hero-Slider damit vertagt). Neue Stufe Kategorie-Boost (nur Branchenseite, 6/10/18 Credits = 50 % aufgerundet); der Startseiten-Boost (12/20/35) erscheint weiter auf Start- UND Branchenseite. - boosts.placement (home/category, Bestand = home) + BoostPlacement-Enum; Preise/Slots in config/credits.php (boost_category, boost_slots) - BoostService::slotAvailability() je Ausgabe (Portal x Sprache, Kategorie zusaetzlich je Rubrik); ausgebucht -> soldOut-Exception mit fruehestem freien Termin; Verlaengerungen halten ihren Slot, Stufen verlaengern unabhaengig; Kategorie-Boost invalidiert nur Kategorie-Caches - Startseite zeigt nur Home-Boosts; Branchenseite: Kategorie-Boosts mit Vorrang (ihre 3 Slots sind die Garantie), Home-Boosts fuellen den Rest - Add-on-Panel der PM-Seite: zwei Boost-Angebote, bei vollem Inventar "Derzeit ausgebucht — frei ab" statt Kauf-Buttons (serverseitig gegated); Buchungsseiten-Preisliste um die Kategorie-Staffel ergaenzt Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
97 lines
2.6 KiB
PHP
97 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Billing;
|
|
|
|
use App\Enums\BoostPlacement;
|
|
use App\Enums\Tier;
|
|
use App\Models\User;
|
|
|
|
/**
|
|
* Leitet die Credit-Preise laut Decision-Update (Rev. 4) zur Kaufzeit aus
|
|
* dem aktiven Tier ab — bewusst nicht statisch je Kauf gespeichert. Einzige
|
|
* Quelle der Preis-Wahrheit ist config/credits.php.
|
|
*/
|
|
class CreditPricingService
|
|
{
|
|
/**
|
|
* Extra-PM-Preis (Credits) für das angegebene Tier. Fällt auf den
|
|
* Einzel-Satz zurück, falls ein Tier nicht konfiguriert ist.
|
|
*/
|
|
public function extraPmCredits(Tier $tier): int
|
|
{
|
|
$table = config('credits.extra_pm', []);
|
|
|
|
return (int) ($table[$tier->value] ?? $table[Tier::Einzel->value]);
|
|
}
|
|
|
|
public function extraPmCreditsFor(User $user): int
|
|
{
|
|
return $this->extraPmCredits($user->currentTier());
|
|
}
|
|
|
|
/**
|
|
* Boost-Preis (Credits) für eine Laufzeit in Tagen, je Boost-Stufe
|
|
* (Startseiten-Boost bzw. Kategorie-Boost zum halben Satz).
|
|
*/
|
|
public function boostCredits(int $days, BoostPlacement $placement = BoostPlacement::Home): int
|
|
{
|
|
$table = $this->boostTable($placement);
|
|
|
|
if (! isset($table[$days])) {
|
|
throw new \InvalidArgumentException("Unbekannte Boost-Laufzeit: {$days} Tage.");
|
|
}
|
|
|
|
return (int) $table[$days];
|
|
}
|
|
|
|
/**
|
|
* Verfügbare Boost-Laufzeiten als [Tage => Credits], aufsteigend.
|
|
*
|
|
* @return array<int, int>
|
|
*/
|
|
public function boostOptions(BoostPlacement $placement = BoostPlacement::Home): array
|
|
{
|
|
$table = $this->boostTable($placement);
|
|
ksort($table);
|
|
|
|
return $table;
|
|
}
|
|
|
|
/**
|
|
* @return array<int, int>
|
|
*/
|
|
private function boostTable(BoostPlacement $placement): array
|
|
{
|
|
return config($placement === BoostPlacement::Home ? 'credits.boost' : 'credits.boost_category', []);
|
|
}
|
|
|
|
public function proofPdfCredits(): int
|
|
{
|
|
return (int) config('credits.proof_pdf');
|
|
}
|
|
|
|
public function depublishCredits(): int
|
|
{
|
|
return (int) config('credits.depublish');
|
|
}
|
|
|
|
/**
|
|
* Freie Prüfungen pro Monat für das Tier (Prüfkontingent §4.3).
|
|
*/
|
|
public function reviewFreeQuota(Tier $tier): int
|
|
{
|
|
$table = config('credits.review.free_per_month', []);
|
|
|
|
return (int) ($table[$tier->value] ?? $table[Tier::Einzel->value]);
|
|
}
|
|
|
|
public function reviewDailyLimit(): int
|
|
{
|
|
return (int) config('credits.review.daily_limit');
|
|
}
|
|
|
|
public function reviewOverflowCost(): int
|
|
{
|
|
return (int) config('credits.review.overflow_cost');
|
|
}
|
|
}
|