removed all references to credits. now credits are completely replaced by addons.

This commit is contained in:
Codex Agent
2025-12-01 15:50:17 +01:00
parent b8e515a03c
commit 28539754a7
76 changed files with 97 additions and 2533 deletions

View File

@@ -30,56 +30,8 @@ class CheckEventPackages extends Command
->sortDesc()
->values();
$creditThresholds = collect(config('package-limits.credit_thresholds', []))
->filter(fn ($value) => is_numeric($value) && $value >= 0)
->map(fn ($value) => (int) $value)
->unique()
->sortDesc()
->values();
$maxCreditThreshold = $creditThresholds->max();
$now = now();
if ($maxCreditThreshold !== null) {
\App\Models\Tenant::query()
->select(['id', 'event_credits_balance', 'credit_warning_sent_at', 'credit_warning_threshold', 'contact_email'])
->chunkById(100, function ($tenants) use ($creditThresholds, $maxCreditThreshold, $now) {
foreach ($tenants as $tenant) {
$balance = (int) ($tenant->event_credits_balance ?? 0);
if ($balance > $maxCreditThreshold && $tenant->credit_warning_sent_at) {
$tenant->forceFill([
'credit_warning_sent_at' => null,
'credit_warning_threshold' => null,
])->save();
PackageLimitMetrics::recordCreditRecovery($balance);
continue;
}
foreach ($creditThresholds as $threshold) {
if (
$balance <= $threshold
&& (
$tenant->credit_warning_sent_at === null
|| $threshold < ($tenant->credit_warning_threshold ?? PHP_INT_MAX)
)
) {
event(new \App\Events\Packages\TenantCreditsLow($tenant, $balance, $threshold));
PackageLimitMetrics::recordCreditWarning($threshold, $balance);
$tenant->forceFill([
'credit_warning_sent_at' => $now,
'credit_warning_threshold' => $threshold,
])->save();
break;
}
}
}
});
}
EventPackage::query()
->whereNotNull('gallery_expires_at')
->chunkById(100, function ($packages) use ($warningDays, $now) {