add sku mapping
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
use Hyperf\Database\Model\Relations\BelongsTo;
|
||||
use Hyperf\DbConnection\Model\Model;
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
/**
|
||||
* @property int $id 主键
|
||||
* @property int $company_id 公司 ID
|
||||
* @property int $platform_id 平台 ID
|
||||
* @property string $platform_product_id 平台商品 ID
|
||||
* @property string $origin_sku 客户侧匹配的 SKU 编码
|
||||
* @property int|null $origin_sku_id 关联 skus_origin.id
|
||||
* @property string|null $platform_outer_sku 平台侧使用的 SKU 编码
|
||||
* @property string|null $generation_strategy 生成策略记录
|
||||
* @property int|null $store_id 店铺 ID
|
||||
* @property int|null $warehouse_id 仓库 ID
|
||||
* @property boolean $enabled 是否启用
|
||||
* @property string|null $note 备注
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
*/
|
||||
#[OA\Schema(
|
||||
schema: 'SkuMapping',
|
||||
description: 'SKU 平台映射',
|
||||
properties: [
|
||||
new OA\Property(property: 'id', type: 'integer', example: 1),
|
||||
new OA\Property(property: 'company_id', type: 'integer', example: 3),
|
||||
new OA\Property(property: 'platform_id', type: 'integer', example: 1),
|
||||
new OA\Property(property: 'platform_product_id', type: 'string', example: 'ITEM-001'),
|
||||
new OA\Property(property: 'origin_sku', type: 'string', example: '0032'),
|
||||
new OA\Property(property: 'origin_sku_id', type: 'integer', nullable: true, example: 1),
|
||||
new OA\Property(property: 'platform_outer_sku', type: 'string', nullable: true, example: 'C03_0032'),
|
||||
new OA\Property(property: 'generation_strategy', type: 'string', nullable: true, example: 'prefix:C03'),
|
||||
new OA\Property(property: 'store_id', type: 'integer', nullable: true, example: 101),
|
||||
new OA\Property(property: 'warehouse_id', type: 'integer', nullable: true, example: 1),
|
||||
new OA\Property(property: 'enabled', type: 'boolean', example: true),
|
||||
new OA\Property(property: 'note', type: 'string', nullable: true, example: '用于 Shopee 马来站'),
|
||||
new OA\Property(property: 'created_at', type: 'string', format: 'date-time'),
|
||||
new OA\Property(property: 'updated_at', type: 'string', format: 'date-time'),
|
||||
]
|
||||
)]
|
||||
class SkuMapping extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'skus_mapping';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = [
|
||||
'company_id',
|
||||
'platform_id',
|
||||
'platform_product_id',
|
||||
'origin_sku',
|
||||
'origin_sku_id',
|
||||
'platform_outer_sku',
|
||||
'generation_strategy',
|
||||
'store_id',
|
||||
'warehouse_id',
|
||||
'enabled',
|
||||
'note',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*/
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
'company_id' => 'integer',
|
||||
'platform_id' => 'integer',
|
||||
'origin_sku_id' => 'integer',
|
||||
'store_id' => 'integer',
|
||||
'warehouse_id' => 'integer',
|
||||
'enabled' => 'boolean',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class, 'company_id');
|
||||
}
|
||||
|
||||
public function platform(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Platform::class, 'platform_id');
|
||||
}
|
||||
|
||||
public function store(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Store::class, 'store_id');
|
||||
}
|
||||
|
||||
public function skuOrigin(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SkuOrigin::class, 'origin_sku_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
use Hyperf\Database\Model\Relations\BelongsTo;
|
||||
use Hyperf\Database\Model\Relations\HasMany;
|
||||
use Hyperf\DbConnection\Model\Model;
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
/**
|
||||
* @property int $id 主键
|
||||
* @property int $company_id 公司 ID
|
||||
* @property string $sku 客户侧提供的 SKU
|
||||
* @property string|null $hs 海关商品分类编码
|
||||
* @property string $barcode 条形码/GTIN
|
||||
* @property string $name 产品名称(英文)
|
||||
* @property string|null $label 产品名称(中文)
|
||||
* @property string|null $ledger 账册与批次备注
|
||||
* @property array|null $ext 扩展字段
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
*/
|
||||
#[OA\Schema(
|
||||
schema: 'SkuOrigin',
|
||||
description: '客户内部 SKU',
|
||||
properties: [
|
||||
new OA\Property(property: 'id', type: 'integer', example: 1),
|
||||
new OA\Property(property: 'company_id', type: 'integer', example: 3),
|
||||
new OA\Property(property: 'sku', type: 'string', example: '0032'),
|
||||
new OA\Property(property: 'hs', type: 'string', nullable: true, example: '6403990090'),
|
||||
new OA\Property(property: 'barcode', type: 'string', example: '6901234567890'),
|
||||
new OA\Property(property: 'name', type: 'string', example: 'Running Shoes Model A'),
|
||||
new OA\Property(property: 'label', type: 'string', nullable: true, example: '跑步鞋 A 款'),
|
||||
new OA\Property(property: 'ledger', type: 'string', nullable: true, example: '批次 2026-Q1'),
|
||||
new OA\Property(property: 'ext', type: 'object', nullable: true, description: '扩展字段'),
|
||||
new OA\Property(property: 'created_at', type: 'string', format: 'date-time'),
|
||||
new OA\Property(property: 'updated_at', type: 'string', format: 'date-time'),
|
||||
]
|
||||
)]
|
||||
class SkuOrigin extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'skus_origin';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = [
|
||||
'company_id',
|
||||
'sku',
|
||||
'hs',
|
||||
'barcode',
|
||||
'name',
|
||||
'label',
|
||||
'ledger',
|
||||
'ext',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*/
|
||||
protected array $casts = [
|
||||
'id' => 'integer',
|
||||
'company_id' => 'integer',
|
||||
'ext' => 'json',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class, 'company_id');
|
||||
}
|
||||
|
||||
public function mappings(): HasMany
|
||||
{
|
||||
return $this->hasMany(SkuMapping::class, 'origin_sku_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user