diff --git a/backend/app/Model/Store.php b/backend/app/Model/Store.php index 81b100a..52201f7 100644 --- a/backend/app/Model/Store.php +++ b/backend/app/Model/Store.php @@ -13,6 +13,7 @@ use Hyperf\DbConnection\Model\Model; * @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 激活状态 @@ -45,6 +46,7 @@ class Store extends Model 'platform_store_id', 'platform_meta', 'timezone', + 'auth', 'warehouse_id', 'currency_id', 'enabled', @@ -64,6 +66,7 @@ class Store extends Model 'platform_id' => 'integer', 'platform_meta' => 'array', 'timezone' => 'integer', + 'auth' => 'array', 'warehouse_id' => 'integer', 'currency_id' => 'integer', 'enabled' => 'boolean', diff --git a/backend/migrations/2025_12_03_155531_add_platform_meta_and_timezone_to_stores_table.php b/backend/migrations/2025_12_03_155531_update_stores_table.php similarity index 73% rename from backend/migrations/2025_12_03_155531_add_platform_meta_and_timezone_to_stores_table.php rename to backend/migrations/2025_12_03_155531_update_stores_table.php index e91244a..638af90 100644 --- a/backend/migrations/2025_12_03_155531_add_platform_meta_and_timezone_to_stores_table.php +++ b/backend/migrations/2025_12_03_155531_update_stores_table.php @@ -24,10 +24,17 @@ return new class extends Migration ->default(8) ->after('platform_meta') ->comment('平台店铺统计时使用的时区 默认为 +8 表示 北京时间, 如果是日本则是 +7, 填写基于 UTC 的偏移值'); + + // 在 timezone 后添加 auth 字段 + $table->jsonb('auth') + ->nullable() + ->after('timezone') + ->comment('电商平台开放接口的授权信息(可选)'); }); - // 为 platform_meta JSONB 字段创建 GIN 索引,支持高效的 JSON 查询 + // 为 JSONB 字段创建 GIN 索引,支持高效的 JSON 查询 Db::statement('CREATE INDEX idx_stores_platform_meta ON stores USING GIN (platform_meta)'); + Db::statement('CREATE INDEX idx_stores_auth ON stores USING GIN (auth)'); } /** @@ -37,10 +44,11 @@ return new class extends Migration { // 删除 GIN 索引 Db::statement('DROP INDEX IF EXISTS idx_stores_platform_meta'); + Db::statement('DROP INDEX IF EXISTS idx_stores_auth'); Schema::table('stores', function (Blueprint $table) { // 删除添加的字段 - $table->dropColumn(['platform_meta', 'timezone']); + $table->dropColumn(['platform_meta', 'timezone', 'auth']); }); } };