*/ public const FIELD_LABELS = [ 'name' => '场馆名称', 'venue_type' => '主题', 'venue_types' => '主题(多选)', 'unit_name' => '所属单位', 'district' => '行政区', 'ticket_type' => '门票类型', 'appointment_type' => '预约类型', 'booking_mode' => '预约模式', 'open_mode' => '开放模式', 'open_time' => '开放时间', 'reservation_notice' => '预约须知', 'ticket_content' => '门票说明', 'booking_method' => '预约方式', 'visit_form' => '参观形式', 'consultation_hours' => '咨询预约时间', 'booking_qr_media' => '预约二维码', 'address' => '场馆地址', 'contact_phone' => '联系电话', 'lat' => '纬度', 'lng' => '经度', 'cover_image' => '封面图', 'gallery_media' => '轮播图与视频', 'detail_html' => '场馆详情', 'live_people_count' => '实时在馆人数', 'sort' => '排序', 'is_active' => '上架', 'is_included_in_stats' => '纳入人数统计', ]; /** * @return list */ public static function diff(Venue $venue): array { $snapshot = $venue->last_approved_snapshot; if (! is_array($snapshot) || $snapshot === []) { return []; } $out = []; foreach (Venue::SNAPSHOT_KEYS as $key) { $before = self::normalizeValue($snapshot[$key] ?? null); $after = self::normalizeValue($venue->getAttribute($key)); if ($before === $after) { continue; } $out[] = [ 'field' => $key, 'label' => self::FIELD_LABELS[$key] ?? $key, 'before' => $before, 'after' => $after, ]; } return $out; } private static function normalizeValue(mixed $v): string { if ($v === null) { return ''; } if (is_bool($v)) { return $v ? '是' : '否'; } if (is_array($v)) { if ($v === []) { return ''; } $encoded = json_encode($v, JSON_UNESCAPED_UNICODE); return is_string($encoded) ? $encoded : ''; } return trim((string) $v); } }