10.April 2026

This commit is contained in:
Kevin Adametz 2026-04-10 17:15:27 +02:00
parent a00c42e770
commit f58c709945
208 changed files with 19280 additions and 2914 deletions

View file

@ -1,8 +1,8 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCountriesTable extends Migration
{
@ -35,13 +35,10 @@ class CreateCountriesTable extends Migration
$table->boolean('currency_calc')->default(false);
$table->decimal('currency_faktor', 4, 2)->nullable();
$table->boolean('active')->default(true);
$table->text('trans_name')->nullable();
$table->text('attr')->nullable();
$table->timestamps();
});
}

View file

@ -11,9 +11,11 @@ return new class extends Migration
*/
public function up(): void
{
Schema::table('dhl_package_shipments', function (Blueprint $table) {
$table->string('routing_code')->nullable()->after('dhl_shipment_no');
});
if (! Schema::hasColumn('dhl_package_shipments', 'routing_code')) {
Schema::table('dhl_package_shipments', function (Blueprint $table) {
$table->string('routing_code')->nullable()->after('dhl_shipment_no');
});
}
}
/**

View file

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('incentives', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 255);
$table->string('slug', 255)->unique();
$table->text('description')->nullable();
$table->string('image', 255)->nullable()->comment('Statisches Bild Dateiname');
$table->text('terms')->nullable()->comment('Teilnahmebedingungen');
$table->date('qualification_start')->comment('Beginn Qualifikationszeitraum');
$table->date('qualification_end')->comment('Ende Qualifikationszeitraum');
$table->date('calculation_end')->comment('Ende Punkteberechnung (inkl. Verlaengerung)');
$table->unsignedInteger('points_partner_onetime')->default(600)->comment('Einmalpunkte pro Neupartner');
$table->unsignedInteger('points_abo_onetime')->default(400)->comment('Einmalpunkte pro Kundenabo');
$table->unsignedInteger('min_direct_partners')->default(4)->comment('Mindestanzahl direkte Teampartner');
$table->unsignedInteger('min_customer_abos')->default(6)->comment('Mindestanzahl Kundenabos');
$table->unsignedInteger('max_winners')->default(30)->comment('Maximale Anzahl Gewinner');
$table->unsignedTinyInteger('status')->default(0)->index()->comment('0=draft, 1=active, 2=closed');
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('incentives');
}
};

View file

@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('incentive_participants', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('incentive_id');
$table->foreign('incentive_id')
->references('id')
->on('incentives')
->onDelete('cascade');
$table->unsignedInteger('user_id');
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
$table->datetime('accepted_terms_at')->comment('Zeitpunkt Teilnahme-Bestaetigung');
$table->integer('total_points')->default(0)->comment('Gesamtpunkte (Cache fuer Ranking)');
$table->unsignedInteger('qualified_partners')->default(0)->comment('Anzahl qualifizierter Neupartner');
$table->unsignedInteger('qualified_abos')->default(0)->comment('Anzahl qualifizierter Kundenabos');
$table->boolean('is_qualified')->default(false)->index()->comment('Mindestqualifikation erreicht');
$table->unsignedInteger('rank')->nullable()->comment('Aktuelle Platzierung');
$table->timestamps();
$table->unique(['incentive_id', 'user_id'], 'incentive_user_unique');
});
}
public function down(): void
{
Schema::dropIfExists('incentive_participants');
}
};

View file

@ -0,0 +1,55 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('incentive_points_log', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('participant_id');
$table->foreign('participant_id')
->references('id')
->on('incentive_participants')
->onDelete('cascade');
$table->string('type', 10)->index()->comment('partner oder abo');
$table->string('source_type', 100)->comment('Polymorphic: App\\User oder App\\Models\\UserAbo');
$table->unsignedInteger('source_id')->comment('ID des Neupartners oder des Abos');
$table->string('source_label', 255)->comment('Name/Bezeichnung fuer Anzeige');
$table->unsignedTinyInteger('month')->comment('Bezugsmonat');
$table->unsignedSmallInteger('year')->comment('Bezugsjahr');
$table->integer('points_onetime')->default(0)->comment('Einmalpunkte (600 bzw. 400)');
$table->integer('points_accumulated')->default(0)->comment('Akkumulierte Punkte des Monats');
$table->boolean('is_storno')->default(false)->index()->comment('Storno-Eintrag');
$table->unsignedInteger('storno_of_id')->nullable()->comment('Referenz auf stornierten Eintrag');
$table->foreign('storno_of_id')
->references('id')
->on('incentive_points_log');
$table->unsignedInteger('user_sales_volume_id')->nullable();
$table->foreign('user_sales_volume_id')
->references('id')
->on('user_sales_volumes');
$table->timestamps();
$table->index(['participant_id', 'type']);
$table->index(['source_type', 'source_id']);
$table->index(['month', 'year']);
});
}
public function down(): void
{
Schema::dropIfExists('incentive_points_log');
}
};

View file

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('incentive_new_partners', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('participant_id');
$table->foreign('participant_id')
->references('id')
->on('incentive_participants')
->onDelete('cascade');
$table->unsignedInteger('user_id')->comment('Der neue Partner');
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
$table->datetime('registered_at')->comment('Registrierungsdatum des Partners');
$table->timestamps();
$table->unique(['participant_id', 'user_id'], 'participant_partner_unique');
});
}
public function down(): void
{
Schema::dropIfExists('incentive_new_partners');
}
};

View file

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('incentive_new_abos', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('participant_id');
$table->foreign('participant_id')
->references('id')
->on('incentive_participants')
->onDelete('cascade');
$table->unsignedInteger('user_abo_id')->comment('Das Kundenabo');
$table->foreign('user_abo_id')
->references('id')
->on('user_abos')
->onDelete('cascade');
$table->datetime('activated_at')->comment('Aktivierungsdatum des Abos');
$table->timestamps();
$table->unique(['participant_id', 'user_abo_id'], 'participant_abo_unique');
});
}
public function down(): void
{
Schema::dropIfExists('incentive_new_abos');
}
};

View file

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('user_sales_volumes', function (Blueprint $table) {
if (! Schema::hasColumn('user_sales_volumes', 'info')) {
$table->string('info', 255)->nullable()->after('message');
}
if (! Schema::hasColumn('user_sales_volumes', 'month_KP_points')) {
$table->decimal('month_KP_points', 13, 2)->nullable()->after('month_shop_points');
}
if (! Schema::hasColumn('user_sales_volumes', 'month_TP_points')) {
$table->decimal('month_TP_points', 13, 2)->nullable()->after('month_KP_points');
}
});
}
public function down(): void
{
Schema::table('user_sales_volumes', function (Blueprint $table) {
$table->dropColumn(['info', 'month_KP_points', 'month_TP_points']);
});
}
};

View file

@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('incentives', function (Blueprint $table) {
$table->json('trans_name')->nullable()->after('name');
$table->json('trans_description')->nullable()->after('description');
$table->json('trans_terms')->nullable()->after('terms');
});
}
public function down(): void
{
Schema::table('incentives', function (Blueprint $table) {
$table->dropColumn(['trans_name', 'trans_description', 'trans_terms']);
});
}
};

View file

@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('incentives', function (Blueprint $table) {
$table->string('subtitle')->nullable()->after('name');
$table->json('trans_subtitle')->nullable()->after('trans_name');
});
}
public function down(): void
{
Schema::table('incentives', function (Blueprint $table) {
$table->dropColumn(['subtitle', 'trans_subtitle']);
});
}
};

View file

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('incentive_points_log', function (Blueprint $table) {
$table->unsignedInteger('incentive_new_partner_id')->nullable()->after('user_sales_volume_id');
$table->unsignedInteger('incentive_new_abo_id')->nullable()->after('incentive_new_partner_id');
$table->foreign('incentive_new_partner_id')
->references('id')
->on('incentive_new_partners')
->nullOnDelete();
$table->foreign('incentive_new_abo_id')
->references('id')
->on('incentive_new_abos')
->nullOnDelete();
$table->index('incentive_new_partner_id');
$table->index('incentive_new_abo_id');
});
}
public function down(): void
{
Schema::table('incentive_points_log', function (Blueprint $table) {
$table->dropForeign(['incentive_new_partner_id']);
$table->dropForeign(['incentive_new_abo_id']);
$table->dropColumn(['incentive_new_partner_id', 'incentive_new_abo_id']);
});
}
};

View file

@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('incentive_participants', function (Blueprint $table) {
$table->datetime('accepted_terms_at')->nullable()->change()->comment('Zeitpunkt Teilnahme-Bestaetigung; null = automatisch erfasst, noch nicht zugestimmt');
});
}
public function down(): void
{
Schema::table('incentive_participants', function (Blueprint $table) {
$table->datetime('accepted_terms_at')->nullable(false)->change()->comment('Zeitpunkt Teilnahme-Bestaetigung');
});
}
};

View file

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('abo_chart_snapshots', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->string('scope', 50); // 'ot' | 'team_abos' | 'team_cust_abos'
$table->unsignedSmallInteger('year');
$table->unsignedTinyInteger('month');
$table->unsignedInteger('count')->default(0);
$table->timestamp('calculated_at');
$table->timestamps();
// Einmaliger Eintrag pro User/Scope/Monat verhindert Doppeleinträge
$table->unique(['user_id', 'scope', 'year', 'month']);
$table->index(['user_id', 'scope', 'year']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('abo_chart_snapshots');
}
};