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,53 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// Anonymous class for migration (Laravel standard since 8.x)
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('dhl_package_shipments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// Basic shipment info
|
||||
$table->unsignedBigInteger('order_id')->nullable()->index();
|
||||
$table->string('dhl_shipment_no')->nullable()->index();
|
||||
$table->enum('type', ['outbound', 'return'])->default('outbound');
|
||||
$table->unsignedBigInteger('related_shipment_id')->nullable()->index(); // For returns
|
||||
|
||||
// Product and billing
|
||||
$table->string('product_code')->default('V01PAK');
|
||||
$table->string('billing_number')->nullable();
|
||||
$table->decimal('weight_kg', 8, 3)->nullable();
|
||||
|
||||
// Label information
|
||||
$table->string('label_format')->default('PDF');
|
||||
$table->string('label_path')->nullable();
|
||||
|
||||
// Status tracking (simplified)
|
||||
$table->string('status')->default('created'); // created, in_transit, delivered, canceled, etc.
|
||||
$table->string('tracking_status')->nullable(); // Last DHL status text
|
||||
$table->timestamp('last_tracked_at')->nullable();
|
||||
|
||||
// API response data
|
||||
$table->json('api_response_data')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
// Foreign key constraints
|
||||
$table->foreign('related_shipment_id')->references('id')->on('dhl_package_shipments')->onDelete('set null');
|
||||
|
||||
// Indexes for performance
|
||||
$table->index(['order_id', 'type']);
|
||||
$table->index(['status', 'created_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('dhl_package_shipments');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?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('shipments', function (Blueprint $t) {
|
||||
$t->id();
|
||||
$t->unsignedBigInteger('order_id')->nullable();
|
||||
$t->string('carrier')->default('dhl');
|
||||
$t->string('dhl_shipment_no')->nullable()->index();
|
||||
$t->string('product_code')->nullable();
|
||||
$t->string('billing_number')->nullable();
|
||||
$t->decimal('weight_kg', 8, 3)->nullable();
|
||||
$t->string('status')->default('created');
|
||||
$t->string('label_format')->nullable();
|
||||
$t->string('label_path')->nullable();
|
||||
$t->json('meta')->nullable();
|
||||
$t->timestamps();
|
||||
});
|
||||
}
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('shipments');
|
||||
}
|
||||
};
|
||||
|
|
@ -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::create('shipment_labels', function (Blueprint $t) {
|
||||
$t->id();
|
||||
$t->foreignId('shipment_id')->constrained('shipments')->cascadeOnDelete();
|
||||
$t->string('format')->default('PDF');
|
||||
$t->string('path');
|
||||
$t->timestamps();
|
||||
});
|
||||
}
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('shipment_labels');
|
||||
}
|
||||
};
|
||||
|
|
@ -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::create('dhl_package_tracking_events', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('shipment_id')->index();
|
||||
$table->string('status_code')->nullable();
|
||||
$table->string('status_text')->nullable();
|
||||
$table->string('location')->nullable();
|
||||
$table->timestamp('event_time')->nullable();
|
||||
$table->json('raw')->nullable(); // Full event data from API
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('shipment_id')->references('id')->on('dhl_package_shipments')->onDelete('cascade');
|
||||
$table->index(['shipment_id', 'event_time']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('dhl_package_tracking_events');
|
||||
}
|
||||
};
|
||||
|
|
@ -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::create('tracking_events', function (Blueprint $t) {
|
||||
$t->id();
|
||||
$t->foreignId('shipment_id')->constrained('shipments')->cascadeOnDelete();
|
||||
$t->string('status_code')->nullable();
|
||||
$t->string('status_text')->nullable();
|
||||
$t->string('location')->nullable();
|
||||
$t->timestamp('event_time')->nullable();
|
||||
$t->json('raw')->nullable();
|
||||
});
|
||||
}
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tracking_events');
|
||||
}
|
||||
};
|
||||
|
|
@ -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::create('return_labels', function (Blueprint $t) {
|
||||
$t->id();
|
||||
$t->unsignedBigInteger('order_id')->nullable()->index();
|
||||
$t->string('dhl_return_no')->nullable()->index();
|
||||
$t->string('label_path')->nullable();
|
||||
$t->timestamps();
|
||||
});
|
||||
}
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('return_labels');
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue