'integer', 'item_id' => 'integer', 'admin_user_id' => 'integer', 'adjustment_type' => PriceAdjustmentType::class, 'old_min_price' => 'decimal:5', 'new_min_price' => 'decimal:5', 'old_max_price' => 'decimal:5', 'new_max_price' => 'decimal:5', 'old_protection_threshold' => 'integer', 'new_protection_threshold' => 'integer', 'old_is_enabled' => 'boolean', 'new_is_enabled' => 'boolean', ]; /** * 获取关联的价格配置 */ public function priceConfig(): BelongsTo { return $this->belongsTo(MexPriceConfig::class, 'price_config_id'); } /** * 获取关联的商品信息 */ public function item(): BelongsTo { return $this->belongsTo(Item::class, 'item_id'); } /** * 获取价格变化摘要 */ public function getPriceChangeSummaryAttribute(): string { $changes = []; if ($this->old_min_price !== $this->new_min_price) { $changes[] = "最低价: {$this->old_min_price} → {$this->new_min_price}"; } if ($this->old_max_price !== $this->new_max_price) { $changes[] = "最高价: {$this->old_max_price} → {$this->new_max_price}"; } if ($this->old_protection_threshold !== $this->new_protection_threshold) { $changes[] = "保护阈值: {$this->old_protection_threshold} → {$this->new_protection_threshold}"; } if ($this->old_is_enabled !== $this->new_is_enabled) { $oldStatus = $this->old_is_enabled ? '启用' : '禁用'; $newStatus = $this->new_is_enabled ? '启用' : '禁用'; $changes[] = "状态: {$oldStatus} → {$newStatus}"; } return implode('; ', $changes); } }