Files
datahub/backend/app/Model/Store.php
T
2025-12-10 12:56:37 +08:00

92 lines
2.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\DbConnection\Model\Model;
/**
* @property int $id 主键 - 来自远程 和 tools 保持一致
* @property int $company_id 店铺所属的公司 ID
* @property int $platform_id 平台 ID
* @property string $platform_store_id 平台店铺 ID
* @property array $platform_meta 平台店铺扩展信息 如 店铺所属服务商 - 平台应用 id - 平台商家 id, 平台店铺名称-区域 等根据需要补充其他额外信息
* @property int $timezone 平台店铺统计时使用的时区 默认为 +8 表示 北京时间, 如果是日本则是 +7, 填写基于 UTC 的偏移值
* @property array $auth 电商平台开放接口的授权信息(可选)
* @property int $warehouse_id 店铺使用的仓库 ID
* @property int $currency_id 店铺的本币 ID
* @property boolean $enabled 激活状态
* @property string $name 店铺名 英文
* @property string $label 店铺名 中文
* @property array $ext 扩展字段
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
*/
class Store extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'stores';
/**
* Indicates if the IDs are auto-incrementing.
* 由于 ID 来自远程系统,禁用自增
*/
public bool $incrementing = false;
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [
'id',
'company_id',
'platform_id',
'platform_store_id',
'platform_meta',
'timezone',
'auth',
'warehouse_id',
'currency_id',
'enabled',
'name',
'label',
'ext',
'created_at',
'updated_at'
];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = [
'id' => 'integer',
'company_id' => 'integer',
'platform_id' => 'integer',
'platform_meta' => 'array',
'timezone' => 'integer',
'auth' => 'array',
'warehouse_id' => 'integer',
'currency_id' => 'integer',
'enabled' => 'boolean',
'ext' => 'array',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
/**
* 获取标准时区字符串
* 将 UTC 偏移值(如 +8)转换为标准时区格式(如 '+08:00'
*
* @return string 标准时区字符串,可用于 Carbon 和 DateTime
*/
public function getTimezoneString(): string
{
$offset = $this->timezone ?? 0;
$sign = $offset >= 0 ? '+' : '-';
$absOffset = abs($offset);
return sprintf('%s%02d:00', $sign, $absOffset);
}
}