Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Письменов Дмитрий Иванович
/
yourroomads
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit df9dfe11
authored
Sep 22, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#20794 Сделать чтобы в целевых РК оставалась одна карточка (исрпаввлена сиинхрон…
…изация, удаление объявлений)
1 parent
ed83aacf
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
3 deletions
app/Console/Commands/AdvertisementsDelete.php
app/Console/Commands/DictionaryCampaignsSyncByCampaign.php
app/Service/Requests/Direct/AddAds.php
app/Service/Requests/Direct/UpdateAds.php
app/Console/Commands/AdvertisementsDelete.php
View file @
df9dfe1
...
...
@@ -42,12 +42,12 @@ class AdvertisementsDelete extends Command
*/
public
function
handle
()
{
$tokens
=
Tokens
::
has
(
'dictionaryCampaignsEnabledForExternalSynchronized.goalA
udienceTargetsNeedDelete
ForNotReserveDelete'
)
$tokens
=
Tokens
::
has
(
'dictionaryCampaignsEnabledForExternalSynchronized.goalA
dvertisementsForNeedDeleted
ForNotReserveDelete'
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
get
();
foreach
(
$tokens
as
$token
)
{
$this
->
sendRequest
(
$token
,
$token
->
dictionaryCampaignsEnabledForExternalSynchronized
->
pluck
(
'goalA
udienceTargetsNeedDelete
ForNotReserveDelete'
)
->
collapse
());
$this
->
sendRequest
(
$token
,
$token
->
dictionaryCampaignsEnabledForExternalSynchronized
->
pluck
(
'goalA
dvertisementsForNeedDeleted
ForNotReserveDelete'
)
->
collapse
());
}
return
0
;
...
...
app/Console/Commands/DictionaryCampaignsSyncByCampaign.php
View file @
df9dfe1
...
...
@@ -346,6 +346,66 @@ class DictionaryCampaignsSyncByCampaign extends Command
"
);
$this
->
info
(
'goal_bid_modifiers successful!'
);
//обновляем ключ компании в директ, если поо какйто причине не был установлен
DB
::
update
(
"
UPDATE goal_ad_groups gag
INNER JOIN dictionary_campaigns dc ON dc.id = gag.dictionary_campaign_id AND dc.external_id IS NOT NULL AND dc.deleted_at IS NULL
SET gag.dictionary_campaign_external_id = dc.external_id,
gag.updated_at = CURRENT_TIMESTAMP
WHERE gag.deleted_at IS NULL
AND gag.dictionary_campaign_external_id IS NULL
"
);
$this
->
info
(
'update goal_ad_groups.dictionary_campaign_external_id successful!'
);
DB
::
update
(
"
UPDATE goal_keywords gk
INNER JOIN dictionary_campaigns dc ON dc.id = gk.dictionary_campaign_id AND dc.external_id IS NOT NULL AND dc.deleted_at IS NULL
SET gk.dictionary_campaign_external_id = dc.external_id,
gk.updated_at = CURRENT_TIMESTAMP
WHERE gk.dictionary_campaign_external_id IS NULL
"
);
$this
->
info
(
'update goal_keywords.dictionary_campaign_external_id successful!'
);
DB
::
update
(
"
UPDATE goal_advertisements ga
INNER JOIN dictionary_campaigns dc ON dc.id = ga.dictionary_campaign_id AND dc.external_id IS NOT NULL AND dc.deleted_at IS NULL
SET ga.dictionary_campaign_external_id = dc.external_id,
ga.updated_at = CURRENT_TIMESTAMP
WHERE ga.deleted_at IS NULL
AND ga.dictionary_campaign_external_id IS NULL
"
);
$this
->
info
(
'update goal_advertisements.dictionary_campaign_external_id successful!'
);
DB
::
update
(
"
UPDATE goal_bid_modifiers gbm
INNER JOIN dictionary_campaigns dc ON dc.id = gbm.dictionary_campaign_id AND dc.external_id IS NOT NULL AND dc.deleted_at IS NULL
SET gbm.dictionary_campaign_external_id = dc.external_id,
gbm.updated_at = CURRENT_TIMESTAMP
WHERE gbm.deleted_at IS NULL
AND gbm.dictionary_campaign_external_id IS NULL
"
);
$this
->
info
(
'update goal_bid_modifiers.dictionary_campaign_external_id successful!'
);
DB
::
update
(
"
UPDATE goal_v_cards gvc
INNER JOIN dictionary_campaigns dc ON dc.id = gvc.dictionary_campaign_id AND dc.external_id IS NOT NULL AND dc.deleted_at IS NULL
SET gvc.dictionary_campaign_external_id = dc.external_id,
gvc.updated_at = CURRENT_TIMESTAMP
WHERE gvc.deleted_at IS NULL
AND gvc.dictionary_campaign_external_id IS NULL
"
);
$this
->
info
(
'update goal_v_cards.dictionary_campaign_external_id successful!'
);
DB
::
update
(
"
UPDATE goal_audience_targets gat
INNER JOIN dictionary_campaigns dc ON dc.id = gat.dictionary_campaign_id AND dc.external_id IS NOT NULL AND dc.deleted_at IS NULL
SET gat.dictionary_campaign_external_id = dc.external_id,
gat.updated_at = CURRENT_TIMESTAMP
WHERE gat.deleted_at IS NULL
AND gat.dictionary_campaign_external_id IS NULL
"
);
$this
->
info
(
'update goal_v_cards.dictionary_campaign_external_id successful!'
);
DictionaryCampaign
::
needSynced
()
->
update
([
'synced_need'
=>
null
,
]);
...
...
app/Service/Requests/Direct/AddAds.php
View file @
df9dfe1
...
...
@@ -80,7 +80,6 @@ class AddAds extends DirectRequest
$model
=
GoalAdvertisement
::
with
(
'goalAdGroup'
)
->
firstWhere
(
'id'
,
$goalAd
->
id
);
if
(
$model
)
{
$model
->
goalVCard
()
->
delete
();
$model
->
forceDelete
();
}
}
...
...
app/Service/Requests/Direct/UpdateAds.php
View file @
df9dfe1
...
...
@@ -70,6 +70,13 @@ class UpdateAds extends DirectRequest
]);
continue
;
}
elseif
(
isset
(
$update_result
[
'Errors'
][
0
][
'Details'
])
&&
$update_result
[
'Errors'
][
0
][
'Details'
]
===
'Ad not found'
)
{
$model
=
GoalAdvertisement
::
whereExternalId
(
$external_id
)
->
first
();
if
(
$model
)
{
$model
->
goalAdGroup
()
->
delete
();
$model
->
delete
();
}
GoalAdvertisement
::
whereExternalId
(
$external_id
)
->
delete
();
continue
;
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment