Commit 68f31b2a by Vladislav

#19496 Запрос измененных объявлений

1 parent 27516d79
......@@ -67,6 +67,13 @@ class AdvertisementsAdd extends Command
->whereNull('goal_ad_extensions.external_id')
->whereColumn('goal_advertisements.id', 'goal_advertisement_goal_ad_extensions.goal_advertisement_id');
})
->where(function (Builder $query) {
$query->whereNull('goal_advertisements.goal_v_card_id')
->orWhere(function (Builder $query) {
$query->whereNotNull('goal_advertisements.goal_v_card_id')
->whereNotNull('goal_advertisements.goal_v_card_external_id');
});
})
->whereNull('advertisements.deleted_at')
->whereNull('goal_advertisements.external_id')
->whereNull('goal_advertisements.reserve_create_at')
......@@ -83,7 +90,7 @@ class AdvertisementsAdd extends Command
'advertisements.title2 as title2',
'advertisements.href as href',
'advertisements.display_url_path as display_url_path',
'advertisements.v_card_external_id as v_card_external_id',
'goal_advertisements.goal_v_card_external_id as goal_v_card_external_id',
'advertisements.ad_image_hash as ad_image_hash',
'advertisements.site_link_set_id as site_link_set_id',
DB::raw('JSON_ARRAYAGG(goal_ad_extensions.external_id) as ad_extension_ids'),
......@@ -97,6 +104,10 @@ class AdvertisementsAdd extends Command
->groupBy('goal_advertisements.id')
->get();
if (!$goalAds->count()) {
continue;
}
foreach (array_chunk($goalAds->pluck('id')->toArray(), 1000) as $items) {
GoalAdvertisement::whereIn('id', $items)
->update([
......
......@@ -73,7 +73,7 @@ class AdvertisementsUpdate extends Command
'advertisements.title2 as title2',
'advertisements.href as href',
'advertisements.display_url_path as display_url_path',
'advertisements.v_card_external_id as v_card_external_id',
'goal_advertisements.goal_v_card_external_id as goal_v_card_external_id',
'advertisements.ad_image_hash as ad_image_hash',
'advertisements.site_link_set_id as site_link_set_id',
DB::raw("JSON_OBJECTAGG('AdExtensionId', goal_ad_extensions.external_id, 'Operation', 'SET') as ad_extensions"),
......
......@@ -147,7 +147,7 @@ class AddAds extends DirectRequest
}
if ($goalAdvertisement->v_card_external_id) {
$data['TextAd']['VCardId'] = $goalAdvertisement->v_card_external_id;
$data['TextAd']['VCardId'] = $goalAdvertisement->goal_v_card_external_id;
}
if ($goalAdvertisement->ad_image_hash) {
......
......@@ -130,8 +130,8 @@ class UpdateAds extends DirectRequest
$data['TextAd']['DisplayUrlPath'] = StrReplaceByVariables::getInstance($goalAdvertisement->display_url_path, $list)->get();
}
if ($goalAdvertisement->v_card_external_id) {
$data['TextAd']['VCardId'] = $goalAdvertisement->v_card_external_id;
if ($goalAdvertisement->goal_v_card_external_id) {
$data['TextAd']['VCardId'] = $goalAdvertisement->goal_v_card_external_id;
}
if ($goalAdvertisement->ad_image_hash) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!