fix(seo-copy): enrich legacy detail play payloads
This commit is contained in:
@@ -1199,6 +1199,10 @@ class VideoService
|
||||
? SeoCopyStore::getPreferredPageData($strHost, $strScene, $arrPageKeys)
|
||||
: [];
|
||||
|
||||
if (!empty($arrData)) {
|
||||
$arrData = $this->mergeLegacySeoCopyWithDefault($strHost, $strScene, $arrPageKeys, $arrData);
|
||||
}
|
||||
|
||||
if (!empty($arrData)) {
|
||||
$arrData = $this->interpolateSeoCopyData($arrData, $this->buildSeoCopyTokens($strScene, $arrOptions));
|
||||
}
|
||||
@@ -1210,6 +1214,57 @@ class VideoService
|
||||
return $this->normalizeSeoCopyBlock($strScene, $arrData);
|
||||
}
|
||||
|
||||
private function mergeLegacySeoCopyWithDefault(string $strHost, string $strScene, array $arrPageKeys, array $arrData): array
|
||||
{
|
||||
if (!in_array($strScene, ['detail', 'play'], true)) {
|
||||
return $arrData;
|
||||
}
|
||||
|
||||
$arrSpecificKeys = array_values(array_filter($arrPageKeys, static function ($strPageKey): bool {
|
||||
$strPageKey = trim((string)$strPageKey);
|
||||
return $strPageKey !== '' && $strPageKey !== 'default';
|
||||
}));
|
||||
|
||||
if (empty($arrSpecificKeys)) {
|
||||
return $arrData;
|
||||
}
|
||||
|
||||
$boolLegacySpecificPayload = empty($arrData['guide_cards'])
|
||||
&& empty($arrData['title_template'])
|
||||
&& empty($arrData['keywords_template'])
|
||||
&& empty($arrData['description_template']);
|
||||
|
||||
if (!$boolLegacySpecificPayload) {
|
||||
return $arrData;
|
||||
}
|
||||
|
||||
$arrDefaultData = SeoCopyStore::getPreferredPageData($strHost, $strScene, ['default']);
|
||||
if (empty($arrDefaultData)) {
|
||||
return $arrData;
|
||||
}
|
||||
|
||||
$arrMerged = array_merge($arrDefaultData, $arrData);
|
||||
|
||||
foreach (['guide_cards', 'title_template', 'keywords_template', 'description_template'] as $strField) {
|
||||
if (empty($arrData[$strField]) && !empty($arrDefaultData[$strField])) {
|
||||
$arrMerged[$strField] = $arrDefaultData[$strField];
|
||||
}
|
||||
}
|
||||
|
||||
$arrLeadMap = [
|
||||
'detail' => ['detail_body_lead', 'detail_play_link_lead', 'detail_body_tail', 'detail_faq'],
|
||||
'play' => ['play_intro', 'play_meta_note', 'play_body_lead', 'play_body_next'],
|
||||
];
|
||||
|
||||
foreach ((array)($arrLeadMap[$strScene] ?? []) as $strField) {
|
||||
if (!empty($arrDefaultData[$strField])) {
|
||||
$arrMerged[$strField] = $arrDefaultData[$strField];
|
||||
}
|
||||
}
|
||||
|
||||
return $arrMerged;
|
||||
}
|
||||
|
||||
/**
|
||||
* BSONDocument / 对象 / array 统一转数组(递归)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user