Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbe4226347 | ||
|
|
27c1a52edf | ||
|
|
95a888d1ca | ||
|
|
61c65595e1 | ||
|
|
1af462e1d6 | ||
|
|
0ac70884cc | ||
|
|
db3a6ba779 | ||
|
|
3d76062097 | ||
|
|
28e3342b1f | ||
|
|
657578455f | ||
|
|
3b0b4c955e |
No files matched your search
@@ -42,6 +42,7 @@ class EditorialContentKind extends Model
|
||||
protected $fillable = [
|
||||
'slug',
|
||||
'label',
|
||||
'symbol',
|
||||
'sort_order',
|
||||
'is_active',
|
||||
'contexts',
|
||||
|
||||
@@ -22,12 +22,14 @@ class LicenseArticle extends Model
|
||||
'successor_of_id',
|
||||
'current_release_id',
|
||||
'archived_at',
|
||||
'shop_markers',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'archived_at' => 'datetime',
|
||||
'shop_markers' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ class Offer extends Model
|
||||
'composition_id',
|
||||
'option_label',
|
||||
'standalone_bundle',
|
||||
'claim_access',
|
||||
'claim_requires_article_id',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
@@ -31,6 +33,12 @@ public function composition(): BelongsTo
|
||||
return $this->belongsTo(Composition::class);
|
||||
}
|
||||
|
||||
/** Freigaben einzelner Konten für den Abruf (nur bei Vergabe „auf Abruf“ mit der Regel „freigeschaltete Konten“). */
|
||||
public function releases(): HasMany
|
||||
{
|
||||
return $this->hasMany(OfferRelease::class);
|
||||
}
|
||||
|
||||
/** Bezeichnung der Option auf der Produktseite. */
|
||||
public function optionName(): string
|
||||
{
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Catalog;
|
||||
|
||||
use App\Models\User;
|
||||
use Carbon\CarbonInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Freigabe eines Kontos für ein Angebot „auf Abruf“ (ADR-56). Gilt je Angebot und Konto, wird nie gelöscht, nur entzogen.
|
||||
*/
|
||||
class OfferRelease extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'offer_id',
|
||||
'user_id',
|
||||
'granted_by',
|
||||
'granted_at',
|
||||
'valid_until',
|
||||
'revoked_by',
|
||||
'revoked_at',
|
||||
'reason',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'granted_at' => 'datetime',
|
||||
'valid_until' => 'datetime',
|
||||
'revoked_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function offer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Offer::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function grantor(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'granted_by');
|
||||
}
|
||||
|
||||
public function isActiveAt(CarbonInterface $now): bool
|
||||
{
|
||||
return $this->revoked_at === null
|
||||
&& $this->granted_at->lessThanOrEqualTo($now)
|
||||
&& ($this->valid_until === null || $this->valid_until->greaterThan($now));
|
||||
}
|
||||
}
|
||||
@@ -163,6 +163,68 @@ public function activate(Offer $offer, array $lines, array $attributes = []): Of
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bietet einen Lizenzartikel als Kauf an: legt die Option (Angebot) an und aktiviert ihre erste Fassung in einem
|
||||
* Schritt. Besteht eine Prüfung nicht (Stand, Preis, Rechte), bleibt kein leeres Angebot zurück.
|
||||
*
|
||||
* @param array<string, mixed> $attributes holder_kind, licence_scope, trainer_count, price_cents
|
||||
*/
|
||||
public function offerArticle(LicenseArticle $article, RightsProfileVersion $rights, array $attributes, string $name, ?string $label = null): OfferVersion
|
||||
{
|
||||
return DB::transaction(function () use ($article, $rights, $attributes, $name, $label): OfferVersion {
|
||||
$offer = $this->create($name);
|
||||
$this->setOptionLabel($offer, $label);
|
||||
|
||||
return $this->activate($offer, [['target' => $article, 'rights' => $rights]], [...$attributes, 'grant_kind' => 'kauf']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Ändert eine Option eines Artikels: Die nächste Fassung wird aktiv, die bisherige bleibt gespeichert. Bedingungen,
|
||||
* die die Maske nicht zeigt (Laufzeit, Steuerklasse), bleiben die der letzten Fassung. Die Option muss den Artikel
|
||||
* als einzige Position verkaufen.
|
||||
*
|
||||
* @param array<string, mixed> $attributes holder_kind, licence_scope, trainer_count, price_cents
|
||||
*/
|
||||
public function reviseArticleOption(Offer $offer, LicenseArticle $article, RightsProfileVersion $rights, array $attributes, ?string $label = null): OfferVersion
|
||||
{
|
||||
return DB::transaction(function () use ($offer, $article, $rights, $attributes, $label): OfferVersion {
|
||||
$latest = $offer->versions()->with('lines')->orderByDesc('number')->first();
|
||||
|
||||
if ($latest === null || $latest->lines->count() !== 1 || (int) $latest->lines->first()->license_article_id !== $article->id) {
|
||||
throw new DomainRuleException('Diese Option gehört nicht zu diesem Lizenzartikel.');
|
||||
}
|
||||
|
||||
if ($latest->grant_kind !== 'kauf') {
|
||||
throw new DomainRuleException('Nur eine Option, die als Kauf angeboten wird, lässt sich so ändern. Vergaben auf Abruf oder bei Registrierung bearbeitest du am Angebot.');
|
||||
}
|
||||
|
||||
$this->setOptionLabel($offer, $label);
|
||||
|
||||
return $this->activate($offer, [['target' => $article, 'rights' => $rights]], [
|
||||
'term_rule' => $latest->term_rule,
|
||||
'tax_class' => $latest->tax_class,
|
||||
'dynamic' => (bool) $latest->dynamic,
|
||||
...$attributes,
|
||||
'grant_kind' => 'kauf',
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Vorschlag für die Bezeichnung einer Option, wenn keine eingegeben wird: Nutzerkreis und Eignung.
|
||||
*/
|
||||
public static function defaultOptionLabel(?string $holderKind, ?string $licenceScope, mixed $trainers): string
|
||||
{
|
||||
$scope = match ($licenceScope) {
|
||||
LicenceScope::MULTI => 'Mehrfachlizenz ('.(int) $trainers.' Trainer)',
|
||||
LicenceScope::SINGLE => 'Einzellizenz',
|
||||
default => 'Lizenz',
|
||||
};
|
||||
|
||||
return $scope.' für '.($holderKind === 'organisation' ? 'Organisationen und Vereine' : 'Privatpersonen');
|
||||
}
|
||||
|
||||
/**
|
||||
* Zieht die Option aus dem Verkauf zurück: Die aktive Fassung wird beendet und bleibt gespeichert. Bereits
|
||||
* begründete Berechtigungen und Bestellungen ändern sich nicht; offene Warenkörbe zeigen die Position als
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Domain\Media\WebsitePresentation;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -430,6 +431,32 @@ public function coverElementId(Model $subject): ?int
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Das öffentlich zeigbare Titelbild: das erste Titel- oder Galeriebild in der Reihenfolge der Rollen, das für die
|
||||
* Website freigegeben ist (WebsiteMedia). Ein nicht freigegebenes Bild wird übersprungen, nie ausgeliefert.
|
||||
*/
|
||||
public function coverPresentation(Model $subject): ?WebsitePresentation
|
||||
{
|
||||
$assignments = PresentationAssignment::query()
|
||||
->with('role')
|
||||
->where('subject_type', $subject->getMorphClass())
|
||||
->where('subject_id', $subject->getKey())
|
||||
->orderBy('position')
|
||||
->get();
|
||||
|
||||
foreach (PresentationRole::COVER_ROLES as $slug) {
|
||||
foreach ($assignments->filter(fn (PresentationAssignment $row): bool => $row->role?->slug === $slug) as $row) {
|
||||
$presentation = $this->website->present((int) $row->content_element_id);
|
||||
|
||||
if ($presentation !== null && $presentation->kind === 'bild') {
|
||||
return $presentation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function owned(Model $subject, int $assignmentId): PresentationAssignment
|
||||
{
|
||||
$assignment = PresentationAssignment::query()
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Domain\Cms;
|
||||
|
||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -79,6 +80,11 @@ public function scopeVisible(Builder $query): void
|
||||
|
||||
public function href(): ?string
|
||||
{
|
||||
// Ein Menüpunkt in den Shop erscheint nicht, solange der Shop nicht sichtbar ist: Er führte ins Leere (404).
|
||||
if ($this->pointsIntoShop() && ! Shop::visible()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($this->page !== null) {
|
||||
return $this->page->path === '/' ? url('/') : url($this->page->path);
|
||||
}
|
||||
@@ -94,6 +100,24 @@ public function href(): ?string
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/** Ziel ist der Shop selbst oder eine seiner Seiten: Übersicht, Produktseiten, Hinweisseite, Warenkorb, Kasse. */
|
||||
private function pointsIntoShop(): bool
|
||||
{
|
||||
$path = $this->targetPath();
|
||||
|
||||
if ($path === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (['/shop', '/warenkorb', '/kasse', '/kauf-noch-nicht-moeglich'] as $prefix) {
|
||||
if ($path === $prefix || str_starts_with($path, $prefix.'/')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pfad des Ziels innerhalb der Website (für die Kennzeichnung des aktiven Eintrags); null bei externen Zielen.
|
||||
*/
|
||||
|
||||
@@ -34,18 +34,31 @@ class FeaturesWidget extends WidgetType
|
||||
*/
|
||||
public const SYMBOL_SIZE = HeadingAccent::STEPS;
|
||||
|
||||
/**
|
||||
* Lage des Symbols zum Text jedes Merkmals: über dem Text (Vorgabe), links oder rechts daneben.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public const SYMBOL_POSITION = ['top' => 'Über dem Text', 'left' => 'Links neben dem Text', 'right' => 'Rechts neben dem Text'];
|
||||
|
||||
/** @var array<string, string> */
|
||||
public const DIVIDER = ['line' => 'Feiner Strich zwischen den Merkmalen'];
|
||||
|
||||
/**
|
||||
* Gültige Layout-Einstellungen mit Vorgaben (links, mittel, ohne Strich); alles andere fällt auf die Vorgabe zurück.
|
||||
* Gültige Layout-Einstellungen mit Vorgaben (links, mittel, Symbol oben, ohne Strich); alles andere fällt auf die
|
||||
* Vorgabe zurück.
|
||||
*
|
||||
* @param array<string, mixed> $settings
|
||||
* @return array{align: string, size: string, divider: bool}
|
||||
* @return array{align: string, size: string, position: string, divider: bool}
|
||||
*/
|
||||
public static function layout(array $settings): array
|
||||
{
|
||||
return HeadingAccent::block($settings) + ['divider' => ($settings['divider'] ?? null) === 'line'];
|
||||
$position = $settings['symbol_position'] ?? null;
|
||||
|
||||
return HeadingAccent::block($settings) + [
|
||||
'position' => is_string($position) && array_key_exists($position, self::SYMBOL_POSITION) ? $position : 'top',
|
||||
'divider' => ($settings['divider'] ?? null) === 'line',
|
||||
];
|
||||
}
|
||||
|
||||
public function key(): string
|
||||
@@ -70,7 +83,7 @@ public function supportedUnits(): array
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Die Merkmale stehen nebeneinander, solange jedes mindestens 12 rem breit bleibt; darunter stehen sie untereinander.';
|
||||
return 'Die Merkmale stehen nebeneinander, solange jedes mindestens 12 rem breit bleibt (mit Symbol neben dem Text 18 rem); darunter stehen sie untereinander.';
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
@@ -113,6 +126,7 @@ public function settings(): array
|
||||
return [
|
||||
'align' => self::ALIGN,
|
||||
'symbol_size' => self::SYMBOL_SIZE,
|
||||
'symbol_position' => self::SYMBOL_POSITION,
|
||||
'divider' => self::DIVIDER,
|
||||
'link_style' => HeadingAccent::LINK_STYLE,
|
||||
];
|
||||
@@ -120,7 +134,7 @@ public function settings(): array
|
||||
|
||||
public function settingGroups(): array
|
||||
{
|
||||
return ['Aussehen' => ['align', 'symbol_size', 'divider', 'link_style']];
|
||||
return ['Aussehen' => ['align', 'symbol_size', 'symbol_position', 'divider', 'link_style']];
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
@@ -128,6 +142,7 @@ public function settingLabels(): array
|
||||
return [
|
||||
'align' => ['Ausrichtung', 'Richtet Symbol, Titel, Satz und Link jedes Merkmals aus. Vorgabe: linksbündig.'],
|
||||
'symbol_size' => ['Größe der Symbole', 'Kantenlänge der Symbole: Klein 2,5 rem, Mittel 3,5 rem, Groß 5 rem, Sehr groß 7 rem. Vorgabe: Mittel.'],
|
||||
'symbol_position' => ['Lage des Symbols', 'Über dem Text (Vorgabe) oder links bzw. rechts neben Titel, Satz und Link jedes Merkmals. Neben dem Text braucht jedes Merkmal mindestens 18 rem Breite, sonst stehen die Merkmale untereinander. Vorgabe: über dem Text.'],
|
||||
'divider' => ['Trennstrich', 'Ein feiner Strich zwischen den Merkmalen: senkrecht zwischen Spalten, waagerecht zwischen Zeilen und bei untereinander stehenden Merkmalen. Vorgabe: ohne.'],
|
||||
'link_style' => HeadingAccent::LINK_STYLE_LABEL,
|
||||
];
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Types;
|
||||
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use App\Domain\Commerce\ShopCatalog;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
|
||||
/**
|
||||
* Shop-Produkte (ADR-55): die kaufbaren Produkte als Kacheln, aus derselben Datenquelle wie die Shopseite (ShopCatalog).
|
||||
*
|
||||
* Gespeichert werden nur Darstellungswahl und Filter (Säule, Materialart); Titel, Bild, Preis und Marker kommen zur
|
||||
* Laufzeit aus den Fachdaten. Das Widget zeigt nichts, solange der Shop nicht sichtbar ist (Schalter „Shop sichtbar“).
|
||||
* Eine Kachel begründet keine Berechtigung. Anders als Programm- und Modulkarten trägt es Preise und führt zur Produktseite.
|
||||
*/
|
||||
class ShopProductsWidget extends WidgetType
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'shop_products';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Shop-Produkte';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Die kaufbaren Produkte des Shops als Kacheln mit Bild, Marker und Preis; optional gefiltert und sortiert.';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [2, 3, 4];
|
||||
}
|
||||
|
||||
public function minUnits(): int
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Die Kacheln stehen untereinander; ab etwa 17 rem Kachelbreite mehrere nebeneinander.';
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'narrow' => 'eine Kachel je Zeile',
|
||||
'wide' => 'mehrere Kacheln nebeneinander ab 17 rem Kachelbreite',
|
||||
];
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-shopping-bag';
|
||||
}
|
||||
|
||||
public function schematic(): array
|
||||
{
|
||||
return [[2, 4, 17, 28, 'line'], [21, 4, 17, 28, 'line'], [40, 4, 17, 28, 'line'], [4, 6, 13, 10, 'image'], [23, 6, 13, 10, 'image'], [42, 6, 13, 10, 'image'], [4, 19, 11, 3, 'ink'], [23, 19, 11, 3, 'ink'], [42, 19, 11, 3, 'ink'], [4, 26, 7, 3, 'accent'], [23, 26, 7, 3, 'accent'], [42, 26, 7, 3, 'accent']];
|
||||
}
|
||||
|
||||
public function variants(): array
|
||||
{
|
||||
return [
|
||||
'kacheln' => 'Kacheln mit Bild',
|
||||
];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
return [
|
||||
'sort' => ['name' => 'Alphabetisch', 'neu' => 'Neueste zuerst', 'preis' => 'Preis aufsteigend'],
|
||||
'limit' => ['alle' => 'Alle Produkte', 'n3' => '3 Produkte', 'n6' => '6 Produkte', 'n9' => '9 Produkte', 'n12' => '12 Produkte', 'n24' => '24 Produkte'],
|
||||
'search' => ['aus' => 'Ohne Suchfeld', 'an' => 'Mit Suchfeld'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return [
|
||||
'sort' => ['Reihenfolge', 'Ohne Wahl gilt die Reihenfolge der Shopseite: Altbestand, Artikel, Pakete.'],
|
||||
'limit' => ['Anzahl', 'Wie viele Produkte höchstens erscheinen. Ohne Wahl erscheinen alle.'],
|
||||
'search' => ['Suchfeld', 'Ein Suchfeld über den Kacheln. Es wirkt auf der Shopseite; auf anderen Seiten führt die Suche in den Shop.'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settingGroups(): array
|
||||
{
|
||||
return ['Auswahl' => ['sort', 'limit', 'search']];
|
||||
}
|
||||
|
||||
public function dataRules(): array
|
||||
{
|
||||
return [
|
||||
'heading' => ['nullable', 'string', 'max:160'],
|
||||
'intro' => ['nullable', 'string', 'max:400'],
|
||||
'pillar' => ['nullable', 'integer'],
|
||||
'kind' => ['nullable', 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
public function dataFields(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('heading')->label('Abschnittsüberschrift (optional)')->maxLength(160),
|
||||
Textarea::make('intro')->label('Einleitung (optional)')->rows(2)->maxLength(400),
|
||||
Select::make('pillar')
|
||||
->label('Nur Produkte einer Säule (optional)')
|
||||
->helperText('Nur veröffentlichte Säulen sind wählbar. Ohne Wahl erscheinen alle Produkte.')
|
||||
->options(fn (): array => Pillar::query()->published()->pluck('name', 'id')->all())
|
||||
->placeholder('Alle Säulen')
|
||||
->native(false),
|
||||
Select::make('kind')
|
||||
->label('Nur eine Materialart (optional)')
|
||||
->options(fn (): array => EditorialContentKind::query()->where('is_active', true)->orderBy('sort_order')->get()
|
||||
->filter(fn (EditorialContentKind $kind): bool => in_array('lizenzartikel', (array) ($kind->contexts ?? []), true))
|
||||
->pluck('label', 'id')->all())
|
||||
->placeholder('Alle Materialarten')
|
||||
->native(false),
|
||||
];
|
||||
}
|
||||
|
||||
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
{
|
||||
foreach (['heading', 'intro'] as $key) {
|
||||
$data[$key] = filled($data[$key] ?? null) ? trim((string) $data[$key]) : null;
|
||||
}
|
||||
|
||||
$pillar = filled($data['pillar'] ?? null) ? (int) $data['pillar'] : null;
|
||||
|
||||
if ($pillar !== null && ! Pillar::query()->published()->whereKey($pillar)->exists()) {
|
||||
$errors->add('data.pillar', 'Diese Säule gibt es nicht oder sie ist nicht veröffentlicht.');
|
||||
$pillar = null;
|
||||
}
|
||||
|
||||
$kind = filled($data['kind'] ?? null) ? (int) $data['kind'] : null;
|
||||
|
||||
if ($kind !== null && ! EditorialContentKind::query()->whereKey($kind)->exists()) {
|
||||
$errors->add('data.kind', 'Diese Materialart gibt es nicht.');
|
||||
$kind = null;
|
||||
}
|
||||
|
||||
$data['pillar'] = $pillar;
|
||||
$data['kind'] = $kind;
|
||||
|
||||
return [$data, $refs];
|
||||
}
|
||||
|
||||
public function resolve(array $widget, RenderContext $context): array
|
||||
{
|
||||
if (! Shop::visible()) {
|
||||
return ['cards' => [], 'term' => '', 'shopVisible' => false];
|
||||
}
|
||||
|
||||
$settings = is_array($widget['settings'] ?? null) ? $widget['settings'] : [];
|
||||
$search = ($settings['search'] ?? 'aus') === 'an';
|
||||
$term = $search && ! $context->preview ? trim((string) request()->query('suche', '')) : '';
|
||||
$limit = preg_match('/^n(\d+)$/', (string) ($settings['limit'] ?? ''), $match) === 1 ? (int) $match[1] : null;
|
||||
|
||||
return [
|
||||
'cards' => app(ShopCatalog::class)->cards($term, [
|
||||
'pillar' => $widget['data']['pillar'] ?? null,
|
||||
'kind' => $widget['data']['kind'] ?? null,
|
||||
'sort' => $settings['sort'] ?? null,
|
||||
'limit' => $limit,
|
||||
]),
|
||||
'term' => $term,
|
||||
'shopVisible' => true,
|
||||
];
|
||||
}
|
||||
|
||||
public function summary(array $widget): string
|
||||
{
|
||||
$heading = $widget['data']['heading'] ?? null;
|
||||
|
||||
return trim(($heading ? $heading.' · ' : '').'Shop-Produkte');
|
||||
}
|
||||
}
|
||||
@@ -100,6 +100,41 @@ public function add(Offer $offer): string
|
||||
return self::ADDED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Welche der Optionen das Konto schon besitzt (für einen Lizenzinhaber, für den es bestellen darf, mit denselben
|
||||
* Rechten). Ohne Konto ist es leer; die Kasse prüft den Besitz ohnehin noch einmal.
|
||||
*
|
||||
* @param list<Offer> $offers
|
||||
* @return array<int, true>
|
||||
*/
|
||||
public function ownedAmong(?User $user, array $offers): array
|
||||
{
|
||||
if ($user === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$holders = $this->holders->for($user);
|
||||
$owned = [];
|
||||
|
||||
foreach ($offers as $offer) {
|
||||
$version = $this->purchasable($offer);
|
||||
|
||||
if ($version === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($holders as $holder) {
|
||||
if ($this->suitsHolder($version, $holder) && $this->ownership->covers($holder, $version)) {
|
||||
$owned[$offer->id] = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $owned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ausdrücklicher Wechsel: die Alternative wird durch die gewählte Option ersetzt.
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Commerce\Discount\DiscountCode;
|
||||
use App\Domain\Commerce\Stripe\StripeGateway;
|
||||
@@ -25,39 +24,10 @@ class Checkout
|
||||
{
|
||||
public function __construct(
|
||||
private readonly GrantIssuer $grants,
|
||||
private readonly OfferService $offers,
|
||||
private readonly OrderHolders $holders,
|
||||
private readonly PaymentJournal $journal,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Einzelkauf einer Option als Person (bestehender Weg, ohne Warenkorb).
|
||||
*/
|
||||
public function place(User $user, Offer $offer): Order
|
||||
{
|
||||
$this->assertActive($user);
|
||||
|
||||
// Dieser Einzelkauf kennt weder Zustimmungen noch „Zahlungspflichtig bestellen“. Im Livebetrieb gibt es nur den
|
||||
// Weg über die Kasse mit Pflichtangaben.
|
||||
if (Shop::live()) {
|
||||
throw new DomainRuleException('Bestelle über den Warenkorb und die Kasse.');
|
||||
}
|
||||
|
||||
$version = $this->offers->currentActiveVersion($offer);
|
||||
|
||||
if ($version->grant_kind !== 'kauf' || $version->holder_kind !== 'person') {
|
||||
throw new DomainRuleException('Dieses Angebot kann nicht als persönlicher Kauf bestellt werden.');
|
||||
}
|
||||
|
||||
if ($version->price_cents === null) {
|
||||
throw new DomainRuleException('Der Kauf braucht einen Preis an der Angebotsfassung.');
|
||||
}
|
||||
|
||||
$holder = $this->holders->resolve($user, null);
|
||||
|
||||
return DB::transaction(fn (): Order => $this->createOrder($user, $holder, [[$offer, $version]], null, null, Shop::driver() === 'stripe' ? 'stripe' : 'test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Bestellung aus dem Warenkorb, erst nach serverseitiger Prüfung. Die Prüfsumme bindet die Bestellung an die
|
||||
* Übersicht, die der Käufer gesehen hat: Hat sich Preis, Fassung oder Bedingung seither geändert, entsteht keine
|
||||
|
||||
@@ -33,6 +33,23 @@ public function forArticle(LicenseArticle $article): array
|
||||
return $this->optionsFor('a:'.$article->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alle Optionen, die diesen Artikel als einzige Position verkaufen oder verkauften, auch beendete und solche ohne
|
||||
* Preis (Verwaltung). Die öffentliche Seite zeigt davon nur die kaufbaren (`forArticle`).
|
||||
*
|
||||
* @return list<Offer>
|
||||
*/
|
||||
public function offersOfArticle(LicenseArticle $article): array
|
||||
{
|
||||
return Offer::query()
|
||||
->whereHas('versions.lines', fn ($query) => $query->where('license_article_id', $article->id))
|
||||
->orderBy('id')
|
||||
->get()
|
||||
->filter(fn (Offer $offer): bool => $this->groupKey($offer) === 'a:'.$article->id)
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Kaufbare Optionen der Produktseite eines Pakets: Angebote, deren einzige Position eine Fassung dieses Pakets ist.
|
||||
*
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
/**
|
||||
* Wann der Shop (Warenkorb, Kasse, Kopflink) aktiv ist.
|
||||
* Wann der Shop zu sehen ist (visible) und wann gekauft werden kann (checkoutOpen).
|
||||
*
|
||||
* Test und Sandbox: nicht in Produktion, Zahlungstreiber „test“ oder „stripe“ (Testschlüssel).
|
||||
* Produktion: nur mit der ausdrücklichen Produktivfreigabe (`SHOP_LIVE_RELEASE`, Entscheidung von Lars), dem
|
||||
@@ -27,7 +27,24 @@ public static function live(): bool
|
||||
&& SalesTerms::missingPages() === [];
|
||||
}
|
||||
|
||||
public static function enabled(): bool
|
||||
/**
|
||||
* Schalter 1: Der Shop ist zu sehen (Übersicht, Produktseiten, Pakete, Menüeinträge in den Shop).
|
||||
* In Produktion mit `SHOP_PUBLIC` oder mit der Produktivfreigabe, sonst wie der Checkout.
|
||||
*/
|
||||
public static function visible(): bool
|
||||
{
|
||||
if (app()->isProduction()) {
|
||||
return config('shop.public') === true || self::live();
|
||||
}
|
||||
|
||||
return self::checkoutOpen();
|
||||
}
|
||||
|
||||
/**
|
||||
* Schalter 2: Der Kauf läuft (Warenkorb, Kasse, Zahlung). In Produktion nur mit der Produktivfreigabe, sonst mit
|
||||
* dem Testzahlungsweg oder der Stripe-Sandbox.
|
||||
*/
|
||||
public static function checkoutOpen(): bool
|
||||
{
|
||||
if (app()->isProduction()) {
|
||||
return self::live();
|
||||
@@ -49,7 +66,7 @@ public static function stripe(): bool
|
||||
/** Kauf auf Rechnung für Organisationen (manuelle Rechnung, Zahlungseingang durch den Betreiber). */
|
||||
public static function invoice(): bool
|
||||
{
|
||||
return self::enabled() && (bool) config('shop.invoice', true);
|
||||
return self::checkoutOpen() && (bool) config('shop.invoice', true);
|
||||
}
|
||||
|
||||
private static function liveKey(): bool
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\EditorialProfileReader;
|
||||
use App\Domain\Catalog\FormattedText;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PresentationMedia;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Support\Brand\SymbolCatalog;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Die Produkte des Shops als Kacheln: eine Datenquelle für die Shopseite (und später das Widget).
|
||||
*
|
||||
* Gelistet wird, was mindestens eine kaufbare Option hat (Artikel, Pakete mit eigener Seite, Altbestand mit
|
||||
* Programmseite). Jede Kachel trägt nur öffentlich Zeigbares: Titel und Kurztext aus der Redaktion, das Titelbild nur mit
|
||||
* Website-Freigabe, Säulen nur, wenn sie veröffentlicht sind, die Materialart mit ihrem Symbol, die Marker und den
|
||||
* niedrigsten Preis. Nichts davon begründet eine Berechtigung (ADR-52, ADR-54).
|
||||
*
|
||||
* @phpstan-type Card array{key: string, kind: string, url: string, title: string, teaser: string, from: string, from_cents: int, count: int, image: ?array{url: string, alt: string}, kind_label: string, symbol: ?string, pillars: list<string>, markers: list<array{key: string, label: string}>}
|
||||
*/
|
||||
class ShopCatalog
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ProductOptions $products,
|
||||
private readonly PublicCatalogReader $catalog,
|
||||
private readonly EditorialProfileReader $profiles,
|
||||
private readonly PresentationMedia $presentation,
|
||||
private readonly ShopMarkers $markers,
|
||||
) {}
|
||||
|
||||
public const SORTS = ['name' => 'Alphabetisch', 'neu' => 'Neueste zuerst', 'preis' => 'Preis aufsteigend'];
|
||||
|
||||
/**
|
||||
* @param array{pillar?: int|null, kind?: int|null, sort?: string|null, limit?: int|null} $options Filter nach Säule
|
||||
* und Materialart, Sortierung (name, neu, preis) und Höchstzahl
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function cards(string $term = '', array $options = []): array
|
||||
{
|
||||
$term = mb_strtolower(mb_substr(trim($term), 0, 100));
|
||||
$cards = [];
|
||||
|
||||
// Altbestand: Angebote mit mehreren Positionen auf einer freigegebenen Programmseite.
|
||||
$summaries = $this->products->summaries();
|
||||
|
||||
foreach (Composition::query()->with(['editorialContentKind', 'pillars'])->whereIn('id', array_keys($summaries))->orderBy('designation')->get() as $composition) {
|
||||
if ($this->catalog->shownVersion($composition) === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = (string) ($composition->display_title ?: $composition->designation);
|
||||
$teaser = (string) ($composition->teaser ?: FormattedText::plain($composition->summary));
|
||||
$pillars = $this->pillarNames($composition->pillars);
|
||||
$card = $this->card('c:'.$composition->id, 'programm', route('public.program', $composition), $title, $teaser, $summaries[$composition->id], 'Programm', null, $pillars, [], $this->image($composition));
|
||||
$card['pillar_ids'] = $composition->pillars->pluck('id')->map(fn ($id): int => (int) $id)->all();
|
||||
$card['kind_id'] = $composition->editorial_content_kind_id !== null ? (int) $composition->editorial_content_kind_id : null;
|
||||
|
||||
if ($this->matches($term, $title.' '.$teaser.' '.FormattedText::plain($composition->summary).' '.$composition->search_terms.' '.implode(' ', $pillars))) {
|
||||
$cards[] = $card;
|
||||
}
|
||||
}
|
||||
|
||||
// Lizenzartikel mit kaufbarer Option.
|
||||
$articleSummaries = $this->products->articleSummaries();
|
||||
|
||||
foreach (LicenseArticle::query()->with(['editorialContentKind', 'pillars', 'currentRelease'])->whereIn('id', array_keys($articleSummaries))->whereNull('archived_at')->orderBy('code')->get() as $article) {
|
||||
$profile = $this->profiles->read($article, 'kachel');
|
||||
$title = $this->products->articleTitle($article);
|
||||
$teaser = (string) ($profile->value('teaser') ?: $profile->value('summary'));
|
||||
$kind = $article->editorialContentKind;
|
||||
$pillars = $this->pillarNames($article->pillars);
|
||||
$offerIds = array_map(fn ($offer): int => (int) $offer->id, $this->products->offersOfArticle($article));
|
||||
$card = $this->card(
|
||||
'a:'.$article->id, 'artikel', route('shop.article', $article), $title, $teaser, $articleSummaries[$article->id],
|
||||
(string) ($kind?->label ?? ''), $this->symbol($kind?->symbol), $pillars, $this->markers->visible($article, $offerIds), $this->image($article),
|
||||
);
|
||||
$card['pillar_ids'] = $article->pillars->pluck('id')->map(fn ($id): int => (int) $id)->all();
|
||||
$card['kind_id'] = $kind !== null ? (int) $kind->id : null;
|
||||
$card['since'] = $this->markers->firstOffered($offerIds)?->getTimestamp() ?? 0;
|
||||
|
||||
if ($this->matches($term, $title.' '.$teaser.' '.$profile->value('summary').' '.$profile->searchTerms.' '.($kind?->label ?? '').' '.implode(' ', $pillars))) {
|
||||
$cards[] = $card;
|
||||
}
|
||||
}
|
||||
|
||||
// Pakete mit eigener Produktseite.
|
||||
$bundleSummaries = $this->products->bundleSummaries();
|
||||
|
||||
foreach (Bundle::query()->whereIn('id', array_keys($bundleSummaries))->orderBy('name')->get() as $bundle) {
|
||||
$contents = $this->products->bundleContents($this->products->forBundle($bundle));
|
||||
$names = implode(', ', array_column($contents, 'title'));
|
||||
$teaser = 'Paket mit '.count($contents).' '.(count($contents) === 1 ? 'Inhalt' : 'Inhalten').($names !== '' ? ': '.$names : '');
|
||||
$card = $this->card('b:'.$bundle->id, 'paket', route('public.package', $bundle), (string) $bundle->name, $teaser, $bundleSummaries[$bundle->id], 'Paket', null, [], [], $this->image($bundle));
|
||||
|
||||
if ($this->matches($term, $bundle->name.' '.$names)) {
|
||||
$cards[] = $card;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->arrange($cards, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter, Sortierung und Höchstzahl der Kacheln (Widget und Shopseite). Ohne Angabe bleibt die Reihenfolge der
|
||||
* Datenquelle.
|
||||
*
|
||||
* @param list<array<string, mixed>> $cards
|
||||
* @param array<string, mixed> $options
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
private function arrange(array $cards, array $options): array
|
||||
{
|
||||
$pillar = isset($options['pillar']) ? (int) $options['pillar'] : 0;
|
||||
$kind = isset($options['kind']) ? (int) $options['kind'] : 0;
|
||||
|
||||
if ($pillar > 0) {
|
||||
$cards = array_filter($cards, fn (array $card): bool => in_array($pillar, $card['pillar_ids'] ?? [], true));
|
||||
}
|
||||
|
||||
if ($kind > 0) {
|
||||
$cards = array_filter($cards, fn (array $card): bool => ($card['kind_id'] ?? null) === $kind);
|
||||
}
|
||||
|
||||
$cards = array_values($cards);
|
||||
|
||||
match ($options['sort'] ?? null) {
|
||||
'name' => usort($cards, fn (array $a, array $b): int => strcmp(mb_strtolower($a['title']), mb_strtolower($b['title']))),
|
||||
'neu' => usort($cards, fn (array $a, array $b): int => [$b['since'] ?? 0, mb_strtolower($a['title'])] <=> [$a['since'] ?? 0, mb_strtolower($b['title'])]),
|
||||
'preis' => usort($cards, fn (array $a, array $b): int => [$a['from_cents'], mb_strtolower($a['title'])] <=> [$b['from_cents'], mb_strtolower($b['title'])]),
|
||||
default => null,
|
||||
};
|
||||
|
||||
$limit = isset($options['limit']) ? (int) $options['limit'] : 0;
|
||||
|
||||
return $limit > 0 ? array_slice($cards, 0, $limit) : $cards;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{from_cents: int, count: int} $summary
|
||||
* @param list<string> $pillars
|
||||
* @param list<array{key: string, label: string}> $markers
|
||||
* @param array{url: string, alt: string}|null $image
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function card(string $key, string $kind, string $url, string $title, string $teaser, array $summary, string $kindLabel, ?string $symbol, array $pillars, array $markers, ?array $image): array
|
||||
{
|
||||
return [
|
||||
'key' => $key,
|
||||
'kind' => $kind,
|
||||
'url' => $url,
|
||||
'title' => $title,
|
||||
'teaser' => $teaser,
|
||||
'from' => Money::format($summary['from_cents']),
|
||||
'from_cents' => (int) $summary['from_cents'],
|
||||
'count' => (int) $summary['count'],
|
||||
'image' => $image,
|
||||
'kind_label' => $kindLabel,
|
||||
'symbol' => $symbol,
|
||||
'pillars' => $pillars,
|
||||
'markers' => $markers,
|
||||
'pillar_ids' => [],
|
||||
'kind_id' => null,
|
||||
'since' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
private function matches(string $term, string $haystack): bool
|
||||
{
|
||||
return $term === '' || str_contains(mb_strtolower($haystack), $term);
|
||||
}
|
||||
|
||||
/**
|
||||
* Nur veröffentlichte Säulen sind öffentlich (Säulenverwaltung).
|
||||
*
|
||||
* @param Collection<int, Pillar> $pillars
|
||||
* @return list<string>
|
||||
*/
|
||||
private function pillarNames(Collection $pillars): array
|
||||
{
|
||||
return $pillars->filter(fn (Pillar $pillar): bool => $pillar->published_at !== null)->map(fn (Pillar $pillar): string => (string) $pillar->name)->values()->all();
|
||||
}
|
||||
|
||||
/** Ein Symbol zeigt nur, was die Symbolbibliothek kennt (die Auswahl wird an der Materialart geprüft, hier noch einmal). */
|
||||
private function symbol(?string $key): ?string
|
||||
{
|
||||
return is_string($key) && $key !== '' && array_key_exists($key, SymbolCatalog::options()) ? $key : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{url: string, alt: string}|null
|
||||
*/
|
||||
private function image(Model $subject): ?array
|
||||
{
|
||||
$presentation = $this->presentation->coverPresentation($subject);
|
||||
|
||||
return $presentation === null ? null : ['url' => $presentation->url, 'alt' => $presentation->alt];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* Produktmarker „Neu“, „Aktualisiert“ und „Beliebt“ an einer Kachel (ADR-54).
|
||||
*
|
||||
* „Neu“ und „Aktualisiert“ folgen automatisch den Daten (erstes Angebot als Kauf, neuer Stand), jeweils für eine feste
|
||||
* Zahl Tage (`shop.marker_days`); die Redaktion kann sie auch fest an- oder abschalten. „Beliebt“ setzt die Redaktion
|
||||
* von Hand, solange es keine Verkaufszahlen gibt. Ein Marker trägt immer sein Wort, nie nur Farbe oder Symbol.
|
||||
*/
|
||||
class ShopMarkers
|
||||
{
|
||||
public const KEYS = ['neu' => 'Neu', 'aktualisiert' => 'Aktualisiert', 'beliebt' => 'Beliebt'];
|
||||
|
||||
/** Erlaubte Einstellungen je Marker; der erste Wert ist die Vorgabe. */
|
||||
public const CHOICES = [
|
||||
'neu' => ['auto' => 'Automatisch (zeitlich begrenzt nach dem ersten Angebot)', 'an' => 'Immer anzeigen', 'aus' => 'Nie anzeigen'],
|
||||
'aktualisiert' => ['auto' => 'Automatisch (zeitlich begrenzt nach einem neuen Stand)', 'an' => 'Immer anzeigen', 'aus' => 'Nie anzeigen'],
|
||||
'beliebt' => ['aus' => 'Nicht anzeigen', 'an' => 'Anzeigen'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Die Einstellungen des Artikels mit den Vorgaben für fehlende oder ungültige Werte.
|
||||
*
|
||||
* @return array{neu: string, aktualisiert: string, beliebt: string}
|
||||
*/
|
||||
public function settings(LicenseArticle $article): array
|
||||
{
|
||||
$stored = is_array($article->shop_markers) ? $article->shop_markers : [];
|
||||
$settings = [];
|
||||
|
||||
foreach (self::CHOICES as $key => $choices) {
|
||||
$value = $stored[$key] ?? null;
|
||||
$settings[$key] = is_string($value) && array_key_exists($value, $choices) ? $value : array_key_first($choices);
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $choices
|
||||
*/
|
||||
public function save(LicenseArticle $article, array $choices): void
|
||||
{
|
||||
$settings = [];
|
||||
|
||||
foreach (self::CHOICES as $key => $allowed) {
|
||||
$value = $choices[$key] ?? array_key_first($allowed);
|
||||
|
||||
if (! is_string($value) || ! array_key_exists($value, $allowed)) {
|
||||
throw new DomainRuleException('Der Marker „'.self::KEYS[$key].'“ hat eine unzulässige Einstellung.');
|
||||
}
|
||||
|
||||
$settings[$key] = $value;
|
||||
}
|
||||
|
||||
$article->shop_markers = $settings;
|
||||
$article->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Die anzuzeigenden Marker in fester Reihenfolge.
|
||||
*
|
||||
* @param list<int> $offerIds Angebote dieses Artikels (Optionen)
|
||||
* @return list<array{key: string, label: string}>
|
||||
*/
|
||||
public function visible(LicenseArticle $article, array $offerIds, ?Carbon $now = null): array
|
||||
{
|
||||
$now ??= now();
|
||||
$settings = $this->settings($article);
|
||||
$days = max(1, (int) config('shop.marker_days', 30));
|
||||
$limit = $now->copy()->subDays($days);
|
||||
|
||||
$isNew = match ($settings['neu']) {
|
||||
'an' => true,
|
||||
'aus' => false,
|
||||
default => $this->firstOffered($offerIds)?->greaterThanOrEqualTo($limit) ?? false,
|
||||
};
|
||||
|
||||
$isUpdated = match ($settings['aktualisiert']) {
|
||||
'an' => true,
|
||||
'aus' => false,
|
||||
default => ! $isNew && $this->updatedAt($article)?->greaterThanOrEqualTo($limit) === true,
|
||||
};
|
||||
|
||||
$markers = [];
|
||||
|
||||
foreach (['neu' => $isNew, 'aktualisiert' => $isUpdated, 'beliebt' => $settings['beliebt'] === 'an'] as $key => $shown) {
|
||||
if ($shown) {
|
||||
$markers[] = ['key' => $key, 'label' => self::KEYS[$key]];
|
||||
}
|
||||
}
|
||||
|
||||
return $markers;
|
||||
}
|
||||
|
||||
/** Zeitpunkt der ersten Fassung eines Angebots als Kauf. */
|
||||
public function firstOffered(array $offerIds): ?Carbon
|
||||
{
|
||||
if ($offerIds === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$first = OfferVersion::query()->whereIn('offer_id', $offerIds)->where('grant_kind', 'kauf')->min('created_at');
|
||||
|
||||
return $first === null ? null : Carbon::parse($first);
|
||||
}
|
||||
|
||||
/** Zeitpunkt des neuesten Stands, sofern es nicht der erste ist. */
|
||||
private function updatedAt(LicenseArticle $article): ?Carbon
|
||||
{
|
||||
$release = $article->currentRelease;
|
||||
|
||||
return $release !== null && (int) $release->number > 1 && $release->created_at !== null ? Carbon::parse($release->created_at) : null;
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,11 @@ public function claim(User $user, Offer $offer): Acquisition
|
||||
throw new DomainRuleException('Dieses Angebot richtet sich nicht an Personen.');
|
||||
}
|
||||
|
||||
// Wer ein Angebot auf Abruf übernehmen darf, bestimmt seine Regel (ADR-56); „bei Registrierung“ kennt keine.
|
||||
if ($version->grant_kind === 'auf_abruf') {
|
||||
app(OfferAccess::class)->assertMayClaim($user, $offer);
|
||||
}
|
||||
|
||||
return $this->issue($user, $version, AcquisitionType::FreierAbruf, 'offer', $offer->id);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Entitlement;
|
||||
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Models\User;
|
||||
use Carbon\CarbonInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Neue Stände zu Artikeln, die das Konto bereits besitzt („Neu für dich“, ADR-56).
|
||||
*
|
||||
* Nach der Updatepolitik (ADR-09, OPEN-01) stehen alle später veröffentlichten Stände desselben Artikels dem Inhaber
|
||||
* ohne Aufpreis zu, solange die Lizenz gilt. Sie erscheinen von selbst in der Bibliothek; diese Liste macht sie nur
|
||||
* sichtbar. Es wird nichts vergeben und nichts übernommen.
|
||||
*/
|
||||
class NewStands
|
||||
{
|
||||
/** So lange (in Tagen) nach der Veröffentlichung erscheint ein neuer Stand in der Liste. */
|
||||
public const DAYS = 90;
|
||||
|
||||
/**
|
||||
* @return Collection<int, array{grant: Grant, title: string, number: int, since: CarbonInterface}>
|
||||
*/
|
||||
public function forUser(User $user): Collection
|
||||
{
|
||||
if ($user->party_id === null) {
|
||||
return collect();
|
||||
}
|
||||
|
||||
$limit = now()->subDays(self::DAYS);
|
||||
$titles = app(ProductOptions::class);
|
||||
|
||||
return Grant::query()
|
||||
->with(['article.currentRelease', 'releaseAtGrant'])
|
||||
->where('status', GrantStatus::Aktiv)
|
||||
->where(fn ($query) => $query->whereNull('valid_until')->orWhere('valid_until', '>', now()))
|
||||
->whereHas('acquisition', fn ($query) => $query->where('party_id', $user->party_id))
|
||||
->whereHas('article', fn ($query) => $query->whereNull('archived_at'))
|
||||
->orderByDesc('id')
|
||||
->get()
|
||||
->filter(function (Grant $grant) use ($limit): bool {
|
||||
$current = $grant->article?->currentRelease;
|
||||
$had = $grant->releaseAtGrant;
|
||||
|
||||
return $current instanceof ArticleRelease
|
||||
&& $had instanceof ArticleRelease
|
||||
&& (int) $current->number > (int) $had->number
|
||||
&& $current->created_at !== null
|
||||
&& $current->created_at->greaterThanOrEqualTo($limit);
|
||||
})
|
||||
->unique('license_article_id')
|
||||
->map(fn (Grant $grant): array => [
|
||||
'grant' => $grant,
|
||||
'title' => $titles->articleTitle($grant->article),
|
||||
'number' => (int) $grant->article->currentRelease->number,
|
||||
'since' => $grant->article->currentRelease->created_at,
|
||||
])
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Entitlement;
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferRelease;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Models\User;
|
||||
use Carbon\CarbonInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Wer ein Angebot „auf Abruf“ in die Bibliothek übernehmen darf (ADR-56). Drei Regeln, serverseitig beim Abruf geprüft:
|
||||
* alle angemeldeten Mitglieder, nur ausdrücklich freigeschaltete Konten (Freigabe je Angebot und Konto, wie bei
|
||||
* Rabattcodes, nie gelöscht, nur entzogen) oder Mitglieder, die einen bestimmten anderen Artikel besitzen.
|
||||
*
|
||||
* Die Regel gilt nur für Vergaben „auf Abruf“. „Bei Registrierung“ geht automatisch an neue Konten; Kauf ist Sache der
|
||||
* Kasse. Die Regel begründet keinen Zugang, sie begrenzt nur den freien Abruf.
|
||||
*/
|
||||
class OfferAccess
|
||||
{
|
||||
public const ALL = 'alle';
|
||||
|
||||
public const RELEASED = 'konten';
|
||||
|
||||
public const OWNERS = 'besitz';
|
||||
|
||||
public const OPTIONS = [
|
||||
self::ALL => 'Alle angemeldeten Mitglieder',
|
||||
self::RELEASED => 'Nur freigeschaltete Konten',
|
||||
self::OWNERS => 'Mitglieder, die einen bestimmten Artikel besitzen',
|
||||
];
|
||||
|
||||
public function __construct(private readonly OfferService $offers) {}
|
||||
|
||||
/**
|
||||
* Die Regel eines Angebots festlegen. Der Artikel ist nur bei „besitzt einen Artikel“ gesetzt.
|
||||
*/
|
||||
public function setRule(Offer $offer, string $access, ?int $articleId = null): void
|
||||
{
|
||||
if (! array_key_exists($access, self::OPTIONS)) {
|
||||
throw new DomainRuleException('Diese Regel für den Abruf gibt es nicht.');
|
||||
}
|
||||
|
||||
if ($access === self::OWNERS) {
|
||||
$article = $articleId === null ? null : LicenseArticle::query()->whereNull('archived_at')->find($articleId);
|
||||
|
||||
if ($article === null) {
|
||||
throw new DomainRuleException('Für diese Regel braucht es einen vorhandenen, nicht archivierten Lizenzartikel.');
|
||||
}
|
||||
} else {
|
||||
$articleId = null;
|
||||
}
|
||||
|
||||
$offer->claim_access = $access;
|
||||
$offer->claim_requires_article_id = $articleId;
|
||||
$offer->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Warum das Konto das Angebot nicht abrufen darf; null, wenn es das darf. Regeln gelten nur für Vergaben „auf Abruf“.
|
||||
*/
|
||||
public function refusal(User $user, Offer $offer, ?CarbonInterface $now = null): ?string
|
||||
{
|
||||
$now ??= now();
|
||||
$version = $this->activeVersion($offer);
|
||||
|
||||
if ($version === null || ! in_array($version->grant_kind, ['auf_abruf', 'bei_registrierung'], true) || $version->holder_kind !== 'person') {
|
||||
return 'Dieses Angebot wird nicht frei vergeben.';
|
||||
}
|
||||
|
||||
if ($user->party_id === null) {
|
||||
return 'Nur ein Mitgliedskonto kann ein Angebot abrufen.';
|
||||
}
|
||||
|
||||
// „Bei Registrierung“ geht automatisch an neue Konten und kennt keine Regel.
|
||||
if ($version->grant_kind !== 'auf_abruf') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return match ((string) $offer->claim_access) {
|
||||
self::RELEASED => $this->activeRelease($offer, $user, $now) === null ? 'Dieses Angebot ist für dein Konto nicht freigeschaltet.' : null,
|
||||
self::OWNERS => $offer->claim_requires_article_id !== null && $this->owns($user, (int) $offer->claim_requires_article_id, $now) ? null : 'Dieses Angebot steht für dein Konto nicht zur Verfügung.',
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
public function mayClaim(User $user, Offer $offer, ?CarbonInterface $now = null): bool
|
||||
{
|
||||
return $this->refusal($user, $offer, $now) === null;
|
||||
}
|
||||
|
||||
public function assertMayClaim(User $user, Offer $offer): void
|
||||
{
|
||||
$reason = $this->refusal($user, $offer);
|
||||
|
||||
if ($reason !== null) {
|
||||
throw new DomainRuleException($reason);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Angebote auf Abruf, die das Konto jetzt übernehmen darf und noch nicht übernommen hat.
|
||||
*
|
||||
* @return Collection<int, Offer>
|
||||
*/
|
||||
public function claimable(User $user): Collection
|
||||
{
|
||||
if ($user->party_id === null) {
|
||||
return collect();
|
||||
}
|
||||
|
||||
$taken = Acquisition::query()
|
||||
->where('party_id', $user->party_id)
|
||||
->where('type', AcquisitionType::FreierAbruf)
|
||||
->where('reference_type', 'offer')
|
||||
->pluck('reference_id')
|
||||
->all();
|
||||
|
||||
return Offer::query()
|
||||
->whereHas('versions', fn ($query) => $query->where('status', OfferStatus::Aktiv)->where('holder_kind', 'person')->whereIn('grant_kind', ['auf_abruf', 'bei_registrierung']))
|
||||
->whereNotIn('id', $taken)
|
||||
->orderBy('name')
|
||||
->get()
|
||||
->filter(fn (Offer $offer): bool => $this->mayClaim($user, $offer))
|
||||
->values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ein Konto für ein Angebot freischalten (Regel „nur freigeschaltete Konten“).
|
||||
*/
|
||||
public function release(Offer $offer, User $member, ?User $actor, ?CarbonInterface $until = null, ?string $reason = null): OfferRelease
|
||||
{
|
||||
if ($offer->claim_access !== self::RELEASED) {
|
||||
throw new DomainRuleException('Freigaben gibt es nur bei der Regel „nur freigeschaltete Konten“.');
|
||||
}
|
||||
|
||||
if ($member->party_id === null) {
|
||||
throw new DomainRuleException('Nur ein Mitgliedskonto kann für ein Angebot freigeschaltet werden.');
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($offer, $member, $actor, $until, $reason): OfferRelease {
|
||||
Offer::query()->whereKey($offer->id)->lockForUpdate()->firstOrFail();
|
||||
|
||||
if ($this->activeRelease($offer, $member) !== null) {
|
||||
throw new DomainRuleException('Dieses Konto ist für das Angebot bereits freigeschaltet.');
|
||||
}
|
||||
|
||||
if ($until !== null && $until->lessThanOrEqualTo(now())) {
|
||||
throw new DomainRuleException('Das Ende der Freigabe liegt in der Vergangenheit.');
|
||||
}
|
||||
|
||||
return OfferRelease::query()->create([
|
||||
'offer_id' => $offer->id,
|
||||
'user_id' => $member->id,
|
||||
'granted_by' => $actor?->id,
|
||||
'granted_at' => now(),
|
||||
'valid_until' => $until,
|
||||
'reason' => filled($reason) ? trim((string) $reason) : null,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Entzieht die Freigabe. Sie bleibt mit Zeitpunkt, Person und Begründung gespeichert; bereits übernommene Angebote
|
||||
* bleiben in der Bibliothek.
|
||||
*/
|
||||
public function revoke(OfferRelease $release, ?User $actor, ?string $reason = null): OfferRelease
|
||||
{
|
||||
return DB::transaction(function () use ($release, $actor, $reason): OfferRelease {
|
||||
$release = OfferRelease::query()->lockForUpdate()->findOrFail($release->id);
|
||||
|
||||
if ($release->revoked_at !== null) {
|
||||
throw new DomainRuleException('Diese Freigabe ist bereits entzogen.');
|
||||
}
|
||||
|
||||
$release->forceFill([
|
||||
'revoked_at' => now(),
|
||||
'revoked_by' => $actor?->id,
|
||||
'reason' => filled($reason) ? trim((string) $reason) : $release->reason,
|
||||
])->save();
|
||||
|
||||
return $release;
|
||||
});
|
||||
}
|
||||
|
||||
public function activeRelease(Offer $offer, User $member, ?CarbonInterface $now = null): ?OfferRelease
|
||||
{
|
||||
$now ??= now();
|
||||
|
||||
return OfferRelease::query()
|
||||
->where('offer_id', $offer->id)
|
||||
->where('user_id', $member->id)
|
||||
->whereNull('revoked_at')
|
||||
->where('granted_at', '<=', $now)
|
||||
->where(fn ($query) => $query->whereNull('valid_until')->orWhere('valid_until', '>', $now))
|
||||
->first();
|
||||
}
|
||||
|
||||
/** Das Konto besitzt den Artikel, wenn seine Person eine aktive, gültige Berechtigung darauf hat. */
|
||||
public function owns(User $user, int $articleId, ?CarbonInterface $now = null): bool
|
||||
{
|
||||
$now ??= now();
|
||||
|
||||
if ($user->party_id === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Grant::query()
|
||||
->where('license_article_id', $articleId)
|
||||
->where('status', GrantStatus::Aktiv)
|
||||
->where(fn ($query) => $query->whereNull('valid_from')->orWhere('valid_from', '<=', $now))
|
||||
->where(fn ($query) => $query->whereNull('valid_until')->orWhere('valid_until', '>', $now))
|
||||
->whereHas('acquisition', fn ($query) => $query->where('party_id', $user->party_id))
|
||||
->exists();
|
||||
}
|
||||
|
||||
private function activeVersion(Offer $offer): ?OfferVersion
|
||||
{
|
||||
return $offer->versions()->where('status', OfferStatus::Aktiv)->orderByDesc('number')->first();
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,8 @@
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Resources\Pillars\PillarResource;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Filament\Support\SymbolField;
|
||||
use App\Support\Brand\SymbolCatalog;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
@@ -261,6 +263,8 @@ private function formular(?Model $record): array
|
||||
];
|
||||
|
||||
if ($this->istMaterialart()) {
|
||||
$felder[] = SymbolField::make('symbol', 'Symbol im Shop')
|
||||
->helperText('Optional. Das Symbol steht auf der Shopkachel bei Artikeln dieser Materialart, auch wenn kein Bild gepflegt ist.');
|
||||
$system = $record instanceof EditorialContentKind && $record->isSystem();
|
||||
$felder[] = CheckboxList::make('contexts')
|
||||
->label('Zulässig für')
|
||||
@@ -325,6 +329,7 @@ private function bearbeitenAction(): Action
|
||||
->schema(fn (Model $record): array => $this->formular($record))
|
||||
->fillForm(fn (Model $record): array => [
|
||||
'label' => $record->label,
|
||||
'symbol' => $record instanceof EditorialContentKind ? $record->symbol : null,
|
||||
'contexts' => $record instanceof EditorialContentKind ? (array) ($record->contexts ?? []) : [],
|
||||
])
|
||||
->modalSubmitActionLabel('Speichern')
|
||||
@@ -337,11 +342,21 @@ private function bearbeitenAction(): Action
|
||||
$record->contexts = $this->kontexte((array) $data['contexts']);
|
||||
}
|
||||
|
||||
if ($record instanceof EditorialContentKind) {
|
||||
$record->symbol = $this->symbol($data['symbol'] ?? null);
|
||||
}
|
||||
|
||||
$record->save();
|
||||
Notification::make()->success()->title('Gespeichert')->body('Die neue Bezeichnung gilt sofort in Redaktion, Filtern und Picker.')->send();
|
||||
});
|
||||
}
|
||||
|
||||
/** Ein Symbol wird nur gespeichert, wenn die Symbolbibliothek es kennt; sonst bleibt die Materialart ohne Symbol. */
|
||||
private function symbol(mixed $value): ?string
|
||||
{
|
||||
return is_string($value) && array_key_exists($value, SymbolCatalog::options()) ? $value : null;
|
||||
}
|
||||
|
||||
private function anlegen(array $data): void
|
||||
{
|
||||
$label = trim((string) $data['label']);
|
||||
@@ -354,6 +369,7 @@ private function anlegen(array $data): void
|
||||
'sort_order' => (int) EditorialContentKind::query()->max('sort_order') + 10,
|
||||
'is_active' => true,
|
||||
'contexts' => $this->kontexte((array) ($data['contexts'] ?? [])),
|
||||
'symbol' => $this->symbol($data['symbol'] ?? null),
|
||||
]);
|
||||
} else {
|
||||
$dimension = $this->dimension();
|
||||
|
||||
@@ -85,7 +85,8 @@ public function daten(): array
|
||||
|
||||
$freigabe = [
|
||||
['text' => 'Produktivfreigabe (SHOP_LIVE_RELEASE): '.(config('shop.live_release') === true ? 'gesetzt' : 'nicht gesetzt'), 'neben' => 'Standardmäßig aus. Setzt Lars in der Umgebungsdatei des Servers, wenn er den Verkauf freigibt. Ohne sie bleibt der Shop in Produktion abgeschaltet und Stripe nimmt dort keine Zahlung an.', 'zustand' => config('shop.live_release') === true ? ['label' => 'Gesetzt', 'ton' => 'gut'] : ['label' => 'Aus', 'ton' => 'neutral']],
|
||||
['text' => 'Umgebung: '.(app()->isProduction() ? 'Produktion' : 'Test oder lokal'), 'neben' => app()->isProduction() ? 'Der Shop ist hier '.(Shop::enabled() ? 'aktiv.' : 'abgeschaltet.') : 'Hier läuft der Shop mit Test- oder Sandbox-Zahlung.', 'zustand' => app()->isProduction() ? (Shop::enabled() ? ['label' => 'Live', 'ton' => 'gut'] : ['label' => 'Abgeschaltet', 'ton' => 'neutral']) : ['label' => 'Test', 'ton' => 'neutral']],
|
||||
['text' => 'Shop sichtbar (SHOP_PUBLIC): '.(config('shop.public') === true ? 'gesetzt' : 'nicht gesetzt'), 'neben' => 'Zweiter Schalter, nur Produktion: Übersicht, Produktseiten und Pakete sind öffentlich zu sehen, „Kaufen“ führt auf die Hinweisseite (der Kauf startet zum Verkaufsstart). Die Produktivfreigabe macht den Shop immer auch sichtbar. Wird wie sie in der Umgebungsdatei des Servers gesetzt.', 'zustand' => Shop::visible() ? ['label' => 'Sichtbar', 'ton' => 'gut'] : ['label' => 'Aus', 'ton' => 'neutral']],
|
||||
['text' => 'Umgebung: '.(app()->isProduction() ? 'Produktion' : 'Test oder lokal'), 'neben' => app()->isProduction() ? 'Der Shop ist hier '.(Shop::checkoutOpen() ? 'aktiv: sichtbar und kaufbar.' : (Shop::visible() ? 'sichtbar, der Kauf ist noch nicht freigegeben.' : 'abgeschaltet.')) : 'Hier läuft der Shop mit Test- oder Sandbox-Zahlung.', 'zustand' => app()->isProduction() ? (Shop::enabled() ? ['label' => 'Live', 'ton' => 'gut'] : ['label' => 'Abgeschaltet', 'ton' => 'neutral']) : ['label' => 'Test', 'ton' => 'neutral']],
|
||||
];
|
||||
|
||||
$angebote = [
|
||||
|
||||
@@ -13,20 +13,33 @@
|
||||
use App\Domain\Catalog\IdentityDimension;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
use App\Domain\Catalog\LicenceScope;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Catalog\StatusValue;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Domain\Commerce\ShopMarkers;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Resources\Offers\OfferResource;
|
||||
use App\Filament\Support\AssignsPillars;
|
||||
use App\Filament\Support\CatalogLabels;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Filament\Support\ManagesEditorialSurface;
|
||||
use App\Filament\Support\ManagesRichFields;
|
||||
use App\Filament\Support\PublicationReadiness;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -409,6 +422,248 @@ public function withdrawAction(): Action
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Optionen dieses Artikels im Shop: Bezeichnung, Preis, Rechte, Nutzerkreis und Zustand je Option. Gelesen wird
|
||||
* die aktive, sonst die letzte Fassung.
|
||||
*
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function optionRows(): array
|
||||
{
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
$options = app(ProductOptions::class);
|
||||
$offers = app(OfferService::class);
|
||||
$rows = [];
|
||||
|
||||
foreach ($options->offersOfArticle($article) as $offer) {
|
||||
$version = $offers->purchasableVersion($offer)
|
||||
?? $offer->versions()->where('status', OfferStatus::Aktiv)->orderByDesc('number')->first()
|
||||
?? $offer->versions()->orderByDesc('number')->first();
|
||||
|
||||
if ($version === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$version->loadMissing('lines.rights.profile');
|
||||
$active = StatusValue::of($version->status) === OfferStatus::Aktiv->value;
|
||||
$buyable = $active && $offers->purchasableVersion($offer) !== null;
|
||||
$rows[] = [
|
||||
'offer' => $offer->id,
|
||||
'name' => $offer->optionName(),
|
||||
'price' => $version->price_cents === null ? 'kein Preis' : Money::format((int) $version->price_cents),
|
||||
'licence' => LicenceScope::label($version->licence_scope, $version->trainer_count),
|
||||
'for' => $version->holder_kind === 'organisation' ? 'Organisationen und Vereine' : 'Privatpersonen',
|
||||
'rights' => (string) ($version->lines->first()?->rights?->profile?->name ?? '–'),
|
||||
'number' => $version->number,
|
||||
'active' => $active,
|
||||
'kauf' => $version->grant_kind === 'kauf',
|
||||
'buyable' => $buyable,
|
||||
'zustand' => match (true) {
|
||||
$buyable => ['label' => 'Im Shop', 'ton' => 'gut'],
|
||||
$active => ['label' => CatalogLabels::vergabe($version).' · nicht im Shop', 'ton' => 'neutral'],
|
||||
default => ['label' => 'Nicht im Verkauf', 'ton' => 'leise'],
|
||||
},
|
||||
'page' => $buyable ? parse_url((string) $options->pageUrl($offer), PHP_URL_PATH) : null,
|
||||
'url' => OfferResource::getUrl('view', ['record' => $offer]),
|
||||
];
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/** Ein Artikel lässt sich anbieten, wenn sein aktueller Stand veröffentlicht ist. */
|
||||
public function canOffer(): bool
|
||||
{
|
||||
return app(PublicationReadiness::class)->articleUsable($this->getRecord());
|
||||
}
|
||||
|
||||
/**
|
||||
* Option hinzufügen oder ändern: Rechteprofil, Preis, Nutzerkreis und Eignung. Der Artikel steht fest, es gibt keine
|
||||
* Auswahl von Artikel oder Inhalt. Mit dem Argument `offer` ändert die Aktion eine bestehende Option (nächste Fassung).
|
||||
*/
|
||||
public function optionAction(): Action
|
||||
{
|
||||
return Action::make('option')
|
||||
->modalWidth('2xl')
|
||||
->modalHeading(fn (array $arguments): string => isset($arguments['offer'])
|
||||
? 'Option „'.$this->optionOf($arguments)->optionName().'“ ändern'
|
||||
: 'Option hinzufügen: so wird der Artikel verkauft')
|
||||
->modalDescription(fn (array $arguments): string => isset($arguments['offer'])
|
||||
? 'Die Maske ist mit der letzten Fassung vorbelegt. Erst „Speichern und anbieten“ schaltet die Änderung öffentlich: Die bisherige Fassung wird beendet und bleibt gespeichert, neue Käufe nutzen die neue. Bereits begründete Berechtigungen und Bestellungen ändern sich nicht. „Abbrechen“ verwirft die Eingaben.'
|
||||
: 'Eine Option ist eine Lizenz mit Rechteprofil und Preis. Der Artikel kann mehrere Optionen haben, zum Beispiel für Privatpersonen und für Vereine. Sie erscheinen gemeinsam auf der Produktseite des Artikels. „Abbrechen“ verwirft die Eingaben.')
|
||||
->modalSubmitActionLabel('Speichern und anbieten')
|
||||
->fillForm(fn (array $arguments): array => $this->optionForm($arguments))
|
||||
->schema([
|
||||
Select::make('rights_id')->label('Rechteprofil')
|
||||
->options(fn (): array => CatalogOptions::rights())
|
||||
->required()
|
||||
->helperText('Was Käufer mit dem Artikel tun dürfen (ansehen, herunterladen, Nutzungszweck).'),
|
||||
TextInput::make('price_euro')->label('Preis in Euro')->suffix('€')->required()
|
||||
->helperText('Zum Beispiel 49,00. Ein Kauf braucht einen Preis über 0,00 €.'),
|
||||
Select::make('holder_kind')->label('Geeignet für')->options([
|
||||
'person' => 'Privatpersonen',
|
||||
'organisation' => 'Organisationen und Vereine',
|
||||
])->required()->live()
|
||||
->helperText('Wähle die Eignung passend zum Rechteprofil: Organisationslizenzen brauchen institutionelle Rechte.'),
|
||||
Select::make('licence_scope')->label('Nutzerkreis')
|
||||
->options(LicenceScope::options())
|
||||
->required()->live()
|
||||
->helperText('Wie viele Trainer die Inhalte einsetzen dürfen. Der Download bleibt beim bestellenden Konto.'),
|
||||
TextInput::make('trainer_count')->label('Anzahl Trainer')
|
||||
->numeric()->minValue(2)->maxValue(LicenceScope::MAX_TRAINERS)->integer()
|
||||
->required(fn (Get $get): bool => $get('licence_scope') === LicenceScope::MULTI)
|
||||
->visible(fn (Get $get): bool => $get('licence_scope') === LicenceScope::MULTI)
|
||||
->live(),
|
||||
TextInput::make('option_label')->label('Bezeichnung der Option')
|
||||
->maxLength(120)
|
||||
->placeholder(fn (Get $get): string => OfferService::defaultOptionLabel($get('holder_kind'), $get('licence_scope'), $get('trainer_count')))
|
||||
->helperText('So heißt die Option auf der Produktseite. Leer lassen übernimmt den grauen Vorschlag.'),
|
||||
])
|
||||
->action(function (array $data, array $arguments): void {
|
||||
$this->report(function () use ($data, $arguments): string {
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
$rights = RightsProfileVersion::query()->findOrFail($data['rights_id']);
|
||||
$price = Money::parse($data['price_euro'] ?? null);
|
||||
$label = filled($data['option_label'] ?? null)
|
||||
? trim((string) $data['option_label'])
|
||||
: OfferService::defaultOptionLabel($data['holder_kind'], $data['licence_scope'], $data['trainer_count'] ?? null);
|
||||
$attributes = [
|
||||
'holder_kind' => $data['holder_kind'],
|
||||
'licence_scope' => $data['licence_scope'],
|
||||
'trainer_count' => $data['trainer_count'] ?? null,
|
||||
'price_cents' => $price,
|
||||
];
|
||||
$service = app(OfferService::class);
|
||||
|
||||
if (isset($arguments['offer'])) {
|
||||
$offer = $this->optionOf($arguments);
|
||||
$version = $service->reviseArticleOption($offer, $article, $rights, $attributes, $label);
|
||||
} else {
|
||||
$name = app(ProductOptions::class)->articleTitle($article).': '.$label;
|
||||
$version = $service->offerArticle($article, $rights, $attributes, $name, $label);
|
||||
$offer = $version->offer;
|
||||
}
|
||||
|
||||
$page = app(ProductOptions::class)->pageUrl($offer);
|
||||
|
||||
return 'Die Option „'.$offer->optionName().'“ ist als Fassung '.$version->number.' aktiv und im Shop kaufbar'
|
||||
.($page !== null ? ' unter '.parse_url($page, PHP_URL_PATH) : '').'.';
|
||||
}, 'Die Option ist aktiv.');
|
||||
$this->refreshRecord();
|
||||
});
|
||||
}
|
||||
|
||||
/** Die Marker, die die Kachel im Shop gerade zeigt (Wort je Marker), mit der Einstellung der Redaktion. */
|
||||
public function markerRows(): array
|
||||
{
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
$markers = app(ShopMarkers::class);
|
||||
$offerIds = array_map(fn (Offer $offer): int => (int) $offer->id, app(ProductOptions::class)->offersOfArticle($article));
|
||||
|
||||
return [
|
||||
'sichtbar' => array_column($markers->visible($article, $offerIds), 'label'),
|
||||
'einstellung' => $markers->settings($article),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Marker für die Kachel im Shop: „Neu“ und „Aktualisiert“ folgen automatisch den Daten und lassen sich fest an- oder
|
||||
* abschalten, „Beliebt“ setzt die Redaktion von Hand. Die Aktion speichert nur die Marker, sonst nichts (nicht die
|
||||
* Redaktion des Artikels).
|
||||
*/
|
||||
public function markersAction(): Action
|
||||
{
|
||||
return Action::make('markers')
|
||||
->modalWidth('lg')
|
||||
->modalHeading('Marker für die Kachel im Shop')
|
||||
->modalDescription('Marker erscheinen mit ihrem Wort auf der Kachel des Artikels. „Neu“ und „Aktualisiert“ richten sich automatisch nach den Daten; hier kannst du sie fest an- oder abschalten. „Beliebt“ setzt du von Hand, bis es Verkaufszahlen gibt.')
|
||||
->modalSubmitActionLabel('Marker speichern')
|
||||
->fillForm(fn (): array => $this->markerRows()['einstellung'])
|
||||
->schema(collect(ShopMarkers::CHOICES)->map(fn (array $choices, string $key): Select => Select::make($key)
|
||||
->label(ShopMarkers::KEYS[$key])
|
||||
->options($choices)
|
||||
->required()
|
||||
->native(false))->values()->all())
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
app(ShopMarkers::class)->save($article, $data);
|
||||
|
||||
return 'Die Marker sind gespeichert.';
|
||||
}, 'Die Marker sind gespeichert.');
|
||||
$this->refreshRecord();
|
||||
});
|
||||
}
|
||||
|
||||
/** Eine Option aus dem Verkauf nehmen: nur die aktive Fassung dieser Option wird beendet. */
|
||||
public function optionEndAction(): Action
|
||||
{
|
||||
return Action::make('optionEnd')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->modalHeading(fn (array $arguments): string => 'Option „'.$this->optionOf($arguments)->optionName().'“ aus dem Verkauf nehmen?')
|
||||
->modalDescription('Die aktive Fassung wird beendet und bleibt gespeichert. Die Option ist danach nicht mehr kaufbar; in vorhandenen Warenkörben bleibt sie mit Hinweis sichtbar und blockiert den Abschluss, bis der Käufer sie entfernt. Bestehende Berechtigungen und Bestellungen ändern sich nicht. Andere Optionen des Artikels bleiben kaufbar.')
|
||||
->modalSubmitActionLabel('Aus dem Verkauf nehmen')
|
||||
->action(function (array $arguments): void {
|
||||
$this->report(function () use ($arguments): string {
|
||||
$offer = $this->optionOf($arguments);
|
||||
$version = app(OfferService::class)->end($offer);
|
||||
|
||||
return 'Die Option „'.$offer->optionName().'“ ist aus dem Verkauf genommen (Fassung '.$version->number.' beendet).';
|
||||
}, 'Die Option ist aus dem Verkauf genommen.');
|
||||
$this->refreshRecord();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Option aus den Argumenten der Aktion, nur wenn sie zu diesem Artikel gehört.
|
||||
*
|
||||
* @param array<string, mixed> $arguments
|
||||
*/
|
||||
private function optionOf(array $arguments): Offer
|
||||
{
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
$offer = collect(app(ProductOptions::class)->offersOfArticle($article))->first(fn (Offer $offer): bool => $offer->id === (int) ($arguments['offer'] ?? 0)
|
||||
&& $offer->versions()->orderByDesc('number')->value('grant_kind') === 'kauf');
|
||||
|
||||
// Vergaben auf Abruf oder bei Registrierung sind keine Shop-Optionen und werden am Angebot bearbeitet.
|
||||
return $offer ?? abort(404);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $arguments
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function optionForm(array $arguments): array
|
||||
{
|
||||
if (! isset($arguments['offer'])) {
|
||||
$rights = array_keys(CatalogOptions::rights());
|
||||
|
||||
return [
|
||||
'holder_kind' => 'person',
|
||||
'licence_scope' => LicenceScope::SINGLE,
|
||||
'rights_id' => count($rights) === 1 ? $rights[0] : null,
|
||||
];
|
||||
}
|
||||
|
||||
$offer = $this->optionOf($arguments);
|
||||
$version = $offer->versions()->with('lines')->orderByDesc('number')->firstOrFail();
|
||||
|
||||
return [
|
||||
'rights_id' => $version->lines->first()?->rights_profile_version_id,
|
||||
'price_euro' => $version->price_cents === null ? null : number_format($version->price_cents / 100, 2, ',', ''),
|
||||
'holder_kind' => $version->holder_kind,
|
||||
'licence_scope' => $version->licence_scope,
|
||||
'trainer_count' => $version->trainer_count,
|
||||
'option_label' => $offer->option_label,
|
||||
];
|
||||
}
|
||||
|
||||
private function isFirstStand(): bool
|
||||
{
|
||||
return ! $this->getRecord()->releases()->exists();
|
||||
|
||||
@@ -24,7 +24,7 @@ class ListOffers extends ListRecords
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Ein Angebot verbindet Artikel oder eine Paketfassung mit einem Rechteprofil. Die aufgelösten Berechtigungen stehen auf der Angebotsseite.';
|
||||
return 'Ein Angebot ist eine Option zum Kauf: ein Artikel oder eine Paketfassung mit Rechteprofil und Preis. Optionen eines einzelnen Artikels legst du am Lizenzartikel an („Im Shop verkaufen“); hier stehen alle Angebote, auch die der Pakete.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\BundleVersion;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\LicenceScope;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferRelease;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
@@ -18,6 +18,7 @@
|
||||
use App\Domain\Catalog\StatusValue;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Domain\Entitlement\OfferAccess;
|
||||
use App\Filament\Pages\Zahlungsjournal;
|
||||
use App\Filament\Resources\Offers\OfferResource;
|
||||
use App\Filament\Support\CatalogLabels;
|
||||
@@ -25,9 +26,12 @@
|
||||
use App\Filament\Support\PublicationReadiness;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use App\Filament\Support\ShopAccess;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
@@ -35,6 +39,7 @@
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
@@ -136,18 +141,6 @@ public function activateAction(): Action
|
||||
])->required(),
|
||||
TextInput::make('price_euro')->label('Preis in Euro')->suffix('€')
|
||||
->helperText('Nur bei einem Kauf, zum Beispiel 49,00.'),
|
||||
Select::make('composition_version_id')->label('Programmfassung, die abgedeckt sein muss')
|
||||
->options(function (): array {
|
||||
return CompositionVersion::query()
|
||||
->where('status', 'bereit')
|
||||
->with('composition.editorialContentKind')
|
||||
->orderByDesc('id')
|
||||
->get()
|
||||
->mapWithKeys(fn (CompositionVersion $version): array => [$version->id => CatalogOptions::compositionLabel($version)])
|
||||
->all();
|
||||
})
|
||||
->searchable()
|
||||
->helperText('Wenn gewählt, lässt sich die Fassung nur aktivieren, wenn jeder Bestandteil in den Artikeln enthalten ist.'),
|
||||
Repeater::make('lines')->label('Positionen')->schema([
|
||||
Select::make('kind')->label('Ziel')->options([
|
||||
'article' => 'Lizenzartikel',
|
||||
@@ -217,7 +210,6 @@ public function activateAction(): Action
|
||||
'trainer_count' => $data['trainer_count'] ?? null,
|
||||
'grant_kind' => $data['grant_kind'],
|
||||
'price_cents' => $price,
|
||||
'composition_version_id' => filled($data['composition_version_id'] ?? null) ? (int) $data['composition_version_id'] : null,
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -257,6 +249,175 @@ public function endAction(): Action
|
||||
});
|
||||
}
|
||||
|
||||
/** Ein Angebot auf Abruf: nur dafür gibt es Regeln, wer es übernehmen darf (ADR-56). */
|
||||
private function isOnDemand(): bool
|
||||
{
|
||||
return $this->activeVersion()?->grant_kind === 'auf_abruf';
|
||||
}
|
||||
|
||||
/**
|
||||
* Wer das Angebot übernehmen darf: alle Mitglieder, nur freigeschaltete Konten oder wer einen Artikel besitzt.
|
||||
*/
|
||||
public function claimRuleAction(): Action
|
||||
{
|
||||
return Action::make('claimRule')
|
||||
->label('Regel für den Abruf')
|
||||
->modalHeading(fn (): string => 'Wer darf „'.$this->getRecord()->name.'“ abrufen?')
|
||||
->modalDescription('Die Regel gilt für den kostenlosen Abruf in die Bibliothek und wird beim Abruf geprüft. Sie begrenzt nur den Abruf; sie vergibt nichts. Bereits übernommene Angebote bleiben in der Bibliothek.')
|
||||
->modalSubmitActionLabel('Regel speichern')
|
||||
->visible(fn (): bool => $this->isOnDemand())
|
||||
->fillForm(fn (): array => [
|
||||
'claim_access' => (string) ($this->getRecord()->claim_access ?: OfferAccess::ALL),
|
||||
'claim_requires_article_id' => $this->getRecord()->claim_requires_article_id,
|
||||
])
|
||||
->schema([
|
||||
Select::make('claim_access')->label('Wer darf abrufen')
|
||||
->options(OfferAccess::OPTIONS)
|
||||
->required()->live()->native(false)
|
||||
->helperText('„Nur freigeschaltete Konten“: Du schaltest einzelne Konten auf dieser Seite frei und entziehst die Freigabe wieder. Sie gilt nur für dieses Angebot.'),
|
||||
Select::make('claim_requires_article_id')->label('Artikel, den das Konto besitzen muss')
|
||||
->options(fn (): array => LicenseArticle::query()->whereNull('archived_at')->orderBy('code')->get()
|
||||
->mapWithKeys(fn (LicenseArticle $article): array => [$article->id => app(ProductOptions::class)->articleTitle($article)])->all())
|
||||
->searchable()
|
||||
->required(fn (Get $get): bool => $get('claim_access') === OfferAccess::OWNERS)
|
||||
->visible(fn (Get $get): bool => $get('claim_access') === OfferAccess::OWNERS)
|
||||
->helperText('Das Konto muss eine gültige Berechtigung auf diesen Artikel haben, zum Beispiel durch einen Kauf.'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
app(OfferAccess::class)->setRule($this->getRecord(), (string) $data['claim_access'], filled($data['claim_requires_article_id'] ?? null) ? (int) $data['claim_requires_article_id'] : null);
|
||||
|
||||
return 'Die Regel für den Abruf ist gespeichert.';
|
||||
}, 'Die Regel ist gespeichert.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
});
|
||||
}
|
||||
|
||||
public function releaseAction(): Action
|
||||
{
|
||||
return Action::make('release')
|
||||
->label('Konto freischalten')
|
||||
->modalHeading(fn (): string => 'Konto für „'.$this->getRecord()->name.'“ freischalten')
|
||||
->modalDescription('Das Konto darf genau dieses Angebot abrufen, solange Freigabe und Angebot gelten. Die Freigabe gilt nicht für andere Angebote und bleibt mit dem Entzug im Verlauf stehen.')
|
||||
->modalSubmitActionLabel('Konto freischalten')
|
||||
->visible(fn (): bool => $this->isOnDemand() && $this->getRecord()->claim_access === OfferAccess::RELEASED)
|
||||
->schema([
|
||||
Select::make('user_id')->label('Mitgliedskonto')->required()->searchable()
|
||||
->getSearchResultsUsing(fn (string $search): array => $this->searchMembers($search))
|
||||
->getOptionLabelUsing(fn ($value): ?string => ($user = User::query()->find($value)) === null ? null : $user->name.' ('.$user->email.')')
|
||||
->helperText('Suche nach Name oder E-Mail-Adresse. Nur Konten mit Mitgliedsprofil.'),
|
||||
DatePicker::make('valid_until')->label('Freigabe gültig bis einschließlich')->native(false)->displayFormat('d.m.Y')
|
||||
->helperText('Leer: ohne Ende.'),
|
||||
Textarea::make('reason')->label('Grundlage der Freigabe')->rows(2)->maxLength(500)
|
||||
->helperText('Zum Beispiel „Teilnahme am Seminar am 12.11.2026“. Bleibt im Verlauf stehen.'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
$member = User::query()->findOrFail($data['user_id']);
|
||||
$until = filled($data['valid_until'] ?? null) ? Carbon::parse((string) $data['valid_until'], config('app.timezone'))->endOfDay() : null;
|
||||
app(OfferAccess::class)->release($this->getRecord(), $member, auth('staff')->user() ?? auth()->user(), $until, $data['reason'] ?? null);
|
||||
|
||||
return 'Das Konto von '.$member->name.' ist für das Angebot freigeschaltet.';
|
||||
}, 'Das Konto ist freigeschaltet.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
});
|
||||
}
|
||||
|
||||
public function revokeAction(): Action
|
||||
{
|
||||
return Action::make('revoke')
|
||||
->label('Freigabe entziehen')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Freigabe entziehen?')
|
||||
->modalDescription('Das Konto kann das Angebot danach nicht mehr abrufen. Bereits übernommene Angebote bleiben in der Bibliothek. Die Freigabe bleibt mit dem Entzug im Verlauf stehen.')
|
||||
->modalSubmitActionLabel('Freigabe entziehen')
|
||||
->schema([
|
||||
Textarea::make('reason')->label('Grund')->rows(2)->maxLength(500),
|
||||
])
|
||||
->action(function (array $data, array $arguments): void {
|
||||
$this->report(function () use ($data, $arguments): string {
|
||||
$release = OfferRelease::query()->where('offer_id', $this->getRecord()->id)->findOrFail((int) ($arguments['release'] ?? 0));
|
||||
app(OfferAccess::class)->revoke($release, auth('staff')->user() ?? auth()->user(), $data['reason'] ?? null);
|
||||
|
||||
return 'Die Freigabe ist entzogen.';
|
||||
}, 'Die Freigabe ist entzogen.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
private function searchMembers(string $search): array
|
||||
{
|
||||
$like = '%'.mb_strtolower(trim($search)).'%';
|
||||
|
||||
return User::query()
|
||||
->whereNotNull('party_id')
|
||||
->where(fn ($query) => $query->whereRaw('LOWER(name) LIKE ?', [$like])->orWhereRaw('LOWER(email) LIKE ?', [$like]))
|
||||
->orderBy('name')
|
||||
->limit(20)
|
||||
->get()
|
||||
->mapWithKeys(fn (User $user): array => [$user->id => $user->name.' ('.$user->email.')'])
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Abschnitte „Wer darf abrufen“ und „Freigeschaltete Konten“ für ein Angebot auf Abruf.
|
||||
*
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
private function abrufAbschnitte(Offer $offer): array
|
||||
{
|
||||
$date = fn ($value): string => $value?->format('d.m.Y') ?? '';
|
||||
$access = (string) ($offer->claim_access ?: OfferAccess::ALL);
|
||||
$article = $offer->claim_requires_article_id !== null ? LicenseArticle::query()->find($offer->claim_requires_article_id) : null;
|
||||
$releases = $offer->releases()->with(['user', 'grantor'])->orderByDesc('id')->get();
|
||||
$active = $releases->filter(fn (OfferRelease $release): bool => $release->revoked_at === null);
|
||||
$past = $releases->filter(fn (OfferRelease $release): bool => $release->revoked_at !== null);
|
||||
$sections = [[
|
||||
'titel' => 'Wer darf abrufen',
|
||||
'hilfe' => 'Diese Regel gilt für den kostenlosen Abruf in die Bibliothek (Mitgliederbereich → Angebote). Sie wird beim Abruf geprüft, nicht nur in der Anzeige.',
|
||||
'zeilen' => [[
|
||||
'text' => OfferAccess::OPTIONS[$access] ?? $access,
|
||||
'neben' => $access === OfferAccess::OWNERS
|
||||
? 'Erforderlich: '.($article !== null ? app(ProductOptions::class)->articleTitle($article) : 'ein Artikel fehlt (Regel prüfen)')
|
||||
: ($access === OfferAccess::RELEASED ? 'Mit „Konto freischalten“ gibst du einzelne Konten frei.' : 'Jedes angemeldete Mitgliedskonto sieht das Angebot und kann es übernehmen.'),
|
||||
]],
|
||||
]];
|
||||
|
||||
if ($access === OfferAccess::RELEASED) {
|
||||
$sections[] = [
|
||||
'titel' => 'Freigeschaltete Konten',
|
||||
'zusatz' => $active->count().' aktiv',
|
||||
'hilfe' => 'Nur diese Konten sehen das Angebot im Mitgliederbereich und können es übernehmen.',
|
||||
'zeilen' => $active->map(fn (OfferRelease $release): array => [
|
||||
'text' => ($release->user?->name ?? 'Konto').' ('.($release->user?->email ?? '').')',
|
||||
'neben' => 'freigeschaltet am '.$date($release->granted_at).($release->grantor ? ' von '.$release->grantor->name : '').($release->valid_until ? ', gültig bis einschließlich '.$date($release->valid_until) : '').(filled($release->reason) ? ' · '.$release->reason : ''),
|
||||
'aktion' => ['label' => 'Entziehen', 'wire' => "mountAction('revoke', { release: ".$release->id.' })'],
|
||||
])->values()->all(),
|
||||
'leer' => ['titel' => 'Noch kein Konto freigeschaltet', 'text' => 'Mit „Konto freischalten“ gibst du ein Konto für dieses Angebot frei.'],
|
||||
];
|
||||
|
||||
if ($past->isNotEmpty()) {
|
||||
$sections[] = [
|
||||
'titel' => 'Entzogene Freigaben',
|
||||
'hilfe' => 'Der Verlauf bleibt erhalten.',
|
||||
'zeilen' => $past->map(fn (OfferRelease $release): array => [
|
||||
'text' => $release->user?->name ?? 'Konto',
|
||||
'neben' => 'entzogen am '.$date($release->revoked_at).(filled($release->reason) ? ' · '.$release->reason : ''),
|
||||
])->values()->all(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
||||
/** „ der Produktseite „Titel““ oder leer, wenn die Option (noch) keine Produktseite hat. */
|
||||
private function productPageSuffix(): string
|
||||
{
|
||||
@@ -344,6 +505,16 @@ private function angebotDaten(): array
|
||||
'wire' => "mountAction('end')",
|
||||
'art' => 'line',
|
||||
]] : []),
|
||||
...($this->isOnDemand() ? [[
|
||||
'label' => 'Regel für den Abruf',
|
||||
'wire' => "mountAction('claimRule')",
|
||||
'art' => 'line',
|
||||
]] : []),
|
||||
...($this->isOnDemand() && $offer->claim_access === OfferAccess::RELEASED ? [[
|
||||
'label' => 'Konto freischalten',
|
||||
'wire' => "mountAction('release')",
|
||||
'art' => 'line',
|
||||
]] : []),
|
||||
...(ShopAccess::allowed() ? [[
|
||||
'label' => 'Zahlungen zu diesem Angebot',
|
||||
'href' => Zahlungsjournal::getUrl(['angebot' => $offer->id, 'zeitraum' => 'jahr', 'betrieb' => 'alle']),
|
||||
@@ -354,6 +525,7 @@ private function angebotDaten(): array
|
||||
'voraussetzungen' => app(PublicationReadiness::class)->forOffer($offer),
|
||||
'haupt' => [
|
||||
...($active !== null ? [$this->optionAbschnitt($offer, $active)] : []),
|
||||
...($this->isOnDemand() ? $this->abrufAbschnitte($offer) : []),
|
||||
[
|
||||
'titel' => 'Positionen',
|
||||
'zusatz' => $active !== null ? 'Fassung '.$active->number : null,
|
||||
|
||||
@@ -155,12 +155,14 @@ public function forArticle(LicenseArticle $article): array
|
||||
'aktion' => $this->articleName($article) !== '' ? null : ['label' => 'Redaktion bearbeiten', 'wire' => "openRedaktion('texte')"],
|
||||
],
|
||||
[
|
||||
'titel' => 'In einem Paket oder Angebot verwenden',
|
||||
'titel' => 'Im Shop verkaufen',
|
||||
'text' => $inUse
|
||||
? 'Der Artikel ist in einem Paket oder Angebot enthalten.'
|
||||
: 'Verkauft wird der Artikel erst über ein Angebot, allein oder in einem Paket.',
|
||||
: 'Verkauft wird der Artikel über eine Option mit Rechteprofil und Preis, allein oder in einem Paket.',
|
||||
'stand' => $inUse ? 'erledigt' : 'offen',
|
||||
'aktion' => $inUse ? null : ['label' => 'Angebote öffnen', 'href' => OfferResource::getUrl('index')],
|
||||
'aktion' => $inUse ? null : ($usable
|
||||
? ['label' => 'Option hinzufügen', 'wire' => "mountAction('option')"]
|
||||
: ['label' => 'Angebote öffnen', 'href' => OfferResource::getUrl('index')]),
|
||||
'pflicht' => false,
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -31,14 +31,7 @@ public function show(Request $request, Cart $cart, OrderHolders $holders): View
|
||||
|
||||
public function add(Offer $offer, Cart $cart, PublicCatalogReader $catalog): RedirectResponse
|
||||
{
|
||||
$key = app(ProductOptions::class)->groupKey($offer);
|
||||
$page = $offer->composition;
|
||||
$listed = match (true) {
|
||||
$key === null => false,
|
||||
$key[0] === 'c' => $page !== null && $catalog->shownVersion($page) !== null,
|
||||
default => true,
|
||||
};
|
||||
$result = $listed ? $cart->add($offer) : Cart::UNAVAILABLE;
|
||||
$result = $this->listed($offer, $catalog) ? $cart->add($offer) : Cart::UNAVAILABLE;
|
||||
$back = $this->productPage($offer);
|
||||
|
||||
return match ($result) {
|
||||
@@ -49,6 +42,27 @@ public function add(Offer $offer, Cart $cart, PublicCatalogReader $catalog): Red
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* „Jetzt kaufen“: die gewählte Option kommt in den Warenkorb (eine andere Option derselben Produktseite wird
|
||||
* ersetzt, weil der Käufer sich ausdrücklich für diese entschieden hat) und die Bestellübersicht öffnet sich. Es
|
||||
* entsteht keine Bestellung; die Kasse prüft wie immer Zustimmungen, Rabatt und Inhaber, und erst „Zahlungspflichtig
|
||||
* bestellen“ legt sie an. Ohne Anmeldung führt die Kasse zur Anmeldung; der Warenkorb liegt in der Sitzung und bleibt.
|
||||
*/
|
||||
public function buy(Request $request, Offer $offer, Cart $cart, PublicCatalogReader $catalog): RedirectResponse
|
||||
{
|
||||
if (! $this->listed($offer, $catalog) || $cart->purchasable($offer) === null) {
|
||||
return $this->productPage($offer)->withErrors(['shop' => 'Diese Option ist gerade nicht erhältlich.']);
|
||||
}
|
||||
|
||||
if ($cart->ownedAmong($request->user(), [$offer]) !== []) {
|
||||
return $this->productPage($offer)->with('status', 'Diese Lizenz besitzt du bereits. Sie liegt in deiner Bibliothek.');
|
||||
}
|
||||
|
||||
$cart->switchTo($offer);
|
||||
|
||||
return redirect()->route('checkout');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ausdrücklicher Wechsel zwischen Alternativoptionen derselben Produktseite.
|
||||
*/
|
||||
@@ -84,6 +98,19 @@ public function accept(Offer $offer, Cart $cart): RedirectResponse
|
||||
});
|
||||
}
|
||||
|
||||
/** Nur Optionen mit öffentlicher Produktseite sind im Shop kaufbar (bei Altbestand mit Programmseite: freigegeben). */
|
||||
private function listed(Offer $offer, PublicCatalogReader $catalog): bool
|
||||
{
|
||||
$key = app(ProductOptions::class)->groupKey($offer);
|
||||
$page = $offer->composition;
|
||||
|
||||
return match (true) {
|
||||
$key === null => false,
|
||||
$key[0] === 'c' => $page !== null && $catalog->shownVersion($page) !== null,
|
||||
default => true,
|
||||
};
|
||||
}
|
||||
|
||||
private function productPage(Offer $offer): RedirectResponse
|
||||
{
|
||||
$url = app(ProductOptions::class)->pageUrl($offer);
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\Checkout;
|
||||
use App\Domain\Commerce\LedgerEntry;
|
||||
@@ -12,9 +11,12 @@
|
||||
use App\Domain\Commerce\OrderHolders;
|
||||
use App\Domain\Commerce\SalesTerms;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use App\Domain\Commerce\ShopCatalog;
|
||||
use App\Domain\Commerce\StaleOverview;
|
||||
use App\Domain\Commerce\Stripe\StripeGateway;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Domain\Entitlement\NewStands;
|
||||
use App\Domain\Entitlement\OfferAccess;
|
||||
use App\Domain\Identity\PartyType;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@@ -23,15 +25,22 @@
|
||||
|
||||
class CheckoutController extends Controller
|
||||
{
|
||||
public function offers(): View
|
||||
/**
|
||||
* Angebote für das Konto: was sich ohne Kauf in die Bibliothek übernehmen lässt (Regel des Angebots, ADR-56) und
|
||||
* neue Stände zu bereits besessenen Artikeln. Gekauft wird ausschließlich im Shop über Warenkorb oder „Jetzt kaufen“
|
||||
* und die Kasse.
|
||||
*/
|
||||
public function offers(Request $request, OfferAccess $access, NewStands $stands): View
|
||||
{
|
||||
$offers = Offer::query()
|
||||
->whereHas('versions', fn ($query) => $query->where('status', OfferStatus::Aktiv)->where('holder_kind', 'person'))
|
||||
->with(['versions' => fn ($query) => $query->where('status', OfferStatus::Aktiv)])
|
||||
->orderBy('name')
|
||||
->get();
|
||||
$user = $request->user();
|
||||
$shop = Shop::visible();
|
||||
|
||||
return view('member.offers', ['offers' => $offers]);
|
||||
return view('member.offers', [
|
||||
'offers' => $access->claimable($user),
|
||||
'stands' => $stands->forUser($user),
|
||||
'shop' => $shop,
|
||||
'cards' => $shop ? app(ShopCatalog::class)->cards('', ['sort' => 'neu', 'limit' => 6]) : [],
|
||||
]);
|
||||
}
|
||||
|
||||
public function claim(Request $request, Offer $offer, GrantIssuer $issuer): RedirectResponse
|
||||
@@ -45,17 +54,6 @@ public function claim(Request $request, Offer $offer, GrantIssuer $issuer): Redi
|
||||
return redirect()->route('member.library')->with('status', 'Das Angebot liegt in deiner Bibliothek.');
|
||||
}
|
||||
|
||||
public function place(Request $request, Offer $offer, Checkout $checkout): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$order = $checkout->place($request->user(), $offer);
|
||||
} catch (DomainRuleException $exception) {
|
||||
return back()->withErrors(['offer' => $exception->getMessage()]);
|
||||
}
|
||||
|
||||
return redirect()->route('member.order', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bestellübersicht: zeigt die geprüften Positionen mit dem Inhaber, für den bestellt wird.
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
use App\Domain\Cms\PageTemplates;
|
||||
use App\Domain\Cms\Sections\SectionRenderer;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
@@ -24,6 +26,21 @@ public function show(string $path): View
|
||||
return $this->render(Page::query()->where('path', '/'.$path)->firstOrFail(), preview: false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Die frühere Angebotsseite der Website ist der Shop. Solange er nicht sichtbar ist, bleibt eine noch vorhandene
|
||||
* CMS-Seite unter dieser Adresse erreichbar (sonst 404).
|
||||
*/
|
||||
public function offers(): View|RedirectResponse
|
||||
{
|
||||
return Shop::visible() ? redirect()->route('shop') : $this->show('angebote');
|
||||
}
|
||||
|
||||
/** Eine veröffentlichte CMS-Seite unter einer festen App-Adresse (der Shop unter /shop). */
|
||||
public function showPage(Page $page): View
|
||||
{
|
||||
return $this->render($page, preview: false);
|
||||
}
|
||||
|
||||
public function preview(PageRevision $revision): View
|
||||
{
|
||||
$page = $revision->page;
|
||||
@@ -49,7 +66,9 @@ public function devices(PageRevision $revision): View
|
||||
|
||||
public function sitemap(): Response
|
||||
{
|
||||
$pages = Page::query()->whereNotNull('published_revision_id')->orderBy('path')->get();
|
||||
// Der Shop gehört nicht in die Sitemap, solange man dort nicht kaufen kann (die Seiten sind dann noindex).
|
||||
$pages = Page::query()->whereNotNull('published_revision_id')->orderBy('path')->get()
|
||||
->reject(fn (Page $page): bool => $page->path === '/shop' && ! Shop::checkoutOpen());
|
||||
$themes = Pillar::query()->published()->get();
|
||||
|
||||
return response()
|
||||
|
||||
@@ -26,7 +26,7 @@ public function index(PublicCatalogReader $catalog): View
|
||||
*/
|
||||
public function package(Bundle $bundle, ProductOptions $products, Cart $cart): View
|
||||
{
|
||||
abort_unless(Shop::enabled(), 404);
|
||||
abort_unless(Shop::visible(), 404);
|
||||
$options = $products->forBundle($bundle);
|
||||
abort_if($options === [], 404);
|
||||
|
||||
@@ -45,7 +45,7 @@ public function package(Bundle $bundle, ProductOptions $products, Cart $cart): V
|
||||
*/
|
||||
public function article(LicenseArticle $article, ProductOptions $products, Cart $cart): View
|
||||
{
|
||||
abort_unless(Shop::enabled() && $article->archived_at === null, 404);
|
||||
abort_unless(Shop::visible() && $article->archived_at === null, 404);
|
||||
$options = $products->forArticle($article);
|
||||
abort_if($options === [], 404);
|
||||
|
||||
@@ -70,8 +70,8 @@ public function program(Composition $composition, PublicCatalogReader $catalog,
|
||||
'composition' => $composition,
|
||||
'version' => $version,
|
||||
'nodes' => app(CompositionStructureReader::class)->tree($version),
|
||||
'options' => Shop::enabled() ? $products->forComposition($composition) : [],
|
||||
'articles' => Shop::enabled() ? $products->articlesOf($composition) : [],
|
||||
'options' => Shop::visible() ? $products->forComposition($composition) : [],
|
||||
'articles' => Shop::visible() ? $products->articlesOf($composition) : [],
|
||||
'cart' => $cart,
|
||||
'switchTo' => session('shop.switch'),
|
||||
]);
|
||||
|
||||
@@ -2,96 +2,41 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\EditorialProfileReader;
|
||||
use App\Domain\Catalog\FormattedText;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use App\Domain\Commerce\ShopCatalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
* Durchsuchbarer Shop (Etappe 1): macht kaufbare Produkte auffindbar. Treffer öffnen dieselbe öffentliche Produktseite
|
||||
* wie die Programmkacheln. Gelistet wird nur, was zur Anzeige freigegeben ist und mindestens eine kaufbare Option hat.
|
||||
* Durchsuchbarer Shop: macht kaufbare Produkte auffindbar. Treffer öffnen dieselbe öffentliche Produktseite wie die
|
||||
* Programmkacheln. Gelistet wird nur, was mindestens eine kaufbare Option hat; die Kacheln bildet ShopCatalog.
|
||||
*
|
||||
* Gibt es in der Webpräsenz eine veröffentlichte Seite „shop“, bestimmt sie den Aufbau (Banner, Grafiken, Texte und das
|
||||
* Widget „Shop-Produkte“); sonst zeigt die Anwendung die Standardseite mit Suche und Kacheln (ADR-55).
|
||||
*/
|
||||
class ShopController extends Controller
|
||||
{
|
||||
public function index(Request $request, ProductOptions $products, PublicCatalogReader $catalog): View
|
||||
/**
|
||||
* Hinweisseite, solange der Shop sichtbar, der Checkout aber noch nicht freigegeben ist: Wer „Kaufen“ wählt, sieht,
|
||||
* dass der Kauf zum Verkaufsstart möglich wird. Ist der Checkout offen, gibt es sie nicht mehr.
|
||||
*/
|
||||
public function closed(): View|RedirectResponse
|
||||
{
|
||||
return Shop::checkoutOpen() ? redirect()->route('shop') : view('shop.closed');
|
||||
}
|
||||
|
||||
public function index(Request $request, ShopCatalog $catalog, PageController $pages): View
|
||||
{
|
||||
$page = Page::query()->where('path', '/shop')->whereNotNull('published_revision_id')->first();
|
||||
|
||||
if ($page !== null) {
|
||||
return $pages->showPage($page);
|
||||
}
|
||||
|
||||
$term = trim((string) $request->query('suche', ''));
|
||||
$summaries = $products->summaries();
|
||||
$cards = [];
|
||||
|
||||
foreach (Composition::query()->whereIn('id', array_keys($summaries))->orderBy('designation')->get() as $composition) {
|
||||
$version = $catalog->shownVersion($composition);
|
||||
|
||||
if ($version === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = (string) ($composition->display_title ?: $composition->designation);
|
||||
$haystack = mb_strtolower($title.' '.$composition->teaser.' '.FormattedText::plain($composition->summary).' '.$composition->search_terms);
|
||||
|
||||
if ($term !== '' && ! str_contains($haystack, mb_strtolower($term))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$summary = $summaries[$composition->id];
|
||||
$cards[] = [
|
||||
'url' => route('public.program', $composition),
|
||||
'title' => $title,
|
||||
'teaser' => (string) ($composition->teaser ?: FormattedText::plain($composition->summary)),
|
||||
'from' => Money::format($summary['from_cents']),
|
||||
'count' => $summary['count'],
|
||||
];
|
||||
}
|
||||
|
||||
// Lizenzartikel mit kaufbarer Option: Titel und Kurztext aus der Redaktion des Artikels (sonst seines Inhalts).
|
||||
$articleSummaries = $products->articleSummaries();
|
||||
|
||||
foreach (LicenseArticle::query()->whereIn('id', array_keys($articleSummaries))->whereNull('archived_at')->orderBy('code')->get() as $article) {
|
||||
$profile = app(EditorialProfileReader::class)->read($article, 'kachel');
|
||||
$title = $products->articleTitle($article);
|
||||
$teaser = (string) ($profile->value('teaser') ?: $profile->value('summary'));
|
||||
$haystack = mb_strtolower($title.' '.$teaser.' '.$profile->value('summary').' '.$profile->searchTerms);
|
||||
|
||||
if ($term !== '' && ! str_contains($haystack, mb_strtolower($term))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$summary = $articleSummaries[$article->id];
|
||||
$cards[] = [
|
||||
'url' => route('shop.article', $article),
|
||||
'title' => $title,
|
||||
'teaser' => $teaser,
|
||||
'from' => Money::format($summary['from_cents']),
|
||||
'count' => $summary['count'],
|
||||
];
|
||||
}
|
||||
|
||||
// Pakete mit eigener Produktseite: gelistet mit Name und enthaltenen Artikeln.
|
||||
foreach (Bundle::query()->whereIn('id', array_keys($products->bundleSummaries()))->orderBy('name')->get() as $bundle) {
|
||||
$options = $products->forBundle($bundle);
|
||||
$contents = $products->bundleContents($options);
|
||||
$names = implode(', ', array_column($contents, 'title'));
|
||||
|
||||
if ($term !== '' && ! str_contains(mb_strtolower($bundle->name.' '.$names), mb_strtolower($term))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$summary = $products->bundleSummaries()[$bundle->id];
|
||||
$cards[] = [
|
||||
'url' => route('public.package', $bundle),
|
||||
'title' => (string) $bundle->name,
|
||||
'teaser' => 'Paket mit '.count($contents).' '.(count($contents) === 1 ? 'Inhalt' : 'Inhalten').($names !== '' ? ': '.$names : ''),
|
||||
'from' => Money::format($summary['from_cents']),
|
||||
'count' => $summary['count'],
|
||||
];
|
||||
}
|
||||
|
||||
return view('shop.index', ['cards' => $cards, 'term' => $term]);
|
||||
return view('shop.index', ['cards' => $catalog->cards($term), 'term' => $term]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Domain\Commerce\Shop;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Schalter 2: Warenkorb, Kasse und „Jetzt kaufen“ gibt es nur, wenn der Checkout offen ist (Shop::checkoutOpen).
|
||||
* Ist der Shop sichtbar, aber der Kauf noch nicht freigegeben, führt jede Anfrage (auch ein POST) auf die Hinweisseite.
|
||||
* Dort entsteht nichts: kein Warenkorb, keine Bestellung. Die Prüfung liegt auf dem Server, nicht nur in der Oberfläche.
|
||||
*/
|
||||
class EnsureCheckoutOpen
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (! Shop::checkoutOpen()) {
|
||||
abort_unless(Shop::visible(), 404);
|
||||
|
||||
return redirect()->route('shop.closed');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,14 @@
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Warenkorb und Kasse gibt es nur mit Testzahlung und nie in Produktion (Etappe 1 erteilt keine Produktivfreigabe).
|
||||
* Schalter 1: Shop, Produktseiten und Hinweisseite gibt es nur, wenn der Shop sichtbar ist (Shop::visible). Sonst
|
||||
* antwortet die Anwendung, als gäbe es sie nicht.
|
||||
*/
|
||||
class EnsureShopEnabled
|
||||
class EnsureShopVisible
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
abort_unless(Shop::enabled(), 404);
|
||||
abort_unless(Shop::visible(), 404);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Middleware\EnsureCheckoutOpen;
|
||||
use App\Http\Middleware\IgnoreEmptyForwardedHeaders;
|
||||
use App\Http\Middleware\SanitizeIntendedUrl;
|
||||
use App\Http\Middleware\UseRequestRootUrl;
|
||||
use App\Http\Middleware\UseStaffSessionCookie;
|
||||
use Illuminate\Contracts\Auth\Middleware\AuthenticatesRequests;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
@@ -23,6 +25,9 @@
|
||||
$middleware->prepend(UseRequestRootUrl::class);
|
||||
$middleware->prepend(IgnoreEmptyForwardedHeaders::class);
|
||||
$middleware->web(append: SanitizeIntendedUrl::class);
|
||||
// Der Schalter „Checkout offen“ gilt vor der Anmeldung: Ohne ihn soll ein Gast nicht erst zur Anmeldung geschickt
|
||||
// werden (und bei abgeschaltetem Shop nicht erfahren, dass es die Kasse gibt).
|
||||
$middleware->prependToPriorityList(before: AuthenticatesRequests::class, prepend: EnsureCheckoutOpen::class);
|
||||
$middleware->redirectGuestsTo(function (Request $request) {
|
||||
if ($request->is('verwaltung', 'verwaltung/*')) {
|
||||
return '/verwaltung/login';
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
use App\Domain\Cms\Widgets\Types\MediaCardWidget;
|
||||
use App\Domain\Cms\Widgets\Types\ProgramCardWidget;
|
||||
use App\Domain\Cms\Widgets\Types\ProseWidget;
|
||||
use App\Domain\Cms\Widgets\Types\ShopProductsWidget;
|
||||
use App\Domain\Cms\Widgets\Types\TopicCardWidget;
|
||||
|
||||
return [
|
||||
@@ -34,6 +35,7 @@
|
||||
ProgramCardWidget::class,
|
||||
CallToActionWidget::class,
|
||||
FaqWidget::class,
|
||||
ShopProductsWidget::class,
|
||||
],
|
||||
|
||||
/*
|
||||
@@ -45,7 +47,7 @@
|
||||
|
||||
/*
|
||||
| Früher vorbereiteter Warenkorbzugang. Seit Etappe 1 folgt der Eintrag in der Kopfzeile dem Shop
|
||||
| (App\Domain\Commerce\Shop::enabled: Testzahlung, nie in Produktion). Diese Werte werden nicht mehr gelesen.
|
||||
| (App\Domain\Commerce\Shop::checkoutOpen). Diese Werte werden nicht mehr gelesen.
|
||||
*/
|
||||
'cart' => [
|
||||
'enabled' => (bool) env('LUF_CART_ENABLED', false),
|
||||
|
||||
@@ -16,6 +16,23 @@
|
||||
|
||||
'live_release' => (bool) env('SHOP_LIVE_RELEASE', false),
|
||||
|
||||
/*
|
||||
| Shop sichtbar (zweiter Schalter, nur Produktion): Übersicht, Produktseiten und Pakete sind öffentlich erreichbar,
|
||||
| gekauft werden kann aber erst mit der Produktivfreigabe oben. Wer „Kaufen“ wählt, sieht den Hinweis, dass der Kauf
|
||||
| zum Verkaufsstart startet. Eine Produktivfreigabe macht den Shop immer auch sichtbar. Standardmäßig aus; wie die
|
||||
| Freigabe ausschließlich in /etc/luf/prod.env (SHOP_PUBLIC=true), nie im Repository. Außerhalb der Produktion
|
||||
| richtet sich beides allein nach dem Zahlungstreiber (test oder stripe mit Testschlüssel).
|
||||
*/
|
||||
|
||||
'public' => (bool) env('SHOP_PUBLIC', false),
|
||||
|
||||
/*
|
||||
| Produktmarker „Neu“ und „Aktualisiert“ erscheinen automatisch für diese Zahl Tage (ShopMarkers). Eine Einstellung
|
||||
| der Redaktion am Lizenzartikel hat Vorrang.
|
||||
*/
|
||||
|
||||
'marker_days' => 30,
|
||||
|
||||
/*
|
||||
| Kauf auf Rechnung für Vereine und Organisationen (PAY-006): auf Anfrage, Rechnung manuell durch den Betreiber.
|
||||
| Standardmäßig aus: Das Mitglied sieht die Möglichkeit erst, wenn der Prozess vollständig ist (Rechnungserstellung
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Shopdarstellung (ADR-54), rein ergänzend: ein Symbol je Materialart (Schlüssel der Symbolbibliothek) und die Marker
|
||||
* „Neu“, „Aktualisiert“, „Beliebt“ je Lizenzartikel. Beide Spalten sind leer zulässig; ein Rollback des Codes lässt sie
|
||||
* unbenutzt liegen.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('editorial_content_kinds', function (Blueprint $table): void {
|
||||
$table->string('symbol', 60)->nullable()->after('label');
|
||||
});
|
||||
|
||||
Schema::table('license_articles', function (Blueprint $table): void {
|
||||
$table->json('shop_markers')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('license_articles', function (Blueprint $table): void {
|
||||
$table->dropColumn('shop_markers');
|
||||
});
|
||||
|
||||
Schema::table('editorial_content_kinds', function (Blueprint $table): void {
|
||||
$table->dropColumn('symbol');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Regeln für freie Artikel (ADR-56), rein ergänzend: Wer ein Angebot „auf Abruf“ übernehmen darf (alle Mitglieder,
|
||||
* freigeschaltete Konten oder wer einen bestimmten Artikel besitzt) und die Freigaben je Konto. Freigaben werden nie
|
||||
* gelöscht, nur entzogen; ein Angebot oder Konto mit Freigaben lässt sich nicht löschen (restrict).
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('offers', function (Blueprint $table): void {
|
||||
$table->string('claim_access', 20)->default('alle');
|
||||
$table->foreignId('claim_requires_article_id')->nullable()->constrained('license_articles')->restrictOnDelete();
|
||||
});
|
||||
|
||||
Schema::create('offer_releases', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('offer_id')->constrained('offers')->restrictOnDelete();
|
||||
$table->foreignId('user_id')->constrained('users')->restrictOnDelete();
|
||||
$table->foreignId('granted_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamp('granted_at');
|
||||
$table->timestamp('valid_until')->nullable();
|
||||
$table->foreignId('revoked_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamp('revoked_at')->nullable();
|
||||
$table->text('reason')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index(['offer_id', 'user_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('offer_releases');
|
||||
|
||||
Schema::table('offers', function (Blueprint $table): void {
|
||||
$table->dropConstrainedForeignId('claim_requires_article_id');
|
||||
$table->dropColumn('claim_access');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -104,21 +104,6 @@ private function pages(): array
|
||||
],
|
||||
],
|
||||
],
|
||||
'/angebote' => [
|
||||
'seo_title' => 'Angebote',
|
||||
'seo_description' => 'Lizenzangebote werden aus dem Katalog gelesen, nicht als freier Text gepflegt.',
|
||||
'blocks' => [
|
||||
[
|
||||
'type' => 'heading',
|
||||
'heading' => 'Angebote',
|
||||
'intro' => 'Umfang, Rechte und Preise eines Angebots kommen aus dem Katalog. Sie werden hier nicht als freier Text ersetzt.',
|
||||
],
|
||||
[
|
||||
'type' => 'prose',
|
||||
'body' => 'Es sind noch keine Angebote veröffentlicht. Sobald ein Angebot aktiv ist, zeigt diese Seite seinen Umfang aus dem gespeicherten Stand.',
|
||||
],
|
||||
],
|
||||
],
|
||||
'/trainer' => [
|
||||
'seo_title' => 'Für Trainer und Einrichtungen',
|
||||
'seo_description' => 'Informationen für Gewaltschutztrainer, Übungsleiter, Fachkräfte, Vereine und Bildungseinrichtungen.',
|
||||
@@ -191,7 +176,7 @@ private function navigation(): array
|
||||
['label' => 'Start', 'path' => '/', 'placement' => 'header'],
|
||||
['label' => 'Prävention', 'path' => '/praevention', 'placement' => 'header'],
|
||||
['label' => 'Materialien', 'path' => '/materialien', 'placement' => 'header'],
|
||||
['label' => 'Angebote', 'path' => '/angebote', 'placement' => 'header'],
|
||||
['label' => 'Shop', 'url' => '/shop', 'placement' => 'header'],
|
||||
['label' => 'Trainer und Einrichtungen', 'path' => '/trainer', 'placement' => 'header'],
|
||||
['label' => 'Über das Projekt', 'path' => '/ueber', 'placement' => 'header'],
|
||||
['label' => 'Anmelden', 'url' => '/anmelden', 'placement' => 'header'],
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# Shop-Umbau: Aufräumen, Schalter, Shopdesign, Regeln für freie Artikel
|
||||
|
||||
Stand: 26.11.2026. Auftrag von Lars. Entscheidungen: ADR-53 (Schalter, Kauf nur über die Kasse), ADR-54 und folgende je Phase.
|
||||
|
||||
## Ausgangslage (belegt im Code, Stand `develop` @ `28e3342`)
|
||||
|
||||
- `/shop` und die Produktseiten waren öffentlich, hingen aber an **einem** Schalter (`Shop::enabled()`), der auf Prod den Checkout, den Warenkorb und die Sichtbarkeit zugleich bedeutete.
|
||||
- Die Mitgliederseite „Angebote“ (`/bereich/angebote`) bot einen **Einzelkauf** (`Checkout::place`) ohne Warenkorb, Rabattcode, Zustimmungen und Hinweise. Er war nur im Livebetrieb gesperrt, auf Prod ohne Freigabe legte er offene Bestellungen an.
|
||||
- Die öffentliche Seite `/angebote` war ein Platzhalter aus dem U0-Fundament und nie mit Katalog oder Shop verbunden.
|
||||
- Der Shop zeigt kein Produktbild, keine Gruppen, keine Symbole der Inhaltsarten und keine Marker. Die Kachelbildung steht dreifach in `ShopController`.
|
||||
- Für freie Angebote („auf Abruf“) gibt es keine Regel, wer sie abrufen darf: Jedes angemeldete Konto kann jedes Abrufangebot übernehmen (`GrantIssuer::claim`).
|
||||
|
||||
## Entscheidungen von Lars (26.11.2026)
|
||||
|
||||
1. Die **öffentliche** Angebotsseite entfällt, `/shop` ersetzt sie. Die Mitgliederseite „Angebote“ bleibt mit neuer Aufgabe.
|
||||
2. Mitgliederseite „Angebote“: oben **Für dich** (neue Fassungen bereits gekaufter Artikel, freie Artikel mit Regeln), darunter der Shop mit demselben Widget wie `/shop`.
|
||||
3. **Jetzt kaufen** an der Produktseite führt in die Bestellübersicht der Kasse (nicht ohne Pflichtangaben, nicht mit einem Klick).
|
||||
4. **Zwei Schalter** auf Prod: Shop sichtbar und Checkout offen. Ist nur der Shop sichtbar, führt „Kaufen“ auf eine Hinweisseite.
|
||||
5. **Marker** „Neu“, „Beliebt“, „Aktualisiert“ zum Start. Sterne und Kundenbewertungen später.
|
||||
6. Der Shop ist im CMS **bis zu einem gewissen Grad verwaltbar** (Banner und Grafiken), die Liste als Widget, ohne maximalen Umbau.
|
||||
7. Freie Artikel erhalten ein **Regelmodell**, das auch bestimmten Konten zugeordnet werden kann (wie die Freigaben der Rabattcodes).
|
||||
|
||||
## Phasen
|
||||
|
||||
| Phase | Inhalt | Stand |
|
||||
|---|---|---|
|
||||
| 1 | Aufräumen: Einzelkauf entfernen, zwei Schalter mit Hinweisseite, „Jetzt kaufen“, Menüpunkt „Shop“ nur bei sichtbarem Shop, `/angebote` leitet auf `/shop`, Mitgliederseite ohne Kauf | umgesetzt und auf `luf-test` abgenommen (ADR-53) |
|
||||
| 2 | Kachel und Datenquelle: ein Dienst für Liste und Widget, Titelbild über die Website-Freigabe, Säulen und Materialart als Gruppen, Symbol je Materialart, Marker | umgesetzt (ADR-54) |
|
||||
| 3 | CMS: Seite „shop“ mit Abschnitten, Widget „Shop-Produkte“, Kacheln auf der Mitgliederseite (ADR-55) | umgesetzt; „Für dich“ folgt mit Phase 4 |
|
||||
| 4 | Regelmodell für freie Artikel: für alle, besitzt einen Artikel, bestimmte Konten (Freigabe je Angebot und Konto, wie bei Rabattcodes), „Für dich“ | umgesetzt (ADR-56) |
|
||||
| 5 | Viele Produkte: Listenansicht, Filter, Sortierung, Seiten | offen |
|
||||
|
||||
Jede Phase wird mit Tests, einer Sicherheitsdurchsicht und (bei Oberfläche) der Abnahme auf `luf-test` belegt (`docs/ux/verwaltung/abnahme/etappe-1.md`).
|
||||
|
||||
## Randbedingungen, die der Plan benennt
|
||||
|
||||
- **Daten, nicht Code:** Die CMS-Seite `/angebote` und ihr Menüpunkt liegen in der Datenbank. Auf `luf-test` und Prod entfernt sie Lars in der Webpräsenz; eine Migration löscht sie nicht (CLAUDE.md). Der Seeder legt sie für neue Installationen nicht mehr an.
|
||||
- **Private Medien:** Das Titelbild erscheint nur über die Website-Freigabe (`/website-medien/…`), nie über Mitgliedervorschauen.
|
||||
- **Kein Taxonomie-Ausbau:** Gruppen kommen aus Säulen (`PillarService`) und Materialart (`EditorialVocabulary`).
|
||||
- **Regeln für freie Artikel (Phase 4)** gelten ab dem Deployment; ohne Einstellung bleibt die Regel „alle angemeldeten Mitglieder“, also das bisherige Verhalten.
|
||||
- **Offene Bestellungen auf Prod** aus dem bisherigen Einzelkauf: Lesen nur mit Freigabe von Lars, Löschen entscheidet er.
|
||||
- **Weiter offen (nicht Teil dieses Plans):** Dialog für Pakete, Teilbesitz bei Paketen, Aufteilung des Paketpreises im Journal, Steuer und Belege (OPEN-06), Rechtstexte, Stripe-Live.
|
||||
@@ -775,6 +775,65 @@ ## ADR-52 – Produktseite je Lizenzartikel: Die Seite ergibt sich aus der Angeb
|
||||
- **Aktivieren nur, wenn kaufbar.** `OfferService::activate` verlangt für eine Vergabe „Kauf“ genau eine Position (ein Artikel oder eine Paketfassung) und einen Preis über 0,00 €; mehrere Artikel gemeinsam verkauft ein Paket. Vergaben „bei Registrierung“ und „auf Abruf“ stehen nie im Shop und bleiben ohne diese Einschränkung zulässig.
|
||||
- **Maske.** Die Auswahl „Produktseite“ entfällt; die Voraussetzungen zeigen die abgeleitete Seite.
|
||||
**Altbestand.** Angebote mit mehreren Positionen und einer Programmseite (früher möglich) bleiben unter `c:` auf ihrer Programmseite kaufbar, solange diese zur Anzeige freigegeben ist. Ein Angebot mit genau einer Artikelposition wechselt auf die Artikelseite, auch wenn es früher einem Programm zugeordnet war; ein früher auf einer Programmseite geführtes Paket erhält seine eigene Paketseite und erscheint im Shop als Paket.
|
||||
**Bewusst offen.** (1) Teilbesitz bei Paketen: Wer einen enthaltenen Artikel schon hat, zahlt den vollen Preis (`OwnershipCheck` kennt nur vollständige Abdeckung durch einen Erwerb). (2) Mehrere Optionen (Rechteprofil mit Preis) je Artikel in einem Arbeitsschritt: Die Optionen sind weiterhin je ein Angebot; ein vereinfachter Dialog folgt. (3) Teilen des Paketpreises auf die Artikel für den Journal-Filter „Gekauftes Angebot“.
|
||||
**Bewusst offen.** (1) Teilbesitz bei Paketen: Wer einen enthaltenen Artikel schon hat, zahlt den vollen Preis (`OwnershipCheck` kennt nur vollständige Abdeckung durch einen Erwerb). (2) Mehrere Optionen je Artikel in einem Arbeitsschritt: erledigt am 25.11.2026 (Nachtrag unten). (3) Teilen des Paketpreises auf die Artikel für den Journal-Filter „Gekauftes Angebot“.
|
||||
**Folgen.** Kein Schemawechsel. Vorhandene aktive Kaufangebote mit einer Artikelposition werden mit dem Deployment **sofort öffentlich kaufbar** und stehen im Shop, soweit der Shop läuft; wer das nicht will, nimmt sie vorher aus dem Verkauf.
|
||||
**Nachtrag 25.11.2026: Optionen am Lizenzartikel.** Der Verkauf eines Artikels wird dort gepflegt, wo der Artikel steht. Die Seite des Lizenzartikels hat den Abschnitt „Im Shop verkaufen“: Er listet die Optionen mit Preis, Nutzerkreis, Eignung, Rechten, Fassung und Zustand. „Option hinzufügen“ fragt nur Rechteprofil, Preis, Eignung, Nutzerkreis (Trainerzahl) und eine Bezeichnung ab (Vorschlag aus Nutzerkreis und Eignung); es gibt keine Auswahl von Artikel, Inhalt oder Vergabe, die Vergabe ist „Kauf“. Jede Option bleibt ein Angebot mit genau einer Position; mehrere Optionen eines Artikels erscheinen gemeinsam auf `/shop/{Artikel}` und sind Alternativen im Warenkorb.
|
||||
- `OfferService::offerArticle` legt Angebot und erste Fassung in **einer Transaktion** an: Besteht eine Prüfung nicht (Stand, Preis, Nutzerkreis), bleibt kein leeres Angebot zurück. `reviseArticleOption` aktiviert die nächste Fassung (Laufzeit und Steuerklasse der letzten Fassung bleiben) und lehnt Optionen anderer Artikel und Vergaben auf Abruf oder bei Registrierung ab; diese erscheinen im Abschnitt nur mit dem Hinweis, dass sie am Angebot bearbeitet werden.
|
||||
- Aus der Angebotsmaske entfällt „Programmfassung, die abgedeckt sein muss“; die Prüfung bleibt im Dienst (`assertCoverage`). Pakete und der Altbestand mit mehreren Positionen behalten die Angebotsmaske mit Positionen.
|
||||
- Der Dialog speichert die Redaktion des Artikels nicht mit und verwirft offene Eingaben dort nicht (CLAUDE.md, Redaktion als Arbeitsstand).
|
||||
**Quelle.** Anfrage von Lars vom 25.11.2026; ADR-29, ADR-47; `docs/prinzipien/design-prinzipien.md`; `docs/fachkonzept/produktkonfiguration-und-mitgliederbereich.md`.
|
||||
|
||||
## ADR-53 – Shop: zwei Schalter in Produktion, Kauf nur über die Kasse, „Jetzt kaufen“
|
||||
|
||||
**Status am 26.11.2026:** Umgesetzt auf `feature/shop-aufraeumen` (Phase 1 des Plans `docs/analysen/shop-umbauplan-2026-11-26.md`); Abnahme auf luf-test siehe `docs/ux/verwaltung/abnahme/etappe-1.md`, Abschnitt „Shop aufräumen“. Die Produktivfreigabe bleibt bei Lars.
|
||||
**Kontext.** Bis dahin gab es einen Schalter (`Shop::enabled()`), der auf Prod Sichtbarkeit, Warenkorb und Kasse zugleich bedeutete. Die Mitgliederseite „Angebote“ hatte einen eigenen Einzelkauf (`Checkout::place`) ohne Warenkorb, Rabattcode, Zustimmungen und Hinweise. Er war nur im Livebetrieb gesperrt; auf Prod ohne Freigabe legte er offene Bestellungen an (ohne Zahlmöglichkeit, aber mit Eintrag in der Bestellverwaltung).
|
||||
**Entscheidung (Auftrag von Lars, 26.11.2026).**
|
||||
- **Zwei Schalter.** `Shop::visible()` („Shop sichtbar“): Übersicht, Produktseiten, Pakete, die Hinweisseite und Menüpunkte in den Shop. In Produktion mit `SHOP_PUBLIC=true` oder mit der Produktivfreigabe, sonst wie der Checkout. `Shop::checkoutOpen()` („Checkout offen“, früher `enabled()`): Warenkorb, Kasse, „Jetzt kaufen“, Warenkorb-Symbol. In Produktion nur mit `Shop::live()` (Freigabe, Stripe-Live-Schlüssel, Rechtstexte), sonst mit dem Zahlungstreiber `test` oder `stripe`. Beides steht nur in `/etc/luf/prod.env`, nie im Repository.
|
||||
- **Sichtbar, aber nicht kaufbar.** Jede Anfrage an Warenkorb, Kasse oder „Jetzt kaufen“ (auch ein POST) führt auf die Hinweisseite `/kauf-noch-nicht-moeglich` („Der Kauf ist noch nicht freigeschaltet“). Es entstehen weder Warenkorb noch Bestellung. Die Produktseite zeigt „Kaufen“ (Link auf die Hinweisseite) und einen Hinweis; die Seiten sind `noindex`. Ist der Shop nicht sichtbar, antworten alle diese Adressen mit 404. Die Prüfung liegt in den Middlewares `EnsureShopVisible` und `EnsureCheckoutOpen`; letztere läuft vor der Anmeldeprüfung (`prependToPriorityList`), damit ein Gast ohne Freigabe weder zur Anmeldung geschickt wird noch erfährt, dass es eine Kasse gibt.
|
||||
- **Der alte Einzelkauf entfällt** (`Checkout::place`, Route `member.offers.buy`). Eine Bestellung entsteht nur noch aus dem Warenkorb mit Prüfsumme, Zustimmungen, Rabatt und Inhaberwahl (`Checkout::placeFromCart`).
|
||||
- **„Jetzt kaufen“** an jeder Option der Produktseite (`POST /warenkorb/{Option}/jetzt-kaufen`): Die Option kommt in den Warenkorb, eine andere Option derselben Produktseite wird ersetzt (der Käufer hat sich ausdrücklich entschieden), andere Artikel bleiben, und die Bestellübersicht öffnet sich. Erst „Zahlungspflichtig bestellen“ legt eine Bestellung an; ein Kauf mit einem Klick und sofortiger Abbuchung gibt es nicht. Wer die Lizenz schon besitzt (für einen Inhaber, für den das Konto bestellen darf), sieht „Bereits erworben“ statt der Knöpfe. Ein Gast meldet sich an; der Warenkorb liegt in der Sitzung und bleibt (Test).
|
||||
- **Menü und alte Adresse.** Ein Menüeintrag, dessen Ziel in den Shop führt (`/shop`, `/warenkorb`, `/kasse`), erscheint nur bei sichtbarem Shop (`NavigationItem::href`). `/angebote` leitet auf `/shop`, solange der Shop sichtbar ist; sonst bleibt eine vorhandene CMS-Seite unter der Adresse erreichbar. Die Seite und ihr Menüpunkt sind Daten: Lars entfernt sie in der Webpräsenz auf Test und Prod. Der Seeder legt sie nicht mehr an und führt den Menüpunkt „Shop“.
|
||||
- **Mitgliederseite „Angebote“** zeigt nur noch, was sich ohne Kauf übernehmen lässt (Vergabe „auf Abruf“ oder „bei Registrierung“), und den Link „Zum Shop“, wenn der Shop sichtbar ist. Der feste Text „Testzahlung“ entfällt.
|
||||
**Alternativen.** Ein Schalter mit drei Stufen (verworfen: zwei unabhängige Bedingungen lassen sich einzeln testen und einzeln dokumentieren). Der Einzelkauf bleibt als Abkürzung (verworfen: er umgeht die Pflichtangaben).
|
||||
**Folgen.** Kein Schemawechsel. Auf Prod bleibt ohne neue Einstellung alles aus. `SHOP_PUBLIC=true` macht den Shop sichtbar, ohne dass gekauft werden kann. **Offene Bestellungen**, die der alte Einzelkauf auf Prod angelegt hat, bleiben bestehen; Lesen und Löschen entscheidet Lars. Bis zu den Regeln für freie Artikel (Phase 4) kann jedes angemeldete Konto jedes Abrufangebot übernehmen.
|
||||
**Quelle.** Anfrage von Lars vom 26.11.2026; ADR-42, ADR-47, ADR-52.
|
||||
|
||||
## ADR-54 – Shopkachel: Titelbild, Säulen, Materialart mit Symbol und Marker aus einer Datenquelle
|
||||
|
||||
**Status am 26.11.2026:** Umgesetzt auf `feature/shop-aufraeumen` (Phase 2 des Plans `docs/analysen/shop-umbauplan-2026-11-26.md`); Abnahme auf luf-test siehe `docs/ux/verwaltung/abnahme/etappe-1.md`, Abschnitt „Shopkachel“. Die Produktivfreigabe bleibt bei Lars.
|
||||
**Kontext.** Die Kachel im Shop zeigte nur Titel, Kurztext und „ab Preis“. Die gepflegten Titelbilder, die Säulen, die Materialart und Marker fehlten, und die Kachelbildung stand dreifach im Controller.
|
||||
**Entscheidung (Auftrag von Lars, 26.11.2026).**
|
||||
- **Eine Datenquelle.** `App\Domain\Commerce\ShopCatalog::cards()` liefert die Kacheln für Artikel, Pakete mit eigener Seite und den Altbestand mit Programmseite. Die Shopseite nutzt sie, das Widget (Phase 3) nutzt dieselbe. Die Kachel ist `shop/kachel.blade.php`.
|
||||
- **Titelbild nur mit Website-Freigabe.** `PresentationMedia::coverPresentation` nimmt das erste Titel- oder Galeriebild in der Reihenfolge der Rollen, das über `WebsiteMedia` freigegeben ist, und überspringt nicht freigegebene (nie ausgeliefert, nie verlinkt). Es gelten nur Bilder, keine Filme. Das Bild ist schmückend (leeres `alt`), der Titel ist der Link. Ohne Bild trägt eine helle Tafel das Symbol der Materialart.
|
||||
- **Gruppen aus dem Bestand.** Säulen (`PillarService`), nur veröffentlichte, bis zu drei je Kachel; die Suche findet auch über Säule und Materialart. Es gibt keine neue Taxonomie.
|
||||
- **Symbol je Materialart.** Neue Spalte `editorial_content_kinds.symbol` (Schlüssel der Symbolbibliothek, nur wenn der Katalog ihn kennt), gepflegt unter „Redaktionelle Stammdaten“ mit dem Symbolwähler.
|
||||
- **Marker.** Neue Spalte `license_articles.shop_markers`. „Neu“ (erstes Angebot als Kauf) und „Aktualisiert“ (neuer Stand, nie zusammen mit „Neu“) folgen automatisch für `shop.marker_days` (30) Tage und lassen sich am Artikel fest an- oder abschalten; „Beliebt“ setzt die Redaktion von Hand, bis es Verkaufszahlen gibt. Ein Marker trägt immer sein Wort. Die Aktion „Marker ändern“ im Abschnitt „Im Shop verkaufen“ speichert nur die Marker, nicht die Redaktion des Artikels. Sterne und Kundenbewertungen folgen später und sind nicht vorbereitet.
|
||||
**Folgen.** Zwei neue, leer zulässige Spalten; ein Rollback des Codes lässt sie unbenutzt liegen. Ohne Pflege erscheint die Kachel wie bisher, nur mit Platzhalter statt Bild.
|
||||
**Quelle.** Anfrage von Lars vom 26.11.2026; ADR-30, ADR-40, ADR-52, ADR-53.
|
||||
|
||||
## ADR-55 – Der Shop im CMS: Seite „shop“ der Webpräsenz und das Widget „Shop-Produkte“
|
||||
|
||||
**Status am 26.11.2026:** Umgesetzt auf `feature/shop-aufraeumen` (Phase 3 des Plans `docs/analysen/shop-umbauplan-2026-11-26.md`); Abnahme auf luf-test siehe `docs/ux/verwaltung/abnahme/etappe-1.md`, Abschnitt „Shop im CMS“. Die Produktivfreigabe bleibt bei Lars.
|
||||
**Kontext.** Der Shop (`/shop`) war eine feste Seite der Anwendung ohne Banner, Grafiken oder Texte der Redaktion. Lars wollte den Shop bis zu einem gewissen Grad im CMS verwalten (Banner, grafische Elemente) und die Kacheln als Widget, ohne den Shop umzubauen.
|
||||
**Entscheidung (Auftrag von Lars, 26.11.2026).**
|
||||
- **`/shop` bleibt eine Route der Anwendung** (Schalter, Produktseiten und Kasse hängen daran). Gibt es in der Webpräsenz eine **veröffentlichte Seite mit dem Pfad `/shop`**, rendert die Anwendung sie mit denselben Abschnitten wie jede CMS-Seite (Banner, Grafiken, Texte); ohne sie zeigt `/shop` die Standardseite mit Suche und Kacheln. Es gibt keine Migration; die Redaktion legt die Seite an, wenn sie sie will.
|
||||
- **Widget „Shop-Produkte“ (`shop_products`).** Eine eigene Art, keine Variante der Programmkarte (ADR-39 verbietet dort Preis und Kauf). Es zeigt die Kacheln aus `ShopCatalog`, optional gefiltert nach Säule und Materialart, sortiert (alphabetisch, neueste zuerst, Preis aufsteigend), begrenzt (3 bis 24) und mit Suchfeld. Es speichert nur Darstellungswahl und Filter; Titel, Bild, Preis und Marker kommen zur Laufzeit. Es ist auf jeder CMS-Seite einsetzbar und rendert **nichts**, solange der Shop nicht sichtbar ist (öffentlich leer, in der Vorschau mit Hinweis).
|
||||
- **Sitemap und Indexierung.** Die Seite `/shop` steht nicht in der Sitemap, solange nicht gekauft werden kann; die Shopseiten sind dann `noindex` (ADR-53).
|
||||
- **Mitgliederseite „Angebote“.** Sie zeigt unter dem Abruf kostenloser Angebote die sechs neuesten Produkte als Kacheln aus derselben Datenquelle und „Zum Shop“, wenn der Shop sichtbar ist.
|
||||
- **Suche.** Der Suchbegriff wird auf 100 Zeichen gekürzt und maskiert ausgegeben.
|
||||
**Alternativen.** Der Shop als reine CMS-Seite (verworfen: Suche, Schalter und Produktseiten hingen dann an Widgets und Seitenpfaden; mehr Umbau, mehr Risiko). Feste Bannerfelder in der Anwendung (verworfen: eine zweite Verwaltung neben dem CMS).
|
||||
**Folgen.** Eine neue Widget-Art in `config/cms.php`; keine Daten, kein Schema. Wer die Seite `/shop` in der Webpräsenz anlegt, muss das Widget einsetzen, sonst zeigt `/shop` keine Produkte.
|
||||
**Quelle.** Anfrage von Lars vom 26.11.2026; ADR-30, ADR-38, ADR-39, ADR-53, ADR-54.
|
||||
|
||||
## ADR-56 – Regeln für freie Artikel und „Für dich“ im Mitgliederbereich
|
||||
|
||||
**Status am 26.11.2026:** Umgesetzt auf `feature/shop-aufraeumen` (Phase 4 des Plans `docs/analysen/shop-umbauplan-2026-11-26.md`); Abnahme siehe `docs/ux/verwaltung/abnahme/etappe-1.md`, Abschnitt „Regeln für freie Artikel“. Die Produktivfreigabe bleibt bei Lars.
|
||||
**Kontext.** Jedes angemeldete Konto konnte jedes Angebot „auf Abruf“ übernehmen (`GrantIssuer::claim` prüfte nur Vergabeart und Inhaberart). Freie Artikel sollen aber nach Regeln vergeben werden können, auch an bestimmte Konten, ähnlich den Rabattcodes. Die Mitgliederseite „Angebote“ soll zeigen, was für das Konto bereitliegt.
|
||||
**Entscheidung (Auftrag von Lars, 26.11.2026).**
|
||||
- **Drei Regeln je Angebot auf Abruf** (`offers.claim_access`): alle angemeldeten Mitglieder (Vorgabe, bisheriges Verhalten), nur ausdrücklich freigeschaltete Konten, Mitglieder, die einen bestimmten anderen Artikel besitzen (`offers.claim_requires_article_id`, gültige aktive Berechtigung des Kontos auf diesen Artikel). Die Regel begrenzt nur den freien Abruf; sie vergibt nichts. Vergaben „bei Registrierung“ gehen weiter automatisch an neue Konten und kennen keine Regel; Käufe laufen über die Kasse.
|
||||
- **Serverseitig geprüft.** `OfferAccess::assertMayClaim` läuft in `GrantIssuer::claim`; ein Konto ohne Berechtigung bekommt nichts, auch wenn es die Adresse kennt. Die Meldung nennt die Regel nicht. Die Seite „Angebote“ zeigt ein Angebot nur, wenn das Konto es abrufen darf und noch nicht übernommen hat (`OfferAccess::claimable`).
|
||||
- **Freigaben je Angebot und Konto** (`offer_releases`), nach dem Muster der Rabattcode-Freigaben (ADR-47): Grundlage, optionales Ende, Freigabe und Entzug mit Person und Zeitpunkt, **nie gelöscht, nur entzogen**; eine Freigabe für ein Angebot ist keine für ein anderes. Ein bereits übernommenes Angebot bleibt nach dem Entzug in der Bibliothek. Angebot und Konto mit Freigaben lassen sich nicht löschen (restrict). Gepflegt wird im Angebot (Katalogverwalter): „Regel für den Abruf“, „Konto freischalten“, „Entziehen“.
|
||||
- **„Für dich“ (Mitgliederseite „Angebote“).** Oben „Neu für dich“: neue Stände zu Artikeln, die das Konto besitzt, 90 Tage nach der Veröffentlichung (`NewStands`). Nach der Updatepolitik (ADR-09, OPEN-01) stehen sie dem Inhaber ohne Aufpreis zu und liegen schon in der Bibliothek; die Liste vergibt nichts. Danach „Zum Übernehmen“ (Angebote nach der Regel), darunter der Shop mit den neuesten Produkten (ADR-55).
|
||||
**Nicht Teil dieses Schritts.** Keine Benachrichtigung per E-Mail bei einer Freigabe (das Konto sieht sie bei seinem nächsten Besuch); Gruppen und „Konto seit …“ als weitere Regeln; ein Ende des Abrufs je Angebot (dafür gibt es das Beenden der Fassung).
|
||||
**Folgen.** Eine additive Migration (zwei Spalten an `offers`, Tabelle `offer_releases`). **Bis zum Deployment gilt weiter die Regel „alle“** für jedes Angebot auf Abruf; die Vorgabe ändert kein bestehendes Verhalten. Wer ein Angebot auf Abruf nur bestimmten Konten geben will, stellt die Regel um, bevor er es aktiviert.
|
||||
**Quelle.** Anfrage von Lars vom 26.11.2026; ADR-09, ADR-47, ADR-52, ADR-55.
|
||||
@@ -82,6 +82,7 @@ ## 4. Registrierte Widget-Arten
|
||||
| `program_card` | Programm- oder Modulkarte, Kit v1.7 | 1 | `adaptive`, `stacked` | 1–4 | `auto` (Vorgabe), `fill` | `refs.composition`, `refs.image` |
|
||||
| `call_to_action` | Handlungsaufruf | 1 | `standard` | 1–4 | `auto` (Vorgabe), `fill` (Abschnittshöhe füllen) | – |
|
||||
| `faq` | FAQ | 1 | `standard` | 2–4 | – | – |
|
||||
| `shop_products` | Shop-Produkte (Kacheln aus `ShopCatalog`, ADR-55) | 1 | `kacheln` | 2–4 | – | – (Filter `data.pillar`, `data.kind`; Einstellungen `sort`, `limit`, `search`) |
|
||||
|
||||
Darstellungsklassen an der Widget-Hülle: `widget widget-<typ> widget-variant-<variante>` und, wenn die Art Höhen anbietet, `widget-height-<höhe>`. Premium-Ansichten: `lf-hero lf-hero--{photo-split|editorial-solid} lf-hero--height-<höhe> lf-hero--accent-<akzent>` und `lf-bt lf-bt--{cream|clear|navy} lf-bt--image-{left|right} lf-bt--height-<höhe>`.
|
||||
|
||||
@@ -106,7 +107,7 @@ ## 4. Registrierte Widget-Arten
|
||||
|
||||
**Redaktionelle Karten.** `data.items[].symbol` (optional, nur Schlüssel aus `HeadingAccent::symbols()`; der Schlüssel wird nur gespeichert, wenn ein Symbol gewählt ist, Karten ohne Symbol bleiben unverändert). Einstellungen `settings.symbol_size` (dieselben vier Stufen, Vorgabe Mittel) und `settings.align` (`left` Vorgabe, `center`, `right`). Das Symbol steht über dem Titel in der Kartentextfläche; Klassen `cards--<ausrichtung>` und `cards--size-<stufe>` erscheinen nur bei Abweichung von der Vorgabe. Nicht vorgesehen: Themenkarte, Medienkarte, Programmkarte und Programm- und Modulkarten (Inhalt und Bild kommen aus Katalogobjekten, Medienkarten tragen den Material-Tag).
|
||||
|
||||
**Merkmalszeile.** `data.items[]` mit `symbol` (Auswahl wie oben), `title` (höchstens 60 Zeichen) und optional `text` (höchstens 200 Zeichen), `url` (über `SafeUrl`) und `link_label` (höchstens 60 Zeichen, Vorgabe „Mehr erfahren“, wird ohne `url` verworfen); ein bis zwölf Einträge, in jeder Platzbreite (1–4 Einheiten). Die Spaltenzahl ergibt sich aus der Anzahl der Einträge und der tatsächlichen Breite (Raster ab 12 rem je Merkmal), nicht aus einer eigenen Einstellung. `settings.link_style` bestimmt für alle Links des Widgets die Darstellung: `text` (kleiner Textlink, Vorgabe) oder `pill` (Pille). Weitere Einstellungen: `settings.align` (`left` Vorgabe, `center`, `right`; richtet Symbol, Titel, Satz und Link aus), `settings.symbol_size` (`small` 2,5 rem, `medium` 3,5 rem Vorgabe, `large` 5 rem, `xlarge` 7 rem) und `settings.divider` = `line` (feiner Strich in der Mitte der Lücke: senkrecht zwischen Spalten, waagerecht zwischen Zeilen und bei untereinander stehenden Merkmalen; die Liste schneidet die Striche am Rand ab). Ungültige gespeicherte Werte fallen auf die Vorgaben zurück (`FeaturesWidget::layout`). Der zugängliche Name des Links nennt das Merkmal („Mehr erfahren: Kurze Filme“).
|
||||
**Merkmalszeile.** `data.items[]` mit `symbol` (Auswahl wie oben), `title` (höchstens 60 Zeichen) und optional `text` (höchstens 200 Zeichen), `url` (über `SafeUrl`) und `link_label` (höchstens 60 Zeichen, Vorgabe „Mehr erfahren“, wird ohne `url` verworfen); ein bis zwölf Einträge, in jeder Platzbreite (1–4 Einheiten). Die Spaltenzahl ergibt sich aus der Anzahl der Einträge und der tatsächlichen Breite (Raster ab 12 rem je Merkmal), nicht aus einer eigenen Einstellung. `settings.link_style` bestimmt für alle Links des Widgets die Darstellung: `text` (kleiner Textlink, Vorgabe) oder `pill` (Pille). Weitere Einstellungen: `settings.align` (`left` Vorgabe, `center`, `right`; richtet Symbol, Titel, Satz und Link aus), `settings.symbol_size` (`small` 2,5 rem, `medium` 3,5 rem Vorgabe, `large` 5 rem, `xlarge` 7 rem) `settings.symbol_position` (`top` über dem Text, Vorgabe; `left` oder `right` neben Titel, Satz und Link; die Klasse `lf-features--symbol-<lage>` erscheint nur bei Abweichung, Titel, Satz und Link stehen dann in `lf-features__body`, das Symbol sitzt oben bündig mit dem Titel, Mindestbreite je Merkmal 18 rem statt 12 rem, darunter stehen die Merkmale untereinander) und `settings.divider` = `line` (feiner Strich in der Mitte der Lücke: senkrecht zwischen Spalten, waagerecht zwischen Zeilen und bei untereinander stehenden Merkmalen; die Liste schneidet die Striche am Rand ab). Ungültige gespeicherte Werte fallen auf die Vorgaben zurück (`FeaturesWidget::layout`). Der zugängliche Name des Links nennt das Merkmal („Mehr erfahren: Kurze Filme“).
|
||||
|
||||
**Abweichungen vom Kit (bewusst):**
|
||||
- Kennungen bleiben `hero` und `image_text`, nicht `lf-brand-hero`/`lf-editorial-bild-text`; Varianten `photo_split`/`editorial_solid` mit Unterstrich, weil Variantenkennungen `^[a-z][a-z0-9_]*$` folgen.
|
||||
|
||||
@@ -159,6 +159,7 @@ ## Produktseiten im Shop (ADR-52, 25.11.2026)
|
||||
- **Mit dem Deployment ändert sich der Katalog sofort:** Aktive Kaufangebote mit einer Artikelposition, die bisher keine Produktseite hatten (zum Beispiel ein Lizenzartikel aus einem Modul), sind dann öffentlich kaufbar und gelistet, sofern der Shop läuft (Test: Testzahlung; Prod: nur mit Live-Freigabe, siehe unten). Vor dem Merge nach `main` die Angebote prüfen (Verwaltung → Angebote) und ungewollte mit „Aus dem Verkauf nehmen“ beenden. Eine Prüfung der Produktivdaten erfolgt nur lesend und mit Freigabe von Lars.
|
||||
- Keine Migration. Die Spalten `offers.composition_id` und `offers.standalone_bundle` bleiben, werden aber nicht mehr geschrieben. Ein Rollback des Codes ändert keine Daten.
|
||||
- Ein Kauf braucht genau eine Position (Artikel oder Paketfassung) und einen Preis; die Maske lehnt anderes ab.
|
||||
- Optionen eines Artikels werden am Lizenzartikel gepflegt (Abschnitt „Im Shop verkaufen“, Aktionen „Option hinzufügen“, „Ändern“, „Aus dem Verkauf nehmen“). Das ist eine reine Oberflächen- und Dienständerung ohne Migration; Pakete und Vergaben auf Abruf oder bei Registrierung bleiben in der Angebotsmaske.
|
||||
|
||||
## Verkaufsstart: Freigabe und Betrieb (Stand 24.11.2026, vorbereitet, nicht freigegeben)
|
||||
|
||||
@@ -167,11 +168,26 @@ ## Verkaufsstart: Freigabe und Betrieb (Stand 24.11.2026, vorbereitet, nicht fre
|
||||
| Bedingung | Wo gesetzt |
|
||||
|---|---|
|
||||
| `SHOP_LIVE_RELEASE=true` | `/etc/luf/prod.env` (Standard: aus; nie im Repository) |
|
||||
| `SHOP_PUBLIC=true` (nur für die Sichtbarkeit, **nicht** für den Kauf) | `/etc/luf/prod.env` (Standard: aus; nie im Repository) |
|
||||
| `PAYMENT_DRIVER=stripe` | `/etc/luf/prod.env` |
|
||||
| `STRIPE_SECRET=sk_live_…` (Live-Schlüssel; in Produktion sind Testschlüssel nie live, außerhalb der Produktion sind Live-Schlüssel verboten) | `/etc/luf/prod.env` |
|
||||
| `STRIPE_WEBHOOK_SECRET` des Live-Endpunkts, Adresse `https://lara-und-felix.de/stripe/webhook` (Ereignisse mindestens `checkout.session.completed`, `checkout.session.expired`, `checkout.session.async_payment_succeeded`, `checkout.session.async_payment_failed`) | `/etc/luf/prod.env`, Stripe-Dashboard |
|
||||
| Veröffentlichte CMS-Seiten `/agb`, `/lizenzbedingungen`, `/widerruf`, `/impressum`, `/datenschutz` | Webpräsenz (Redaktion, Text von der Rechtsberatung) |
|
||||
|
||||
**Zwei Schalter in Produktion (ADR-53).** „Shop sichtbar“ (`Shop::visible()`) und „Checkout offen“ (`Shop::checkoutOpen()`) sind getrennt:
|
||||
|
||||
| Zustand | `SHOP_PUBLIC` | Checkout-Bedingungen (alle) | Was Besucher sehen |
|
||||
|---|---|---|---|
|
||||
| beide aus (Standard) | nicht gesetzt | nicht erfüllt | Shop, Produktseiten, Warenkorb, Kasse und Hinweisseite antworten mit 404; kein Warenkorb-Symbol; Menüpunkte in den Shop sind ausgeblendet |
|
||||
| nur sichtbar | `true` | nicht erfüllt | Shop und Produktseiten (`noindex`); „Kaufen“ führt auf `/kauf-noch-nicht-moeglich`; Warenkorb und Kasse leiten dorthin; keine Bestellung, kein Warenkorb |
|
||||
| offen | beliebig (die Freigabe macht den Shop immer auch sichtbar) | erfüllt | Warenkorb, „Jetzt kaufen“, Kasse und Zahlung |
|
||||
|
||||
Außerhalb der Produktion sind beide Schalter an, sobald `PAYMENT_DRIVER` `test` oder `stripe` (Testschlüssel) ist. Die Umgebungsdatei ändert nur Lars; nach einer Änderung den letzten Lauf des Deploy-Workflows erneut starten (siehe „Env-Datei ändern“). Die Verwaltungsseite „Verkauf → Verkaufsstart“ zeigt beide Schalter.
|
||||
|
||||
**Shopkachel (ADR-54):** Migration `2026_12_01_100000_add_shop_presentation_fields`, rein ergänzend (Spalten `editorial_content_kinds.symbol` und `license_articles.shop_markers`, beide leer zulässig; bei einem Rollback des Codes bleiben sie ungenutzt liegen). Titelbilder erscheinen nur mit Website-Freigabe des Mediums.
|
||||
|
||||
**Regeln für freie Artikel (ADR-56):** Migration `2026_12_01_110000_add_offer_claim_rules`, rein ergänzend (`offers.claim_access` mit Vorgabe `alle`, `offers.claim_requires_article_id`, Tabelle `offer_releases` ohne Kaskade). Bestehende Angebote auf Abruf behalten das bisherige Verhalten; bei einem Rollback des Codes bleiben Spalten und Tabelle liegen, die Regeln gelten dann nicht mehr (jedes Konto kann abrufen). **Vor einem Rollback prüfen**, ob ein Angebot auf Abruf nur für bestimmte Konten gedacht war.
|
||||
|
||||
Weitere Einstellungen: `SHOP_INVOICE` (Standard **aus**: Kauf auf Rechnung für Organisationen wird Mitgliedern erst angeboten, wenn der Prozess vollständig ist; die Umsetzung bleibt erhalten, vorhandene Rechnungsbestellungen bleiben in der Verwaltung bearbeitbar; `true` schaltet die Option im Checkout ein), `SHOP_PRICE_NOTE` (Preis- und Steuerhinweis im Warenkorb, Standard „Alle Preise in Euro.“), `STRIPE_TAX_RATE_ID` (im Preis enthaltener Steuersatz; Steuerstatus offen, OPEN-06). Die Verwaltungsseite **Verkauf → Verkaufsstart** zeigt den Zustand ohne Schlüssel.
|
||||
|
||||
- **Erstattung bei Stripe:** `Checkout::refund` ruft vor dem Entzug der Rechte `POST /v1/refunds` (Vollbetrag, Idempotenzschlüssel `luf-refund-<Bestellung>-<Zahlung>`) auf; schlägt das fehl, bleibt die Bestellung unverändert. Dafür muss der API-Schlüssel das Recht „Refunds: write“ haben (bei eingeschränktem Schlüssel `rk_…` prüfen). Die Zahlungsabsicht (`payment_intent`) wird aus der signierten Meldung gespeichert, sonst bei Stripe abgefragt.
|
||||
|
||||
@@ -59,6 +59,102 @@ ## Produktseite je Lizenzartikel (25.11.2026, auf `luf-test`)
|
||||
3. **Altbestand mit mehreren Positionen und Programmseite** im Browser: durch Test belegt, auf `luf-test` gibt es keinen solchen Fall.
|
||||
4. **Der Dialog selbst** ist unverändert lang (Eignung, Nutzerkreis, Vergabe, Preis, „Programmfassung, die abgedeckt sein muss“, Positionen). Die Vereinfachung mit mehreren Optionen je Artikel (Rechteprofil mit Preis) folgt als nächster Schritt.
|
||||
|
||||
## Shopkachel: Titelbild, Säulen, Materialart mit Symbol, Marker (26.11.2026, auf `luf-test` und lokal)
|
||||
|
||||
**Geprüfter Stand:** Commit `0ac7088` auf `develop`; `CI Feature / test`, `Deploy Test / test` und `Deploy Test / deploy` **success** (öffentliche Gitea-Statusabfrage). Entscheidung: ADR-54, Plan `docs/analysen/shop-umbauplan-2026-11-26.md`, Phase 2.
|
||||
|
||||
**Auslöser.** Die Kachel zeigte nur Titel, Kurztext und „ab Preis“: kein Titelbild, keine Gruppen, keine Materialart, keine Marker.
|
||||
|
||||
**Tests.** `ShopTilesTest` (18 Tests): ohne freigegebenes Titelbild ein Platzhalter und kein Bild; ein nicht freigegebenes Titelbild erscheint nie (kein Bild, keine Adresse, kein Titel des Mediums im Quelltext); ein freigegebenes erscheint als schmückendes Bild mit leerem `alt` und `loading="lazy"`; ein nicht freigegebenes erstes Bild wird zugunsten des nächsten freigegebenen übersprungen; ein Film dient nie als Titelbild; nur veröffentlichte Säulen erscheinen, die Suche findet über Säule und Materialart; Materialart und Symbol erscheinen ohne Bild, ein unbekannter Symbolschlüssel wird ignoriert und nicht ausgegeben; das Symbol wird in den Stammdaten gespeichert, ein ungültiges verworfen; „Neu“ erscheint automatisch für 30 Tage nach dem ersten Angebot, „Aktualisiert“ nach einem neuen Stand (nie zusammen mit „Neu“), die Einstellung der Redaktion hat Vorrang und „Beliebt“ ist nur von Hand; eine unzulässige Einstellung wird abgelehnt und Vorgaben greifen; Marker tragen ihr Wort und eine Ansage für Bildschirmleser; die Aktion „Marker ändern“ speichert nur die Marker und lässt die Redaktion unberührt; nur der Katalogverwalter erreicht sie (Redakteur und Mitglied ohne Rolle bekommen 403); Shopseite und Datenquelle zeigen dieselben Produkte in derselben Reihenfolge; ein archivierter Artikel und ein Artikel ohne Option stehen nicht im Shop. Die Gesamtsuite (1043 Tests) lief lokal ohne andere Fehler als die bekannten Symbolfehler der lokalen `vendor`-Kopie; das CI-Gate ist grün.
|
||||
|
||||
**Sicherheitsdurchsicht (Phase 2).** Das Titelbild kommt nur über `WebsiteMedia::present` (Freigabe, Pfadmuster, Datei im öffentlichen Speicher) und wird über `/website-medien/{id}` ausgeliefert, nie über Mitgliedervorschauen oder `originals`. Alle Texte der Kachel sind maskiert; der Symbolschlüssel wird an der Materialart und noch einmal beim Ausgeben gegen den Katalog geprüft. Die Marker-Aktion ist auf den Katalogverwalter beschränkt und prüft jede Einstellung gegen eine feste Liste. Die Migration ist rein ergänzend (zwei leer zulässige Spalten).
|
||||
|
||||
**Geprüft im echten Browser.** Chromium über Playwright (Skripte nicht im Repository). Auf `luf-test` gibt es kein Medium mit Website-Freigabe am Artikel; die Kachel mit Bild, Säulen, Symbol und mehreren Markern wurde deshalb lokal mit der Demo-Datenbank geprüft.
|
||||
|
||||
| Fall | Ort | Ergebnis | Belege |
|
||||
|---|---|---|---|
|
||||
| Kacheln mit Bild, Platzhalter mit Symbol, Marker, Säulen (1280, 768, 390 px) | lokal | drei Kacheln: Titelbild, Symbol-Tafel und Paket ohne Bild; Marker „Neu“, „Beliebt“, „Aktualisiert“ mit Wort; Säulen als Chips; kein Überlauf; ein Tabstopp je Kachel, Enter auf dem Titel öffnet die Produktseite | [01](etappe-1/shop-kachel/01-lokal-kacheln-1280.jpg), [02](etappe-1/shop-kachel/02-lokal-kacheln-390.jpg) |
|
||||
| Kachel im Shop, 1280 und 390 px | `luf-test` | Platzhalter, „Neu“ (erstes Angebot jünger als 30 Tage), Preis und Optionen; kein Überlauf; Enter auf dem Titel öffnet die Produktseite | [03](etappe-1/shop-kachel/03-luf-test-kachel-1280.jpg), [04](etappe-1/shop-kachel/04-luf-test-kachel-390.jpg) |
|
||||
| „Marker ändern“ am Artikel | `luf-test` | Dialog mit den drei Markern; „Beliebt“ auf „Anzeigen“ stellt das Wort auf die Kachel, das Zurücksetzen nimmt es wieder weg | [05](etappe-1/shop-kachel/05-luf-test-dialog-marker.jpg), [06](etappe-1/shop-kachel/06-luf-test-kachel-beliebt.jpg) |
|
||||
| Materialart bearbeiten | `luf-test` | das Formular bietet „Symbol im Shop“ an | [07](etappe-1/shop-kachel/07-luf-test-materialart-symbol.jpg) |
|
||||
|
||||
**Zustand von `luf-test` danach:** Die Option „Einzellizenz Abstand“ am Artikel „Programm Abstand“ wurde für den Lauf aktiv gesetzt (Fassung 6) und wieder aus dem Verkauf genommen; `/shop/4` antwortet 404. Der Marker „Beliebt“ ist zurückgesetzt. Im Shop steht außerdem ein weiterer Artikel (Kennung 10, „ab 12,00 €“), den ich nicht angefasst habe.
|
||||
|
||||
**Nicht geprüft (mit Grund):**
|
||||
|
||||
1. **Titelbild auf `luf-test`:** Dort ist am Artikel kein Bild mit Website-Freigabe gepflegt; geprüft durch Tests und lokal. Die Bildpflege selbst (Präsentationsmedien) ist unverändert.
|
||||
2. **Symbolwähler bei der Materialart im Browser:** Das Feld ist im Formular sichtbar; die Auswahl eines Symbols und das Speichern sind durch Test belegt, nicht im Browser durchgespielt.
|
||||
3. **Paketkacheln ohne Bild und ohne Symbol:** Pakete haben keine Materialart; sie zeigen eine leere Tafel. Ein Bild oder Symbol für Pakete gibt es noch nicht (offen).
|
||||
4. **Zoom und Bildschirmleser** nicht geprüft.
|
||||
|
||||
## Shop aufräumen: zwei Schalter, Kauf nur über die Kasse, „Jetzt kaufen“ (26.11.2026, `luf-test` und lokal)
|
||||
|
||||
**Geprüfter Stand:** Commit `3d76062` auf `develop` (zuvor `CI Feature / test` auf `feature/shop-aufraeumen`); `CI Feature / test`, `Deploy Test / test` und `Deploy Test / deploy` **success** (öffentliche Gitea-Statusabfrage). Entscheidung: ADR-53, Plan `docs/analysen/shop-umbauplan-2026-11-26.md`, Phase 1.
|
||||
|
||||
**Auslöser.** Auf Prod ohne Freigabe konnte die Mitgliederseite „Angebote“ über den alten Einzelkauf offene Bestellungen anlegen. Die öffentliche Seite „Angebote“ war ein Platzhalter ohne Verbindung zum Shop. Der Shop hatte nur einen Schalter.
|
||||
|
||||
**Tests.** `ShopSwitchTest` (20 Tests): Prod ohne Freigabe legt über die entfernte Route keine Bestellung an (CSRF-Token gesetzt, 404); es gibt weder die Route `member.offers.buy` noch `Checkout::place`; beide Schalter aus: Shop, Produktseite, Paket, Warenkorb, Kasse, Hinweisseite und „Jetzt kaufen“ antworten mit 404; nur sichtbar: Shop und Produktseite zeigen `noindex`, „Kaufen“ führt auf die Hinweisseite, Warenkorb, Kasse, Hinweisseite und „Jetzt kaufen“ (auch als Gast und als angemeldetes Konto, auch als POST) leiten dorthin, es entstehen Warenkorb und Bestellung nicht, das Warenkorb-Symbol fehlt; beide an: wie bisher; eine Freigabe allein macht den Shop sichtbar; Test oder lokal: beide an bei Treiber `test` oder `stripe`, beide aus ohne Treiber; der Stripe-Webhook bleibt an der Produktivfreigabe, nicht an der Sichtbarkeit; `/angebote` leitet auf `/shop`, solange er sichtbar ist, und bleibt als CMS-Seite erreichbar (sonst 404), solange er es nicht ist; Menüpunkte in den Shop erscheinen nur bei sichtbarem Shop; „Jetzt kaufen“ legt die Option in den Warenkorb und öffnet die Bestellübersicht ohne Bestellung, ersetzt eine andere Option derselben Produktseite ohne Rückfrage und behält andere Artikel, schickt einen Gast zur Anmeldung und behält den Warenkorb über die Anmeldung, lehnt eine nicht verkaufte Option und eine unbekannte Kennung ab, zeigt „Bereits erworben“ ohne Kaufknöpfe; die Mitgliederseite „Angebote“ zeigt nur den kostenlosen Abruf und „Zum Shop“ (nur bei sichtbarem Shop), ohne „Testzahlung“ und ohne Kauf, der Abruf funktioniert auch bei verstecktem Shop, die Seite verlangt eine Anmeldung. Bestehende Tests, die den Einzelkauf als Hilfsmittel nutzten, bestellen über den Warenkorb (`Tests\Support\PlacesOrders`), der Seeder führt den Menüpunkt „Shop“ statt „Angebote“.
|
||||
|
||||
**Gefundener Fehler beim Schreiben der Tests.** Die Anmeldeprüfung lief vor dem neuen Schalter: Ein Gast wäre bei sichtbarem, aber geschlossenem Shop auf `/kasse` zur Anmeldung geschickt worden, und bei abgeschaltetem Shop hätte `/kasse` mit 302 statt 404 geantwortet. Behoben mit der Rangfolge der Middlewares (`prependToPriorityList`), abgesichert durch die Tests oben.
|
||||
|
||||
**Sicherheitsdurchsicht (Phase 1).** Alle neuen Aufrufe sind `POST` hinter dem CSRF-Schutz (in Produktion wirksam, im Test mit gesetztem Token geprüft). „Jetzt kaufen“ leitet nur auf die feste Adresse der Kasse weiter, keine Eingabe fließt in ein Ziel. Die Produktseite zeigt nur Besitz des eigenen Kontos. Optionsnamen in den Knöpfen sind maskiert. Eine Option ohne öffentliche Produktseite oder ohne aktive Kauffassung lässt sich nicht in den Warenkorb legen. Der Stripe-Webhook, die Testzahlung und die Erstattung hängen unverändert an `Shop::stripe()` bzw. am Testtreiber, nicht an der Sichtbarkeit. Keine neue Tabelle, keine Migration.
|
||||
|
||||
**Geprüft im echten Browser.** Chromium über Playwright (Skripte nicht im Repository). `luf-test`: Checkout offen. Der geschlossene Zustand ist auf `luf-test` nicht herzustellen (Produktion ist dort nie aktiv); er wurde mit einer lokalen Instanz mit `APP_ENV=production`, `SHOP_PUBLIC=true` und ohne Freigabe geprüft. Das angemeldete Mitglied wurde lokal mit der Demo-Datenbank geprüft (auf `luf-test` gibt es kein Mitgliedskonto).
|
||||
|
||||
| Fall | Ort | Ergebnis | Belege |
|
||||
|---|---|---|---|
|
||||
| Produktseite mit „Jetzt kaufen“ und „In den Warenkorb“, 1280 und 390 px | `luf-test` | beide Knöpfe je Option, kein `noindex`, kein Überlauf | [01](etappe-1/shop-aufraeumen/01-luf-test-produktseite-1280.jpg), [02](etappe-1/shop-aufraeumen/02-luf-test-produktseite-390.jpg) |
|
||||
| „Jetzt kaufen“ per Tastatur (Fokus, Enter) als Gast | `luf-test` | Anmeldung; der Warenkorb mit der Option bleibt | [03](etappe-1/shop-aufraeumen/03-luf-test-gast-bei-anmeldung.jpg), [04](etappe-1/shop-aufraeumen/04-luf-test-warenkorb-bleibt.jpg) |
|
||||
| `/angebote` und der Menüpunkt „Angebote“ | `luf-test` | führt in den Shop; `/kauf-noch-nicht-moeglich` leitet bei offenem Checkout in den Shop | Text im Lauf |
|
||||
| Alter Einzelkauf `POST /bereich/angebote/1/kaufen` | `luf-test` | 404 | Text im Lauf |
|
||||
| Prod-Zustand „nur sichtbar“: Shop, Produktseite, Hinweis (1280 und 390 px) | lokal | `noindex`, kein Warenkorb-Symbol, „Kaufen“ statt Warenkorb und „Jetzt kaufen“, Hinweis über den Optionen, Hinweisseite; Warenkorb und Kasse leiten dorthin; „Kaufen“ per Tastatur erreichbar; kein Überlauf | [05](etappe-1/shop-aufraeumen/05-lokal-produktion-geschlossen-1280.jpg), [06](etappe-1/shop-aufraeumen/06-lokal-produktion-geschlossen-390.jpg), [07](etappe-1/shop-aufraeumen/07-lokal-hinweisseite.jpg) |
|
||||
| „Jetzt kaufen“ als Gast, Anmeldung, Bestellübersicht | lokal | nach der Anmeldung öffnet sich `/kasse` mit der Option, zwei Zustimmungen und „Zahlungspflichtig bestellen“; noch keine Bestellung | [08](etappe-1/shop-aufraeumen/08-lokal-bestelluebersicht.jpg) |
|
||||
| Bestellung mit Testzahlung, danach Produktseite | lokal | die erworbene Option zeigt „Bereits erworben“ ohne Kaufknöpfe, die andere bleibt kaufbar | [09](etappe-1/shop-aufraeumen/09-lokal-bereits-erworben.jpg) |
|
||||
| Mitgliederseite „Angebote“ (1280 und 390 px) | lokal | nur kostenloser Abruf und „Zum Shop“, kein Kauf, kein „Testzahlung“, kein Überlauf | [10](etappe-1/shop-aufraeumen/10-lokal-mitglied-angebote.jpg), [11](etappe-1/shop-aufraeumen/11-lokal-mitglied-angebote-390.jpg) |
|
||||
|
||||
**Zustand von `luf-test` danach:** Der Menüpunkt „Angebote“ führt weiter auf die alte CMS-Seite `/angebote`, die jetzt auf `/shop` umleitet; Seite und Menüpunkt entfernt Lars in der Webpräsenz (Daten, nicht per Migration). Für den Lauf wurde die Option „Einzellizenz Abstand“ als Fassung 3 aktiv gesetzt und danach wieder aus dem Verkauf genommen; `/shop/4` antwortet 404. Auf Prod ist ohne neue Einstellung alles aus.
|
||||
|
||||
**Nicht geprüft (mit Grund):**
|
||||
|
||||
1. **Produktivdaten:** Offene Bestellungen aus dem früheren Einzelkauf auf Prod sind nicht gelesen (nur mit Freigabe von Lars); löschen entscheidet er.
|
||||
2. **Zustand „nur sichtbar“ auf `luf-test`:** nicht herstellbar (Produktion nur lokal simuliert), siehe oben.
|
||||
3. **Registrierung statt Anmeldung** beim „Jetzt kaufen“ (E-Mail-Bestätigung): Es gibt keinen Test über Registrierung und Bestätigung; geprüft ist nur die Anmeldung mit vorhandenem Konto.
|
||||
4. **Zoom und Bildschirmleser** nicht geprüft; Tastaturbedienung der Knöpfe und der Hinweisseite wurde geprüft.
|
||||
|
||||
## Optionen am Lizenzartikel (25.11.2026, auf `luf-test`)
|
||||
|
||||
**Geprüfter Stand:** Commit `6575784` auf `develop`; `CI Feature / test` (Branch `feature/artikel-optionen`), `Deploy Test / test` und `Deploy Test / deploy` **success** (öffentliche Gitea-Statusabfrage). Entscheidung: ADR-52, Nachtrag „Optionen am Lizenzartikel“.
|
||||
|
||||
**Auslöser.** Mehrere Optionen (Rechteprofil mit Preis) je Artikel ließen sich nur über je ein Angebot mit langer Maske anlegen (Auswahl von Artikel, Ziel, Programmfassung, Vergabe). Jetzt legt der Artikel seine Optionen selbst an.
|
||||
|
||||
**Tests.** `ArticleOptionsTest` (13 Tests): Der Dialog fragt nur Rechteprofil, Preis, Eignung, Nutzerkreis und Bezeichnung (keine Auswahl von Artikel, Ziel, Positionen, Paketfassung, Programmfassung, Vergabe); zwei Optionen teilen sich `/shop/{Artikel}` und sind Alternativen im Warenkorb; der Abschnitt listet Preis, Rechte und Zustand; ein Artikel ohne Stand ist nicht verkaufbar; Preis 0, negativ oder Text und Mehrfachlizenz mit einem Trainer hinterlassen **kein leeres Angebot**; Ändern aktiviert die nächste Fassung, die frühere bleibt, die andere Option bleibt unberührt; Abbrechen ändert nichts; eine Option beenden lässt die andere kaufbar, „Wieder anbieten“ funktioniert; eine Option eines anderen Artikels liefert 404 und wird vom Dienst abgelehnt; ein Angebot auf Abruf wird gelistet, aber weder geändert noch beendet noch zum Kauf umgestellt; der Dialog speichert die Redaktion nicht mit und lässt offene Eingaben stehen; die Angebotsmaske kennt „Programmfassung, die abgedeckt sein muss“ nicht mehr. Die Gesamtsuite lief lokal ohne andere Fehler als die bekannten 46 Symbolfehler der lokalen `vendor`-Kopie; das CI-Gate ist grün.
|
||||
|
||||
**Gefundener Fehler beim Abnahmelauf.** Am Artikel „Programm Abstand“ hing schon das Angebot „Testangebot Abstand“ (Vergabe Auf Abruf). Der erste Stand des Abschnitts bot dafür „Ändern“ und „Aus dem Verkauf nehmen“ an; „Ändern“ hätte es zum Kauf umgestellt. Mein Aufräumskript beendete es dabei auf `luf-test`. Behoben in `6575784` (Test oben), das Angebot danach über die Angebotsmaske wieder aktiviert (jetzt Fassung 2, Vergabe Auf Abruf, Nutzerkreis Einzellizenz statt „nicht festgelegt“; die frühere Fassung 1 ist beendet gespeichert).
|
||||
|
||||
**Geprüft im echten Browser** (Chromium über Playwright, Skripte nicht im Repository; 1280, 1440 und 390 px, Tastatur).
|
||||
|
||||
| Fall | Ergebnis | Belege |
|
||||
|---|---|---|
|
||||
| Abschnitt „Im Shop verkaufen“ | Liste der Optionen mit Preis, Nutzerkreis, Eignung, Rechten, Fassung und Zustand; beendete Option mit „Wieder anbieten“ | [01](etappe-1/optionen/01-abschnitt-vorher.jpg) |
|
||||
| Dialog „Option hinzufügen“ | Fünf Felder; per Tastatur (Enter auf dem Knopf) geöffnet, Fokus im Dialog, Escape schließt ohne Wirkung | [02](etappe-1/optionen/02-dialog-option-hinzufuegen.jpg) |
|
||||
| Beendete Option wieder anbieten | Maske vorbelegt (Preis 15,00); Meldung „ist als Fassung 2 aktiv und im Shop kaufbar unter /shop/4“ | [03](etappe-1/optionen/03-dialog-vorbelegt.jpg) |
|
||||
| Zweite Option für Vereine | Vorschlag „Mehrfachlizenz (8 Trainer) für Organisationen und Vereine“, eigene Bezeichnung übernommen, Fassung 1 aktiv | [04](etappe-1/optionen/04-dialog-zweite-option.jpg), [05](etappe-1/optionen/05-abschnitt-zwei-optionen.jpg) |
|
||||
| Öffentliche Artikelseite | Beide Optionen mit Preis, Eignung und Nutzerkreis, bei 1280 und 390 px ohne horizontalen Überlauf | [06](etappe-1/optionen/06-artikelseite-1280.jpg) |
|
||||
| Alternativen im Warenkorb | Zweite Option desselben Artikels fragt „Optionen wechseln?“; nach dem Wechsel liegt genau die gewählte Option im Warenkorb | [07](etappe-1/optionen/07-optionen-wechseln.jpg), [08](etappe-1/optionen/08-warenkorb-nach-wechsel.jpg) |
|
||||
| Schmales Fenster (390 px) | Abschnitt der Verwaltung ohne Überlauf, Aktionen umbrechen | [09](etappe-1/optionen/09-abschnitt-390.jpg) |
|
||||
| Angebot auf Abruf | „Kein Kauf im Shop. Diese Vergabe bearbeitest du am Angebot.“, keine Änderungs- oder Beenden-Aktion | [10](etappe-1/optionen/10-angebot-auf-abruf-ohne-aktionen.jpg) |
|
||||
| Aufräumen | Nur die Kauf-Option bietet „Aus dem Verkauf nehmen“ an; danach `/shop/4` 404 und aus dem Shop verschwunden | [11](etappe-1/optionen/11-abschnitt-nachher.jpg) |
|
||||
|
||||
Die Bilder 01 bis 09 stammen vom ersten Lauf vor dem Fehlerfix (dort steht „Testangebot Abstand“ noch mit „Ändern“; Bild 09 zeigt das); Bild 10 und 11 sind nach dem Fix aufgenommen.
|
||||
|
||||
**Zustand von `luf-test` danach:** Artikel „Programm Abstand“ hat die beendeten Kauf-Optionen „Einzellizenz Abstand“ (Fassung 1 und 2) und „Vereinslizenz Abstand“ (Fassung 1) sowie das Angebot „Testangebot Abstand“ (Auf Abruf, Fassung 2 aktiv); `/shop/4` antwortet 404. Es entstand ein zusätzliches Angebot („Programm Abstand: Vereinslizenz Abstand“).
|
||||
|
||||
**Nicht geprüft (mit Grund):**
|
||||
|
||||
1. **Produktivdaten:** Nicht gelesen. Lars nennt nur ein Angebot auf Prod (das fehlerhafte).
|
||||
2. **Pakete:** Optionen eines Pakets bleiben in der Angebotsmaske; ein gleichartiger Dialog am Paket ist nicht gebaut.
|
||||
3. **Teilbesitz bei Paketen und der Journal-Filter je Paket** bleiben offen (ADR-52).
|
||||
|
||||
## Zahlungsjournal: Standardansicht je Umgebung (23.11.2026, auf `luf-test`)
|
||||
|
||||
**Geprüfter Stand:** Commit `3f9e463` auf `develop`; `CI Feature / test`, `Deploy Test / test` und `Deploy Test / deploy` **success** (öffentliche Gitea-Statusabfrage). Tests lokal 714 grün, Pint auf den geänderten Dateien bestanden.
|
||||
|
||||
|
After Width: | Height: | Size: 174 KiB |
|
After Width: | Height: | Size: 142 KiB |
|
After Width: | Height: | Size: 139 KiB |
|
After Width: | Height: | Size: 152 KiB |
|
After Width: | Height: | Size: 216 KiB |
|
After Width: | Height: | Size: 143 KiB |
|
After Width: | Height: | Size: 165 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 189 KiB |
|
After Width: | Height: | Size: 214 KiB |
|
After Width: | Height: | Size: 224 KiB |
|
After Width: | Height: | Size: 72 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 99 KiB |
|
After Width: | Height: | Size: 93 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 108 KiB |
|
After Width: | Height: | Size: 95 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 127 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 116 KiB |
@@ -0,0 +1,15 @@
|
||||
# Abnahme: Merkmalszeile, Lage des Symbols (2026-11-26)
|
||||
|
||||
**Geprüft wurde nur die Ausgabe, lokal und nicht auf luf-test:** Die Ansicht der Merkmalszeile wurde mit den gebauten Styles in Chromium gerendert (Playwright), je Lage (über dem Text, links, rechts) auf hellem und dunklem Grund, in 1180 px und 420 px Fensterbreite. Der Reiter „Darstellung“ im Seiteneditor wurde noch nicht im Browser geprüft; das steht nach dem Deploy auf Test aus.
|
||||
|
||||
- Einstellung „Lage des Symbols“: Über dem Text (Vorgabe, unverändert), Links neben dem Text, Rechts neben dem Text.
|
||||
- Die Zeichnung sitzt oben, bündig mit dem Titel; Titel, Satz und Link stehen in einer Spalte daneben. Rechts steht das Symbol am rechten Rand, auch bei rechtsbündigem Text.
|
||||
- Mit Trennstrich und auf dunklem Grund (runde weiße Scheibe) bleibt die Anordnung gleich.
|
||||
- Neben dem Text braucht ein Merkmal mindestens 18 rem Breite, sonst stehen die Merkmale untereinander.
|
||||
- Schmal: „Sehr groß“ wird neben dem Text eine Stufe kleiner (Groß), damit Titel nicht mitten im Wort umbrechen.
|
||||
|
||||
Nicht geprüft: Screenreader, Touch, Browser außer Chromium.
|
||||
|
||||
| Breit | Schmal |
|
||||
|---|---|
|
||||
|  |  |
|
||||
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 248 KiB |
@@ -149,6 +149,49 @@ .lf-features--right .lf-features__item { text-align: right; }
|
||||
.lf-features--right .lf-features__symbol { align-self: flex-end; }
|
||||
.lf-features--right .lf-features__text { margin-inline-start: auto; }
|
||||
|
||||
/*
|
||||
* Lage des Symbols (Einstellung „Lage des Symbols“): Vorgabe über dem Text. Links oder rechts steht das Symbol neben Titel,
|
||||
* Satz und Link (Klassen nur bei Abweichung). Die Zeichnung sitzt oben, bündig mit der Oberkante des Titels, egal wie die
|
||||
* Texte ausgerichtet sind. Neben dem Text braucht ein Merkmal mehr Breite, sonst bliebe für große Symbole kaum Zeile übrig.
|
||||
*/
|
||||
.lf-features__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
min-inline-size: 0;
|
||||
}
|
||||
|
||||
.lf-features--symbol-left,
|
||||
.lf-features--symbol-right {
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
|
||||
}
|
||||
|
||||
.lf-features--symbol-left.lf-features--1,
|
||||
.lf-features--symbol-right.lf-features--1 {
|
||||
grid-template-columns: minmax(0, 28rem);
|
||||
}
|
||||
|
||||
.lf-features--symbol-left .lf-features__item,
|
||||
.lf-features--symbol-right .lf-features__item {
|
||||
flex-direction: row;
|
||||
align-items: flex-start;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.lf-features--symbol-right .lf-features__item { flex-direction: row-reverse; }
|
||||
|
||||
.lf-features--symbol-left .lf-features__symbol,
|
||||
.lf-features--symbol-right .lf-features__symbol { align-self: flex-start; }
|
||||
|
||||
.lf-features--symbol-left .lf-features__body,
|
||||
.lf-features--symbol-right .lf-features__body { flex: 1 1 0; }
|
||||
|
||||
/* Auf schmalen Fenstern steht „Sehr groß“ neben dem Text eine Stufe kleiner, damit für Titel und Satz genug Zeile bleibt. */
|
||||
@media (max-width: 30rem) {
|
||||
.lf-features--symbol-left.lf-features--size-xlarge .lf-features__symbol,
|
||||
.lf-features--symbol-right.lf-features--size-xlarge .lf-features__symbol { --sym-s: var(--lf-symbol-large); }
|
||||
}
|
||||
|
||||
/* Größe der Symbole (Einstellung „Größe der Symbole“): Kantenlänge des Quadrats, in das die Zeichnung passt. */
|
||||
.lf-features--size-small .lf-features__symbol { --sym-s: var(--lf-symbol-small); }
|
||||
.lf-features--size-large .lf-features__symbol { --sym-s: var(--lf-symbol-large); }
|
||||
|
||||
@@ -1726,7 +1726,8 @@ .mb-offer {
|
||||
background: var(--color-surface-raised);
|
||||
}
|
||||
|
||||
.mb-offer h2 {
|
||||
.mb-offer h2,
|
||||
.mb-offer h4 {
|
||||
font-size: var(--text-h3);
|
||||
}
|
||||
|
||||
|
||||
@@ -421,3 +421,145 @@ .mb-withdraw textarea {
|
||||
width: 100%;
|
||||
margin: var(--space-2) 0 var(--space-3);
|
||||
}
|
||||
|
||||
/*
|
||||
* Produktkachel (ADR-54): Titelbild oder Platzhalter mit Symbol der Materialart, Marker mit Wort, Art, Titel, Kurztext,
|
||||
* Themen und Preis. Bilder erscheinen nur mit Website-Freigabe; ohne Bild trägt eine helle Tafel das Symbol.
|
||||
*/
|
||||
.shop-tile {
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.shop-tile-media {
|
||||
position: relative;
|
||||
aspect-ratio: 16 / 9;
|
||||
background: var(--color-surface-subtle);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.shop-tile-media img {
|
||||
inline-size: 100%;
|
||||
block-size: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.shop-tile-symbol {
|
||||
--sym-s: 4.5rem;
|
||||
}
|
||||
|
||||
.shop-tile-body {
|
||||
padding: var(--space-4) var(--space-5) var(--space-5);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.shop-tile-kind {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
margin: 0 0 var(--space-2);
|
||||
color: var(--color-text-muted);
|
||||
font-size: var(--text-small);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.shop-tile-kind-symbol {
|
||||
--sym-s: 1.25rem;
|
||||
}
|
||||
|
||||
.shop-tile-body h2 {
|
||||
margin: 0 0 var(--space-2);
|
||||
}
|
||||
|
||||
.shop-tile-body h2 a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.shop-tile-body h2 a:hover,
|
||||
.shop-tile-body h2 a:focus-visible {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* Die ganze Kachel ist klickbar; der Link im Titel bleibt der einzige Tabstopp. */
|
||||
.shop-tile {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.shop-tile-body h2 a::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
}
|
||||
|
||||
.shop-tile-teaser {
|
||||
margin: 0 0 var(--space-3);
|
||||
color: var(--color-text);
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.shop-tile-pillars {
|
||||
list-style: none;
|
||||
margin: 0 0 var(--space-3);
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.shop-tile-pillars li {
|
||||
padding: 0.1rem 0.6rem;
|
||||
border: 1px solid var(--color-border-strong);
|
||||
border-radius: var(--radius-pill);
|
||||
font-size: var(--text-small);
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.shop-tile-price {
|
||||
margin-top: auto;
|
||||
padding-top: var(--space-3);
|
||||
}
|
||||
|
||||
.shop-markers {
|
||||
position: absolute;
|
||||
inset-block-start: var(--space-3);
|
||||
inset-inline-start: var(--space-3);
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.shop-marker {
|
||||
padding: 0.15rem 0.7rem;
|
||||
border-radius: var(--radius-pill);
|
||||
border: 2px solid var(--lf-navy);
|
||||
background: var(--color-surface);
|
||||
color: var(--lf-navy);
|
||||
font-weight: 700;
|
||||
font-size: var(--text-small);
|
||||
}
|
||||
|
||||
.shop-marker-neu {
|
||||
background: var(--color-accent);
|
||||
}
|
||||
|
||||
.shop-marker-aktualisiert {
|
||||
background: var(--color-info-surface);
|
||||
}
|
||||
|
||||
.shop-marker-beliebt {
|
||||
background: var(--color-success-surface);
|
||||
border-color: var(--color-success);
|
||||
color: var(--color-success);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
{{--
|
||||
Warenkorbzugang im Seitenkopf. Der Warenkorb gehört zum kommerziellen Anwendungssystem, nicht zum CMS.
|
||||
Er erscheint nur, wenn der Shop aktiv ist (Testzahlung, nie in Produktion): kein funktionsloser Kaufknopf.
|
||||
Er erscheint nur, wenn der Checkout offen ist (Schalter 2, Shop::checkoutOpen): kein funktionsloser Kaufknopf.
|
||||
--}}
|
||||
@if (\App\Domain\Commerce\Shop::enabled())
|
||||
@if (\App\Domain\Commerce\Shop::checkoutOpen())
|
||||
@php $cartCount = app(\App\Domain\Commerce\Cart::class)->count(); @endphp
|
||||
<a class="site-icon-link" href="{{ route('cart') }}">
|
||||
<x-heroicon-o-shopping-bag aria-hidden="true" />
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
@include('filament.verwaltung.abgang', ['offen' => $offen])
|
||||
|
||||
<div class="vw-medien-raster">
|
||||
<div class="vw-spalte">
|
||||
<section class="vw-karte-box" aria-labelledby="artikel-redaktion">
|
||||
<div class="vw-spalte-kopf">
|
||||
<h2 id="artikel-redaktion">Präsentation des Artikels</h2>
|
||||
@@ -66,6 +67,56 @@
|
||||
<div><button type="button" class="vw-btn is-line" wire:click="openRedaktion('texte')">@include('filament.verwaltung.icon', ['name' => 'stift'])Redaktion bearbeiten</button></div>
|
||||
@endif
|
||||
</section>
|
||||
|
||||
<section class="vw-karte-box" aria-labelledby="artikel-optionen" id="optionen">
|
||||
<div class="vw-spalte-kopf">
|
||||
<h2 id="artikel-optionen">Im Shop verkaufen</h2>
|
||||
<span class="vw-feld-hilfe">Jede Option ist eine Lizenz mit Rechteprofil und Preis. Alle Optionen erscheinen auf der Produktseite dieses Artikels.</span>
|
||||
</div>
|
||||
@if (! $this->canOffer())
|
||||
<p class="vw-feld-hilfe">Zuerst den Inhalt festlegen: Ohne veröffentlichten Stand lizenziert der Artikel nichts und lässt sich nicht verkaufen.</p>
|
||||
@else
|
||||
@php($optionen = $this->optionRows())
|
||||
@if ($optionen === [])
|
||||
<div class="vw-leer">
|
||||
<strong>Noch keine Option</strong>
|
||||
<p>Lege fest, mit welchem Rechteprofil und zu welchem Preis der Artikel verkauft wird. Mehrere Optionen, etwa für Privatpersonen und für Vereine, sind möglich.</p>
|
||||
</div>
|
||||
@else
|
||||
<ul class="vw-verwendungsliste">
|
||||
@foreach ($optionen as $option)
|
||||
<li>
|
||||
<strong>{{ $option['name'] }}</strong>
|
||||
<span @class(['vw-zustand', 'is-'.$option['zustand']['ton']])>{{ $option['zustand']['label'] }}</span>
|
||||
<span class="vw-feld-hilfe">{{ $option['price'] }} · {{ $option['licence'] }} · {{ $option['for'] }} · Rechte: {{ $option['rights'] }} · Fassung {{ $option['number'] }}</span>
|
||||
<span class="vw-zeilenaktionen">
|
||||
@if ($option['kauf'])
|
||||
<button type="button" class="vw-link" wire:click="mountAction('option', { offer: {{ $option['offer'] }} })">{{ $option['active'] ? 'Ändern' : 'Wieder anbieten' }}</button>
|
||||
@if ($option['active'])
|
||||
<button type="button" class="vw-link is-quiet" wire:click="mountAction('optionEnd', { offer: {{ $option['offer'] }} })">Aus dem Verkauf nehmen</button>
|
||||
@endif
|
||||
@else
|
||||
<span class="vw-feld-hilfe">Kein Kauf im Shop. Diese Vergabe bearbeitest du am Angebot.</span>
|
||||
@endif
|
||||
@if ($option['page'])
|
||||
<a class="vw-link is-quiet" href="{{ $option['page'] }}" target="_blank" rel="noopener">Produktseite ansehen</a>
|
||||
@endif
|
||||
<a class="vw-link is-quiet" href="{{ $option['url'] }}">Angebot öffnen</a>
|
||||
</span>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
<div><button type="button" class="vw-btn is-line" wire:click="mountAction('option')">@include('filament.verwaltung.icon', ['name' => 'plus'])Option hinzufügen</button></div>
|
||||
@php($marker = $this->markerRows())
|
||||
<div class="vw-spalte-kopf">
|
||||
<h3 id="artikel-marker">Marker auf der Kachel</h3>
|
||||
<span class="vw-feld-hilfe">Zurzeit: {{ $marker['sichtbar'] === [] ? 'kein Marker' : implode(', ', $marker['sichtbar']) }}. „Neu“ und „Aktualisiert“ richten sich automatisch nach den Daten, „Beliebt“ setzt du von Hand.</span>
|
||||
<span class="vw-zeilenaktionen"><button type="button" class="vw-link" wire:click="mountAction('markers')">Marker ändern</button></span>
|
||||
</div>
|
||||
@endif
|
||||
</section>
|
||||
</div>
|
||||
<aside class="vw-spalte">
|
||||
@include('filament.verwaltung.voraussetzungen', ['voraussetzungen' => $voraussetzungen])
|
||||
<section class="vw-karte-box" aria-labelledby="artikel-stand">
|
||||
|
||||
@@ -378,6 +378,7 @@
|
||||
.vw-schritt.is-erledigt .vw-schritt-text { color: var(--vw-quiet); }
|
||||
@media (max-width: 640px) { .vw-schritt { grid-template-columns: minmax(0, 1fr); } .vw-schritt .vw-btn { grid-column: 1; grid-row: auto; justify-self: start; } }
|
||||
.vw-verwendungsliste li { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; padding: 0.6rem 0; border-bottom: 1px solid var(--vw-line); }
|
||||
.vw-zeilenaktionen { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
|
||||
.vw-vorschaubild.is-gross { max-width: 40rem; }
|
||||
.vw-trennlinie { padding-top: 0.85rem; border-top: 1px solid var(--vw-line); }
|
||||
.vw-inhaltsvorschau { width: 100%; height: 34rem; border: 1px solid var(--vw-line); border-radius: var(--vw-radius); background: #fff; }
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
@hasSection('canonical')
|
||||
<link rel="canonical" href="@yield('canonical')">
|
||||
@endif
|
||||
{{-- Solange der Kauf nicht freigegeben ist, soll der sichtbare Shop nicht in Suchmaschinen erscheinen. --}}
|
||||
@if (! \App\Domain\Commerce\Shop::checkoutOpen() && request()->routeIs('shop', 'shop.*', 'public.package'))
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
@endif
|
||||
<x-site.favicon />
|
||||
@stack('head')
|
||||
<script>document.documentElement.classList.add('js');</script>
|
||||
|
||||
@@ -5,34 +5,58 @@
|
||||
|
||||
@section('content')
|
||||
<x-member.hero kicker="Zugang" title="Angebote">
|
||||
Ein Abruf legt die Lizenz an. Die Inhalte erscheinen danach in der Bibliothek.
|
||||
Hier findest du, was für dich bereitliegt: neue Stände deiner Artikel und Angebote ohne Kauf. Gekauft wird im Shop.
|
||||
</x-member.hero>
|
||||
@if ($errors->any())
|
||||
<div class="errors" role="alert">{{ $errors->first() }}</div>
|
||||
@endif
|
||||
@if ($offers->isEmpty())
|
||||
<div class="empty"><h2>Keine Angebote</h2><p>Gerade ist kein persönliches Angebot aktiv.</p></div>
|
||||
@else
|
||||
<ul class="mb-offers">
|
||||
@foreach ($offers as $offer)
|
||||
@php $version = $offer->versions->first(); @endphp
|
||||
<li class="mb-offer">
|
||||
<h2>{{ $offer->name }}</h2>
|
||||
@if ($version)
|
||||
<p>
|
||||
@if ($version->grant_kind === 'kauf')
|
||||
{{ number_format($version->price_cents / 100, 2, ',', '.') }} €, Testzahlung
|
||||
@else
|
||||
Kostenlos abrufen
|
||||
@endif
|
||||
</p>
|
||||
<form method="post" action="{{ $version->grant_kind === 'kauf' ? route('member.offers.buy', $offer) : route('member.offers.claim', $offer) }}">
|
||||
|
||||
<section class="mb-offers-foryou" aria-labelledby="angebote-fuer-dich">
|
||||
<h2 id="angebote-fuer-dich">Für dich</h2>
|
||||
@if ($stands->isEmpty() && $offers->isEmpty())
|
||||
<div class="empty"><h3>Gerade liegt nichts Neues für dich bereit</h3><p>Neue Stände deiner Artikel und freie Angebote erscheinen hier.</p></div>
|
||||
@endif
|
||||
@if ($stands->isNotEmpty())
|
||||
<h3>Neu für dich</h3>
|
||||
<p class="lede">Zu diesen Artikeln gibt es einen neuen Stand. Er steht dir ohne Aufpreis zu und liegt schon in deiner Bibliothek.</p>
|
||||
<ul class="mb-offers">
|
||||
@foreach ($stands as $stand)
|
||||
<li class="mb-offer">
|
||||
<h4>{{ $stand['title'] }}</h4>
|
||||
<p>Stand {{ $stand['number'] }} seit {{ $stand['since']->format('d.m.Y') }}</p>
|
||||
<p><a class="button button-secondary" href="{{ route('member.grant', $stand['grant']) }}">In der Bibliothek ansehen<span class="sr-only">: {{ $stand['title'] }}</span></a></p>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
@if ($offers->isNotEmpty())
|
||||
<h3>Zum Übernehmen</h3>
|
||||
<ul class="mb-offers">
|
||||
@foreach ($offers as $offer)
|
||||
<li class="mb-offer">
|
||||
<h4>{{ $offer->name }}</h4>
|
||||
<p>Kostenlos abrufen</p>
|
||||
<form method="post" action="{{ route('member.offers.claim', $offer) }}">
|
||||
@csrf
|
||||
<button class="button" type="submit">{{ $version->grant_kind === 'kauf' ? 'Kaufen' : 'In die Bibliothek' }}</button>
|
||||
<button class="button" type="submit">In die Bibliothek<span class="sr-only">: {{ $offer->name }}</span></button>
|
||||
</form>
|
||||
@endif
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
</section>
|
||||
|
||||
@if ($shop)
|
||||
<section class="mb-offers-shop" aria-labelledby="angebote-shop">
|
||||
<h2 id="angebote-shop">Im Shop</h2>
|
||||
@if ($cards !== [])
|
||||
<ul class="shop-tiles">
|
||||
@foreach ($cards as $card)
|
||||
@include('shop.kachel', ['card' => $card])
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
<p><a class="button button-secondary" href="{{ route('shop') }}">Zum Shop</a></p>
|
||||
</section>
|
||||
@endif
|
||||
@endsection
|
||||
@@ -0,0 +1,9 @@
|
||||
@extends('layouts.site')
|
||||
|
||||
@section('title', 'Kauf noch nicht möglich')
|
||||
|
||||
@section('content')
|
||||
<h1>Der Kauf ist noch nicht freigeschaltet</h1>
|
||||
<p class="lede">Du kannst dir den Shop schon ansehen. Gekauft werden kann ab dem Verkaufsstart. Bis dahin entsteht keine Bestellung und es wird nichts abgebucht.</p>
|
||||
<p><a class="button" href="{{ route('shop') }}">Zurück zum Shop</a></p>
|
||||
@endsection
|
||||
@@ -24,11 +24,7 @@
|
||||
<p class="shop-count" role="status">{{ count($cards) }} {{ count($cards) === 1 ? 'Produkt' : 'Produkte' }}</p>
|
||||
<ul class="shop-tiles">
|
||||
@foreach ($cards as $card)
|
||||
<li class="shop-tile">
|
||||
<h2><a href="{{ $card['url'] }}">{{ $card['title'] }}</a></h2>
|
||||
@if ($card['teaser'] !== '')<p>{{ $card['teaser'] }}</p>@endif
|
||||
<p class="shop-tile-price">ab {{ $card['from'] }} · {{ $card['count'] }} {{ $card['count'] === 1 ? 'Lizenzoption' : 'Lizenzoptionen' }}</p>
|
||||
</li>
|
||||
@include('shop.kachel', ['card' => $card])
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
{{--
|
||||
Eine Produktkachel des Shops. Parameter: $card (ShopCatalog). Die Kachel trägt nur Öffentliches: Titelbild nur mit
|
||||
Website-Freigabe, Säulen nur veröffentlicht, die Materialart mit ihrem Symbol, die Marker mit Wort. Das Bild ist
|
||||
schmückend (leeres alt), der Titel ist der Link.
|
||||
--}}
|
||||
<li class="shop-tile">
|
||||
<div class="shop-tile-media @if ($card['image'] === null) is-placeholder @endif" aria-hidden="true">
|
||||
@if ($card['image'] !== null)
|
||||
<img src="{{ $card['image']['url'] }}" alt="" loading="lazy" decoding="async">
|
||||
@elseif ($card['symbol'] !== null)
|
||||
<x-brand.symbol :name="$card['symbol']" class="shop-tile-symbol" />
|
||||
@endif
|
||||
@if ($card['markers'] !== [])
|
||||
<span class="shop-markers">
|
||||
@foreach ($card['markers'] as $marker)
|
||||
<span class="shop-marker shop-marker-{{ $marker['key'] }}">{{ $marker['label'] }}</span>
|
||||
@endforeach
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="shop-tile-body">
|
||||
@if ($card['markers'] !== [])
|
||||
<p class="sr-only">{{ implode(', ', array_column($card['markers'], 'label')) }}</p>
|
||||
@endif
|
||||
@if ($card['kind_label'] !== '')
|
||||
<p class="shop-tile-kind">
|
||||
@if ($card['symbol'] !== null && $card['image'] !== null)<x-brand.symbol :name="$card['symbol']" class="shop-tile-kind-symbol" aria-hidden="true" />@endif
|
||||
<span>{{ $card['kind_label'] }}</span>
|
||||
</p>
|
||||
@endif
|
||||
<h2><a href="{{ $card['url'] }}">{{ $card['title'] }}</a></h2>
|
||||
@if ($card['teaser'] !== '')<p class="shop-tile-teaser">{{ $card['teaser'] }}</p>@endif
|
||||
@if ($card['pillars'] !== [])
|
||||
<ul class="shop-tile-pillars" aria-label="Themen">
|
||||
@foreach (array_slice($card['pillars'], 0, 3) as $pillar)
|
||||
<li>{{ $pillar }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
<p class="shop-tile-price">ab {{ $card['from'] }} · {{ $card['count'] }} {{ $card['count'] === 1 ? 'Lizenzoption' : 'Lizenzoptionen' }}</p>
|
||||
</div>
|
||||
</li>
|
||||
@@ -3,15 +3,24 @@
|
||||
Parameter: $options (ProductOptions), $cart (Cart), $switchTo (Angebotskennung eines ausstehenden Wechsels)
|
||||
--}}
|
||||
@if ($options !== [])
|
||||
@php
|
||||
// Schalter 2: Ist der Checkout noch nicht freigegeben, führt „Kaufen“ auf die Hinweisseite statt in den Warenkorb.
|
||||
$open = \App\Domain\Commerce\Shop::checkoutOpen();
|
||||
$owned = $open ? $cart->ownedAmong(auth()->user(), array_column($options, 'offer')) : [];
|
||||
@endphp
|
||||
<section class="shop-options" aria-labelledby="shop-options-title">
|
||||
<h2 id="shop-options-title">Lizenzoptionen</h2>
|
||||
<p class="shop-options-lede">Wähle die Lizenz, die zu deiner Nutzung passt. Jede Option ist einzeln kaufbar. Preis und Bedingungen gelten ab dem Bestellabschluss; es wird nichts reserviert.</p>
|
||||
|
||||
@unless ($open)
|
||||
<p class="shop-closed-note ui-notice ui-notice-warning" role="note">Der Kauf ist noch nicht freigeschaltet und startet zum Verkaufsstart. Du kannst dir Umfang und Preise schon ansehen.</p>
|
||||
@endunless
|
||||
|
||||
@if ($errors->has('shop'))
|
||||
<p class="errors" role="alert">{{ $errors->first('shop') }}</p>
|
||||
@endif
|
||||
|
||||
@if ($switchTo)
|
||||
@if ($open && $switchTo)
|
||||
@php
|
||||
$wanted = collect($options)->first(fn ($option) => $option['offer']->id === (int) $switchTo);
|
||||
$current = $wanted ? $cart->alternativeTo($wanted['offer']) : null;
|
||||
@@ -53,13 +62,26 @@
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@if ($cart->has($option['offer']))
|
||||
<p class="shop-in-cart">Im Warenkorb. <a href="{{ route('cart') }}">Zum Warenkorb</a></p>
|
||||
@if (! $open)
|
||||
<p><a class="button" href="{{ route('shop.closed') }}">Kaufen<span class="sr-only">: {{ $option['name'] }}</span></a></p>
|
||||
@elseif (isset($owned[$option['offer']->id]))
|
||||
<p class="shop-badge shop-badge-owned">Bereits erworben · Du findest die Lizenz in deiner Bibliothek.</p>
|
||||
@else
|
||||
<form method="post" action="{{ route('cart.add', $option['offer']) }}">
|
||||
@csrf
|
||||
<button class="button" type="submit">In den Warenkorb<span class="sr-only">: {{ $option['name'] }}</span></button>
|
||||
</form>
|
||||
@if ($cart->has($option['offer']))
|
||||
<p class="shop-in-cart">Im Warenkorb. <a href="{{ route('cart') }}">Zum Warenkorb</a></p>
|
||||
@endif
|
||||
<div class="shop-actions">
|
||||
<form method="post" action="{{ route('cart.buy', $option['offer']) }}">
|
||||
@csrf
|
||||
<button class="button" type="submit">Jetzt kaufen<span class="sr-only">: {{ $option['name'] }}</span></button>
|
||||
</form>
|
||||
@unless ($cart->has($option['offer']))
|
||||
<form method="post" action="{{ route('cart.add', $option['offer']) }}">
|
||||
@csrf
|
||||
<button class="button button-secondary" type="submit">In den Warenkorb<span class="sr-only">: {{ $option['name'] }}</span></button>
|
||||
</form>
|
||||
@endunless
|
||||
</div>
|
||||
@endif
|
||||
</li>
|
||||
@endforeach
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
Merkmalszeile: ein bis zwölf Merkmale mit Symbol, Kurztitel, Satz und optionalem Link. Die Spaltenzahl folgt der Anzahl
|
||||
der Einträge und der tatsächlichen Breite (Raster mit Mindestbreite). Die Symbole sind Zierde; der Kurztitel trägt die
|
||||
Aussage. Der Link erscheint als kleiner Textlink oder als Pille (Einstellung link_style); sein zugänglicher Name nennt
|
||||
das Merkmal, damit mehrere „Mehr erfahren“ unterscheidbar bleiben. Layout (Ausrichtung, Symbolgröße, Trennstrich) kommt
|
||||
das Merkmal, damit mehrere „Mehr erfahren“ unterscheidbar bleiben. Layout (Ausrichtung, Symbolgröße, Lage des Symbols,
|
||||
Trennstrich) kommt
|
||||
als Klassen an der Liste; ungültige Werte sind bereits auf die Vorgabe zurückgefallen (FeaturesWidget::layout).
|
||||
--}}
|
||||
@if ($items !== [])
|
||||
@@ -11,6 +12,7 @@
|
||||
'lf-features--'.count($items),
|
||||
'lf-features--'.$layout['align'],
|
||||
'lf-features--size-'.$layout['size'],
|
||||
'lf-features--symbol-'.$layout['position'] => $layout['position'] !== 'top',
|
||||
'lf-features--lines' => $layout['divider'],
|
||||
])>
|
||||
@foreach ($items as $item)
|
||||
@@ -18,13 +20,15 @@
|
||||
@if ($item['symbol'] !== null)
|
||||
<x-brand.symbol :name="$item['symbol']" class="lf-features__symbol" preserveAspectRatio="xMinYMin meet" />
|
||||
@endif
|
||||
<p class="lf-features__title">{{ $item['title'] }}</p>
|
||||
@if (filled($item['text']))
|
||||
<p class="lf-features__text">{{ $item['text'] }}</p>
|
||||
@endif
|
||||
@if ($item['url'] !== null)
|
||||
<p class="lf-features__more"><a class="lf-features__link lf-features__link--{{ $linkStyle }}" href="{{ $item['url'] }}" aria-label="{{ $item['linkLabel'] }}: {{ $item['title'] }}">{{ $item['linkLabel'] }}</a></p>
|
||||
@endif
|
||||
<div class="lf-features__body">
|
||||
<p class="lf-features__title">{{ $item['title'] }}</p>
|
||||
@if (filled($item['text']))
|
||||
<p class="lf-features__text">{{ $item['text'] }}</p>
|
||||
@endif
|
||||
@if ($item['url'] !== null)
|
||||
<p class="lf-features__more"><a class="lf-features__link lf-features__link--{{ $linkStyle }}" href="{{ $item['url'] }}" aria-label="{{ $item['linkLabel'] }}: {{ $item['title'] }}">{{ $item['linkLabel'] }}</a></p>
|
||||
@endif
|
||||
</div>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
{{--
|
||||
Shop-Produkte (ADR-55). Die Kacheln kommen aus ShopCatalog, nichts davon wird im CMS gespeichert. Ist der Shop nicht
|
||||
sichtbar, bleibt der Abschnitt öffentlich leer; die Redaktionsvorschau zeigt einen Hinweis.
|
||||
--}}
|
||||
@if ($shopVisible || $context->preview)
|
||||
<div class="shop-products">
|
||||
@if (filled($data['heading'] ?? null))
|
||||
<h2>{{ $data['heading'] }}</h2>
|
||||
@endif
|
||||
@if (filled($data['intro'] ?? null))
|
||||
<p class="lede">{{ $data['intro'] }}</p>
|
||||
@endif
|
||||
@unless ($shopVisible)
|
||||
<p class="preview-note">Der Shop ist zurzeit nicht sichtbar. Öffentlich erscheint dieser Abschnitt nicht.</p>
|
||||
@else
|
||||
@if (($settings['search'] ?? 'aus') === 'an')
|
||||
<form class="shop-search" method="get" action="{{ route('shop') }}" role="search">
|
||||
<label for="shop-suche-{{ $widget['id'] ?? 'w' }}">Shop durchsuchen</label>
|
||||
<input id="shop-suche-{{ $widget['id'] ?? 'w' }}" type="search" name="suche" value="{{ $term }}" autocomplete="off">
|
||||
<button class="button" type="submit">Suchen</button>
|
||||
@if ($term !== '')
|
||||
<a class="button button-quiet" href="{{ route('shop') }}">Suche zurücksetzen</a>
|
||||
@endif
|
||||
</form>
|
||||
@endif
|
||||
@if ($cards === [])
|
||||
<div class="empty">
|
||||
<h3>{{ $term !== '' ? 'Keine Treffer' : 'Noch keine kaufbaren Produkte' }}</h3>
|
||||
<p>{{ $term !== '' ? 'Zu „'.$term.'“ gibt es keine kaufbaren Produkte. Prüfe die Schreibweise oder setze die Suche zurück.' : 'Sobald ein Angebot aktiv ist, erscheint es hier.' }}</p>
|
||||
</div>
|
||||
@else
|
||||
<p class="shop-count" role="status">{{ count($cards) }} {{ count($cards) === 1 ? 'Produkt' : 'Produkte' }}</p>
|
||||
<ul class="shop-tiles">
|
||||
@foreach ($cards as $card)
|
||||
@include('shop.kachel', ['card' => $card])
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
@endunless
|
||||
</div>
|
||||
@endif
|
||||
@@ -24,7 +24,8 @@
|
||||
use App\Http\Controllers\SymbolPickerController;
|
||||
use App\Http\Controllers\ThemeController;
|
||||
use App\Http\Controllers\WebsiteMediaController;
|
||||
use App\Http\Middleware\EnsureShopEnabled;
|
||||
use App\Http\Middleware\EnsureCheckoutOpen;
|
||||
use App\Http\Middleware\EnsureShopVisible;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/', [PageController::class, 'home'])->name('home');
|
||||
@@ -37,11 +38,18 @@
|
||||
Route::get('/medien/{path}', [PublicMediaController::class, 'show'])->where('path', '.*')->name('media.public');
|
||||
Route::get('/website-medien/{element}', [WebsiteMediaController::class, 'show'])->whereNumber('element')->name('website.media');
|
||||
|
||||
Route::middleware(EnsureShopEnabled::class)->group(function () {
|
||||
// Schalter 1 (Shop sichtbar): Übersicht, Produktseiten und die Hinweisseite. Schalter 2 (Checkout offen): Warenkorb und
|
||||
// Kasse; ist der Shop nur sichtbar, führen sie auf die Hinweisseite (EnsureCheckoutOpen).
|
||||
Route::middleware(EnsureShopVisible::class)->group(function () {
|
||||
Route::get('/shop', [ShopController::class, 'index'])->name('shop');
|
||||
Route::get('/shop/{article}', [PublicCatalogController::class, 'article'])->whereNumber('article')->name('shop.article');
|
||||
Route::get('/kauf-noch-nicht-moeglich', [ShopController::class, 'closed'])->name('shop.closed');
|
||||
});
|
||||
|
||||
Route::middleware(EnsureCheckoutOpen::class)->group(function () {
|
||||
Route::get('/warenkorb', [CartController::class, 'show'])->name('cart');
|
||||
Route::post('/warenkorb/{offer}', [CartController::class, 'add'])->name('cart.add');
|
||||
Route::post('/warenkorb/{offer}/jetzt-kaufen', [CartController::class, 'buy'])->name('cart.buy');
|
||||
Route::post('/warenkorb/{offer}/wechseln', [CartController::class, 'switch'])->name('cart.switch');
|
||||
Route::post('/warenkorb/{offer}/entfernen', [CartController::class, 'remove'])->name('cart.remove');
|
||||
Route::post('/warenkorb/{offer}/uebernehmen', [CartController::class, 'accept'])->name('cart.accept');
|
||||
@@ -54,6 +62,10 @@
|
||||
});
|
||||
});
|
||||
|
||||
// Die frühere Angebotsseite der Website ist der Shop. Solange er nicht sichtbar ist, bleibt eine noch vorhandene CMS-Seite
|
||||
// unter dieser Adresse erreichbar (die Redaktion entfernt sie in der Webpräsenz).
|
||||
Route::get('/angebote', [PageController::class, 'offers'])->name('public.offers');
|
||||
|
||||
Route::post('/stripe/webhook', StripeWebhookController::class)->name('stripe.webhook');
|
||||
|
||||
Route::middleware('guest')->group(function () {
|
||||
@@ -176,7 +188,6 @@
|
||||
Route::get('/berechtigungen/{grant}', [LibraryController::class, 'grant'])->whereNumber('grant')->name('grant');
|
||||
Route::get('/angebote', [CheckoutController::class, 'offers'])->name('offers');
|
||||
Route::post('/angebote/{offer}/abrufen', [CheckoutController::class, 'claim'])->name('offers.claim');
|
||||
Route::post('/angebote/{offer}/kaufen', [CheckoutController::class, 'place'])->name('offers.buy');
|
||||
Route::get('/bestellung/{order}', [CheckoutController::class, 'show'])->name('order');
|
||||
Route::post('/bestellung/{order}/bezahlen', [CheckoutController::class, 'pay'])->name('order.pay');
|
||||
Route::post('/bestellung/{order}/bestaetigen', [CheckoutController::class, 'confirm'])->name('order.confirm');
|
||||
|
||||
@@ -0,0 +1,372 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle;
|
||||
use App\Filament\Resources\Offers\Pages\ViewOffer;
|
||||
use App\Filament\Support\PublicationReadiness;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
use Tests\Support\BuildsShop;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Optionen am Lizenzartikel: Der Artikel wird direkt in seiner Maske verkauft (Rechteprofil, Preis, Nutzerkreis,
|
||||
* Eignung), mehrere Optionen je Artikel sind möglich, und eine fehlgeschlagene Prüfung hinterlässt kein leeres Angebot.
|
||||
*/
|
||||
class ArticleOptionsTest extends TestCase
|
||||
{
|
||||
use BuildsShop;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->seedShop();
|
||||
}
|
||||
|
||||
private function keeper(): User
|
||||
{
|
||||
$keeper = User::factory()->katalogverwalter()->create();
|
||||
$keeper->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
return $keeper;
|
||||
}
|
||||
|
||||
/** Ein Artikel mit veröffentlichtem Stand, aber ohne Angebot. */
|
||||
private function freshArticle(string $code = 'neu-optionen'): LicenseArticle
|
||||
{
|
||||
$article = app(ArticleService::class)->create($code);
|
||||
app(ArticleService::class)->publishRelease($article, $this->article('shop-grenzen')->currentRelease->rootCompositionVersion, 'Erster Stand dieses Lizenzartikels.');
|
||||
|
||||
return $article->fresh();
|
||||
}
|
||||
|
||||
private function privateRights(): RightsProfileVersion
|
||||
{
|
||||
return RightsProfileVersion::query()->whereHas('profile', fn ($query) => $query->where('name', 'Privatlizenz ehrenamtlich'))->firstOrFail();
|
||||
}
|
||||
|
||||
private function clubRights(): RightsProfileVersion
|
||||
{
|
||||
return RightsProfileVersion::query()->whereHas('profile', fn ($query) => $query->where('name', 'Vereinslizenz institutionell'))->firstOrFail();
|
||||
}
|
||||
|
||||
private function page(LicenseArticle $article)
|
||||
{
|
||||
return Livewire::actingAs($this->keeper(), 'staff')->test(ViewLicenseArticle::class, ['record' => $article->getKey()]);
|
||||
}
|
||||
|
||||
public function test_the_dialog_asks_only_for_rights_price_scope_suitability_and_label(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
|
||||
$component = $this->page($article)->mountAction('option');
|
||||
$page = $component->instance();
|
||||
$schema = (new \ReflectionMethod($page, 'getMountedActionSchema'))->invoke($page);
|
||||
$labels = collect($schema->getFlatComponents())
|
||||
->map(fn ($field): ?string => method_exists($field, 'getLabel') ? (string) $field->getLabel() : null)
|
||||
->filter()
|
||||
->values()
|
||||
->all();
|
||||
|
||||
foreach (['Rechteprofil', 'Preis in Euro', 'Geeignet für', 'Nutzerkreis', 'Bezeichnung der Option'] as $label) {
|
||||
$this->assertContains($label, $labels);
|
||||
}
|
||||
|
||||
foreach (['Artikel', 'Ziel', 'Positionen', 'Paketfassung', 'Programmfassung, die abgedeckt sein muss', 'Vergabe'] as $label) {
|
||||
$this->assertNotContains($label, $labels, 'Der Artikel steht fest, es gibt keine Auswahl von Artikel, Inhalt oder Vergabe.');
|
||||
}
|
||||
|
||||
$data = $component->get('mountedActions.0.data');
|
||||
$this->assertSame('person', $data['holder_kind']);
|
||||
$this->assertSame('einzel', $data['licence_scope']);
|
||||
}
|
||||
|
||||
public function test_an_article_gets_two_options_that_share_its_product_page_and_are_alternatives_in_the_cart(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
|
||||
$this->page($article)
|
||||
->mountAction('option')
|
||||
->fillForm(['rights_id' => $this->privateRights()->id, 'price_euro' => '39,00', 'holder_kind' => 'person', 'licence_scope' => 'einzel', 'option_label' => ''])
|
||||
->callMountedAction()
|
||||
->assertHasNoActionErrors();
|
||||
|
||||
$this->page($article)
|
||||
->mountAction('option')
|
||||
->fillForm(['rights_id' => $this->clubRights()->id, 'price_euro' => '149,00', 'holder_kind' => 'organisation', 'licence_scope' => 'mehrfach', 'trainer_count' => 8, 'option_label' => 'Vereinslizenz'])
|
||||
->callMountedAction()
|
||||
->assertHasNoActionErrors();
|
||||
|
||||
$offers = app(ProductOptions::class)->offersOfArticle($article);
|
||||
$this->assertCount(2, $offers);
|
||||
[$private, $club] = $offers;
|
||||
$this->assertSame('Einzellizenz für Privatpersonen', $private->optionName(), 'Ohne Eingabe gilt der Vorschlag aus Nutzerkreis und Eignung.');
|
||||
$this->assertSame('Vereinslizenz', $club->optionName());
|
||||
$this->assertStringStartsWith(app(ProductOptions::class)->articleTitle($article).': ', $private->name);
|
||||
|
||||
$privateVersion = $private->versions()->firstOrFail();
|
||||
$this->assertSame(OfferStatus::Aktiv, $privateVersion->status);
|
||||
$this->assertSame(3900, $privateVersion->price_cents);
|
||||
$this->assertSame('kauf', $privateVersion->grant_kind);
|
||||
$this->assertSame('einzel', $privateVersion->licence_scope);
|
||||
$clubVersion = $club->versions()->firstOrFail();
|
||||
$this->assertSame(14900, $clubVersion->price_cents);
|
||||
$this->assertSame('organisation', $clubVersion->holder_kind);
|
||||
$this->assertSame(8, $clubVersion->trainer_count);
|
||||
|
||||
$this->get('/shop/'.$article->id)
|
||||
->assertOk()
|
||||
->assertSee('Einzellizenz für Privatpersonen')
|
||||
->assertSee('39,00')
|
||||
->assertSee('Vereinslizenz')
|
||||
->assertSee('149,00');
|
||||
$this->get('/shop')->assertOk()->assertSee('/shop/'.$article->id, false);
|
||||
|
||||
$cart = app(Cart::class);
|
||||
$this->assertSame(Cart::ADDED, $cart->add($private));
|
||||
$this->assertSame(Cart::ALTERNATIVE, $cart->add($club), 'Zwei Optionen desselben Artikels sind Alternativen im Warenkorb.');
|
||||
$this->assertSame(1, $cart->count());
|
||||
}
|
||||
|
||||
public function test_the_article_page_lists_its_options_with_price_rights_and_state(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$this->page($article)->assertSee('Im Shop verkaufen')->assertSee('Noch keine Option')->assertSee('Option hinzufügen');
|
||||
|
||||
app(OfferService::class)->offerArticle($article, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'einzel', 'trainer_count' => 1, 'price_cents' => 3900], 'Neu: Privat', 'Privatlizenz');
|
||||
|
||||
$this->page($article)
|
||||
->assertSee('Privatlizenz')
|
||||
->assertSee('39,00 €')
|
||||
->assertSee('Einzellizenz · 1 Trainer')
|
||||
->assertSee('Rechte: Privatlizenz ehrenamtlich')
|
||||
->assertSee('Im Shop')
|
||||
->assertSee('Produktseite ansehen')
|
||||
->assertSee('Aus dem Verkauf nehmen')
|
||||
->assertDontSee('Noch keine Option');
|
||||
}
|
||||
|
||||
public function test_an_article_without_stand_cannot_be_offered_and_the_page_says_so(): void
|
||||
{
|
||||
$article = app(ArticleService::class)->create('neu-ohne-stand-optionen');
|
||||
|
||||
$this->page($article)
|
||||
->assertSee('Zuerst den Inhalt festlegen')
|
||||
->assertDontSee('Noch keine Option');
|
||||
|
||||
$before = Offer::query()->count();
|
||||
$this->page($article)
|
||||
->mountAction('option')
|
||||
->fillForm(['rights_id' => $this->privateRights()->id, 'price_euro' => '39,00', 'holder_kind' => 'person', 'licence_scope' => 'einzel'])
|
||||
->callMountedAction();
|
||||
|
||||
$this->assertSame($before, Offer::query()->count(), 'Ein Artikel ohne Stand hinterlässt kein Angebot.');
|
||||
}
|
||||
|
||||
public function test_a_failed_check_leaves_no_empty_offer_behind(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$before = Offer::query()->count();
|
||||
|
||||
foreach (['0,00', '-3', 'abc'] as $price) {
|
||||
$this->page($article)
|
||||
->mountAction('option')
|
||||
->fillForm(['rights_id' => $this->privateRights()->id, 'price_euro' => $price, 'holder_kind' => 'person', 'licence_scope' => 'einzel'])
|
||||
->callMountedAction();
|
||||
}
|
||||
|
||||
$this->assertSame($before, Offer::query()->count(), 'Ein Kauf ohne Preis über 0,00 € legt kein Angebot an.');
|
||||
|
||||
$service = app(OfferService::class);
|
||||
|
||||
try {
|
||||
$service->offerArticle($article, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'mehrfach', 'trainer_count' => 1, 'price_cents' => 3900], 'Neu: Fehler');
|
||||
$this->fail('Eine Mehrfachlizenz mit einem Trainer wird abgelehnt.');
|
||||
} catch (DomainRuleException) {
|
||||
$this->assertSame($before, Offer::query()->count());
|
||||
}
|
||||
|
||||
$withoutStand = app(ArticleService::class)->create('neu-ohne-stand-dienst');
|
||||
|
||||
try {
|
||||
$service->offerArticle($withoutStand, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'einzel', 'trainer_count' => 1, 'price_cents' => 3900], 'Neu: Ohne Stand');
|
||||
$this->fail('Ein Artikel ohne Stand lässt sich nicht verkaufen.');
|
||||
} catch (DomainRuleException) {
|
||||
$this->assertSame($before, Offer::query()->count());
|
||||
}
|
||||
}
|
||||
|
||||
public function test_changing_an_option_activates_the_next_version_and_keeps_the_others(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$service = app(OfferService::class);
|
||||
$service->offerArticle($article, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'einzel', 'trainer_count' => 1, 'price_cents' => 3900], 'Neu: Privat', 'Privatlizenz');
|
||||
$service->offerArticle($article, $this->clubRights(), ['holder_kind' => 'organisation', 'licence_scope' => 'mehrfach', 'trainer_count' => 5, 'price_cents' => 14900], 'Neu: Verein', 'Vereinslizenz');
|
||||
[$private, $club] = app(ProductOptions::class)->offersOfArticle($article);
|
||||
|
||||
$component = $this->page($article)->mountAction('option', ['offer' => $private->id]);
|
||||
$data = $component->get('mountedActions.0.data');
|
||||
$this->assertSame('39,00', $data['price_euro'], 'Die Maske ist mit der letzten Fassung vorbelegt, der Preis steht in Euro.');
|
||||
$this->assertSame('Privatlizenz', $data['option_label']);
|
||||
$this->assertSame($this->privateRights()->id, (int) $data['rights_id']);
|
||||
|
||||
$component->fillForm(['price_euro' => '29,00'])->callMountedAction()->assertHasNoActionErrors();
|
||||
|
||||
$versions = $private->versions()->orderBy('number')->get();
|
||||
$this->assertCount(2, $versions);
|
||||
$this->assertSame(OfferStatus::Beendet, $versions[0]->status);
|
||||
$this->assertSame(3900, $versions[0]->price_cents, 'Die frühere Fassung bleibt unverändert gespeichert.');
|
||||
$this->assertSame(OfferStatus::Aktiv, $versions[1]->status);
|
||||
$this->assertSame(2900, $versions[1]->price_cents);
|
||||
$this->assertSame(1, $club->versions()->count(), 'Die andere Option bleibt unberührt.');
|
||||
$this->assertSame(14900, $club->versions()->firstOrFail()->price_cents);
|
||||
}
|
||||
|
||||
public function test_cancelling_the_dialog_changes_nothing(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
app(OfferService::class)->offerArticle($article, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'einzel', 'trainer_count' => 1, 'price_cents' => 3900], 'Neu: Privat', 'Privatlizenz');
|
||||
[$offer] = app(ProductOptions::class)->offersOfArticle($article);
|
||||
|
||||
$this->page($article)
|
||||
->mountAction('option', ['offer' => $offer->id])
|
||||
->fillForm(['price_euro' => '1,00', 'option_label' => 'Geändert'])
|
||||
->unmountAction();
|
||||
|
||||
$this->assertSame(1, $offer->versions()->count());
|
||||
$this->assertSame(3900, $offer->versions()->firstOrFail()->price_cents);
|
||||
$this->assertSame('Privatlizenz', $offer->fresh()->option_label);
|
||||
}
|
||||
|
||||
public function test_ending_one_option_leaves_the_other_purchasable_and_it_can_be_offered_again(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$service = app(OfferService::class);
|
||||
$service->offerArticle($article, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'einzel', 'trainer_count' => 1, 'price_cents' => 3900], 'Neu: Privat', 'Privatlizenz');
|
||||
$service->offerArticle($article, $this->clubRights(), ['holder_kind' => 'organisation', 'licence_scope' => 'mehrfach', 'trainer_count' => 5, 'price_cents' => 14900], 'Neu: Verein', 'Vereinslizenz');
|
||||
[$private, $club] = app(ProductOptions::class)->offersOfArticle($article);
|
||||
|
||||
$this->page($article)->mountAction('optionEnd', ['offer' => $private->id])->callMountedAction();
|
||||
|
||||
$this->assertNull($service->purchasableVersion($private->fresh()));
|
||||
$this->assertNotNull($service->purchasableVersion($club->fresh()));
|
||||
$this->get('/shop/'.$article->id)->assertOk()->assertDontSee('Privatlizenz')->assertSee('Vereinslizenz');
|
||||
|
||||
$this->page($article)
|
||||
->assertSee('Nicht im Verkauf')
|
||||
->assertSee('Wieder anbieten')
|
||||
->mountAction('option', ['offer' => $private->id])
|
||||
->callMountedAction()
|
||||
->assertHasNoActionErrors();
|
||||
|
||||
$this->assertNotNull($service->purchasableVersion($private->fresh()));
|
||||
$this->assertSame(2, $private->versions()->count());
|
||||
|
||||
$this->page($article)->mountAction('optionEnd', ['offer' => $private->id])->callMountedAction();
|
||||
$this->page($article)->mountAction('optionEnd', ['offer' => $club->id])->callMountedAction();
|
||||
$this->get('/shop/'.$article->id)->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_an_option_of_another_article_cannot_be_opened_or_changed(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$foreign = $this->privateKonflikte();
|
||||
|
||||
$this->page($article)->call('mountAction', 'option', ['offer' => $foreign->id])->assertStatus(404);
|
||||
$this->page($article)->call('mountAction', 'optionEnd', ['offer' => $foreign->id])->assertStatus(404);
|
||||
$this->assertSame(1, $foreign->versions()->count());
|
||||
$this->assertNotNull(app(OfferService::class)->purchasableVersion($foreign->fresh()), 'Eine fremde Option lässt sich weder öffnen noch beenden.');
|
||||
|
||||
try {
|
||||
app(OfferService::class)->reviseArticleOption($foreign, $article, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'einzel', 'trainer_count' => 1, 'price_cents' => 100]);
|
||||
$this->fail('Der Dienst lehnt eine Option eines anderen Artikels ab.');
|
||||
} catch (DomainRuleException $exception) {
|
||||
$this->assertStringContainsString('gehört nicht zu diesem Lizenzartikel', $exception->getMessage());
|
||||
$this->assertSame(1, $foreign->versions()->count());
|
||||
}
|
||||
}
|
||||
|
||||
public function test_an_offer_on_demand_is_listed_but_cannot_be_changed_or_ended_as_a_shop_option(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$service = app(OfferService::class);
|
||||
$offer = $service->create('Neu: Auf Abruf');
|
||||
$service->activate($offer, [['target' => $article, 'rights' => $this->privateRights()]], ['grant_kind' => 'auf_abruf', 'holder_kind' => 'person']);
|
||||
|
||||
$component = $this->page($article)
|
||||
->assertSee('Neu: Auf Abruf')
|
||||
->assertSee('nicht im Shop')
|
||||
->assertSee('Kein Kauf im Shop')
|
||||
->assertDontSee('Wieder anbieten');
|
||||
$this->assertStringNotContainsString('offer: '.$offer->id.' }', $component->html(), 'Für eine Vergabe auf Abruf gibt es weder „Ändern“ noch „Aus dem Verkauf nehmen“.');
|
||||
|
||||
$this->page($article)->call('mountAction', 'option', ['offer' => $offer->id])->assertStatus(404);
|
||||
$this->page($article)->call('mountAction', 'optionEnd', ['offer' => $offer->id])->assertStatus(404);
|
||||
|
||||
try {
|
||||
$service->reviseArticleOption($offer, $article, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'einzel', 'trainer_count' => 1, 'price_cents' => 1000]);
|
||||
$this->fail('Eine Vergabe auf Abruf wird nicht zum Kauf umgestellt.');
|
||||
} catch (DomainRuleException $exception) {
|
||||
$this->assertStringContainsString('als Kauf angeboten', $exception->getMessage());
|
||||
}
|
||||
|
||||
$this->assertSame(1, $offer->versions()->count());
|
||||
$this->assertSame('auf_abruf', $offer->versions()->firstOrFail()->grant_kind);
|
||||
$this->assertSame(OfferStatus::Aktiv, $offer->versions()->firstOrFail()->status);
|
||||
}
|
||||
|
||||
public function test_the_dialog_neither_saves_nor_resets_open_editorial_input(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$storedTitle = $article->display_title;
|
||||
|
||||
$component = $this->page($article)->set('displayTitle', 'Noch nicht gespeichert');
|
||||
$component
|
||||
->mountAction('option')
|
||||
->fillForm(['rights_id' => $this->privateRights()->id, 'price_euro' => '39,00', 'holder_kind' => 'person', 'licence_scope' => 'einzel'])
|
||||
->callMountedAction()
|
||||
->assertHasNoActionErrors();
|
||||
|
||||
$component->assertSet('displayTitle', 'Noch nicht gespeichert');
|
||||
$this->assertSame($storedTitle, $article->fresh()->display_title, 'Die Option speichert die Redaktion nicht mit.');
|
||||
$this->assertCount(1, app(ProductOptions::class)->offersOfArticle($article));
|
||||
}
|
||||
|
||||
public function test_the_next_step_on_the_article_opens_the_option_dialog(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$steps = collect(app(PublicationReadiness::class)->forArticle($article)['schritte']);
|
||||
$step = $steps->firstWhere('titel', 'Im Shop verkaufen');
|
||||
|
||||
$this->assertNotNull($step);
|
||||
$this->assertSame("mountAction('option')", $step['aktion']['wire']);
|
||||
}
|
||||
|
||||
public function test_the_offer_dialog_no_longer_asks_for_a_program_version_to_cover(): void
|
||||
{
|
||||
$component = Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewOffer::class, ['record' => $this->privateKonflikte()->getKey()])
|
||||
->mountAction('activate');
|
||||
$page = $component->instance();
|
||||
$schema = (new \ReflectionMethod($page, 'getMountedActionSchema'))->invoke($page);
|
||||
$labels = collect($schema->getFlatComponents())
|
||||
->map(fn ($field): ?string => method_exists($field, 'getLabel') ? (string) $field->getLabel() : null)
|
||||
->filter()
|
||||
->all();
|
||||
|
||||
$this->assertNotContains('Programmfassung, die abgedeckt sein muss', $labels);
|
||||
$this->assertContains('Positionen', $labels, 'Pakete und der Altbestand behalten die Positionen.');
|
||||
}
|
||||
}
|
||||
@@ -333,9 +333,30 @@ public function test_the_features_row_takes_alignment_symbol_size_and_divider_fr
|
||||
$this->assertStringNotContainsString('lf-features--lines', $right);
|
||||
}
|
||||
|
||||
public function test_the_features_row_places_the_symbol_above_or_beside_the_text(): void
|
||||
{
|
||||
$items = [['symbol' => 'buch', 'title' => 'Eins', 'text' => 'Satz', 'url' => '/materialien'], ['symbol' => 'gruppe', 'title' => 'Zwei', 'text' => null]];
|
||||
|
||||
$above = $this->publish('/merkmale-lage-oben', $this->widget('features', ['items' => $items], ['symbol_position' => 'top']));
|
||||
$this->assertStringContainsString('class="lf-features lf-features--2 lf-features--left lf-features--size-medium"', $above, 'Über dem Text ist die Vorgabe und setzt keine eigene Klasse.');
|
||||
$this->assertStringNotContainsString('lf-features--symbol-', $above);
|
||||
|
||||
$left = $this->publish('/merkmale-lage-links', $this->widget('features', ['items' => $items], ['symbol_position' => 'left']));
|
||||
$this->assertStringContainsString('class="lf-features lf-features--2 lf-features--left lf-features--size-medium lf-features--symbol-left"', $left);
|
||||
|
||||
$right = $this->publish('/merkmale-lage-rechts', $this->widget('features', ['items' => $items], ['symbol_position' => 'right', 'align' => 'right']));
|
||||
$this->assertStringContainsString('class="lf-features lf-features--2 lf-features--right lf-features--size-medium lf-features--symbol-right"', $right);
|
||||
|
||||
// Titel, Satz und Link stehen zusammen in einer Spalte neben dem Symbol; das Symbol bleibt vor dem Text im Quelltext.
|
||||
foreach ([$left, $right] as $html) {
|
||||
$this->assertSame(2, substr_count($html, 'class="lf-features__body"'));
|
||||
$this->assertMatchesRegularExpression('~<svg[^>]*lf-features__symbol[^>]*>.*?</svg>\s*<div class="lf-features__body">\s*<p class="lf-features__title">Eins</p>\s*<p class="lf-features__text">Satz</p>\s*<p class="lf-features__more">~s', $html);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_unknown_layout_values_of_the_features_row_are_rejected_and_fall_back_to_the_defaults(): void
|
||||
{
|
||||
foreach ([['align' => 'justify'], ['symbol_size' => 'huge'], ['divider' => 'double']] as $index => $settings) {
|
||||
foreach ([['align' => 'justify'], ['symbol_size' => 'huge'], ['symbol_position' => 'bottom'], ['divider' => 'double']] as $index => $settings) {
|
||||
try {
|
||||
$this->publish('/merkmale-layout-falsch-'.$index, $this->widget('features', ['items' => [['symbol' => 'buch', 'title' => 'Eins', 'text' => null], ['symbol' => 'buch', 'title' => 'Zwei', 'text' => null]]], $settings));
|
||||
$this->fail('Angenommen: '.json_encode($settings));
|
||||
@@ -345,8 +366,8 @@ public function test_unknown_layout_values_of_the_features_row_are_rejected_and_
|
||||
}
|
||||
|
||||
// Schon gespeicherte, später ungültig gewordene Werte dürfen die Ausgabe nicht brechen.
|
||||
$this->assertSame(['align' => 'left', 'size' => 'medium', 'divider' => false], FeaturesWidget::layout(['align' => ['x'], 'symbol_size' => 'huge', 'divider' => 'double']));
|
||||
$this->assertSame(['align' => 'right', 'size' => 'large', 'divider' => true], FeaturesWidget::layout(['align' => 'right', 'symbol_size' => 'large', 'divider' => 'line']));
|
||||
$this->assertSame(['align' => 'left', 'size' => 'medium', 'position' => 'top', 'divider' => false], FeaturesWidget::layout(['align' => ['x'], 'symbol_size' => 'huge', 'symbol_position' => ['x'], 'divider' => 'double']));
|
||||
$this->assertSame(['align' => 'right', 'size' => 'large', 'position' => 'left', 'divider' => true], FeaturesWidget::layout(['align' => 'right', 'symbol_size' => 'large', 'symbol_position' => 'left', 'divider' => 'line']));
|
||||
}
|
||||
|
||||
public function test_the_features_row_fits_every_slot_width(): void
|
||||
|
||||
@@ -65,7 +65,7 @@ public function test_legacy_page_survives_a_round_trip_through_the_editor(): voi
|
||||
}
|
||||
}
|
||||
|
||||
private const LEGACY_PAGES = ['/' => 'home', '/praevention' => 'praevention', '/materialien' => 'materialien', '/angebote' => 'angebote', '/trainer' => 'trainer', '/ueber' => 'ueber', '/impressum' => 'impressum', '/datenschutz' => 'datenschutz'];
|
||||
private const LEGACY_PAGES = ['/' => 'home', '/praevention' => 'praevention', '/materialien' => 'materialien', '/trainer' => 'trainer', '/ueber' => 'ueber', '/impressum' => 'impressum', '/datenschutz' => 'datenschutz'];
|
||||
|
||||
/**
|
||||
* Auf Test und Produktion liegen die Seiten im flachen Format vor der Registry. Die Migration ruft den
|
||||
|
||||
@@ -20,10 +20,12 @@
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\Support\PlacesOrders;
|
||||
use Tests\TestCase;
|
||||
|
||||
class MembershipAccessTest extends TestCase
|
||||
{
|
||||
use PlacesOrders;
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_a_free_offer_is_claimed_once_per_member(): void
|
||||
@@ -77,14 +79,14 @@ public function test_test_payment_grants_once_and_a_failure_grants_nothing(): vo
|
||||
[$article, $offer] = $this->paidOffer();
|
||||
$member = User::factory()->create();
|
||||
$checkout = app(Checkout::class);
|
||||
$order = $checkout->place($member, $offer);
|
||||
$order = $this->orderOf($member, [$offer]);
|
||||
$second = $this->orderOf($member, [$offer]);
|
||||
$checkout->confirmTestPayment($order, 'test-1');
|
||||
$checkout->confirmTestPayment($order->fresh(), 'test-2');
|
||||
|
||||
$this->assertSame(1, Grant::query()->where('license_article_id', $article->id)->count());
|
||||
Mail::assertSent(OrderConfirmed::class, 1);
|
||||
|
||||
$second = $checkout->place($member, $offer);
|
||||
$checkout->failTestPayment($second, 'test-fail-1');
|
||||
|
||||
$this->assertSame('fehlgeschlagen', $second->fresh()->status);
|
||||
@@ -131,7 +133,7 @@ public function test_refund_revokes_the_grant(): void
|
||||
[, $offer] = $this->paidOffer();
|
||||
$member = User::factory()->create();
|
||||
$checkout = app(Checkout::class);
|
||||
$order = $checkout->place($member, $offer);
|
||||
$order = $this->orderOf($member, [$offer]);
|
||||
$checkout->confirmTestPayment($order, 'test-refund');
|
||||
$checkout->refund($order->fresh(), 'Testwiderruf');
|
||||
|
||||
|
||||
@@ -0,0 +1,391 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferRelease;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Commerce\Checkout;
|
||||
use App\Domain\Entitlement\Acquisition;
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Domain\Entitlement\GrantStatus;
|
||||
use App\Domain\Entitlement\NewStands;
|
||||
use App\Domain\Entitlement\OfferAccess;
|
||||
use App\Filament\Resources\Offers\Pages\ViewOffer;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
use Tests\Support\BuildsShop;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Regeln für freie Artikel (ADR-56): Wer ein Angebot „auf Abruf“ übernehmen darf (alle, freigeschaltete Konten, wer einen
|
||||
* Artikel besitzt), serverseitig beim Abruf geprüft; Freigaben je Angebot und Konto, nie gelöscht; „Neu für dich“.
|
||||
*/
|
||||
class OfferClaimRulesTest extends TestCase
|
||||
{
|
||||
use BuildsShop;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||
$this->seedShop();
|
||||
}
|
||||
|
||||
private function access(): OfferAccess
|
||||
{
|
||||
return app(OfferAccess::class);
|
||||
}
|
||||
|
||||
private function rights(): RightsProfileVersion
|
||||
{
|
||||
return RightsProfileVersion::query()->whereHas('profile', fn ($query) => $query->where('name', 'Privatlizenz ehrenamtlich'))->firstOrFail();
|
||||
}
|
||||
|
||||
/** Ein freies Angebot auf Abruf mit eigenem Artikel. */
|
||||
private function freeOffer(string $name = 'Gratis zum Start', string $kind = 'auf_abruf'): Offer
|
||||
{
|
||||
$article = app(ArticleService::class)->create('gratis-'.str($name)->slug());
|
||||
app(ArticleService::class)->publishRelease($article, $this->article('shop-grenzen')->currentRelease->rootCompositionVersion, 'Erster Stand.');
|
||||
$service = app(OfferService::class);
|
||||
$offer = $service->create($name);
|
||||
$service->activate($offer, [['target' => $article->fresh(), 'rights' => $this->rights()]], ['grant_kind' => $kind, 'holder_kind' => 'person']);
|
||||
|
||||
return $offer->fresh();
|
||||
}
|
||||
|
||||
private function keeper(): User
|
||||
{
|
||||
$keeper = User::factory()->katalogverwalter()->create();
|
||||
$keeper->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
return $keeper;
|
||||
}
|
||||
|
||||
private function userWithoutProfile(): User
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$user->forceFill(['party_id' => null])->save();
|
||||
|
||||
return $user->fresh();
|
||||
}
|
||||
|
||||
private function claim(User $user, Offer $offer)
|
||||
{
|
||||
return $this->actingAs($user)->post(route('member.offers.claim', $offer));
|
||||
}
|
||||
|
||||
private function taken(User $user): int
|
||||
{
|
||||
return Acquisition::query()->where('party_id', $user->party_id)->count();
|
||||
}
|
||||
|
||||
// ---- Regel „alle“ -------------------------------------------------------------------------------------------------
|
||||
|
||||
public function test_by_default_every_member_sees_and_claims_a_free_offer_exactly_once(): void
|
||||
{
|
||||
$offer = $this->freeOffer();
|
||||
$tina = $this->tina();
|
||||
|
||||
$this->assertSame('alle', $offer->claim_access);
|
||||
$this->assertTrue($this->access()->mayClaim($tina, $offer));
|
||||
$this->actingAs($tina)->get(route('member.offers'))->assertOk()->assertSee('Gratis zum Start');
|
||||
|
||||
$this->claim($tina, $offer)->assertRedirect(route('member.library'));
|
||||
$this->claim($tina, $offer)->assertRedirect();
|
||||
$this->assertSame(1, $this->taken($tina), 'Ein zweiter Abruf legt nichts doppelt an.');
|
||||
$this->actingAs($tina)->get(route('member.offers'))->assertOk()->assertDontSee('In die Bibliothek');
|
||||
}
|
||||
|
||||
// ---- Regel „nur freigeschaltete Konten“ --------------------------------------------------------------------------
|
||||
|
||||
public function test_a_released_only_offer_is_hidden_and_refused_for_everyone_else_on_the_server(): void
|
||||
{
|
||||
$offer = $this->freeOffer();
|
||||
$this->access()->setRule($offer, OfferAccess::RELEASED);
|
||||
$tina = $this->tina();
|
||||
$max = $this->max();
|
||||
$this->access()->release($offer->fresh(), $tina, $this->keeper());
|
||||
|
||||
$this->actingAs($tina)->get(route('member.offers'))->assertOk()->assertSee('Gratis zum Start');
|
||||
$this->actingAs($max)->get(route('member.offers'))->assertOk()->assertDontSee('Gratis zum Start');
|
||||
|
||||
$this->claim($max, $offer)->assertRedirect()->assertSessionHasErrors('offer');
|
||||
$this->assertSame(0, $this->taken($max), 'Ein nicht freigeschaltetes Konto bekommt nichts, auch mit der Adresse.');
|
||||
$this->claim($tina, $offer)->assertRedirect(route('member.library'));
|
||||
$this->assertSame(1, $this->taken($tina));
|
||||
}
|
||||
|
||||
public function test_a_release_counts_only_for_its_own_offer_and_account(): void
|
||||
{
|
||||
$first = $this->freeOffer('Erstes Angebot');
|
||||
$second = $this->freeOffer('Zweites Angebot');
|
||||
$this->access()->setRule($first, OfferAccess::RELEASED);
|
||||
$this->access()->setRule($second, OfferAccess::RELEASED);
|
||||
$this->access()->release($first->fresh(), $this->tina(), $this->keeper());
|
||||
|
||||
$this->assertTrue($this->access()->mayClaim($this->tina(), $first->fresh()));
|
||||
$this->assertFalse($this->access()->mayClaim($this->tina(), $second->fresh()));
|
||||
$this->assertFalse($this->access()->mayClaim($this->max(), $first->fresh()));
|
||||
}
|
||||
|
||||
public function test_a_revoked_or_expired_release_no_longer_allows_the_claim_but_keeps_what_was_taken(): void
|
||||
{
|
||||
$offer = $this->freeOffer();
|
||||
$this->access()->setRule($offer, OfferAccess::RELEASED);
|
||||
$keeper = $this->keeper();
|
||||
$tina = $this->tina();
|
||||
$max = $this->max();
|
||||
$releaseTina = $this->access()->release($offer->fresh(), $tina, $keeper, now()->addDays(2));
|
||||
$releaseMax = $this->access()->release($offer->fresh(), $max, $keeper);
|
||||
$this->claim($max, $offer)->assertRedirect(route('member.library'));
|
||||
|
||||
$this->access()->revoke($releaseMax, $keeper, 'Irrtum');
|
||||
$this->assertSame(1, $this->taken($max), 'Ein bereits übernommenes Angebot bleibt nach dem Entzug.');
|
||||
$this->assertNotNull(OfferRelease::query()->find($releaseMax->id)->revoked_at, 'Die Freigabe bleibt mit dem Entzug gespeichert.');
|
||||
|
||||
$this->travel(3)->days();
|
||||
$this->assertFalse($this->access()->mayClaim($tina, $offer->fresh()), 'Nach dem Ende der Freigabe ist der Abruf gesperrt.');
|
||||
$this->claim($tina, $offer)->assertRedirect()->assertSessionHasErrors('offer');
|
||||
$this->assertSame(0, $this->taken($tina));
|
||||
$this->assertSame(2, OfferRelease::query()->count(), 'Freigaben werden nie gelöscht.');
|
||||
$this->assertNotNull($releaseTina->fresh());
|
||||
}
|
||||
|
||||
public function test_releases_are_validated(): void
|
||||
{
|
||||
$offer = $this->freeOffer();
|
||||
$keeper = $this->keeper();
|
||||
|
||||
try {
|
||||
$this->access()->release($offer, $this->tina(), $keeper);
|
||||
$this->fail('Bei der Regel „alle“ gibt es keine Freigaben.');
|
||||
} catch (DomainRuleException $exception) {
|
||||
$this->assertStringContainsString('nur freigeschaltete Konten', $exception->getMessage());
|
||||
}
|
||||
|
||||
$this->access()->setRule($offer, OfferAccess::RELEASED);
|
||||
$offer = $offer->fresh();
|
||||
$this->access()->release($offer, $this->tina(), $keeper);
|
||||
|
||||
foreach ([
|
||||
'doppelt' => fn () => $this->access()->release($offer, $this->tina(), $keeper),
|
||||
'Vergangenheit' => fn () => $this->access()->release($offer, $this->max(), $keeper, now()->subDay()),
|
||||
'ohne Profil' => fn () => $this->access()->release($offer, $this->userWithoutProfile(), $keeper),
|
||||
] as $name => $attempt) {
|
||||
try {
|
||||
$attempt();
|
||||
$this->fail('Diese Freigabe muss abgelehnt werden: '.$name);
|
||||
} catch (DomainRuleException) {
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertSame(1, OfferRelease::query()->count());
|
||||
}
|
||||
|
||||
// ---- Regel „besitzt einen Artikel“ -------------------------------------------------------------------------------
|
||||
|
||||
private function buy(User $user, Offer $offer): void
|
||||
{
|
||||
$order = $this->orderOf($user, [$offer]);
|
||||
app(Checkout::class)->confirmTestPayment($order, 'test-'.$order->id);
|
||||
}
|
||||
|
||||
public function test_an_owner_rule_opens_the_offer_only_for_accounts_with_a_valid_grant_on_the_article(): void
|
||||
{
|
||||
$offer = $this->freeOffer();
|
||||
$article = $this->article('shop-konflikte');
|
||||
$this->access()->setRule($offer, OfferAccess::OWNERS, $article->id);
|
||||
$offer = $offer->fresh();
|
||||
$tina = $this->tina();
|
||||
|
||||
$this->assertFalse($this->access()->mayClaim($tina, $offer));
|
||||
$this->claim($tina, $offer)->assertRedirect()->assertSessionHasErrors('offer');
|
||||
$this->assertSame(0, $this->taken($tina));
|
||||
|
||||
$this->buy($tina, $this->privateKonflikte());
|
||||
$this->assertTrue($this->access()->mayClaim($tina, $offer));
|
||||
$this->actingAs($tina)->get(route('member.offers'))->assertOk()->assertSee('Gratis zum Start');
|
||||
$this->assertFalse($this->access()->mayClaim($this->max(), $offer), 'Der Besitz gilt je Konto.');
|
||||
|
||||
Grant::query()->where('license_article_id', $article->id)->update(['status' => GrantStatus::Widerrufen]);
|
||||
$this->assertFalse($this->access()->mayClaim($tina, $offer), 'Eine widerrufene Berechtigung zählt nicht als Besitz.');
|
||||
}
|
||||
|
||||
public function test_the_rule_itself_is_validated_and_clears_a_stale_article(): void
|
||||
{
|
||||
$offer = $this->freeOffer();
|
||||
$article = $this->article('shop-konflikte');
|
||||
|
||||
foreach ([['unbekannt', null], [OfferAccess::OWNERS, null], [OfferAccess::OWNERS, 999999]] as [$access, $articleId]) {
|
||||
try {
|
||||
$this->access()->setRule($offer, $access, $articleId);
|
||||
$this->fail('Diese Regel muss abgelehnt werden.');
|
||||
} catch (DomainRuleException) {
|
||||
$this->assertSame('alle', $offer->fresh()->claim_access);
|
||||
}
|
||||
}
|
||||
|
||||
$article->forceFill(['archived_at' => now()])->save();
|
||||
|
||||
try {
|
||||
$this->access()->setRule($offer, OfferAccess::OWNERS, $article->id);
|
||||
$this->fail('Ein archivierter Artikel ist keine Voraussetzung.');
|
||||
} catch (DomainRuleException) {
|
||||
$this->assertNull($offer->fresh()->claim_requires_article_id);
|
||||
}
|
||||
|
||||
$article->forceFill(['archived_at' => null])->save();
|
||||
$this->access()->setRule($offer, OfferAccess::OWNERS, $article->id);
|
||||
$this->assertSame($article->id, $offer->fresh()->claim_requires_article_id);
|
||||
$this->access()->setRule($offer->fresh(), OfferAccess::ALL, $article->id);
|
||||
$this->assertNull($offer->fresh()->claim_requires_article_id, 'Eine andere Regel löscht den Artikel.');
|
||||
}
|
||||
|
||||
// ---- Was die Regel nicht betrifft --------------------------------------------------------------------------------
|
||||
|
||||
public function test_on_registration_offers_ignore_the_rule_and_stay_listed(): void
|
||||
{
|
||||
$offer = $this->freeOffer('Zur Registrierung', 'bei_registrierung');
|
||||
$this->access()->setRule($offer, OfferAccess::RELEASED);
|
||||
$max = $this->max();
|
||||
|
||||
$this->assertTrue($this->access()->mayClaim($max, $offer->fresh()));
|
||||
$this->assertTrue($this->access()->claimable($max)->contains('id', $offer->id));
|
||||
}
|
||||
|
||||
public function test_a_purchase_offer_or_an_ended_offer_cannot_be_claimed_for_free(): void
|
||||
{
|
||||
$purchase = $this->privateKonflikte();
|
||||
$tina = $this->tina();
|
||||
|
||||
$this->assertFalse($this->access()->mayClaim($tina, $purchase));
|
||||
$this->claim($tina, $purchase)->assertRedirect()->assertSessionHasErrors('offer');
|
||||
|
||||
$offer = $this->freeOffer();
|
||||
app(OfferService::class)->end($offer);
|
||||
$this->assertFalse($this->access()->mayClaim($tina, $offer->fresh()));
|
||||
$this->assertSame(0, $this->taken($tina));
|
||||
}
|
||||
|
||||
public function test_the_issuer_enforces_the_rule_even_without_the_page(): void
|
||||
{
|
||||
$offer = $this->freeOffer();
|
||||
$this->access()->setRule($offer, OfferAccess::RELEASED);
|
||||
|
||||
$this->expectException(DomainRuleException::class);
|
||||
app(GrantIssuer::class)->claim($this->max(), $offer->fresh());
|
||||
}
|
||||
|
||||
// ---- Verwaltung --------------------------------------------------------------------------------------------------
|
||||
|
||||
public function test_the_keeper_sets_the_rule_releases_and_revokes_on_the_offer_page(): void
|
||||
{
|
||||
$offer = $this->freeOffer();
|
||||
$tina = $this->tina();
|
||||
|
||||
$page = Livewire::actingAs($this->keeper(), 'staff')->test(ViewOffer::class, ['record' => $offer->getKey()]);
|
||||
$page->assertSee('Wer darf abrufen')->assertSee('Alle angemeldeten Mitglieder');
|
||||
$page->callAction('claimRule', ['claim_access' => OfferAccess::RELEASED, 'claim_requires_article_id' => null])->assertHasNoActionErrors();
|
||||
$this->assertSame('konten', $offer->fresh()->claim_access);
|
||||
|
||||
$page->assertSee('Freigeschaltete Konten')->callAction('release', ['user_id' => $tina->id, 'valid_until' => null, 'reason' => 'Seminar am 12.11.2026'])->assertHasNoActionErrors();
|
||||
$release = OfferRelease::query()->firstOrFail();
|
||||
$this->assertSame($tina->id, $release->user_id);
|
||||
$this->assertTrue($this->access()->mayClaim($tina, $offer->fresh()));
|
||||
$page->assertSee('Seminar am 12.11.2026');
|
||||
|
||||
$page->callAction('revoke', ['reason' => 'Irrtum'], ['release' => $release->id])->assertHasNoActionErrors();
|
||||
$this->assertNotNull($release->fresh()->revoked_at);
|
||||
$this->assertFalse($this->access()->mayClaim($tina, $offer->fresh()));
|
||||
}
|
||||
|
||||
public function test_the_rule_actions_exist_only_for_offers_on_demand_and_only_for_the_keeper(): void
|
||||
{
|
||||
$purchase = $this->privateKonflikte();
|
||||
Livewire::actingAs($this->keeper(), 'staff')->test(ViewOffer::class, ['record' => $purchase->getKey()])
|
||||
->assertDontSee('Wer darf abrufen')
|
||||
->assertActionHidden('claimRule');
|
||||
|
||||
$offer = $this->freeOffer();
|
||||
$redakteur = User::factory()->redakteur()->create();
|
||||
$redakteur->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
Livewire::actingAs($redakteur, 'staff')->test(ViewOffer::class, ['record' => $offer->getKey()])->assertForbidden();
|
||||
$this->assertSame('alle', $offer->fresh()->claim_access);
|
||||
}
|
||||
|
||||
public function test_a_release_of_another_offer_cannot_be_revoked_through_this_offer(): void
|
||||
{
|
||||
$first = $this->freeOffer('Erstes');
|
||||
$second = $this->freeOffer('Zweites');
|
||||
$this->access()->setRule($first, OfferAccess::RELEASED);
|
||||
$this->access()->setRule($second, OfferAccess::RELEASED);
|
||||
$foreign = $this->access()->release($first->fresh(), $this->tina(), $this->keeper());
|
||||
|
||||
try {
|
||||
Livewire::actingAs($this->keeper(), 'staff')->test(ViewOffer::class, ['record' => $second->getKey()])
|
||||
->callAction('revoke', ['reason' => 'x'], ['release' => $foreign->id]);
|
||||
} catch (\Throwable) {
|
||||
// Die Freigabe eines anderen Angebots wird nicht gefunden.
|
||||
}
|
||||
|
||||
$this->assertNull($foreign->fresh()->revoked_at);
|
||||
}
|
||||
|
||||
// ---- Neu für dich ------------------------------------------------------------------------------------------------
|
||||
|
||||
public function test_a_new_stand_of_an_owned_article_is_listed_for_ninety_days_and_only_for_the_owner(): void
|
||||
{
|
||||
$tina = $this->tina();
|
||||
$article = $this->article('shop-konflikte');
|
||||
$this->buy($tina, $this->privateKonflikte());
|
||||
$this->assertCount(0, app(NewStands::class)->forUser($tina), 'Ohne neuen Stand gibt es nichts zu zeigen.');
|
||||
|
||||
app(ArticleService::class)->publishRelease($article, $article->fresh()->currentRelease->rootCompositionVersion, 'Neuer Stand mit Ergänzungen.');
|
||||
$list = app(NewStands::class)->forUser($tina);
|
||||
|
||||
$this->assertCount(1, $list);
|
||||
$this->assertSame(2, $list[0]['number']);
|
||||
$this->assertCount(0, app(NewStands::class)->forUser($this->max()), 'Wer den Artikel nicht besitzt, sieht keinen neuen Stand.');
|
||||
$this->actingAs($tina)->get(route('member.offers'))->assertOk()->assertSee('Neu für dich')->assertSee('Stand 2')->assertSee(route('member.grant', $list[0]['grant']), false);
|
||||
|
||||
$this->travel(91)->days();
|
||||
$this->assertCount(0, app(NewStands::class)->forUser($tina), 'Nach 90 Tagen verschwindet der Hinweis.');
|
||||
}
|
||||
|
||||
public function test_a_withdrawn_grant_shows_no_new_stand(): void
|
||||
{
|
||||
$tina = $this->tina();
|
||||
$article = $this->article('shop-konflikte');
|
||||
$this->buy($tina, $this->privateKonflikte());
|
||||
app(ArticleService::class)->publishRelease($article, $article->fresh()->currentRelease->rootCompositionVersion, 'Neuer Stand.');
|
||||
Grant::query()->where('license_article_id', $article->id)->update(['status' => GrantStatus::Widerrufen]);
|
||||
|
||||
$this->assertCount(0, app(NewStands::class)->forUser($tina));
|
||||
}
|
||||
|
||||
public function test_the_member_offers_page_shows_an_honest_empty_state(): void
|
||||
{
|
||||
$this->actingAs($this->max())->get(route('member.offers'))->assertOk()->assertSee('Gerade liegt nichts Neues für dich bereit');
|
||||
}
|
||||
|
||||
public function test_the_article_title_helper_is_the_label_in_the_rule_form(): void
|
||||
{
|
||||
$offer = $this->freeOffer();
|
||||
$this->access()->setRule($offer, OfferAccess::OWNERS, $this->article('shop-konflikte')->id);
|
||||
|
||||
Livewire::actingAs($this->keeper(), 'staff')->test(ViewOffer::class, ['record' => $offer->getKey()])
|
||||
->assertSee('Mitglieder, die einen bestimmten Artikel besitzen')
|
||||
->assertSee('Konflikte im Training');
|
||||
$this->assertInstanceOf(LicenseArticle::class, $this->article('shop-konflikte'));
|
||||
}
|
||||
}
|
||||
@@ -11,16 +11,17 @@
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Commerce\Checkout;
|
||||
use App\Domain\Entitlement\Acquisition;
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\Support\PlacesOrders;
|
||||
use Tests\TestCase;
|
||||
|
||||
class OfferVersioningTest extends TestCase
|
||||
{
|
||||
use PlacesOrders;
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_a_second_activation_leaves_one_active_version_and_keeps_the_first_intact(): void
|
||||
@@ -103,7 +104,7 @@ public function test_order_line_stores_offer_name_and_keeps_it_when_the_offer_is
|
||||
], ['grant_kind' => 'kauf', 'price_cents' => 1200]);
|
||||
|
||||
$member = User::factory()->create();
|
||||
$order = app(Checkout::class)->place($member, $offer);
|
||||
$order = $this->orderOf($member, [$offer]);
|
||||
$line = $order->lines()->first();
|
||||
|
||||
$this->assertSame('Testangebot', $line->offer_name);
|
||||
|
||||
@@ -26,7 +26,7 @@ public function test_home_page_is_published_from_the_cms(): void
|
||||
public function test_known_pages_and_sitemap_are_available(): void
|
||||
{
|
||||
$this->get('/praevention')->assertOk()->assertSee('Prävention im Alltag');
|
||||
$this->get('/angebote')->assertOk()->assertDontSee('€');
|
||||
$this->get('/angebote')->assertRedirect(route('shop'));
|
||||
$this->get('/sitemap.xml')->assertOk()->assertSee(url('/praevention'), false);
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ public function test_the_shop_stays_off_in_production_unless_released_keyed_and_
|
||||
config(['services.payment.driver' => 'stripe', 'services.stripe.secret' => 'sk_live_nur_fuer_tests']);
|
||||
|
||||
$this->assertFalse(config('shop.live_release'), 'Die Freigabe ist standardmäßig aus.');
|
||||
$this->assertFalse(Shop::enabled());
|
||||
$this->assertFalse(Shop::checkoutOpen());
|
||||
$this->assertFalse(Shop::stripe());
|
||||
|
||||
config(['shop.live_release' => true]);
|
||||
@@ -297,7 +297,7 @@ public function test_the_shop_stays_off_in_production_unless_released_keyed_and_
|
||||
}
|
||||
|
||||
$this->assertTrue(Shop::live());
|
||||
$this->assertTrue(Shop::enabled());
|
||||
$this->assertTrue(Shop::checkoutOpen());
|
||||
$this->assertTrue(Shop::stripe());
|
||||
|
||||
config(['services.stripe.secret' => 'sk_test_nur_fuer_tests']);
|
||||
@@ -404,12 +404,7 @@ public function test_in_live_mode_only_the_checkout_with_consents_creates_an_ord
|
||||
$this->assertTrue(Shop::live());
|
||||
$tina = $this->tina();
|
||||
|
||||
try {
|
||||
app(Checkout::class)->place($tina, $this->privateKonflikte());
|
||||
$this->fail('Der alte Einzelkauf kennt keine Pflichtangaben und ist im Livebetrieb gesperrt.');
|
||||
} catch (DomainRuleException) {
|
||||
$this->assertSame(0, Order::query()->count());
|
||||
}
|
||||
$this->assertFalse(method_exists(Checkout::class, 'place'), 'Der frühere Einzelkauf ohne Pflichtangaben ist entfernt.');
|
||||
|
||||
$cart = app(Cart::class);
|
||||
$cart->add($this->privateKonflikte());
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\PillarService;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use App\Domain\Commerce\ShopCatalog;
|
||||
use App\Filament\Resources\Pages\Pages\CreatePage;
|
||||
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Livewire;
|
||||
use Tests\Support\BuildsShop;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Der Shop im CMS (ADR-55): Die Seite „shop“ der Webpräsenz bestimmt den Aufbau von /shop; das Widget „Shop-Produkte“
|
||||
* zeigt die Kacheln aus derselben Datenquelle, mit Filter, Reihenfolge und Anzahl, und nichts, solange der Shop nicht
|
||||
* sichtbar ist.
|
||||
*/
|
||||
class ShopCmsTest extends TestCase
|
||||
{
|
||||
use BuildsShop;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||
$this->seedShop();
|
||||
}
|
||||
|
||||
private function editor(): User
|
||||
{
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
return $editor;
|
||||
}
|
||||
|
||||
private function widget(array $data = [], array $settings = []): array
|
||||
{
|
||||
return ['type' => 'shop_products', 'v' => 1, 'variant' => 'kacheln', 'settings' => $settings, 'data' => $data];
|
||||
}
|
||||
|
||||
private function publish(string $path, array $sections): Page
|
||||
{
|
||||
$page = Page::query()->firstOrCreate(['path' => $path]);
|
||||
$service = app(PageService::class);
|
||||
$service->publish($page, $service->saveRevision($page, $sections, null, null, null));
|
||||
|
||||
return $page->fresh();
|
||||
}
|
||||
|
||||
private function section(array $widget): array
|
||||
{
|
||||
return ['layout' => 'u4', 'style' => [], 'slots' => [$widget]];
|
||||
}
|
||||
|
||||
private function banner(string $text): array
|
||||
{
|
||||
return ['layout' => 'u4', 'style' => [], 'slots' => [['type' => 'heading', 'v' => 1, 'variant' => 'standard', 'settings' => [], 'data' => ['heading' => $text], 'refs' => []]]];
|
||||
}
|
||||
|
||||
public function test_the_widget_is_registered_with_an_honest_contract(): void
|
||||
{
|
||||
$type = app(WidgetRegistry::class)->get('shop_products');
|
||||
|
||||
$this->assertSame('Shop-Produkte', $type->label());
|
||||
$this->assertContains(4, $type->supportedUnits());
|
||||
$this->assertNotSame([], $type->schematic());
|
||||
$this->assertArrayHasKey('kacheln', $type->variants());
|
||||
}
|
||||
|
||||
public function test_the_editor_offers_the_widget_saves_its_choices_and_reopens_the_page(): void
|
||||
{
|
||||
$widget = ['type' => 'shop_products', 'data' => ['variant' => 'kacheln', 'data' => ['heading' => 'Alle Produkte', 'pillar' => null, 'kind' => null], 'settings' => ['sort' => 'preis', 'limit' => 'n6', 'search' => 'an']]];
|
||||
$slots = [(string) Str::uuid() => ['widget' => [(string) Str::uuid() => $widget]]];
|
||||
|
||||
Livewire::actingAs($this->editor(), 'staff')
|
||||
->test(CreatePage::class)
|
||||
->fillForm(['path' => '/shop', 'seo_title' => 'Shop', 'sections' => [['id' => null, 'layout' => 'u4', 'style' => [], 'slots' => $slots]]])
|
||||
->call('create')
|
||||
->assertHasNoFormErrors();
|
||||
|
||||
$page = Page::query()->where('path', '/shop')->firstOrFail();
|
||||
$saved = $page->latestRevision->sections[0]['slots'][0];
|
||||
$this->assertSame('shop_products', $saved['type']);
|
||||
$this->assertSame('kacheln', $saved['variant']);
|
||||
$this->assertSame(['sort' => 'preis', 'limit' => 'n6', 'search' => 'an'], $saved['settings']);
|
||||
|
||||
Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->getKey()])->assertOk();
|
||||
}
|
||||
|
||||
public function test_the_widget_lists_the_products_with_tiles_on_any_page(): void
|
||||
{
|
||||
$this->publish('/empfehlungen', [$this->section($this->widget(['heading' => 'Unsere Produkte']))]);
|
||||
|
||||
$this->get('/empfehlungen')->assertOk()
|
||||
->assertSee('Unsere Produkte')
|
||||
->assertSee('Konflikte im Training')
|
||||
->assertSee('Grenzen setzen im Verein')
|
||||
->assertSee('class="shop-tile"', false);
|
||||
}
|
||||
|
||||
public function test_the_shop_page_of_the_web_presence_shapes_the_shop_with_banner_and_widget(): void
|
||||
{
|
||||
$this->publish('/shop', [$this->banner('Willkommen im Shop'), $this->section($this->widget([], ['search' => 'an']))]);
|
||||
|
||||
$this->get(route('shop'))->assertOk()
|
||||
->assertSee('Willkommen im Shop')
|
||||
->assertSee('Konflikte im Training')
|
||||
->assertSee('Shop durchsuchen');
|
||||
$this->get(route('shop', ['suche' => 'Grenzen']))->assertOk()
|
||||
->assertSee(route('shop.article', $this->article('shop-grenzen')), false)
|
||||
->assertDontSee(route('shop.article', $this->article('shop-konflikte')), false);
|
||||
}
|
||||
|
||||
public function test_without_a_cms_page_the_application_default_shop_stays(): void
|
||||
{
|
||||
$this->get(route('shop'))->assertOk()->assertSee('Shop durchsuchen')->assertSee('Konflikte im Training');
|
||||
}
|
||||
|
||||
public function test_an_unpublished_shop_page_does_not_replace_the_default(): void
|
||||
{
|
||||
Page::query()->create(['path' => '/shop']);
|
||||
|
||||
$this->get(route('shop'))->assertOk()->assertSee('Shop durchsuchen');
|
||||
}
|
||||
|
||||
public function test_the_widget_hides_itself_and_the_shop_page_is_gone_while_the_shop_is_not_visible(): void
|
||||
{
|
||||
$this->publish('/shop', [$this->banner('Willkommen im Shop'), $this->section($this->widget())]);
|
||||
$this->publish('/empfehlungen', [$this->banner('Seite'), $this->section($this->widget(['heading' => 'Unsere Produkte']))]);
|
||||
$this->app['env'] = 'production';
|
||||
config(['services.payment.driver' => 'stripe', 'services.stripe.secret' => 'sk_live_nur_fuer_tests', 'shop.public' => false, 'shop.live_release' => false]);
|
||||
|
||||
$this->assertFalse(Shop::visible());
|
||||
$this->get('/shop')->assertNotFound();
|
||||
$this->get('/empfehlungen')->assertOk()->assertDontSee('Unsere Produkte')->assertDontSee('shop-tile');
|
||||
}
|
||||
|
||||
public function test_the_shop_page_is_left_out_of_the_sitemap_while_nobody_can_buy(): void
|
||||
{
|
||||
$this->publish('/shop', [$this->section($this->widget())]);
|
||||
$this->get('/sitemap.xml')->assertOk()->assertSee(url('/shop'), false);
|
||||
|
||||
$this->app['env'] = 'production';
|
||||
config(['services.payment.driver' => 'stripe', 'services.stripe.secret' => 'sk_live_nur_fuer_tests', 'shop.public' => true, 'shop.live_release' => false]);
|
||||
$this->assertTrue(Shop::visible());
|
||||
$this->get('/sitemap.xml')->assertOk()->assertDontSee(url('/shop'), false);
|
||||
}
|
||||
|
||||
public function test_the_widget_limit_setting_cuts_the_list(): void
|
||||
{
|
||||
$this->publish('/zwei-produkte', [$this->section($this->widget([], ['limit' => 'n3', 'sort' => 'name']))]);
|
||||
$this->get('/zwei-produkte')->assertOk()->assertSee('3 Produkte');
|
||||
|
||||
$widget = app(WidgetRegistry::class)->get('shop_products');
|
||||
$cards = $widget->resolve(['data' => [], 'settings' => ['limit' => 'n2']], RenderContext::publicPage())['cards'];
|
||||
$this->assertCount(2, $cards);
|
||||
}
|
||||
|
||||
public function test_the_widget_filters_by_pillar_and_kind_sorts_and_limits(): void
|
||||
{
|
||||
$service = app(PillarService::class);
|
||||
$pillar = $service->create('Grenzen und Wertschätzung');
|
||||
$service->present($pillar, 'Grenzen und Wertschätzung', 'grenzen-wertschaetzung', null, true, 10);
|
||||
$service->assign($this->article('shop-grenzen'), [$pillar->id]);
|
||||
|
||||
$this->publish('/nur-grenzen', [$this->section($this->widget(['pillar' => $pillar->id]))]);
|
||||
$this->get('/nur-grenzen')->assertOk()->assertSee('Grenzen setzen im Verein')->assertDontSee('Konflikte im Training');
|
||||
|
||||
$names = fn (array $options): array => array_column(app(ShopCatalog::class)->cards('', $options), 'title');
|
||||
$this->assertSame(['Grenzen setzen im Verein', 'Konflikte im Training', 'Starterpaket'], $names(['sort' => 'name']));
|
||||
$this->assertSame(['Grenzen setzen im Verein', 'Konflikte im Training', 'Starterpaket'], $names(['sort' => 'preis']), 'Preis aufsteigend: 29, 49, 59 Euro');
|
||||
$this->assertCount(2, $names(['limit' => 2]));
|
||||
$this->assertSame([], $names(['pillar' => 999999]));
|
||||
|
||||
$kind = EditorialContentKind::query()->where('slug', 'programm')->firstOrFail();
|
||||
$this->article('shop-konflikte')->forceFill(['editorial_content_kind_id' => $kind->id])->save();
|
||||
$this->assertSame(['Konflikte im Training'], $names(['kind' => $kind->id]));
|
||||
}
|
||||
|
||||
public function test_a_very_long_search_term_is_cut_and_never_breaks_the_page(): void
|
||||
{
|
||||
$term = str_repeat('Grenzen ', 500);
|
||||
|
||||
$this->get(route('shop', ['suche' => $term]))->assertOk();
|
||||
$this->assertSame([], app(ShopCatalog::class)->cards(str_repeat('x', 5000)));
|
||||
$this->get(route('shop', ['suche' => '<script>alert(1)</script>']))->assertOk()->assertDontSee('<script>alert(1)</script>', false);
|
||||
}
|
||||
|
||||
public function test_the_widget_cleaning_drops_unknown_pillars_and_kinds_and_reports_them(): void
|
||||
{
|
||||
$type = app(WidgetRegistry::class)->get('shop_products');
|
||||
$errors = new WidgetErrors;
|
||||
|
||||
[$data] = $type->clean(['heading' => ' Titel ', 'pillar' => 999999, 'kind' => 999999], [], $errors);
|
||||
|
||||
$this->assertSame('Titel', $data['heading']);
|
||||
$this->assertNull($data['pillar']);
|
||||
$this->assertNull($data['kind']);
|
||||
$this->assertNotEmpty($errors->all());
|
||||
}
|
||||
|
||||
public function test_the_member_offers_page_shows_the_newest_products_as_tiles_below_the_free_offers(): void
|
||||
{
|
||||
$this->actingAs($this->tina())->get(route('member.offers'))->assertOk()
|
||||
->assertSee('Im Shop')
|
||||
->assertSee('class="shop-tile"', false)
|
||||
->assertSee('Konflikte im Training')
|
||||
->assertSee(route('shop'), false);
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public function test_free_and_unpriced_offers_are_not_shown_as_purchasable(): vo
|
||||
|
||||
public function test_the_shop_exists_only_with_test_payment_and_never_in_production(): void
|
||||
{
|
||||
$this->assertTrue(Shop::enabled());
|
||||
$this->assertTrue(Shop::checkoutOpen());
|
||||
|
||||
// Ein nicht freigegebener Zahlungsweg (Stripe ist seit der Sandbox-Anbindung freigegeben, siehe StripeSandboxTest).
|
||||
config(['services.payment.driver' => 'unbekannt']);
|
||||
@@ -113,7 +113,7 @@ public function test_the_shop_exists_only_with_test_payment_and_never_in_product
|
||||
|
||||
config(['services.payment.driver' => 'test']);
|
||||
$this->app['env'] = 'production';
|
||||
$this->assertFalse(Shop::enabled());
|
||||
$this->assertFalse(Shop::checkoutOpen());
|
||||
$this->get(route('shop'))->assertNotFound();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,368 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Cms\NavigationItem;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageRevision;
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\Checkout;
|
||||
use App\Domain\Commerce\Order;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use App\Domain\Entitlement\Acquisition;
|
||||
use App\Models\User;
|
||||
use Database\Seeders\ShopDemoSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Tests\Support\BuildsShop;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Zwei Schalter für Produktion: „Shop sichtbar“ (SHOP_PUBLIC) zeigt Shop und Produktseiten, „Checkout offen“
|
||||
* (SHOP_LIVE_RELEASE mit Live-Schlüssel und Rechtstexten) öffnet Warenkorb, Kasse und Zahlung. Dazu: Der alte Einzelkauf
|
||||
* auf der Mitgliederseite ist entfernt, „Jetzt kaufen“ führt über die Kasse mit allen Pflichtangaben.
|
||||
*/
|
||||
class ShopSwitchTest extends TestCase
|
||||
{
|
||||
use BuildsShop;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->seedShop();
|
||||
}
|
||||
|
||||
private function publishLegalPages(): void
|
||||
{
|
||||
foreach (['/agb', '/lizenzbedingungen', '/widerruf', '/impressum', '/datenschutz'] as $path) {
|
||||
$page = Page::query()->firstOrCreate(['path' => $path]);
|
||||
$revision = PageRevision::query()->create(['page_id' => $page->id, 'blocks' => [], 'sections' => [], 'seo_title' => ltrim($path, '/')]);
|
||||
$page->published_revision_id = $revision->id;
|
||||
$page->save();
|
||||
}
|
||||
}
|
||||
|
||||
/** Produktion mit Stripe-Live-Schlüssel, aber ohne Freigabe: beide Schalter aus. */
|
||||
private function production(bool $public = false, bool $release = false): void
|
||||
{
|
||||
$this->app['env'] = 'production';
|
||||
config([
|
||||
'services.payment.driver' => 'stripe',
|
||||
'services.stripe.secret' => 'sk_live_nur_fuer_tests',
|
||||
'shop.public' => $public,
|
||||
'shop.live_release' => $release,
|
||||
]);
|
||||
|
||||
if ($release) {
|
||||
$this->publishLegalPages();
|
||||
}
|
||||
}
|
||||
|
||||
/** In Produktion prüft die Anwendung das CSRF-Token (im Testbetrieb wird es sonst übersprungen). */
|
||||
private function postProduction(string $uri, array $data = [], ?User $user = null)
|
||||
{
|
||||
$request = $user === null ? $this : $this->actingAs($user);
|
||||
|
||||
return $request->withSession(['_token' => 'produktion'])->post($uri, $data + ['_token' => 'produktion']);
|
||||
}
|
||||
|
||||
private function articleUrl(): string
|
||||
{
|
||||
return route('shop.article', $this->article('shop-konflikte'));
|
||||
}
|
||||
|
||||
// ---- Der alte Einzelkauf ----------------------------------------------------------------------------------------
|
||||
|
||||
public function test_production_without_release_creates_no_order_through_the_removed_direct_purchase(): void
|
||||
{
|
||||
$this->production();
|
||||
$offer = $this->privateKonflikte();
|
||||
|
||||
foreach (['/bereich/angebote/'.$offer->id.'/kaufen', '/angebote/'.$offer->id.'/kaufen'] as $path) {
|
||||
$this->postProduction($path, [], $this->tina())->assertStatus(404);
|
||||
}
|
||||
|
||||
$this->assertSame(0, Order::query()->count());
|
||||
$this->assertFalse(Route::has('member.offers.buy'), 'Die Route des Einzelkaufs ist entfernt.');
|
||||
}
|
||||
|
||||
public function test_the_direct_purchase_is_gone_in_test_mode_too_and_checkout_has_no_place_method(): void
|
||||
{
|
||||
$offer = $this->privateKonflikte();
|
||||
|
||||
$this->actingAs($this->tina())->post('/bereich/angebote/'.$offer->id.'/kaufen')->assertStatus(404);
|
||||
$this->assertSame(0, Order::query()->count());
|
||||
$this->assertFalse(method_exists(Checkout::class, 'place'), 'Es gibt nur noch die Bestellung aus dem Warenkorb mit Pflichtangaben.');
|
||||
}
|
||||
|
||||
// ---- Die Schalter -----------------------------------------------------------------------------------------------
|
||||
|
||||
public function test_in_production_both_switches_are_off_by_default_and_nothing_of_the_shop_is_reachable(): void
|
||||
{
|
||||
$this->production();
|
||||
|
||||
$this->assertFalse(Shop::visible());
|
||||
$this->assertFalse(Shop::checkoutOpen());
|
||||
$this->get(route('shop'))->assertNotFound();
|
||||
$this->get($this->articleUrl())->assertNotFound();
|
||||
$this->get(route('public.package', Bundle::query()->firstOrFail()))->assertNotFound();
|
||||
$this->get(route('cart'))->assertNotFound();
|
||||
$this->get(route('checkout'))->assertNotFound();
|
||||
$this->get(route('shop.closed'))->assertNotFound();
|
||||
$this->postProduction(route('cart.add', $this->privateKonflikte()))->assertNotFound();
|
||||
$this->postProduction(route('cart.buy', $this->privateKonflikte()))->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_with_the_shop_visible_but_the_checkout_closed_the_shop_can_be_viewed_but_not_bought_from(): void
|
||||
{
|
||||
$this->production(public: true);
|
||||
|
||||
$this->assertTrue(Shop::visible());
|
||||
$this->assertFalse(Shop::checkoutOpen());
|
||||
|
||||
$this->get(route('shop'))
|
||||
->assertOk()
|
||||
->assertSee('Konflikte im Training')
|
||||
->assertSee('<meta name="robots" content="noindex, nofollow">', false);
|
||||
|
||||
$page = $this->get($this->articleUrl())->assertOk();
|
||||
$page->assertSee('Privatlizenz')
|
||||
->assertSee('49,00 €')
|
||||
->assertSee('Kaufen')
|
||||
->assertSee(route('shop.closed'), false)
|
||||
->assertDontSee('In den Warenkorb')
|
||||
->assertDontSee('Jetzt kaufen')
|
||||
->assertSee('noindex', false);
|
||||
|
||||
$this->get(route('shop.closed'))
|
||||
->assertOk()
|
||||
->assertSee('noch nicht freigeschaltet')
|
||||
->assertSee('Verkaufsstart')
|
||||
->assertSee('noindex', false)
|
||||
->assertSee(route('shop'), false);
|
||||
}
|
||||
|
||||
public function test_with_the_checkout_closed_cart_checkout_and_buy_now_lead_to_the_notice_and_change_nothing(): void
|
||||
{
|
||||
$this->production(public: true);
|
||||
$offer = $this->privateKonflikte();
|
||||
$member = $this->tina();
|
||||
|
||||
$this->postProduction(route('cart.add', $offer))->assertRedirect(route('shop.closed'));
|
||||
$this->postProduction(route('cart.buy', $offer))->assertRedirect(route('shop.closed'));
|
||||
$this->get(route('cart'))->assertRedirect(route('shop.closed'));
|
||||
$this->get(route('checkout'))->assertRedirect(route('shop.closed'));
|
||||
$this->actingAs($member)->get(route('checkout'))->assertRedirect(route('shop.closed'));
|
||||
$this->postProduction(route('checkout.place'), $this->consentFields() + ['digest' => str_repeat('a', 64)], $member)->assertRedirect(route('shop.closed'));
|
||||
|
||||
$this->assertSame([], app(Cart::class)->items());
|
||||
$this->assertSame(0, Order::query()->count());
|
||||
$this->assertStringNotContainsString('href="'.route('cart').'"', $this->get(route('shop'))->getContent(), 'Das Warenkorb-Symbol bleibt aus.');
|
||||
}
|
||||
|
||||
public function test_with_both_switches_on_the_shop_works_as_before(): void
|
||||
{
|
||||
$this->production(public: true, release: true);
|
||||
|
||||
$this->assertTrue(Shop::visible());
|
||||
$this->assertTrue(Shop::checkoutOpen());
|
||||
$this->get($this->articleUrl())->assertOk()->assertSee('In den Warenkorb')->assertSee('Jetzt kaufen')->assertDontSee('noindex', false);
|
||||
$this->postProduction(route('cart.add', $this->privateKonflikte()))->assertRedirect();
|
||||
$this->get(route('cart'))->assertOk()->assertSee('Privatlizenz');
|
||||
$this->get(route('shop.closed'))->assertRedirect(route('shop'));
|
||||
}
|
||||
|
||||
public function test_a_release_alone_makes_the_shop_visible_without_a_second_setting(): void
|
||||
{
|
||||
$this->production(public: false, release: true);
|
||||
|
||||
$this->assertTrue(Shop::visible(), 'Wer den Checkout öffnet, hat den Shop damit sichtbar gemacht.');
|
||||
$this->get(route('shop'))->assertOk();
|
||||
}
|
||||
|
||||
public function test_a_test_or_local_instance_has_both_switches_on_with_the_test_driver_and_off_without_a_driver(): void
|
||||
{
|
||||
$this->assertTrue(Shop::visible());
|
||||
$this->assertTrue(Shop::checkoutOpen());
|
||||
|
||||
config(['services.payment.driver' => 'aus']);
|
||||
|
||||
$this->assertFalse(Shop::visible());
|
||||
$this->assertFalse(Shop::checkoutOpen());
|
||||
$this->get(route('shop'))->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_the_stripe_webhook_and_gateway_stay_bound_to_the_live_release_not_to_visibility(): void
|
||||
{
|
||||
$this->production(public: true);
|
||||
|
||||
$this->assertFalse(Shop::stripe());
|
||||
$this->assertFalse(Shop::live());
|
||||
$this->postProduction(route('stripe.webhook'))->assertNotFound();
|
||||
}
|
||||
|
||||
// ---- Menü und alte Adresse --------------------------------------------------------------------------------------
|
||||
|
||||
public function test_the_old_public_offers_address_redirects_to_the_shop_when_the_shop_is_visible(): void
|
||||
{
|
||||
$this->get('/angebote')->assertRedirect(route('shop'));
|
||||
}
|
||||
|
||||
public function test_while_the_shop_is_hidden_an_existing_cms_page_stays_and_without_one_the_address_is_gone(): void
|
||||
{
|
||||
$page = Page::query()->create(['path' => '/angebote']);
|
||||
$revision = PageRevision::query()->create(['page_id' => $page->id, 'blocks' => [], 'sections' => [], 'seo_title' => 'Angebote']);
|
||||
$page->published_revision_id = $revision->id;
|
||||
$page->save();
|
||||
|
||||
$this->production();
|
||||
$this->get('/angebote')->assertOk();
|
||||
|
||||
$page->delete();
|
||||
$this->get('/angebote')->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_menu_entries_pointing_into_the_shop_are_hidden_while_the_shop_is_not_visible(): void
|
||||
{
|
||||
NavigationItem::query()->create(['label' => 'Shopartikel', 'url' => '/shop/4', 'placement' => 'footer', 'sort_order' => 91, 'is_visible' => true]);
|
||||
NavigationItem::query()->create(['label' => 'Warenkorbweg', 'url' => '/warenkorb', 'placement' => 'footer', 'sort_order' => 92, 'is_visible' => true]);
|
||||
$startseite = Page::query()->firstOrCreate(['path' => '/']);
|
||||
$revision = PageRevision::query()->create(['page_id' => $startseite->id, 'blocks' => [], 'sections' => [], 'seo_title' => 'Start']);
|
||||
$startseite->published_revision_id = $revision->id;
|
||||
$startseite->save();
|
||||
|
||||
$this->get('/')->assertOk()->assertSee('href="'.url('/shop').'"', false);
|
||||
|
||||
$this->production();
|
||||
$this->get('/')->assertOk()
|
||||
->assertDontSee('href="'.url('/shop').'"', false)
|
||||
->assertDontSee('href="'.url('/shop/4').'"', false)
|
||||
->assertDontSee('href="'.url('/warenkorb').'"', false);
|
||||
|
||||
$this->production(public: true);
|
||||
$this->get('/')->assertOk()->assertSee('href="'.url('/shop').'"', false);
|
||||
}
|
||||
|
||||
// ---- „Jetzt kaufen“ ---------------------------------------------------------------------------------------------
|
||||
|
||||
public function test_buy_now_puts_the_option_in_the_cart_and_opens_the_order_overview(): void
|
||||
{
|
||||
$offer = $this->privateKonflikte();
|
||||
|
||||
$this->actingAs($this->tina())->post(route('cart.buy', $offer))->assertRedirect(route('checkout'));
|
||||
|
||||
$this->assertSame([$offer->id], array_keys(app(Cart::class)->items()));
|
||||
$this->assertSame(0, Order::query()->count(), 'Erst der Knopf „Zahlungspflichtig bestellen“ legt eine Bestellung an.');
|
||||
$this->actingAs($this->tina())->get(route('checkout'))
|
||||
->assertOk()
|
||||
->assertSee('Zahlungspflichtig bestellen')
|
||||
->assertSee('Privatlizenz');
|
||||
}
|
||||
|
||||
public function test_buy_now_replaces_another_option_of_the_same_product_without_asking_and_keeps_other_products(): void
|
||||
{
|
||||
$private = $this->privateKonflikte();
|
||||
$club = $this->clubKonflikte();
|
||||
$other = $this->privateGrenzen();
|
||||
$cart = app(Cart::class);
|
||||
$cart->add($private);
|
||||
$cart->add($other);
|
||||
|
||||
$this->actingAs($this->tina())->post(route('cart.buy', $club))->assertRedirect(route('checkout'));
|
||||
|
||||
$ids = array_keys(app(Cart::class)->items());
|
||||
sort($ids);
|
||||
$expected = [$club->id, $other->id];
|
||||
sort($expected);
|
||||
$this->assertSame($expected, $ids);
|
||||
}
|
||||
|
||||
public function test_a_guest_buying_now_is_sent_to_the_login_and_keeps_the_cart(): void
|
||||
{
|
||||
$offer = $this->privateKonflikte();
|
||||
|
||||
$this->post(route('cart.buy', $offer))->assertRedirect(route('checkout'));
|
||||
$this->get(route('checkout'))->assertRedirect(route('login'));
|
||||
$this->assertSame([$offer->id], array_keys(app(Cart::class)->items()));
|
||||
|
||||
$this->post('/anmelden', ['email' => $this->tina()->email, 'password' => ShopDemoSeeder::PASSWORD])->assertRedirect();
|
||||
$this->assertAuthenticatedAs($this->tina());
|
||||
$this->assertSame([$offer->id], array_keys(app(Cart::class)->items()), 'Der Warenkorb übersteht die Anmeldung.');
|
||||
}
|
||||
|
||||
public function test_buy_now_refuses_an_option_that_is_not_for_sale_and_a_missing_one(): void
|
||||
{
|
||||
$offer = $this->privateKonflikte();
|
||||
app(OfferService::class)->end($offer);
|
||||
|
||||
$this->actingAs($this->tina())->post(route('cart.buy', $offer))->assertRedirect()->assertSessionHasErrors('shop');
|
||||
$this->assertSame([], app(Cart::class)->items());
|
||||
$this->actingAs($this->tina())->post('/warenkorb/999999/jetzt-kaufen')->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_buy_now_is_not_offered_for_an_option_the_account_already_owns_and_does_not_add_it(): void
|
||||
{
|
||||
$offer = $this->privateKonflikte();
|
||||
$order = $this->orderOf($this->tina(), [$offer]);
|
||||
app(Checkout::class)->confirmTestPayment($order, 'test-eigen');
|
||||
Mail::fake();
|
||||
|
||||
$page = $this->actingAs($this->tina())->get($this->articleUrl())->assertOk();
|
||||
$page->assertSee('Bereits erworben');
|
||||
|
||||
$this->actingAs($this->tina())->post(route('cart.buy', $offer))->assertRedirect()->assertSessionHas('status');
|
||||
$this->assertSame([], app(Cart::class)->items());
|
||||
}
|
||||
|
||||
// ---- Mitgliederseite „Angebote“ ---------------------------------------------------------------------------------
|
||||
|
||||
private function freeOffer(): Offer
|
||||
{
|
||||
$article = app(ArticleService::class)->create('gratis-artikel');
|
||||
app(ArticleService::class)->publishRelease($article, $this->article('shop-grenzen')->currentRelease->rootCompositionVersion, 'Erster Stand.');
|
||||
$service = app(OfferService::class);
|
||||
$offer = $service->create('Gratis zum Start');
|
||||
$rights = RightsProfileVersion::query()->whereHas('profile', fn ($query) => $query->where('name', 'Privatlizenz ehrenamtlich'))->firstOrFail();
|
||||
$service->activate($offer, [['target' => $article->fresh(), 'rights' => $rights]], ['grant_kind' => 'auf_abruf', 'holder_kind' => 'person']);
|
||||
|
||||
return $offer;
|
||||
}
|
||||
|
||||
public function test_the_member_offers_page_offers_only_the_free_claim_and_a_link_to_the_shop_but_no_purchase(): void
|
||||
{
|
||||
$free = $this->freeOffer();
|
||||
|
||||
$page = $this->actingAs($this->tina())->get(route('member.offers'))->assertOk();
|
||||
$page->assertSee('Gratis zum Start')
|
||||
->assertSee('In die Bibliothek')
|
||||
->assertSee(route('shop'), false)
|
||||
->assertDontSee('Testzahlung')
|
||||
->assertDontSee('Kaufen')
|
||||
->assertDontSee('Konflikte im Training: Privatlizenz');
|
||||
$page->assertSee(route('member.offers.claim', $free), false);
|
||||
}
|
||||
|
||||
public function test_the_member_offers_page_hides_the_shop_link_while_the_shop_is_not_visible_and_claiming_still_works(): void
|
||||
{
|
||||
$free = $this->freeOffer();
|
||||
$this->production();
|
||||
|
||||
$page = $this->actingAs($this->tina())->get(route('member.offers'))->assertOk();
|
||||
$page->assertSee('Gratis zum Start')->assertDontSee(route('shop'), false);
|
||||
|
||||
$this->postProduction(route('member.offers.claim', $free), [], $this->tina())->assertRedirect(route('member.library'));
|
||||
$this->assertSame(1, Acquisition::query()->where('party_id', $this->tina()->party_id)->count());
|
||||
}
|
||||
|
||||
public function test_the_member_offers_page_requires_a_login(): void
|
||||
{
|
||||
$this->get(route('member.offers'))->assertRedirect();
|
||||
}
|
||||
}
|
||||