DHL Modul v0.5 Shipping Label ok
This commit is contained in:
parent
480fdc65ed
commit
8fdaa0ba1d
122 changed files with 17938 additions and 2239 deletions
|
|
@ -0,0 +1,109 @@
|
|||
<?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('dhl_shipments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// Relationship zu ShoppingOrder
|
||||
$table->unsignedInteger('shopping_order_id'); // int(10) unsigned to match shopping_orders.id
|
||||
$table->foreign('shopping_order_id')->references('id')->on('shopping_orders')->onDelete('cascade');
|
||||
|
||||
// DHL Shipment Daten
|
||||
$table->string('shipment_number')->nullable(); // DHL Sendungsnummer
|
||||
$table->string('tracking_number')->nullable(); // DHL Tracking-Nummer (kann identisch sein)
|
||||
|
||||
// Sendungstyp: 'outbound' (regulär) oder 'return' (Retoure)
|
||||
$table->enum('type', ['outbound', 'return'])->default('outbound');
|
||||
|
||||
// Für Retouren: Verweis auf ursprüngliche Sendung
|
||||
$table->unsignedBigInteger('related_shipment_id')->nullable(); // id() uses bigInteger
|
||||
$table->foreign('related_shipment_id')->references('id')->on('dhl_shipments')->onDelete('set null');
|
||||
|
||||
// Paketdaten
|
||||
$table->decimal('weight', 8, 2)->default(1.0); // in kg
|
||||
$table->integer('length')->nullable(); // in cm
|
||||
$table->integer('width')->nullable(); // in cm
|
||||
$table->integer('height')->nullable(); // in cm
|
||||
|
||||
// DHL Service-Optionen
|
||||
$table->string('product_code')->default('V01PAK'); // V01PAK = DHL Paket
|
||||
$table->json('services')->nullable(); // Zusätzliche Services (Premium, etc.)
|
||||
|
||||
// Labels und Dokumente
|
||||
$table->string('label_path')->nullable(); // Pfad zum generierten Label
|
||||
$table->string('label_format')->default('PDF'); // PDF oder ZPL
|
||||
$table->boolean('label_printed')->default(false);
|
||||
|
||||
// Status-Management
|
||||
$table->enum('status', [
|
||||
'created', // Sendung erstellt, noch nicht bei DHL
|
||||
'submitted', // An DHL übertragen
|
||||
'in_transit', // Unterwegs
|
||||
'delivered', // Zugestellt
|
||||
'returned', // Zurückgeschickt
|
||||
'cancelled', // Storniert
|
||||
'failed' // Fehler bei Erstellung/Übertragung
|
||||
])->default('created');
|
||||
|
||||
// Tracking-Status (von DHL API)
|
||||
$table->string('tracking_status')->nullable();
|
||||
$table->text('tracking_details')->nullable(); // JSON für detaillierte Tracking-Info
|
||||
$table->timestamp('last_tracked_at')->nullable();
|
||||
|
||||
// Empfängeradresse (Kopie für Archivierung)
|
||||
$table->string('recipient_name');
|
||||
$table->string('recipient_company')->nullable();
|
||||
$table->string('recipient_street');
|
||||
$table->string('recipient_street_number');
|
||||
$table->string('recipient_postal_code');
|
||||
$table->string('recipient_city');
|
||||
$table->string('recipient_state')->nullable();
|
||||
$table->string('recipient_country', 2)->default('DE');
|
||||
$table->string('recipient_email')->nullable();
|
||||
$table->string('recipient_phone')->nullable();
|
||||
|
||||
// API Response Data (für Debugging und Audit)
|
||||
$table->json('api_request_data')->nullable(); // Gesendete Daten
|
||||
$table->json('api_response_data')->nullable(); // Empfangene Antwort
|
||||
$table->text('api_errors')->nullable(); // Fehlermeldungen
|
||||
|
||||
// Kosten und Abrechnung
|
||||
$table->decimal('shipping_cost', 10, 2)->nullable(); // Versandkosten
|
||||
$table->string('currency', 3)->default('EUR');
|
||||
|
||||
// Zusätzliche Metadaten
|
||||
$table->text('notes')->nullable(); // Interne Notizen
|
||||
$table->json('metadata')->nullable(); // Flexible zusätzliche Daten
|
||||
|
||||
// Timestamps
|
||||
$table->timestamp('shipped_at')->nullable(); // Wann wurde versendet
|
||||
$table->timestamp('delivered_at')->nullable(); // Wann zugestellt
|
||||
$table->timestamps();
|
||||
|
||||
// Indizes für Performance
|
||||
$table->index('shopping_order_id');
|
||||
$table->index('shipment_number');
|
||||
$table->index('tracking_number');
|
||||
$table->index(['type', 'status']);
|
||||
$table->index('created_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('dhl_shipments');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?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::table('dhl_package_shipments', function (Blueprint $table) {
|
||||
$table->string('routing_code')->nullable()->after('dhl_shipment_no');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('dhl_package_shipments', function (Blueprint $table) {
|
||||
$table->dropColumn('routing_code');
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue