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 5643bc09
authored
Sep 16, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#20794
1 parent
7ca13fc3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
433 additions
and
165 deletions
app/Console/Commands/DictionaryCampaignsSyncByCampaign.php
app/Models/Advertisement.php
app/Models/Pivots/DictionaryCampaign.php
app/Models/Pivots/GoalAdExtension.php
app/Models/Pivots/GoalAdGroup.php
app/Models/Pivots/GoalBidModifier.php
app/Models/Pivots/GoalNegativeKeywordSharedSet.php
app/Models/Pivots/GoalSitelink.php
app/Models/VCard.php
app/Service/Requests/Direct/AddAdExtensions.php
app/Service/Requests/Direct/AddAdGroups.php
app/Service/Requests/Direct/AddAdImages.php
app/Service/Requests/Direct/AddAds.php
app/Service/Requests/Direct/AddAudienceTargets.php
app/Service/Requests/Direct/AddBidModifiers.php
app/Service/Requests/Direct/AddCampaigns.php
app/Service/Requests/Direct/AddKeywords.php
app/Service/Requests/Direct/AddNegativeKeywordSharedSets.php
app/Service/Requests/Direct/AddRetargetinglists.php
app/Service/Requests/Direct/AddSitelinks.php
app/Service/Requests/Direct/AddVCards.php
app/Service/Requests/Direct/ArchiveAds.php
app/Service/Requests/Direct/DeleteAdGroups.php
app/Service/Requests/Direct/DeleteAudienceTarget.php
app/Service/Requests/Direct/DeleteBidModifiers.php
app/Service/Requests/Direct/DeleteKeywords.php
app/Service/Requests/Direct/DeleteVCards.php
app/Service/Requests/Direct/ResumeCampaigns.php
app/Service/Requests/Direct/SetBidModifiers.php
app/Service/Requests/Direct/SuspendCampaigns.php
app/Service/Requests/Direct/UpdateAdGroups.php
app/Service/Requests/Direct/UpdateAds.php
app/Service/Requests/Direct/UpdateCampaigns.php
app/Service/Requests/Direct/UpdateKeywords.php
app/Service/Requests/Direct/UpdateNegativeKeywordSharedSets.php
app/Service/Requests/Direct/UpdateRetargetinglists.php
app/Console/Commands/DictionaryCampaignsSyncByCampaign.php
View file @
5643bc0
This diff is collapsed.
Click to expand it.
app/Models/Advertisement.php
View file @
5643bc0
...
...
@@ -248,4 +248,9 @@ class Advertisement extends Model
->
withTimestamps
();
}
public
function
errors
()
{
return
$this
->
morphMany
(
YandexError
::
class
,
'cause'
);
}
}
app/Models/Pivots/DictionaryCampaign.php
View file @
5643bc0
...
...
@@ -5,6 +5,7 @@ namespace App\Models\Pivots;
use
App\Models\Campaigns
;
use
App\Models\Dictionary
;
use
App\Models\Variable
;
use
App\Models\YandexError
;
use
Carbon\Carbon
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Database\Eloquent\Relations\Pivot
;
...
...
@@ -574,4 +575,9 @@ class DictionaryCampaign extends Pivot
return
$this
->
goalAudienceTargets
()
->
needDeleted
()
->
forNotReserveDelete
();
}
public
function
errors
()
{
return
$this
->
morphMany
(
YandexError
::
class
,
'cause'
);
}
}
app/Models/Pivots/GoalAdExtension.php
View file @
5643bc0
...
...
@@ -3,6 +3,7 @@
namespace
App\Models\Pivots
;
use
App\Models\AdExtension
;
use
App\Models\YandexError
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Database\Eloquent\Relations\Pivot
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
...
...
@@ -99,4 +100,9 @@ class GoalAdExtension extends Pivot
return
$this
->
belongsTo
(
AdExtension
::
class
,
'ad_extension_id'
);
}
public
function
errors
()
{
return
$this
->
morphMany
(
YandexError
::
class
,
'cause'
);
}
}
app/Models/Pivots/GoalAdGroup.php
View file @
5643bc0
...
...
@@ -5,6 +5,7 @@ namespace App\Models\Pivots;
use
App\Models\AdGroup
;
use
App\Models\BidModifier
;
use
App\Models\Variable
;
use
App\Models\YandexError
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Database\Eloquent\Relations\Pivot
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
...
...
@@ -253,4 +254,9 @@ class GoalAdGroup extends Pivot
return
$this
->
hasMany
(
GoalAudienceTarget
::
class
,
'goal_ad_group_id'
);
}
public
function
errors
()
{
return
$this
->
morphMany
(
YandexError
::
class
,
'cause'
);
}
}
app/Models/Pivots/GoalBidModifier.php
View file @
5643bc0
...
...
@@ -3,6 +3,7 @@
namespace
App\Models\Pivots
;
use
App\Models\BidModifier
;
use
App\Models\YandexError
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Database\Eloquent\Relations\Pivot
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
...
...
@@ -140,4 +141,9 @@ class GoalBidModifier extends Pivot
return
$this
->
belongsTo
(
DictionaryCampaign
::
class
,
'dictionary_campaign_id'
);
}
public
function
errors
()
{
return
$this
->
morphMany
(
YandexError
::
class
,
'cause'
);
}
}
app/Models/Pivots/GoalNegativeKeywordSharedSet.php
View file @
5643bc0
...
...
@@ -4,6 +4,7 @@ namespace App\Models\Pivots;
use
App\Models\AdExtension
;
use
App\Models\NegativeKeywordSharedSet
;
use
App\Models\YandexError
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Database\Eloquent\Relations\Pivot
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
...
...
@@ -100,4 +101,9 @@ class GoalNegativeKeywordSharedSet extends Pivot
return
$this
->
belongsTo
(
NegativeKeywordSharedSet
::
class
,
'negative_keyword_shared_set_id'
);
}
public
function
errors
()
{
return
$this
->
morphMany
(
YandexError
::
class
,
'cause'
);
}
}
app/Models/Pivots/GoalSitelink.php
View file @
5643bc0
...
...
@@ -3,6 +3,7 @@
namespace
App\Models\Pivots
;
use
App\Models\Sitelink
;
use
App\Models\YandexError
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Database\Eloquent\Relations\Pivot
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
...
...
@@ -104,4 +105,9 @@ class GoalSitelink extends Pivot
return
$this
->
hasMany
(
GoalAdvertisement
::
class
,
'goal_sitelink_id'
);
}
public
function
errors
()
{
return
$this
->
morphMany
(
YandexError
::
class
,
'cause'
);
}
}
app/Models/VCard.php
View file @
5643bc0
...
...
@@ -89,4 +89,9 @@ class VCard extends Model
return
$this
->
hasMany
(
GoalAdvertisement
::
class
,
'v_card_id'
);
}
public
function
errors
()
{
return
$this
->
morphMany
(
YandexError
::
class
,
'cause'
);
}
}
app/Service/Requests/Direct/AddAdExtensions.php
View file @
5643bc0
...
...
@@ -58,9 +58,22 @@ class AddAdExtensions extends DirectRequest
$goalAdExtension
=
$this
->
goalAdExtensions
->
get
(
$key
);
if
(
!
isset
(
$add_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'AdExtensions'
][
$key
];
if
(
isset
(
$add_result
[
'Errors'
])
&&
count
(
$add_result
[
'Errors'
]))
{
$goalAdExtension
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$data
,
'errors'
=>
$add_result
[
'Errors'
],
]);
}
else
{
Log
::
debug
(
"AddAdExtension, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$add_result
);
Log
::
debug
(
$this
->
getParams
()[
'AdExtensions'
][
$key
]);
Log
::
debug
(
$data
);
}
GoalAdExtension
::
where
(
'id'
,
$goalAdExtension
->
getKey
())
->
update
([
...
...
app/Service/Requests/Direct/AddAdGroups.php
View file @
5643bc0
...
...
@@ -58,9 +58,22 @@ class AddAdGroups extends DirectRequest
$goalAdGroup
=
$this
->
goalAdGroups
->
get
(
$key
);
if
(
!
isset
(
$add_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'AdGroups'
][
$key
];
if
(
isset
(
$add_result
[
'Errors'
])
&&
count
(
$add_result
[
'Errors'
]))
{
$goalAdGroup
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$data
,
'errors'
=>
$add_result
[
'Errors'
],
]);
}
else
{
Log
::
debug
(
"AddAdGroup, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$add_result
);
Log
::
debug
(
$this
->
getParams
()[
'AdGroups'
][
$key
]);
Log
::
debug
(
$data
);
}
GoalAdGroup
::
where
(
'id'
,
$goalAdGroup
->
getKey
())
->
update
([
...
...
app/Service/Requests/Direct/AddAdImages.php
View file @
5643bc0
...
...
@@ -55,10 +55,10 @@ class AddAdImages extends DirectRequest
$goalAdImage
=
$this
->
goalAdImages
->
get
(
$key
);
$data
=
$this
->
getParams
()[
'AdImages'
][
$key
];
if
(
!
isset
(
$add_result
[
'AdImageHash'
]))
{
$data
=
$this
->
getParams
()[
'AdImages'
][
$key
];
if
(
isset
(
$add_result
[
'Errors'
])
&&
count
(
$add_result
[
'Errors'
]))
{
$goalAdImage
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
...
...
@@ -67,19 +67,11 @@ class AddAdImages extends DirectRequest
'params'
=>
[
'Name'
=>
$data
[
'Name'
]],
'errors'
=>
$add_result
[
'Errors'
],
]);
GoalAdImage
::
where
(
'id'
,
$goalAdImage
->
getKey
())
->
update
([
'reserve_create_at'
=>
null
,
]);
continue
;
}
}
else
{
Log
::
debug
(
"AddAdImage, empty AdImageHash, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$add_result
);
Log
::
debug
(
$data
[
'Name'
]);
}
GoalAdImage
::
where
(
'id'
,
$goalAdImage
->
getKey
())
->
update
([
...
...
app/Service/Requests/Direct/AddAds.php
View file @
5643bc0
...
...
@@ -59,10 +59,10 @@ class AddAds extends DirectRequest
/* @var $goalAd GoalAdvertisement|Advertisement|\stdClass */
$goalAd
=
$this
->
goalAds
->
get
(
$key
);
$data
=
$this
->
getParams
()[
'Ads'
][
$key
];
if
(
!
isset
(
$add_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'Ads'
][
$key
];
if
(
isset
(
$add_result
[
'Errors'
][
0
][
'Code'
])
&&
...
...
@@ -80,15 +80,11 @@ class AddAds extends DirectRequest
$model
=
GoalAdvertisement
::
with
(
'goalAdGroup'
)
->
firstWhere
(
'id'
,
$goalAd
->
id
);
if
(
$model
)
{
if
(
$model
->
goalAdGroup
)
{
$model
->
goalAdGroup
->
delete
();
}
$model
->
goalVCard
()
->
delete
();
$model
->
forceDelete
();
}
}
continue
;
}
elseif
(
isset
(
$add_result
[
'Errors'
][
0
][
'Code'
])
&&
...
...
@@ -106,36 +102,28 @@ class AddAds extends DirectRequest
$model
=
GoalAdvertisement
::
with
(
'goalAdGroup'
)
->
firstWhere
(
'id'
,
$goalAd
->
id
);
if
(
$model
)
{
if
(
$model
->
goalVCard
)
{
$model
->
goalVCard
->
delete
();
}
$model
->
goalVCard
()
->
delete
();
$model
->
forceDelete
();
}
}
continue
;
}
elseif
(
isset
(
$add_result
[
'Errors'
])
&&
count
(
$add_result
[
'Errors'
]))
{
$goalAd
->
errors
()
->
create
([
$model
=
GoalAdvertisement
::
with
(
'goalAdGroup'
)
->
firstWhere
(
'id'
,
$goalAd
->
id
);
if
(
$model
)
{
$model
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$data
,
'errors'
=>
$add_result
[
'Errors'
],
]);
GoalAdvertisement
::
whereId
(
$goalAd
->
id
)
->
update
([
'reserve_create_at'
=>
null
,
]);
continue
;
}
}
else
{
Log
::
debug
(
"AddAds, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$add_result
);
Log
::
debug
(
$data
);
}
GoalAdvertisement
::
whereId
(
$goalAd
->
id
)
->
update
([
...
...
app/Service/Requests/Direct/AddAudienceTargets.php
View file @
5643bc0
...
...
@@ -55,10 +55,10 @@ class AddAudienceTargets extends DirectRequest
$goalAudienceTarget
=
$this
->
goalAudienceTargets
->
get
(
$key
);
$data
=
$this
->
getParams
()[
'AudienceTargets'
][
$key
];
if
(
!
isset
(
$add_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'AudienceTargets'
][
$key
];
if
(
isset
(
$add_result
[
'Errors'
][
0
][
'Message'
])
&&
$add_result
[
'Errors'
][
0
][
'Message'
]
===
'Object not found'
)
{
GoalAudienceTarget
::
where
(
'id'
,
$goalAudienceTarget
->
getKey
())
->
forceDelete
();
...
...
app/Service/Requests/Direct/AddBidModifiers.php
View file @
5643bc0
...
...
@@ -59,9 +59,26 @@ class AddBidModifiers extends DirectRequest
$ids
=
json_decode
(
$goalBidModifier
->
ids
);
if
(
!
isset
(
$add_result
[
'Ids'
]))
{
$data
=
$this
->
getParams
()[
'BidModifiers'
][
$key
];
if
(
isset
(
$add_result
[
'Errors'
])
&&
count
(
$add_result
[
'Errors'
]))
{
$model
=
GoalBidModifier
::
whereIn
(
'id'
,
$ids
)
->
first
();
if
(
$model
)
{
$model
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$data
,
'errors'
=>
$add_result
[
'Errors'
],
]);
}
}
else
{
Log
::
debug
(
"AddBidModifiers, empty Ids, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$add_result
);
Log
::
debug
(
$this
->
getParams
()[
'BidModifiers'
][
$key
]);
Log
::
debug
(
$data
);
}
GoalBidModifier
::
whereIn
(
'id'
,
$ids
)
->
update
([
...
...
app/Service/Requests/Direct/AddCampaigns.php
View file @
5643bc0
...
...
@@ -60,14 +60,24 @@ class AddCampaigns extends DirectRequest
if
(
!
isset
(
$add_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'Campaigns'
][
$key
];
if
(
isset
(
$add_result
[
'Errors'
])
&&
count
(
$add_result
[
'Errors'
]))
{
$dictionaryCampaign
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$data
,
'errors'
=>
$add_result
[
'Errors'
],
]);
}
else
{
Log
::
debug
(
"AddCampaigns, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$add_result
);
Log
::
debug
(
$this
->
getParams
()[
'Campaigns'
][
$key
]);
Log
::
debug
(
$data
);
}
DictionaryCampaign
::
whereExternalId
(
$dictionaryCampaign
->
external_id
)
->
update
([
'reserve_create_at'
=>
null
,
]);
$dictionaryCampaign
->
update
([
DictionaryCampaign
::
where
(
'id'
,
$dictionaryCampaign
->
getKey
())
->
update
([
'reserve_create_at'
=>
null
,
]);
...
...
@@ -76,7 +86,8 @@ class AddCampaigns extends DirectRequest
$external_id
=
(
string
)
$add_result
[
'Id'
];
DictionaryCampaign
::
whereExternalId
(
$external_id
)
->
update
([
DictionaryCampaign
::
where
(
'id'
,
$dictionaryCampaign
->
getKey
())
->
update
([
'external_id'
=>
$external_id
,
'external_upload_at'
=>
Carbon
::
now
(),
'reserve_create_at'
=>
null
,
]);
...
...
app/Service/Requests/Direct/AddKeywords.php
View file @
5643bc0
...
...
@@ -18,7 +18,7 @@ class AddKeywords extends DirectRequest
protected
$max_count
=
1000
;
protected
$timestamp
;
/* @var Collection|
GoalKeyword[]|Keyword[]|
\stdClass[] */
/* @var Collection|\stdClass[] */
protected
$goalKeywords
;
public
function
call
(
$params
=
null
)
...
...
@@ -50,7 +50,6 @@ class AddKeywords extends DirectRequest
public
function
handle
(
$response
)
{
try
{
if
(
!
isset
(
$response
[
'result'
][
'AddResults'
]))
{
return
;
}
...
...
@@ -59,10 +58,10 @@ class AddKeywords extends DirectRequest
$goalKeyword
=
$this
->
goalKeywords
[
$key
];
$data
=
$this
->
getParams
()[
'Keywords'
][
$key
];
if
(
!
isset
(
$add_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'Keywords'
][
$key
];
if
(
isset
(
$add_result
[
'Errors'
][
0
][
'Code'
])
&&
...
...
@@ -75,13 +74,9 @@ class AddKeywords extends DirectRequest
$model
=
GoalKeyword
::
with
(
'goalAdGroup'
)
->
firstWhere
(
'id'
,
$goalKeyword
->
id
);
if
(
$model
)
{
if
(
$model
->
goalAdGroup
)
{
$model
->
goalAdGroup
->
delete
();
}
$model
->
goalAdGroup
()
->
delete
();
$model
->
delete
();
}
continue
;
}
elseif
(
isset
(
$add_result
[
'Errors'
])
&&
count
(
$add_result
[
'Errors'
]))
{
$model
=
GoalKeyword
::
whereId
(
$goalKeyword
->
id
)
->
first
();
...
...
@@ -93,16 +88,12 @@ class AddKeywords extends DirectRequest
'params'
=>
$data
,
'errors'
=>
$add_result
[
'Errors'
],
]);
$model
->
update
([
'reserve_create_at'
=>
null
,
]);
continue
;
}
}
}
else
{
Log
::
debug
(
"AddKeywords, empty Id"
);
Log
::
debug
(
$add_result
);
Log
::
debug
(
$data
);
}
GoalKeyword
::
whereId
(
$goalKeyword
->
id
)
->
update
([
...
...
@@ -122,10 +113,6 @@ class AddKeywords extends DirectRequest
]);
}
}
catch
(
\Exception
$e
)
{
Log
::
debug
(
$e
);
throw
$e
;
}
}
public
function
putParams
(
$params
)
...
...
@@ -155,7 +142,7 @@ class AddKeywords extends DirectRequest
$this
->
setParams
([
'Keywords'
=>
$this
->
goalKeywords
->
map
(
function
(
$goalKeyword
)
use
(
$variables
,
&
$lists
)
{
/* @var $goalKeyword
GoalKeyword|Keyword|
\stdClass */
/* @var $goalKeyword \stdClass */
if
(
!
isset
(
$lists
[
$goalKeyword
->
dictionary_campaign_id
]))
{
$list
=
Variable
::
getListVariablesByDictionaryCampaign
(
$goalKeyword
->
dictionary_campaign_id
,
$variables
);
...
...
app/Service/Requests/Direct/AddNegativeKeywordSharedSets.php
View file @
5643bc0
...
...
@@ -59,11 +59,24 @@ class AddNegativeKeywordSharedSets extends DirectRequest
$goalNegativeKeywordSharedSet
=
$this
->
goalNegativeKeywordSharedSets
->
get
(
$key
);
if
(
!
isset
(
$add_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'NegativeKeywordSharedSets'
][
$key
];
if
(
isset
(
$add_result
[
'Errors'
])
&&
count
(
$add_result
[
'Errors'
]))
{
$goalNegativeKeywordSharedSet
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$data
,
'errors'
=>
$add_result
[
'Errors'
],
]);
}
else
{
Log
::
debug
(
"AddNegativeKeywordSharedSet, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$add_result
);
Log
::
debug
(
$this
->
getParams
()[
'NegativeKeywordSharedSets'
][
$key
]);
Log
::
debug
(
$data
);
}
GoalNegativeKeywordSharedSet
::
where
(
'id'
,
$goalNegativeKeywordSharedSet
->
id
)
GoalNegativeKeywordSharedSet
::
where
(
'id'
,
$goalNegativeKeywordSharedSet
->
getKey
()
)
->
update
([
'reserve_create_at'
=>
null
,
]);
...
...
app/Service/Requests/Direct/AddRetargetinglists.php
View file @
5643bc0
...
...
@@ -57,10 +57,10 @@ class AddRetargetinglists extends DirectRequest
$goalRetargetinglist
=
$this
->
goalRetargetinglists
->
get
(
$key
);
$data
=
$this
->
getParams
()[
'RetargetingLists'
][
$key
];
if
(
!
isset
(
$add_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'RetargetingLists'
][
$key
];
if
(
isset
(
$add_result
[
'Errors'
])
&&
count
(
$add_result
[
'Errors'
]))
{
$goalRetargetinglist
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
...
...
@@ -69,19 +69,11 @@ class AddRetargetinglists extends DirectRequest
'params'
=>
$data
,
'errors'
=>
$add_result
[
'Errors'
],
]);
GoalRetargetinglist
::
whereId
(
$goalRetargetinglist
->
id
)
->
update
([
'reserve_create_at'
=>
null
,
]);
continue
;
}
}
else
{
Log
::
debug
(
"AddRetargetinglist, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$add_result
);
Log
::
debug
(
$data
);
}
GoalRetargetinglist
::
where
(
'id'
,
$goalRetargetinglist
->
getKey
())
->
update
([
...
...
app/Service/Requests/Direct/AddSitelinks.php
View file @
5643bc0
...
...
@@ -58,11 +58,25 @@ class AddSitelinks extends DirectRequest
$goalSitelink
=
$this
->
goalSitelinks
->
get
(
$key
);
if
(
!
isset
(
$add_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'SitelinksSets'
][
$key
];
if
(
isset
(
$add_result
[
'Errors'
])
&&
count
(
$add_result
[
'Errors'
]))
{
$goalSitelink
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$data
,
'errors'
=>
$add_result
[
'Errors'
],
]);
}
else
{
Log
::
debug
(
"AddSitelink, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$add_result
);
Log
::
debug
(
$this
->
getParams
()[
'SitelinksSets'
][
$key
]);
Log
::
debug
(
$data
);
}
$goalSitelink
->
update
([
GoalSitelink
::
where
(
'id'
,
$goalSitelink
->
getKey
())
->
update
([
'reserve_create_at'
=>
null
,
]);
...
...
@@ -71,7 +85,8 @@ class AddSitelinks extends DirectRequest
$external_id
=
(
string
)
$add_result
[
'Id'
];
$goalSitelink
->
update
([
GoalSitelink
::
where
(
'id'
,
$goalSitelink
->
getKey
())
->
update
([
'external_id'
=>
$external_id
,
'external_upload_at'
=>
Carbon
::
now
(),
'reserve_create_at'
=>
null
,
...
...
app/Service/Requests/Direct/AddVCards.php
View file @
5643bc0
...
...
@@ -58,11 +58,25 @@ class AddVCards extends DirectRequest
$goalVCard
=
$this
->
goalVCards
->
get
(
$key
);
if
(
!
isset
(
$add_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'VCards'
][
$key
];
if
(
isset
(
$add_result
[
'Errors'
])
&&
count
(
$add_result
[
'Errors'
]))
{
$goalVCard
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$data
,
'errors'
=>
$add_result
[
'Errors'
],
]);
}
else
{
Log
::
debug
(
"AddNegativeKeywordSharedSet, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$add_result
);
Log
::
debug
(
$this
->
getParams
()[
'VCards'
][
$key
]);
Log
::
debug
(
$data
);
}
$goalVCard
->
update
([
GoalVCard
::
where
(
'id'
,
$goalVCard
->
getKey
())
->
update
([
'reserve_create_at'
=>
null
,
]);
...
...
@@ -71,7 +85,8 @@ class AddVCards extends DirectRequest
$external_id
=
(
string
)
$add_result
[
'Id'
];
$goalVCard
->
update
([
GoalVCard
::
where
(
'id'
,
$goalVCard
->
getKey
())
->
update
([
'external_id'
=>
$external_id
,
'external_upload_at'
=>
Carbon
::
now
(),
'reserve_create_at'
=>
null
,
...
...
app/Service/Requests/Direct/ArchiveAds.php
View file @
5643bc0
...
...
@@ -70,13 +70,26 @@ class ArchiveAds extends DirectRequest
'reserve_archive_at'
=>
null
,
]);
}
continue
;
}
elseif
(
isset
(
$archive_result
[
'Errors'
])
&&
count
(
$archive_result
[
'Errors'
]))
{
if
(
$this
->
getToken
()
->
isMain
())
{
$model
=
Advertisement
::
whereExternalId
(
$external_id
)
->
first
();
}
else
{
$model
=
GoalAdvertisement
::
whereExternalId
(
$external_id
)
->
first
();
}
if
(
$model
)
{
$model
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$external_id
,
'errors'
=>
$archive_result
[
'Errors'
],
]);
}
}
else
{
Log
::
debug
(
"ArchiveAds, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$archive_result
);
Log
::
debug
(
$external_id
);
}
if
(
$this
->
getToken
()
->
isMain
())
{
...
...
app/Service/Requests/Direct/DeleteAdGroups.php
View file @
5643bc0
...
...
@@ -38,18 +38,32 @@ class DeleteAdGroups extends DirectRequest
}
foreach
(
$response
[
'result'
][
'DeleteResults'
]
as
$key
=>
$delete_result
)
{
if
(
!
isset
(
$delete_result
[
'Id'
]))
{
Log
::
debug
(
"DeleteAdGroups, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$delete_result
);
Log
::
debug
(
$this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
][
$key
]);
$external_id
=
$this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
][
$key
];
if
(
$delete_result
[
'Errors'
][
0
][
'Code'
]
==
8800
)
{
if
(
$external_id
=
$this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
][
$key
])
{
GoalAdGroup
::
where
(
'external_id'
,
$external_id
)
->
delete
();
}
elseif
(
isset
(
$delete_result
[
'Errors'
])
&&
count
(
$delete_result
[
'Errors'
]))
{
$model
=
GoalAdGroup
::
whereExternalId
(
$external_id
)
->
first
();
if
(
$model
)
{
$model
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$external_id
,
'errors'
=>
$delete_result
[
'Errors'
],
]);
}
}
else
{
Log
::
debug
(
"DeleteAdGroups, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$delete_result
);
Log
::
debug
(
$external_id
);
}
GoalAdGroup
::
where
(
'external_id'
,
$
this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
][
$key
]
)
GoalAdGroup
::
where
(
'external_id'
,
$
external_id
)
->
update
([
'reserve_delete_at'
=>
null
,
]);
...
...
app/Service/Requests/Direct/DeleteAudienceTarget.php
View file @
5643bc0
...
...
@@ -42,10 +42,30 @@ class DeleteAudienceTarget extends DirectRequest
if
(
!
isset
(
$delete_result
[
'Id'
]))
{
$external_id
=
$this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
][
$key
];
if
(
isset
(
$delete_result
[
'Errors'
])
&&
count
(
$delete_result
[
'Errors'
]))
{
if
(
$this
->
getToken
()
->
isMain
())
{
$model
=
AudienceTarget
::
whereExternalId
(
$external_id
)
->
first
();
}
else
{
$model
=
GoalAudienceTarget
::
whereExternalId
(
$external_id
)
->
first
();
}
if
(
$model
)
{
$model
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$external_id
,
'errors'
=>
$delete_result
[
'Errors'
],
]);
}
}
else
{
Log
::
debug
(
"DeleteAudienceTargets, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$delete_result
);
$external_id
=
$this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
][
$key
];
Log
::
debug
(
$external_id
);
}
if
(
$this
->
getToken
()
->
isMain
())
{
AudienceTarget
::
whereExternalId
(
$external_id
)
...
...
app/Service/Requests/Direct/DeleteBidModifiers.php
View file @
5643bc0
...
...
@@ -38,17 +38,34 @@ class DeleteBidModifiers extends DirectRequest
}
foreach
(
$response
[
'result'
][
'DeleteResults'
]
as
$key
=>
$delete_result
)
{
if
(
!
isset
(
$delete_result
[
'Id'
]))
{
$external_id
=
$this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
][
$key
];
if
(
isset
(
$delete_result
[
'Errors'
][
0
][
'Message'
])
&&
$delete_result
[
'Errors'
][
0
][
'Message'
]
===
'Object not found'
)
{
GoalBidModifier
::
where
(
'external_id'
,
$this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
][
$key
])
->
delete
();
continue
;
GoalBidModifier
::
where
(
'external_id'
,
$external_id
)
->
delete
();
}
elseif
(
isset
(
$delete_result
[
'Errors'
])
&&
count
(
$delete_result
[
'Errors'
]))
{
$model
=
GoalBidModifier
::
whereExternalId
(
$external_id
)
->
first
();
if
(
$model
)
{
$model
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$external_id
,
'errors'
=>
$delete_result
[
'Errors'
],
]);
}
}
else
{
Log
::
debug
(
"DeleteBidModifier, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$delete_result
);
Log
::
debug
(
$this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
][
$key
]);
}
continue
;
}
$external_id
=
(
string
)
$delete_result
[
'Id'
];
...
...
app/Service/Requests/Direct/DeleteKeywords.php
View file @
5643bc0
...
...
@@ -43,7 +43,10 @@ class DeleteKeywords extends DirectRequest
if
(
!
isset
(
$delete_result
[
'Id'
]))
{
if
(
isset
(
$delete_result
[
'Errors'
])
&&
count
(
$delete_result
[
'Errors'
]))
{
if
(
isset
(
$delete_result
[
'Errors'
][
0
][
'Details'
])
&&
$delete_result
[
'Errors'
][
0
][
'Details'
]
===
'Keyword not found'
)
{
//объекта по какой то причине нет
GoalKeyword
::
where
(
'external_id'
,
$external_id
)
->
delete
();
}
elseif
(
isset
(
$delete_result
[
'Errors'
])
&&
count
(
$delete_result
[
'Errors'
]))
{
$goalKeyword
=
GoalKeyword
::
whereExternalId
(
$external_id
)
->
first
();
if
(
$goalKeyword
)
{
...
...
@@ -59,15 +62,12 @@ class DeleteKeywords extends DirectRequest
]);
continue
;
}
}
}
else
{
Log
::
debug
(
"DeleteKeywords, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$delete_result
);
Log
::
debug
(
$this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
][
$key
]);
if
(
$delete_result
[
'Errors'
][
0
][
'Code'
]
==
8800
){
//объекта по какой то причине нет
GoalKeyword
::
where
(
'external_id'
,
$external_id
)
->
delete
();
Log
::
debug
(
$external_id
);
}
continue
;
}
...
...
app/Service/Requests/Direct/DeleteVCards.php
View file @
5643bc0
...
...
@@ -58,29 +58,27 @@ class DeleteVCards extends DirectRequest
->
delete
();
}
continue
;
}
elseif
(
isset
(
$delete_result
[
'Errors'
])
&&
count
(
$delete_result
[
'Errors'
]))
{
$goalVCard
=
GoalVCard
::
whereExternalId
(
$external_id
)
->
first
();
if
(
$this
->
getToken
()
->
isMain
())
{
$model
=
VCard
::
whereExternalId
(
$external_id
)
->
first
();
}
else
{
$model
=
GoalVCard
::
whereExternalId
(
$external_id
)
->
first
();
}
if
(
$
goalVCard
)
{
$
goalVCard
->
errors
()
->
create
([
if
(
$
model
)
{
$
model
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$external_id
,
'errors'
=>
$delete_result
[
'Errors'
],
]);
$goalVCard
->
update
([
'reserve_update_at'
=>
null
,
]);
continue
;
}
}
}
else
{
Log
::
debug
(
"DeleteVCards, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$delete_result
);
Log
::
debug
(
$external_id
);
}
if
(
$this
->
getToken
()
->
isMain
())
{
VCard
::
whereExternalId
(
$external_id
)
...
...
app/Service/Requests/Direct/ResumeCampaigns.php
View file @
5643bc0
...
...
@@ -32,11 +32,36 @@ class ResumeCampaigns extends DirectRequest
public
function
handle
(
$response
)
{
foreach
(
$response
[
'result'
][
'ResumeResults'
]
as
$key
=>
$resume_result
)
{
if
(
!
isset
(
$resume_result
[
'Id'
]))
{
$external_id
=
$this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
][
$key
];
if
(
isset
(
$resume_result
[
'Errors'
])
&&
count
(
$resume_result
[
'Errors'
]))
{
$model
=
DictionaryCampaign
::
whereExternalId
(
$external_id
)
->
first
();
if
(
$model
)
{
$model
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$external_id
,
'errors'
=>
$resume_result
[
'Errors'
],
]);
}
}
else
{
Log
::
debug
(
"ResumeCampaigns, empty Id"
);
Log
::
debug
(
$resume_result
);
Log
::
debug
(
$this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
][
$key
]);
Log
::
debug
(
$external_id
);
}
DictionaryCampaign
::
whereExternalId
(
$external_id
)
->
update
([
'reserve_resume_at'
=>
null
,
]);
continue
;
}
$external_id
=
(
string
)
$resume_result
[
'Id'
];
...
...
app/Service/Requests/Direct/SetBidModifiers.php
View file @
5643bc0
...
...
@@ -38,15 +38,38 @@ class SetBidModifiers extends DirectRequest
}
foreach
(
$response
[
'result'
][
'SetResults'
]
as
$key
=>
$set_result
)
{
if
(
!
isset
(
$set_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'BidModifiers'
][
$key
];
$external_id
=
$data
[
'Id'
];
if
(
isset
(
$set_result
[
'Errors'
][
0
][
'Message'
])
&&
$set_result
[
'Errors'
][
0
][
'Message'
]
===
'Object not found'
)
{
GoalBidModifier
::
whereExternalId
(
$external_id
)
->
delete
();
}
elseif
(
isset
(
$set_result
[
'Errors'
])
&&
count
(
$set_result
[
'Errors'
]))
{
$model
=
GoalBidModifier
::
whereExternalId
(
$external_id
)
->
first
();
if
(
$model
)
{
$model
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$external_id
,
'errors'
=>
$set_result
[
'Errors'
],
]);
}
}
else
{
Log
::
debug
(
"UpdateBidModifier, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$set_result
);
Log
::
debug
(
$this
->
getParams
()[
'BidModifiers'
][
$key
]);
Log
::
debug
(
$data
);
}
GoalBidModifier
::
whereExternalId
(
$
this
->
getParams
()[
'BidModifiers'
][
$key
][
'Id'
]
)
GoalBidModifier
::
whereExternalId
(
$
external_id
)
->
update
([
'reserve_update_at'
=>
null
,
]);
continue
;
}
...
...
app/Service/Requests/Direct/SuspendCampaigns.php
View file @
5643bc0
...
...
@@ -33,10 +33,34 @@ class SuspendCampaigns extends DirectRequest
public
function
handle
(
$response
)
{
foreach
(
$response
[
'result'
][
'SuspendResults'
]
as
$key
=>
$suspend_result
)
{
$external_id
=
$this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
][
$key
];
if
(
!
isset
(
$suspend_result
[
'Id'
]))
{
if
(
isset
(
$suspend_result
[
'Errors'
])
&&
count
(
$suspend_result
[
'Errors'
]))
{
$model
=
DictionaryCampaign
::
whereExternalId
(
$external_id
)
->
first
();
if
(
$model
)
{
$model
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$external_id
,
'errors'
=>
$suspend_result
[
'Errors'
],
]);
}
}
else
{
Log
::
debug
(
"SuspendCampaigns, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$suspend_result
);
Log
::
debug
(
$this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
][
$key
]);
Log
::
debug
(
$external_id
);
}
DictionaryCampaign
::
where
(
'external_id'
,
$external_id
)
->
update
([
'reserve_suspend_at'
=>
null
,
]);
continue
;
}
...
...
app/Service/Requests/Direct/UpdateAdGroups.php
View file @
5643bc0
...
...
@@ -41,27 +41,35 @@ class UpdateAdGroups extends DirectRequest
}
foreach
(
$response
[
'result'
][
'UpdateResults'
]
as
$key
=>
$update_result
)
{
if
(
!
isset
(
$update_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'AdGroups'
][
$key
];
$external_id
=
$data
[
'Id'
];
if
(
isset
(
$update_result
[
'Message'
])
&&
$update_result
[
'Message'
]
===
'Object not found'
)
{
$goalAdGroup
=
GoalAdGroup
::
whereExternalId
(
$this
->
getParams
()[
'AdGroups'
][
$key
][
'Id'
])
->
first
();
$model
=
GoalAdGroup
::
whereExternalId
(
$external_id
)
->
first
();
$goalAdGroup
->
goalKeywords
()
->
delete
();
$goalAdGroup
->
goalAdvertisements
()
->
delete
();
$goalAdGroup
->
goalBidModifiers
()
->
delete
();
$goalAdGroup
->
goalAudienceTargets
()
->
delete
();
if
(
$model
)
{
$model
->
goalKeywords
()
->
delete
();
$model
->
goalAdvertisements
()
->
delete
();
$model
->
goalBidModifiers
()
->
delete
();
$model
->
goalAudienceTargets
()
->
delete
();
$goalAdGroup
->
forceDelete
();
$model
->
forceDelete
();
}
}
else
{
Log
::
debug
(
"UpdateAdGroup, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$update_result
);
Log
::
debug
(
$this
->
getParams
()[
'AdGroups'
][
$key
]);
Log
::
debug
(
$data
);
}
GoalAdGroup
::
whereExternalId
(
$this
->
getParams
()[
'AdGroups'
][
$key
][
'Id'
])
GoalAdGroup
::
withTrashed
()
->
whereExternalId
(
$this
->
getParams
()[
'AdGroups'
][
$key
][
'Id'
])
->
update
([
'reserve_update_at'
=>
null
,
]);
}
continue
;
}
...
...
app/Service/Requests/Direct/UpdateAds.php
View file @
5643bc0
...
...
@@ -43,50 +43,43 @@ class UpdateAds extends DirectRequest
foreach
(
$response
[
'result'
][
'UpdateResults'
]
as
$key
=>
$update_result
)
{
if
(
!
isset
(
$update_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'Ads'
][
$key
];
if
(
!
isset
(
$update_result
[
'Id'
]))
{
$external_id
=
$data
[
'Id'
];
if
(
isset
(
$update_result
[
'Errors'
][
0
][
'Details'
])
&&
$update_result
[
'Errors'
][
0
][
'Details'
]
===
'You cannot update an archived ad'
)
{
GoalAdvertisement
::
whereExternalId
(
$
data
[
'Id'
]
)
GoalAdvertisement
::
whereExternalId
(
$
external_id
)
->
update
([
'deleted_need'
=>
Carbon
::
now
(),
'archived_need'
=>
null
,
'reserve_archive_at'
=>
null
,
'reserve_update_at'
=>
null
,
]);
continue
;
}
elseif
(
isset
(
$update_result
[
'Errors'
][
0
][
'Details'
])
&&
$update_result
[
'Errors'
][
0
][
'Details'
]
===
'Ad not found'
)
{
GoalAdvertisement
::
whereExternalId
(
$data
[
'Id'
])
->
update
([
'reserve_update_at'
=>
null
,
]);
GoalAdvertisement
::
whereExternalId
(
$data
[
'Id'
])
GoalAdvertisement
::
whereExternalId
(
$external_id
)
->
delete
();
continue
;
}
elseif
(
isset
(
$update_result
[
'Errors'
])
&&
count
(
$update_result
[
'Errors'
]))
{
$
goalAd
=
GoalAdvertisement
::
whereExternalId
(
$data
[
'Id'
]
)
->
first
();
$
model
=
GoalAdvertisement
::
whereExternalId
(
$external_id
)
->
first
();
if
(
$
goalAd
)
{
$
goalAd
->
errors
()
->
create
([
if
(
$
model
)
{
$
model
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$data
,
'errors'
=>
$update_result
[
'Errors'
],
]);
$goalAd
->
update
([
'reserve_update_at'
=>
null
,
]);
continue
;
}
}
}
else
{
Log
::
debug
(
"UpdateAds, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$update_result
);
Log
::
debug
(
$data
);
}
GoalAdvertisement
::
w
hereExternalId
(
$data
[
'Id'
]
)
GoalAdvertisement
::
w
ithTrashed
()
->
whereExternalId
(
$external_id
)
->
update
([
'reserve_update_at'
=>
null
,
]);
...
...
app/Service/Requests/Direct/UpdateCampaigns.php
View file @
5643bc0
...
...
@@ -5,6 +5,7 @@ namespace App\Service\Requests\Direct;
use
App\Jobs\ProcessCallLimitedAPI
;
use
App\Models\Campaigns
;
use
App\Models\Pivots\DictionaryCampaign
;
use
App\Models\Pivots\GoalAdGroup
;
use
App\Models\Variable
;
use
App\Service\Contract\APIRequest
;
use
App\Service\Requests\DirectRequest
;
...
...
@@ -41,20 +42,34 @@ class UpdateCampaigns extends DirectRequest
return
;
}
foreach
(
$response
[
'result'
][
'UpdateResults'
]
as
$key
=>
$add_result
)
{
if
(
!
isset
(
$add_result
[
'Id'
]))
{
foreach
(
$response
[
'result'
][
'UpdateResults'
]
as
$key
=>
$update_result
)
{
if
(
isset
(
$add_result
[
'Errors'
][
0
][
'Details'
])
&&
$add_result
[
'Errors'
][
0
][
'Details'
]
===
'It is forbidden to change an archived campaign'
)
{
DictionaryCampaign
::
whereExternalId
(
$this
->
getParams
()[
'Campaigns'
][
$key
][
'Id'
])
->
forceDelete
()
;
continue
;
}
if
(
!
isset
(
$update_result
[
'Id'
])
)
{
$data
=
$this
->
getParams
()[
'Campaigns'
][
$key
]
;
$external_id
=
$data
[
'Id'
];
if
(
isset
(
$update_result
[
'Errors'
][
0
][
'Details'
])
&&
$update_result
[
'Errors'
][
0
][
'Details'
]
===
'It is forbidden to change an archived campaign'
)
{
DictionaryCampaign
::
whereExternalId
(
$external_id
)
->
delete
();
}
elseif
(
isset
(
$update_result
[
'Message'
])
&&
$update_result
[
'Message'
]
===
'Object not found'
)
{
$model
=
GoalAdGroup
::
whereExternalId
(
$external_id
)
->
first
();
if
(
$model
)
{
$model
->
goalKeywords
()
->
delete
();
$model
->
goalAdvertisements
()
->
delete
();
$model
->
goalBidModifiers
()
->
delete
();
$model
->
goalAudienceTargets
()
->
delete
();
$model
->
delete
();
}
}
else
{
Log
::
debug
(
"UpdateCampaigns, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$add_result
);
Log
::
debug
(
$this
->
getParams
()[
'Campaigns'
][
$key
]);
Log
::
debug
(
$update_result
);
Log
::
debug
(
$data
);
}
DictionaryCampaign
::
w
hereExternalId
(
$this
->
getParams
()[
'Campaigns'
][
$key
][
'Id'
]
)
DictionaryCampaign
::
w
ithTrashed
()
->
whereExternalId
(
$external_id
)
->
update
([
'reserve_update_at'
=>
null
,
]);
...
...
@@ -62,7 +77,7 @@ class UpdateCampaigns extends DirectRequest
continue
;
}
$external_id
=
(
string
)
$
add
_result
[
'Id'
];
$external_id
=
(
string
)
$
update
_result
[
'Id'
];
DictionaryCampaign
::
forExternal
()
->
needUpdated
()
->
where
(
'external_id'
,
$external_id
)
...
...
app/Service/Requests/Direct/UpdateKeywords.php
View file @
5643bc0
...
...
@@ -41,12 +41,15 @@ class UpdateKeywords extends DirectRequest
}
foreach
(
$response
[
'result'
][
'UpdateResults'
]
as
$key
=>
$update_result
)
{
if
(
!
isset
(
$update_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'Keywords'
][
$key
];
$external_id
=
$data
[
'Id'
];
if
(
isset
(
$update_result
[
'Errors'
])
&&
count
(
$update_result
[
'Errors'
]))
{
$goalKeyword
=
GoalKeyword
::
whereExternalId
(
$
data
[
'Id'
]
)
->
first
();
$goalKeyword
=
GoalKeyword
::
whereExternalId
(
$
external_id
)
->
first
();
if
(
$goalKeyword
)
{
$goalKeyword
->
errors
()
->
create
([
...
...
@@ -61,13 +64,13 @@ class UpdateKeywords extends DirectRequest
]);
continue
;
}
}
}
else
{
Log
::
debug
(
"UpdateKeywords, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$update_result
);
Log
::
debug
(
$data
);
}
GoalKeyword
::
whereExternalId
(
$
data
[
'Id'
]
)
GoalKeyword
::
whereExternalId
(
$
external_id
)
->
update
([
'reserve_update_at'
=>
null
,
]);
...
...
@@ -89,7 +92,7 @@ class UpdateKeywords extends DirectRequest
public
function
failed
()
{
GoalKeyword
::
whereIn
(
'external_id'
,
array_column
(
$this
->
getParams
()[
'
goal
Keywords'
],
'Id'
))
GoalKeyword
::
whereIn
(
'external_id'
,
array_column
(
$this
->
getParams
()[
'Keywords'
],
'Id'
))
->
update
([
'reserve_update_at'
=>
null
,
]);
...
...
app/Service/Requests/Direct/UpdateNegativeKeywordSharedSets.php
View file @
5643bc0
...
...
@@ -58,11 +58,24 @@ class UpdateNegativeKeywordSharedSets extends DirectRequest
$goalNegativeKeywordSharedSet
=
$this
->
goalNegativeKeywordSharedSets
->
get
(
$key
);
if
(
!
isset
(
$update_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'NegativeKeywordSharedSets'
][
$key
];
if
(
isset
(
$update_result
[
'Errors'
])
&&
count
(
$update_result
[
'Errors'
]))
{
$goalNegativeKeywordSharedSet
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'service'
=>
$this
->
getService
(),
'method'
=>
$this
->
getMethod
(),
'params'
=>
$data
,
'errors'
=>
$update_result
[
'Errors'
],
]);
}
else
{
Log
::
debug
(
"UpdateNegativeKeywordSharedSet, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
$update_result
);
Log
::
debug
(
$this
->
getParams
()[
'NegativeKeywordSharedSets'
][
$key
]);
Log
::
debug
(
$data
);
}
GoalNegativeKeywordSharedSet
::
where
(
'
external_id'
,
$goalNegativeKeywordSharedSet
->
external_id
)
GoalNegativeKeywordSharedSet
::
where
(
'
id'
,
$goalNegativeKeywordSharedSet
->
getKey
()
)
->
update
([
'reserve_update_at'
=>
null
,
]);
...
...
app/Service/Requests/Direct/UpdateRetargetinglists.php
View file @
5643bc0
...
...
@@ -43,10 +43,10 @@ class UpdateRetargetinglists extends DirectRequest
foreach
(
$response
[
'result'
][
'UpdateResults'
]
as
$key
=>
$update_result
)
{
$data
=
$this
->
getParams
()[
'RetargetingLists'
][
$key
];
if
(
!
isset
(
$update_result
[
'Id'
]))
{
$data
=
$this
->
getParams
()[
'RetargetingLists'
][
$key
];
if
(
isset
(
$update_result
[
'Errors'
])
&&
count
(
$update_result
[
'Errors'
]))
{
$goalRetargetinglist
=
GoalRetargetinglist
::
whereExternalId
(
$data
[
'Id'
])
->
first
();
...
...
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