84 lines
2.6 KiB
PHP
84 lines
2.6 KiB
PHP
<?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');
|
|
}
|
|
}
|