Führe Rabattcodes, Nutzerkreis der Lizenzoption und Pflichtangaben der Kasse ein
Domäne: Rabattcodes mit Geltungsbereich (Warenkorb oder gewählte Ziele) und Einlösungsberechtigung (allgemein oder freigeschaltete Konten) unabhängig voneinander; Prüfung bei Eingabe, in jeder Übersicht und unter Sperre vor Bestellabschluss (Prüfsumme der Übersicht enthält den Rabatt). Rabatt je Position, Zwischensumme und Zahlbetrag in der Bestellung; Stripe erhält den Preis nach Rabatt. Nutzerkreis (Einzel-/Mehrfachlizenz, Trainerzahl) an der Angebotsfassung, kopiert in Bestellposition und Erwerb, Teil der Prüfung "Bereits erworben". OfferService::activate lehnt Angebote ohne veröffentlichten Artikelstand ab. Kasse: Zustimmungen als Pflichtangabe mit Nachweis, "Zahlungspflichtig bestellen", Rechnungsweg für Organisationen, Erstattung über Stripe, Widerruf erklären. Produktivfreigabe SHOP_LIVE_RELEASE standardmäßig aus. Bestandstests geändert (fachlich überholt, Assertions nicht abgeschwächt): die Schaltfläche heißt "Zahlungspflichtig bestellen" (§ 312j BGB), die Summe heißt "Zu zahlen", der Vereinshinweis steht als Rollenliste; Bestellungen über die Kasse senden jetzt die Zustimmungen. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cb80835c92
commit
0154182f3b
40 files changed
+2151
-92
No files matched your search
+113
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Verkaufsstart Deutschland (A1): nur ergänzend, nichts wird gelöscht oder umbenannt; ein Rollback des Codes lässt
|
||||
* die neuen Spalten und Tabellen liegen (der frühere Code kennt sie nicht).
|
||||
*
|
||||
* - Rabattcodes mit Geltungsbereich (Warenkorb oder ausgewählte Ziele) und Einlösungsberechtigung (allgemein oder
|
||||
* nur für freigeschaltete Konten). Freigaben werden nie gelöscht, nur entzogen.
|
||||
* - Nutzerkreis der Lizenzoption (Einzel- oder Mehrfachlizenz, Zahl der Trainer) an der Angebotsfassung, kopiert in
|
||||
* die Bestellposition. Lizenzinhaber, berechtigte Trainer und Downloadzugriff sind getrennte Angaben.
|
||||
* - Rabatt, Zahlbetrag, Zahlungsweg und Zustimmungsnachweis an der Bestellung.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('discount_codes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('code')->unique();
|
||||
$table->string('label');
|
||||
$table->string('kind', 12);
|
||||
$table->unsignedTinyInteger('percent')->nullable();
|
||||
$table->unsignedInteger('amount_cents')->nullable();
|
||||
$table->string('scope', 12)->default('warenkorb');
|
||||
$table->string('eligibility', 12)->default('allgemein');
|
||||
$table->timestamp('valid_from')->nullable();
|
||||
$table->timestamp('valid_until')->nullable();
|
||||
$table->boolean('active')->default(true);
|
||||
$table->text('note')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('discount_code_targets', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('discount_code_id')->constrained('discount_codes')->cascadeOnDelete();
|
||||
$table->string('target_type', 16);
|
||||
$table->unsignedBigInteger('target_id');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['discount_code_id', 'target_type', 'target_id']);
|
||||
});
|
||||
|
||||
Schema::create('discount_code_releases', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('discount_code_id')->constrained('discount_codes')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
|
||||
$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(['discount_code_id', 'user_id']);
|
||||
});
|
||||
|
||||
Schema::table('offer_versions', function (Blueprint $table) {
|
||||
$table->string('licence_scope', 12)->nullable();
|
||||
$table->unsignedSmallInteger('trainer_count')->nullable();
|
||||
});
|
||||
|
||||
Schema::table('order_lines', function (Blueprint $table) {
|
||||
$table->string('licence_scope', 12)->nullable();
|
||||
$table->unsignedSmallInteger('trainer_count')->nullable();
|
||||
$table->unsignedInteger('discount_cents')->default(0);
|
||||
});
|
||||
|
||||
Schema::table('orders', function (Blueprint $table) {
|
||||
$table->unsignedInteger('subtotal_cents')->nullable();
|
||||
$table->unsignedInteger('discount_cents')->default(0);
|
||||
$table->foreignId('discount_code_id')->nullable()->constrained('discount_codes')->nullOnDelete();
|
||||
$table->json('discount_snapshot')->nullable();
|
||||
$table->string('payment_method', 16)->nullable();
|
||||
$table->timestamp('terms_accepted_at')->nullable();
|
||||
$table->json('terms_snapshot')->nullable();
|
||||
$table->timestamp('withdrawal_requested_at')->nullable();
|
||||
$table->text('withdrawal_note')->nullable();
|
||||
});
|
||||
|
||||
Schema::table('payments', function (Blueprint $table) {
|
||||
$table->string('provider_payment_ref')->nullable();
|
||||
$table->unsignedInteger('amount_cents')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('payments', function (Blueprint $table) {
|
||||
$table->dropColumn(['provider_payment_ref', 'amount_cents']);
|
||||
});
|
||||
Schema::table('orders', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('discount_code_id');
|
||||
$table->dropColumn([
|
||||
'subtotal_cents', 'discount_cents', 'discount_snapshot', 'payment_method',
|
||||
'terms_accepted_at', 'terms_snapshot', 'withdrawal_requested_at', 'withdrawal_note',
|
||||
]);
|
||||
});
|
||||
Schema::table('order_lines', function (Blueprint $table) {
|
||||
$table->dropColumn(['licence_scope', 'trainer_count', 'discount_cents']);
|
||||
});
|
||||
Schema::table('offer_versions', function (Blueprint $table) {
|
||||
$table->dropColumn(['licence_scope', 'trainer_count']);
|
||||
});
|
||||
Schema::dropIfExists('discount_code_releases');
|
||||
Schema::dropIfExists('discount_code_targets');
|
||||
Schema::dropIfExists('discount_codes');
|
||||
}
|
||||
};
|
||||
@@ -8,6 +8,7 @@
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\LicenceScope;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
@@ -78,14 +79,14 @@ public function run(): void
|
||||
'pdf' => ['ansehen', 'laden'],
|
||||
]);
|
||||
|
||||
$this->offer($offers, 'Konflikte im Training: Privatlizenz', 'Privatlizenz', $konflikteVersion, [$konflikteArticle, $privat], 4900, 'person');
|
||||
$this->offer($offers, 'Konflikte im Training: Vereinslizenz', 'Mehrfachlizenz für Vereine', $konflikteVersion, [$konflikteArticle, $verein], 14900, 'organisation');
|
||||
$this->offer($offers, 'Grenzen setzen: Privatlizenz', 'Privatlizenz', $grenzenVersion, [$grenzenArticle, $privat], 2900, 'person');
|
||||
$this->offer($offers, 'Konflikte im Training: Privatlizenz', 'Privatlizenz', $konflikteVersion, [$konflikteArticle, $privat], 4900, 'person', LicenceScope::SINGLE, 1);
|
||||
$this->offer($offers, 'Konflikte im Training: Vereinslizenz', 'Mehrfachlizenz für Vereine', $konflikteVersion, [$konflikteArticle, $verein], 14900, 'organisation', LicenceScope::MULTI, 5);
|
||||
$this->offer($offers, 'Grenzen setzen: Privatlizenz', 'Privatlizenz', $grenzenVersion, [$grenzenArticle, $privat], 2900, 'person', LicenceScope::SINGLE, 1);
|
||||
|
||||
$bundle = $bundles->create('Starterpaket');
|
||||
$starter = $bundles->publish($bundle, [$konflikteArticle->fresh(), $grenzenArticle->fresh(), $starterArticle->fresh()]);
|
||||
$paket = $offers->create('Starterpaket: Privatlizenz');
|
||||
$offers->activate($paket, [['target' => $starter, 'rights' => $privat]], ['grant_kind' => 'kauf', 'price_cents' => 5900, 'holder_kind' => 'person']);
|
||||
$offers->activate($paket, [['target' => $starter, 'rights' => $privat]], ['grant_kind' => 'kauf', 'price_cents' => 5900, 'holder_kind' => 'person', 'licence_scope' => LicenceScope::SINGLE, 'trainer_count' => 1]);
|
||||
$offers->assignProduct($paket, $starterVersion->composition_id, 'Starterpaket (zwei Programme und Einführung)');
|
||||
|
||||
$tina = $this->account('Tina Trainerin', 'tina.trainerin@example.test');
|
||||
@@ -160,13 +161,15 @@ private function program(
|
||||
/**
|
||||
* @param array{0: LicenseArticle, 1: RightsProfileVersion} $line
|
||||
*/
|
||||
private function offer(OfferService $offers, string $name, string $label, CompositionVersion $version, array $line, int $cents, string $holder): Offer
|
||||
private function offer(OfferService $offers, string $name, string $label, CompositionVersion $version, array $line, int $cents, string $holder, ?string $scope = null, ?int $trainers = null): Offer
|
||||
{
|
||||
$offer = $offers->create($name);
|
||||
$offers->activate($offer, [['target' => $line[0], 'rights' => $line[1]]], [
|
||||
'grant_kind' => 'kauf',
|
||||
'price_cents' => $cents,
|
||||
'holder_kind' => $holder,
|
||||
'licence_scope' => $scope,
|
||||
'trainer_count' => $trainers,
|
||||
]);
|
||||
$offers->assignProduct($offer, $version->composition_id, $label);
|
||||
|
||||
|
||||
Reference in new issue
Block a user