add skus related table

This commit is contained in:
2025-11-13 16:27:32 +08:00
parent e3cc31b947
commit 49d4f280f3
3 changed files with 90 additions and 28 deletions
@@ -0,0 +1,44 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('skus_origin', function (Blueprint $table) {
$table->comment('存储客户原始 SKU 与 业务侧 SKU 的映射信息, 特殊商品如 补差价/锁价券 等,需要手动创建');
$table->bigIncrements('id')->primary()->comment('主键');
$table->integer('company_id')->comment('公司 ID 与 Tools 保持一致');
$table->text('sku')->comment('客户侧提供的 SKU - 作为向客户提供数据报表的基准');
$table->text('hs')->nullable()->comment('海关商品分类编码');
$table->text('barcode')->comment('客户侧提供的 条形码/GTIN 编码');
$table->text('name')->comment('客户侧提供的 产品名称');
$table->text('label')->nullable()->default(null)->comment('客户侧提供的 产品 中文 名称');
$table->text('ledger')->nullable()->default(null)->comment('账册与批次备注');
$table->jsonb('ext')->nullable()->default(null)->comment('扩展字段');
$table->timestampsTz();
// 创建联合唯一索引
$table->unique(['company_id', 'sku'], 'uk_company_sku');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('skus_origin');
}
};
@@ -1,28 +0,0 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('skus', function (Blueprint $table) {
$table->bigIncrements('id');
$table->datetimes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('skus');
}
};
@@ -0,0 +1,46 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('skus_mapping', function (Blueprint $table) {
$table->comment('存储 业务侧 SKU 到 客户原始 SKU 的映射信息, 当平台绑定异常时使用');
$table->bigIncrements('id')->primary()->comment('主键');
$table->integer('company_id')->comment('公司 ID 与 Tools 保持一致');
$table->integer('platform_id')->comment('平台 ID 与 Tools 保持一致');
$table->text('platform_product_id')->comment('平台 商品 ID 与 电商平台 保持一致');
$table->text('origin_sku')->comment('客户侧匹配的 SKU 编码, 组合商品需要拆分');
$table->integer('store_id')->nullable()->comment('店铺 ID 与 Tools 保持一致, 建议填写以方便核对');
$table->integer('warehouse_id')->nullable()->comment('店铺绑定仓库 ID 与 Tools 保持一致,建议填写,建议填写以方便核对');
$table->boolean('enabled')->default(true)->comment('是否启用映射规则,默认为启用');
$table->text('note')->nullable()->default(null)->comment('备注信息');
$table->timestampsTz();
// 创建联合唯一索引
$table->unique(['platform_id', 'platform_product_id', 'origin_sku'], 'uk_platform_product_origin');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('skus_mapping');
}
};