Credit-Wallet + Ledger + Tier-Preisableitung (Fundament)
Echte Credit-Wallet (1 Credit = 1 EUR) mit append-only Ledger als Basis fuer die Credit-Oekonomie aus dem Decision-Update (Rev. 4): - credit_wallets (denormalisierter Saldo) + credit_transactions (Ledger, vorzeichenbehaftet, balance_after, polymorphe reference) - CreditWalletService: einziger Schreibpfad, atomar mit Row-Lock, InsufficientCreditsException mit shortfall fuer den Mini-Checkout - Tier-Enum (Einzel/Starter/Business/Pro/Agency) + User::currentTier() - CreditPricingService: tier-gestaffelte Ableitung aus config/credits.php (Extra-PM 19/15/12/10/8, Boost 12/20/35, PDF 3, Depublish 25, Pruef-Quota) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
5a9aab7012
commit
b63cd26326
15 changed files with 756 additions and 0 deletions
25
app/Exceptions/InsufficientCreditsException.php
Normal file
25
app/Exceptions/InsufficientCreditsException.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Wird geworfen, wenn eine Wallet-Belastung das verfügbare Guthaben
|
||||
* übersteigt. Trägt benötigtes und verfügbares Guthaben für den
|
||||
* kontextuellen Mini-Checkout („Kostet 15 Credits, du hast 8").
|
||||
*/
|
||||
class InsufficientCreditsException extends RuntimeException
|
||||
{
|
||||
public function __construct(
|
||||
public readonly int $required,
|
||||
public readonly int $available,
|
||||
) {
|
||||
parent::__construct("Nicht genügend Credits: benötigt {$required}, verfügbar {$available}.");
|
||||
}
|
||||
|
||||
public function shortfall(): int
|
||||
{
|
||||
return max(0, $this->required - $this->available);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue