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 1f978e1d
authored
Jun 29, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#20359 Каждый час обновляются РК
1 parent
285cfa43
Hide whitespace changes
Inline
Side-by-side
Showing
37 changed files
with
455 additions
and
94 deletions
app/Console/Commands/AdGroupsAdd.php
app/Console/Commands/AdGroupsUpdate.php
app/Console/Commands/AdvertisementsAdd.php
app/Console/Commands/AdvertisementsUpdate.php
app/Console/Commands/BidModifiersAdd.php
app/Console/Commands/CampaignsAdd.php
app/Console/Commands/CampaignsResume.php
app/Console/Commands/CampaignsSuspend.php
app/Console/Commands/CampaignsUpdate.php
app/Console/Commands/KeywordsUpdate.php
app/Models/Campaigns.php
app/Models/Pivots/DictionaryCampaign.php
app/Models/Pivots/GoalAdGroup.php
app/Models/Pivots/GoalAdvertisement.php
app/Models/Pivots/GoalBidModifier.php
app/Models/Pivots/GoalKeyword.php
app/Models/Tokens.php
app/Service/Requests/Direct/AddAdGroups.php
app/Service/Requests/Direct/AddAds.php
app/Service/Requests/Direct/AddBidModifiers.php
app/Service/Requests/Direct/AddCampaigns.php
app/Service/Requests/Direct/CheckCampaignsChanges.php
app/Service/Requests/Direct/GetAdGroups.php
app/Service/Requests/Direct/ResumeCampaigns.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
database/migrations/2021_06_29_131245_add_reserve_columns.php
resources/js/Pages/Tokens/CitySettings.vue
tests/Unit/AddAdGroupTest.php
tests/Unit/AddCampaignsTest.php
tests/Unit/CheckChangesAdGroupsTest.php
tests/Unit/LimitsTest.php
tests/Unit/ProcessCallSliceTest.php
tests/Unit/UpdateCampaignsTest.php
app/Console/Commands/AdGroupsAdd.php
View file @
1f978e1
...
@@ -2,9 +2,11 @@
...
@@ -2,9 +2,11 @@
namespace
App\Console\Commands
;
namespace
App\Console\Commands
;
use
App\Models\Pivots\GoalAdGroup
;
use
App\Models\Tokens
;
use
App\Models\Tokens
;
use
App\Service\API\API
;
use
App\Service\API\API
;
use
App\Service\Requests\APIRequest
;
use
App\Service\Requests\APIRequest
;
use
Carbon\Carbon
;
use
Illuminate\Console\Command
;
use
Illuminate\Console\Command
;
use
Illuminate\Database\Eloquent\Relations\HasMany
;
use
Illuminate\Database\Eloquent\Relations\HasMany
;
...
@@ -41,25 +43,34 @@ class AdGroupsAdd extends Command
...
@@ -41,25 +43,34 @@ class AdGroupsAdd extends Command
*/
*/
public
function
handle
()
public
function
handle
()
{
{
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForExternalSynchronized.groupsForNotExternal.group'
)
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForExternalSynchronized.groupsForNotExternal
ForNotReserveCreate
.group'
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
get
();
->
get
();
foreach
(
$tokens
as
$token
)
{
foreach
(
$tokens
as
$token
)
{
$token
->
load
([
$token
->
load
([
'dictionaryCampaignsEnabledForExternalSynchronized.groupsForNotExternal'
=>
function
(
HasMany
$query
)
{
'dictionaryCampaignsEnabledForExternalSynchronized.groupsForNotExternal
ForNotReserveCreate
'
=>
function
(
HasMany
$query
)
{
return
$query
->
has
(
'group'
);
return
$query
->
has
(
'group'
);
},
},
'dictionaryCampaignsEnabledForExternalSynchronized.groupsForNotExternal.group'
,
'dictionaryCampaignsEnabledForExternalSynchronized.groupsForNotExternal
ForNotReserveCreate
.group'
,
]);
]);
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
->
setToken
(
$token
);
$factory
->
setToken
(
$token
);
$goalAdGroups
=
$token
->
dictionaryCampaignsEnabledForExternalSynchronized
->
pluck
(
'groupsForNotExternalForNotReserveCreate'
)
->
collapse
();
foreach
(
array_chunk
(
$goalAdGroups
->
pluck
(
'id'
)
->
toArray
(),
1000
)
as
$items
)
{
GoalAdGroup
::
whereIn
(
'id'
,
$items
)
->
update
([
'reserve_create_at'
=>
Carbon
::
now
(),
]);
}
$factory
->
getRequest
(
'AdGroups'
,
'add'
)
$factory
->
getRequest
(
'AdGroups'
,
'add'
)
->
call
([
->
call
([
'goalAdGroups'
=>
$token
->
dictionaryCampaignsEnabledForExternalSynchronized
->
pluck
(
'groupsForNotExternal'
)
'goalAdGroups'
=>
$goalAdGroups
,
->
collapse
(),
]);
]);
}
}
...
...
app/Console/Commands/AdGroupsUpdate.php
View file @
1f978e1
...
@@ -2,9 +2,11 @@
...
@@ -2,9 +2,11 @@
namespace
App\Console\Commands
;
namespace
App\Console\Commands
;
use
App\Models\Pivots\GoalAdGroup
;
use
App\Models\Tokens
;
use
App\Models\Tokens
;
use
App\Service\API\API
;
use
App\Service\API\API
;
use
App\Service\Requests\APIRequest
;
use
App\Service\Requests\APIRequest
;
use
Carbon\Carbon
;
use
Illuminate\Console\Command
;
use
Illuminate\Console\Command
;
use
Illuminate\Database\Eloquent\Relations\HasMany
;
use
Illuminate\Database\Eloquent\Relations\HasMany
;
...
@@ -41,27 +43,36 @@ class AdGroupsUpdate extends Command
...
@@ -41,27 +43,36 @@ class AdGroupsUpdate extends Command
*/
*/
public
function
handle
()
public
function
handle
()
{
{
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForExternalUpdated.groupsForExternalForNeedUpdated.group'
)
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForExternalUpdated.groupsForExternalForNeedUpdated
ForNotReserveUpdate
.group'
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
get
();
->
get
();
foreach
(
$tokens
as
$token
)
{
foreach
(
$tokens
as
$token
)
{
$token
->
load
([
$token
->
load
([
'dictionaryCampaignsEnabledForExternalUpdated.groupsForExternalForNeedUpdated'
=>
function
(
HasMany
$query
)
{
'dictionaryCampaignsEnabledForExternalUpdated.groupsForExternalForNeedUpdated
ForNotReserveUpdate
'
=>
function
(
HasMany
$query
)
{
return
$query
->
has
(
'group'
);
return
$query
->
has
(
'group'
);
},
},
'dictionaryCampaignsEnabledForExternalUpdated.groupsForExternalForNeedUpdated.group'
,
'dictionaryCampaignsEnabledForExternalUpdated.groupsForExternalForNeedUpdated
ForNotReserveUpdate
.group'
,
]);
]);
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
->
setToken
(
$token
);
$factory
->
setToken
(
$token
);
$goalAdGroups
=
$token
->
dictionaryCampaignsEnabledForExternalUpdated
->
pluck
(
'groupsForExternalForNeedUpdatedForNotReserveUpdate'
)
->
collapse
();
foreach
(
array_chunk
(
$goalAdGroups
->
pluck
(
'id'
)
->
toArray
(),
1000
)
as
$items
){
GoalAdGroup
::
whereIn
(
'id'
,
$items
)
->
update
([
'reserve_update_at'
=>
Carbon
::
now
(),
]);
}
$factory
->
getRequest
(
'AdGroups'
,
'update'
)
$factory
->
getRequest
(
'AdGroups'
,
'update'
)
->
call
([
->
call
([
'goalAdGroups'
=>
$token
->
dictionaryCampaignsEnabledForExternalUpdated
->
pluck
(
'groupsForExternalForNeedUpdated'
)
'goalAdGroups'
=>
$goalAdGroups
,
->
collapse
(),
]);
]);
}
}
...
...
app/Console/Commands/AdvertisementsAdd.php
View file @
1f978e1
...
@@ -2,9 +2,11 @@
...
@@ -2,9 +2,11 @@
namespace
App\Console\Commands
;
namespace
App\Console\Commands
;
use
App\Models\Pivots\GoalAdvertisement
;
use
App\Models\Tokens
;
use
App\Models\Tokens
;
use
App\Service\API\API
;
use
App\Service\API\API
;
use
App\Service\Requests\APIRequest
;
use
App\Service\Requests\APIRequest
;
use
Carbon\Carbon
;
use
Illuminate\Console\Command
;
use
Illuminate\Console\Command
;
use
Illuminate\Database\Eloquent\Relations\HasMany
;
use
Illuminate\Database\Eloquent\Relations\HasMany
;
use
Illuminate\Database\Eloquent\Relations\HasManyThrough
;
use
Illuminate\Database\Eloquent\Relations\HasManyThrough
;
...
@@ -56,6 +58,7 @@ class AdvertisementsAdd extends Command
...
@@ -56,6 +58,7 @@ class AdvertisementsAdd extends Command
->
join
(
'advertisements'
,
'goal_advertisements.advertisement_id'
,
'='
,
'advertisements.id'
)
->
join
(
'advertisements'
,
'goal_advertisements.advertisement_id'
,
'='
,
'advertisements.id'
)
->
whereNull
(
'advertisements.deleted_at'
)
->
whereNull
(
'advertisements.deleted_at'
)
->
whereNull
(
'goal_advertisements.external_id'
)
->
whereNull
(
'goal_advertisements.external_id'
)
->
whereNull
(
'goal_advertisements.reserve_create_at'
)
->
whereNotNull
(
'goal_advertisements.goal_ad_group_external_id'
)
->
whereNotNull
(
'goal_advertisements.goal_ad_group_external_id'
)
->
whereNotNull
(
'goal_advertisements.dictionary_campaign_external_id'
)
->
whereNotNull
(
'goal_advertisements.dictionary_campaign_external_id'
)
->
whereIn
(
'goal_advertisements.dictionary_campaign_id'
,
$token
->
dictionaryCampaignsEnabledForExternalSynchronized
->
pluck
(
'id'
))
->
whereIn
(
'goal_advertisements.dictionary_campaign_id'
,
$token
->
dictionaryCampaignsEnabledForExternalSynchronized
->
pluck
(
'id'
))
...
@@ -81,6 +84,13 @@ class AdvertisementsAdd extends Command
...
@@ -81,6 +84,13 @@ class AdvertisementsAdd extends Command
])
])
->
get
();
->
get
();
foreach
(
array_chunk
(
$goalAds
->
pluck
(
'id'
)
->
toArray
(),
1000
)
as
$items
)
{
GoalAdvertisement
::
whereIn
(
'id'
,
$items
)
->
update
([
'reserve_create_at'
=>
Carbon
::
now
(),
]);
}
$factory
->
getRequest
(
'Ads'
,
'add'
)
$factory
->
getRequest
(
'Ads'
,
'add'
)
->
call
([
->
call
([
'goalAds'
=>
$goalAds
,
'goalAds'
=>
$goalAds
,
...
...
app/Console/Commands/AdvertisementsUpdate.php
View file @
1f978e1
...
@@ -2,9 +2,11 @@
...
@@ -2,9 +2,11 @@
namespace
App\Console\Commands
;
namespace
App\Console\Commands
;
use
App\Models\Pivots\GoalAdvertisement
;
use
App\Models\Tokens
;
use
App\Models\Tokens
;
use
App\Service\API\API
;
use
App\Service\API\API
;
use
App\Service\Requests\APIRequest
;
use
App\Service\Requests\APIRequest
;
use
Carbon\Carbon
;
use
Illuminate\Console\Command
;
use
Illuminate\Console\Command
;
use
Illuminate\Database\Eloquent\Relations\HasMany
;
use
Illuminate\Database\Eloquent\Relations\HasMany
;
use
Illuminate\Database\Eloquent\Relations\HasManyThrough
;
use
Illuminate\Database\Eloquent\Relations\HasManyThrough
;
...
@@ -61,6 +63,7 @@ class AdvertisementsUpdate extends Command
...
@@ -61,6 +63,7 @@ class AdvertisementsUpdate extends Command
$goalAds
=
DB
::
table
(
'goal_advertisements'
)
$goalAds
=
DB
::
table
(
'goal_advertisements'
)
->
join
(
'advertisements'
,
'goal_advertisements.advertisement_id'
,
'='
,
'advertisements.id'
)
->
join
(
'advertisements'
,
'goal_advertisements.advertisement_id'
,
'='
,
'advertisements.id'
)
->
whereNull
(
'advertisements.deleted_at'
)
->
whereNull
(
'advertisements.deleted_at'
)
->
whereNull
(
'advertisements.reserve_update_at'
)
->
whereNotNull
(
'goal_advertisements.updated_need'
)
->
whereNotNull
(
'goal_advertisements.updated_need'
)
->
whereNotNull
(
'goal_advertisements.goal_ad_group_external_id'
)
->
whereNotNull
(
'goal_advertisements.goal_ad_group_external_id'
)
->
whereNotNull
(
'goal_advertisements.dictionary_campaign_external_id'
)
->
whereNotNull
(
'goal_advertisements.dictionary_campaign_external_id'
)
...
@@ -86,6 +89,13 @@ class AdvertisementsUpdate extends Command
...
@@ -86,6 +89,13 @@ class AdvertisementsUpdate extends Command
])
])
->
get
();
->
get
();
foreach
(
array_chunk
(
$goalAds
->
pluck
(
'id'
)
->
toArray
(),
1000
)
as
$items
){
GoalAdvertisement
::
whereIn
(
'id'
,
$items
)
->
update
([
'reserve_update_at'
=>
Carbon
::
now
(),
]);
}
$factory
->
getRequest
(
'Ads'
,
'update'
)
$factory
->
getRequest
(
'Ads'
,
'update'
)
->
call
([
->
call
([
'goalAds'
=>
$goalAds
,
'goalAds'
=>
$goalAds
,
...
...
app/Console/Commands/BidModifiersAdd.php
View file @
1f978e1
...
@@ -2,12 +2,12 @@
...
@@ -2,12 +2,12 @@
namespace
App\Console\Commands
;
namespace
App\Console\Commands
;
use
App\Models\Pivots\GoalBidModifier
;
use
App\Models\Tokens
;
use
App\Models\Tokens
;
use
App\Service\API\API
;
use
App\Service\API\API
;
use
App\Service\Requests\APIRequest
;
use
App\Service\Requests\APIRequest
;
use
Carbon\Carbon
;
use
Illuminate\Console\Command
;
use
Illuminate\Console\Command
;
use
Illuminate\Database\Eloquent\Relations\HasMany
;
use
Illuminate\Database\Eloquent\Relations\HasManyThrough
;
use
Illuminate\Database\Query\Builder
;
use
Illuminate\Database\Query\Builder
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
...
@@ -57,6 +57,7 @@ class BidModifiersAdd extends Command
...
@@ -57,6 +57,7 @@ class BidModifiersAdd extends Command
->
join
(
'bid_modifiers'
,
'goal_bid_modifiers.bid_modifier_id'
,
'='
,
'bid_modifiers.id'
)
->
join
(
'bid_modifiers'
,
'goal_bid_modifiers.bid_modifier_id'
,
'='
,
'bid_modifiers.id'
)
->
whereNull
(
'bid_modifiers.deleted_at'
)
->
whereNull
(
'bid_modifiers.deleted_at'
)
->
whereNull
(
'goal_bid_modifiers.external_id'
)
->
whereNull
(
'goal_bid_modifiers.external_id'
)
->
whereNull
(
'goal_bid_modifiers.reserve_create_at'
)
->
whereNotNull
(
'goal_bid_modifiers.dictionary_campaign_external_id'
)
->
whereNotNull
(
'goal_bid_modifiers.dictionary_campaign_external_id'
)
->
where
(
function
(
Builder
$query
)
{
->
where
(
function
(
Builder
$query
)
{
$query
->
whereNull
(
'goal_bid_modifiers.goal_ad_group_id'
)
$query
->
whereNull
(
'goal_bid_modifiers.goal_ad_group_id'
)
...
@@ -77,6 +78,13 @@ class BidModifiersAdd extends Command
...
@@ -77,6 +78,13 @@ class BidModifiersAdd extends Command
])
])
->
get
();
->
get
();
foreach
(
array_chunk
(
$goalBidModifiers
->
pluck
(
'id'
)
->
toArray
(),
1000
)
as
$items
)
{
GoalBidModifier
::
whereIn
(
'id'
,
$items
)
->
update
([
'reserve_create_at'
=>
Carbon
::
now
(),
]);
}
$factory
->
getRequest
(
'BidModifiers'
,
'add'
)
$factory
->
getRequest
(
'BidModifiers'
,
'add'
)
->
call
([
->
call
([
'goalBidModifiers'
=>
$goalBidModifiers
,
'goalBidModifiers'
=>
$goalBidModifiers
,
...
...
app/Console/Commands/CampaignsAdd.php
View file @
1f978e1
...
@@ -2,9 +2,11 @@
...
@@ -2,9 +2,11 @@
namespace
App\Console\Commands
;
namespace
App\Console\Commands
;
use
App\Models\Pivots\DictionaryCampaign
;
use
App\Models\Tokens
;
use
App\Models\Tokens
;
use
App\Service\API\API
;
use
App\Service\API\API
;
use
App\Service\Requests\APIRequest
;
use
App\Service\Requests\APIRequest
;
use
Carbon\Carbon
;
use
Illuminate\Console\Command
;
use
Illuminate\Console\Command
;
class
CampaignsAdd
extends
Command
class
CampaignsAdd
extends
Command
...
@@ -40,8 +42,8 @@ class CampaignsAdd extends Command
...
@@ -40,8 +42,8 @@ class CampaignsAdd extends Command
*/
*/
public
function
handle
()
public
function
handle
()
{
{
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForNotExternal'
)
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForNotExternal
ForNotReserveCreate
'
)
->
with
(
'dictionaryCampaignsEnabledForNotExternal.campaign'
)
->
with
(
'dictionaryCampaignsEnabledForNotExternal
ForNotReserveCreate
.campaign'
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
get
();
->
get
();
...
@@ -50,9 +52,16 @@ class CampaignsAdd extends Command
...
@@ -50,9 +52,16 @@ class CampaignsAdd extends Command
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
->
setToken
(
$token
);
$factory
->
setToken
(
$token
);
foreach
(
array_chunk
(
$token
->
dictionaryCampaignsEnabledForNotExternalForNotReserveCreate
->
pluck
(
'id'
)
->
toArray
(),
1000
)
as
$items
)
{
DictionaryCampaign
::
whereIn
(
'id'
,
$items
)
->
update
([
'reserve_create_at'
=>
Carbon
::
now
(),
]);
}
$factory
->
getRequest
(
'Campaigns'
,
'add'
)
$factory
->
getRequest
(
'Campaigns'
,
'add'
)
->
call
([
->
call
([
'dictionaryCampaigns'
=>
$token
->
dictionaryCampaignsEnabledForNotExternal
,
'dictionaryCampaigns'
=>
$token
->
dictionaryCampaignsEnabledForNotExternal
ForNotReserveCreate
,
]);
]);
}
}
...
...
app/Console/Commands/CampaignsResume.php
View file @
1f978e1
...
@@ -2,9 +2,11 @@
...
@@ -2,9 +2,11 @@
namespace
App\Console\Commands
;
namespace
App\Console\Commands
;
use
App\Models\Pivots\DictionaryCampaign
;
use
App\Models\Tokens
;
use
App\Models\Tokens
;
use
App\Service\API\API
;
use
App\Service\API\API
;
use
App\Service\Requests\APIRequest
;
use
App\Service\Requests\APIRequest
;
use
Carbon\Carbon
;
use
Illuminate\Console\Command
;
use
Illuminate\Console\Command
;
class
CampaignsResume
extends
Command
class
CampaignsResume
extends
Command
...
@@ -56,8 +58,8 @@ class CampaignsResume extends Command
...
@@ -56,8 +58,8 @@ class CampaignsResume extends Command
}
}
*/
*/
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForExternalDisabled'
)
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForExternalDisabled
ForNotReserveResume
'
)
->
with
(
'dictionaryCampaignsEnabledForExternalDisabled'
)
->
with
(
'dictionaryCampaignsEnabledForExternalDisabled
ForNotReserveResume
'
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
get
();
->
get
();
...
@@ -65,9 +67,16 @@ class CampaignsResume extends Command
...
@@ -65,9 +67,16 @@ class CampaignsResume extends Command
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
->
setToken
(
$token
);
$factory
->
setToken
(
$token
);
foreach
(
array_chunk
(
$token
->
dictionaryCampaignsEnabledForExternalDisabledForNotReserveResume
->
pluck
(
'id'
)
->
toArray
(),
1000
)
as
$items
){
DictionaryCampaign
::
whereIn
(
'id'
,
$items
)
->
update
([
'reserve_resume_at'
=>
Carbon
::
now
(),
]);
}
$factory
->
getRequest
(
'Campaigns'
,
'resume'
)
$factory
->
getRequest
(
'Campaigns'
,
'resume'
)
->
call
([
->
call
([
'ids'
=>
$token
->
dictionaryCampaignsEnabledForExternalDisabled
->
pluck
(
'external_id'
)
->
toArray
(),
'ids'
=>
$token
->
dictionaryCampaignsEnabledForExternalDisabled
ForNotReserveResume
->
pluck
(
'external_id'
)
->
toArray
(),
]);
]);
}
}
...
...
app/Console/Commands/CampaignsSuspend.php
View file @
1f978e1
...
@@ -2,9 +2,11 @@
...
@@ -2,9 +2,11 @@
namespace
App\Console\Commands
;
namespace
App\Console\Commands
;
use
App\Models\Pivots\DictionaryCampaign
;
use
App\Models\Tokens
;
use
App\Models\Tokens
;
use
App\Service\API\API
;
use
App\Service\API\API
;
use
App\Service\Requests\APIRequest
;
use
App\Service\Requests\APIRequest
;
use
Carbon\Carbon
;
use
Illuminate\Console\Command
;
use
Illuminate\Console\Command
;
class
CampaignsSuspend
extends
Command
class
CampaignsSuspend
extends
Command
...
@@ -56,8 +58,8 @@ class CampaignsSuspend extends Command
...
@@ -56,8 +58,8 @@ class CampaignsSuspend extends Command
}
}
*/
*/
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsNotEnabledForExternalNotDisabled'
)
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsNotEnabledForExternalNotDisabled
ForNotReserveSuspend
'
)
->
with
(
'dictionaryCampaignsNotEnabledForExternalNotDisabled'
)
->
with
(
'dictionaryCampaignsNotEnabledForExternalNotDisabled
ForNotReserveSuspend
'
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
get
();
->
get
();
...
@@ -65,9 +67,16 @@ class CampaignsSuspend extends Command
...
@@ -65,9 +67,16 @@ class CampaignsSuspend extends Command
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
->
setToken
(
$token
);
$factory
->
setToken
(
$token
);
foreach
(
array_chunk
(
$token
->
dictionaryCampaignsNotEnabledForExternalNotDisabledForNotReserveSuspend
->
pluck
(
'id'
)
->
toArray
(),
1000
)
as
$items
){
DictionaryCampaign
::
whereIn
(
'id'
,
$items
)
->
update
([
'reserve_suspend_at'
=>
Carbon
::
now
(),
]);
}
$factory
->
getRequest
(
'Campaigns'
,
'suspend'
)
$factory
->
getRequest
(
'Campaigns'
,
'suspend'
)
->
call
([
->
call
([
'ids'
=>
$token
->
dictionaryCampaignsNotEnabledForExternalNotDisabled
->
pluck
(
'external_id'
)
->
toArray
(),
'ids'
=>
$token
->
dictionaryCampaignsNotEnabledForExternalNotDisabled
ForNotReserveSuspend
->
pluck
(
'external_id'
)
->
toArray
(),
]);
]);
}
}
...
...
app/Console/Commands/CampaignsUpdate.php
View file @
1f978e1
...
@@ -2,9 +2,11 @@
...
@@ -2,9 +2,11 @@
namespace
App\Console\Commands
;
namespace
App\Console\Commands
;
use
App\Models\Pivots\DictionaryCampaign
;
use
App\Models\Tokens
;
use
App\Models\Tokens
;
use
App\Service\API\API
;
use
App\Service\API\API
;
use
App\Service\Requests\APIRequest
;
use
App\Service\Requests\APIRequest
;
use
Carbon\Carbon
;
use
Illuminate\Console\Command
;
use
Illuminate\Console\Command
;
class
CampaignsUpdate
extends
Command
class
CampaignsUpdate
extends
Command
...
@@ -40,8 +42,8 @@ class CampaignsUpdate extends Command
...
@@ -40,8 +42,8 @@ class CampaignsUpdate extends Command
*/
*/
public
function
handle
()
public
function
handle
()
{
{
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated.campaign'
)
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
ForNotReserveUpdate
.campaign'
)
->
with
(
'dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated.campaign'
)
->
with
(
'dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
ForNotReserveUpdate
.campaign'
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
get
();
->
get
();
...
@@ -49,9 +51,16 @@ class CampaignsUpdate extends Command
...
@@ -49,9 +51,16 @@ class CampaignsUpdate extends Command
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
->
setToken
(
$token
);
$factory
->
setToken
(
$token
);
foreach
(
array_chunk
(
$token
->
dictionaryCampaignsEnabledForExternalUpdatedNeedUpdatedForNotReserveUpdate
->
pluck
(
'id'
)
->
toArray
(),
1000
)
as
$items
){
DictionaryCampaign
::
whereIn
(
'id'
,
$items
)
->
update
([
'reserve_update_at'
=>
Carbon
::
now
(),
]);
}
$factory
->
getRequest
(
'Campaigns'
,
'update'
)
$factory
->
getRequest
(
'Campaigns'
,
'update'
)
->
call
([
->
call
([
'dictionaryCampaigns'
=>
$token
->
dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
,
'dictionaryCampaigns'
=>
$token
->
dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
ForNotReserveUpdate
,
]);
]);
}
}
...
...
app/Console/Commands/KeywordsUpdate.php
View file @
1f978e1
...
@@ -2,9 +2,11 @@
...
@@ -2,9 +2,11 @@
namespace
App\Console\Commands
;
namespace
App\Console\Commands
;
use
App\Models\Pivots\GoalKeyword
;
use
App\Models\Tokens
;
use
App\Models\Tokens
;
use
App\Service\API\API
;
use
App\Service\API\API
;
use
App\Service\Requests\APIRequest
;
use
App\Service\Requests\APIRequest
;
use
Carbon\Carbon
;
use
Illuminate\Console\Command
;
use
Illuminate\Console\Command
;
use
Illuminate\Database\Eloquent\Relations\HasMany
;
use
Illuminate\Database\Eloquent\Relations\HasMany
;
use
Illuminate\Database\Eloquent\Relations\HasManyThrough
;
use
Illuminate\Database\Eloquent\Relations\HasManyThrough
;
...
@@ -61,6 +63,7 @@ class KeywordsUpdate extends Command
...
@@ -61,6 +63,7 @@ class KeywordsUpdate extends Command
$goalKeywords
=
DB
::
table
(
'goal_keywords'
)
$goalKeywords
=
DB
::
table
(
'goal_keywords'
)
->
join
(
'keywords'
,
'goal_keywords.keyword_id'
,
'='
,
'keywords.id'
)
->
join
(
'keywords'
,
'goal_keywords.keyword_id'
,
'='
,
'keywords.id'
)
->
whereNull
(
'keywords.deleted_at'
)
->
whereNull
(
'keywords.deleted_at'
)
->
whereNull
(
'keywords.reserve_update_at'
)
->
whereNotNull
(
'goal_advertisements.updated_need'
)
->
whereNotNull
(
'goal_advertisements.updated_need'
)
->
whereNotNull
(
'goal_keywords.goal_ad_group_external_id'
)
->
whereNotNull
(
'goal_keywords.goal_ad_group_external_id'
)
->
whereNotNull
(
'goal_keywords.dictionary_campaign_external_id'
)
->
whereNotNull
(
'goal_keywords.dictionary_campaign_external_id'
)
...
@@ -74,6 +77,13 @@ class KeywordsUpdate extends Command
...
@@ -74,6 +77,13 @@ class KeywordsUpdate extends Command
])
])
->
get
();
->
get
();
foreach
(
array_chunk
(
$goalKeywords
->
pluck
(
'id'
)
->
toArray
(),
1000
)
as
$items
){
GoalKeyword
::
whereIn
(
'id'
,
$items
)
->
update
([
'reserve_update_at'
=>
Carbon
::
now
(),
]);
}
$factory
->
getRequest
(
'Keywords'
,
'update'
)
$factory
->
getRequest
(
'Keywords'
,
'update'
)
->
call
([
->
call
([
'goalKeywords'
=>
$goalKeywords
,
'goalKeywords'
=>
$goalKeywords
,
...
...
app/Models/Campaigns.php
View file @
1f978e1
...
@@ -201,12 +201,14 @@ class Campaigns extends Model
...
@@ -201,12 +201,14 @@ class Campaigns extends Model
$campaign
->
copyInGoalCampaign
();
$campaign
->
copyInGoalCampaign
();
}
}
if
(
self
::
getPropertiesWatch
()
->
first
(
function
(
$property_name
)
use
(
$campaign
)
{
if
(
$campaign
->
manage
)
{
return
$campaign
->
{
$property_name
}
!==
$campaign
->
getOriginal
(
$property_name
);
if
(
self
::
getPropertiesWatch
()
->
first
(
function
(
$property_name
)
use
(
$campaign
)
{
}))
{
return
$campaign
->
{
$property_name
}
!==
$campaign
->
getOriginal
(
$property_name
);
$campaign
->
dictionaryCampaigns
()
->
forExternal
()
->
update
([
}))
{
'updated_need'
=>
Carbon
::
now
(),
$campaign
->
dictionaryCampaigns
()
->
forExternal
()
->
update
([
]);
'updated_need'
=>
Carbon
::
now
(),
]);
}
}
}
});
});
...
...
app/Models/Pivots/DictionaryCampaign.php
View file @
1f978e1
...
@@ -20,9 +20,9 @@ use Illuminate\Support\Collection;
...
@@ -20,9 +20,9 @@ use Illuminate\Support\Collection;
* @property-read DictionaryCampaignVariable[] $dictionaryCampaignVariables
* @property-read DictionaryCampaignVariable[] $dictionaryCampaignVariables
* @property-read Variable[] $variables
* @property-read Variable[] $variables
* @property-read \Illuminate\Database\Eloquent\Collection|GoalAdGroup[] $groups
* @property-read \Illuminate\Database\Eloquent\Collection|GoalAdGroup[] $groups
* @property-read \Illuminate\Database\Eloquent\Collection|GoalAdGroup[] $groupsForNotExternal
* @property-read \Illuminate\Database\Eloquent\Collection|GoalAdGroup[] $groupsForNotExternal
ForNotReserveCreate
* @property-read \Illuminate\Database\Eloquent\Collection|GoalAdGroup[] $groupsForExternalForUpdatedSelf
* @property-read \Illuminate\Database\Eloquent\Collection|GoalAdGroup[] $groupsForExternalForUpdatedSelf
* @property-read \Illuminate\Database\Eloquent\Collection|GoalAdGroup[] $groupsForExternalForNeedUpdated
* @property-read \Illuminate\Database\Eloquent\Collection|GoalAdGroup[] $groupsForExternalForNeedUpdated
ForNotReserveUpdate
* @mixin \Eloquent
* @mixin \Eloquent
* @property int $id
* @property int $id
* @property int|null $external_id
* @property int|null $external_id
...
@@ -44,6 +44,10 @@ use Illuminate\Support\Collection;
...
@@ -44,6 +44,10 @@ use Illuminate\Support\Collection;
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign notDisabled()
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign notDisabled()
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign disabled()
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign disabled()
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign forNotExternal()
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign forNotExternal()
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign forNotReserveCreate()
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign forNotReserveUpdate()
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign forNotReserveResume()
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign forNotReserveSuspend()
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign needUpdated()
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign needUpdated()
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign enabled($value = true)
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign enabled($value = true)
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign forUpdated($value = true)
* @method static \Illuminate\Database\Eloquent\Builder|DictionaryCampaign forUpdated($value = true)
...
@@ -110,6 +114,10 @@ class DictionaryCampaign extends Pivot
...
@@ -110,6 +114,10 @@ class DictionaryCampaign extends Pivot
'disabled_at'
,
'disabled_at'
,
'deleted_at'
,
'deleted_at'
,
'synced_need'
,
'synced_need'
,
'reserve_create_at'
,
'reserve_update_at'
,
'reserve_resume_at'
,
'reserve_suspend_at'
,
];
];
protected
$casts
=
[
protected
$casts
=
[
...
@@ -125,6 +133,10 @@ class DictionaryCampaign extends Pivot
...
@@ -125,6 +133,10 @@ class DictionaryCampaign extends Pivot
'synced'
=>
'boolean'
,
'synced'
=>
'boolean'
,
'disabled_at'
=>
'datetime'
,
'disabled_at'
=>
'datetime'
,
'synced_need'
=>
'datetime'
,
'synced_need'
=>
'datetime'
,
'reserve_create_at'
=>
'datetime'
,
'reserve_update_at'
=>
'datetime'
,
'reserve_resume_at'
=>
'datetime'
,
'reserve_suspend_at'
=>
'datetime'
,
];
];
public
$incrementing
=
true
;
public
$incrementing
=
true
;
...
@@ -147,6 +159,10 @@ class DictionaryCampaign extends Pivot
...
@@ -147,6 +159,10 @@ class DictionaryCampaign extends Pivot
'synced'
,
'synced'
,
'disabled_at'
,
'disabled_at'
,
'synced_need'
,
'synced_need'
,
'reserve_create_at'
,
'reserve_update_at'
,
'reserve_resume_at'
,
'reserve_suspend_at'
,
];
];
}
}
...
@@ -278,6 +294,42 @@ class DictionaryCampaign extends Pivot
...
@@ -278,6 +294,42 @@ class DictionaryCampaign extends Pivot
/**
/**
* @param Builder $query
* @param Builder $query
* @return Builder
*/
public
function
scopeForNotReserveCreate
(
$query
)
{
return
$query
->
whereNull
(
'reserve_create_at'
);
}
/**
* @param Builder $query
* @return Builder
*/
public
function
scopeForNotReserveUpdate
(
$query
)
{
return
$query
->
whereNull
(
'reserve_update_at'
);
}
/**
* @param Builder $query
* @return Builder
*/
public
function
scopeForNotReserveResume
(
$query
)
{
return
$query
->
whereNull
(
'reserve_resume_at'
);
}
/**
* @param Builder $query
* @return Builder
*/
public
function
scopeForNotReserveSuspend
(
$query
)
{
return
$query
->
whereNull
(
'reserve_suspend_at'
);
}
/**
* @param Builder $query
* @param bool $enabled
* @param bool $enabled
* @return Builder
* @return Builder
*/
*/
...
@@ -399,9 +451,9 @@ class DictionaryCampaign extends Pivot
...
@@ -399,9 +451,9 @@ class DictionaryCampaign extends Pivot
return
$this
->
hasMany
(
GoalAdGroup
::
class
,
'dictionary_campaign_id'
);
return
$this
->
hasMany
(
GoalAdGroup
::
class
,
'dictionary_campaign_id'
);
}
}
public
function
groupsForNotExternal
()
public
function
groupsForNotExternal
ForNotReserveCreate
()
{
{
return
$this
->
groups
()
->
forNotExternal
();
return
$this
->
groups
()
->
forNotExternal
()
->
forNotReserveCreate
()
;
}
}
public
function
groupsForExternalForUpdatedSelf
()
public
function
groupsForExternalForUpdatedSelf
()
...
@@ -409,9 +461,9 @@ class DictionaryCampaign extends Pivot
...
@@ -409,9 +461,9 @@ class DictionaryCampaign extends Pivot
return
$this
->
groups
()
->
forExternal
()
->
forUpdatedSelf
();
return
$this
->
groups
()
->
forExternal
()
->
forUpdatedSelf
();
}
}
public
function
groupsForExternalForNeedUpdated
()
public
function
groupsForExternalForNeedUpdated
ForNotReserveUpdate
()
{
{
return
$this
->
groups
()
->
forExternal
()
->
needUpdated
();
return
$this
->
groups
()
->
forExternal
()
->
needUpdated
()
->
forNotReserveUpdate
()
;
}
}
public
function
goalKeywords
()
public
function
goalKeywords
()
...
...
app/Models/Pivots/GoalAdGroup.php
View file @
1f978e1
...
@@ -34,6 +34,8 @@ use Illuminate\Support\Collection;
...
@@ -34,6 +34,8 @@ use Illuminate\Support\Collection;
* @property-read int|null $variables_count
* @property-read int|null $variables_count
* @method static Builder|GoalAdGroup forExternal()
* @method static Builder|GoalAdGroup forExternal()
* @method static Builder|GoalAdGroup forNotExternal()
* @method static Builder|GoalAdGroup forNotExternal()
* @method static Builder|GoalAdGroup forNotReserveCreate()
* @method static Builder|GoalAdGroup forNotReserveUpdate()
* @method static Builder|GoalAdGroup forUpdatedSelf()
* @method static Builder|GoalAdGroup forUpdatedSelf()
* @method static Builder|GoalAdGroup needUpdated()
* @method static Builder|GoalAdGroup needUpdated()
* @method static Builder|GoalAdGroup newModelQuery()
* @method static Builder|GoalAdGroup newModelQuery()
...
@@ -71,6 +73,8 @@ class GoalAdGroup extends Pivot
...
@@ -71,6 +73,8 @@ class GoalAdGroup extends Pivot
'external_updated_at'
,
'external_updated_at'
,
'updated_need'
,
'updated_need'
,
'updated_self'
,
'updated_self'
,
'reserve_create_at'
,
'reserve_update_at'
,
];
];
protected
$casts
=
[
protected
$casts
=
[
...
@@ -79,6 +83,8 @@ class GoalAdGroup extends Pivot
...
@@ -79,6 +83,8 @@ class GoalAdGroup extends Pivot
'external_updated_at'
=>
'datetime'
,
'external_updated_at'
=>
'datetime'
,
'updated_need'
=>
'datetime'
,
'updated_need'
=>
'datetime'
,
'updated_self'
=>
'datetime'
,
'updated_self'
=>
'datetime'
,
'reserve_create_at'
=>
'datetime'
,
'reserve_update_at'
=>
'datetime'
,
];
];
public
$incrementing
=
true
;
public
$incrementing
=
true
;
...
@@ -95,8 +101,10 @@ class GoalAdGroup extends Pivot
...
@@ -95,8 +101,10 @@ class GoalAdGroup extends Pivot
'negative_keywords'
,
'negative_keywords'
,
'external_upload_at'
,
'external_upload_at'
,
'external_updated_at'
,
'external_updated_at'
,
'updated_self'
,
'updated_need'
,
'updated_need'
,
'updated_self'
,
'reserve_create_at'
,
'reserve_update_at'
,
];
];
}
}
...
@@ -169,6 +177,24 @@ class GoalAdGroup extends Pivot
...
@@ -169,6 +177,24 @@ class GoalAdGroup extends Pivot
* @param Builder $query
* @param Builder $query
* @return Builder
* @return Builder
*/
*/
public
function
scopeForNotReserveCreate
(
$query
)
{
return
$query
->
whereNull
(
'reserve_create_at'
);
}
/**
* @param Builder $query
* @return Builder
*/
public
function
scopeForNotReserveUpdate
(
$query
)
{
return
$query
->
whereNull
(
'reserve_update_at'
);
}
/**
* @param Builder $query
* @return Builder
*/
public
function
scopeNeedUpdated
(
$query
)
public
function
scopeNeedUpdated
(
$query
)
{
{
return
$query
->
whereNotNull
(
'updated_need'
);
return
$query
->
whereNotNull
(
'updated_need'
);
...
...
app/Models/Pivots/GoalAdvertisement.php
View file @
1f978e1
...
@@ -25,6 +25,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
...
@@ -25,6 +25,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property-read Advertisement $advertisement
* @property-read Advertisement $advertisement
* @method static Builder|GoalAdvertisement forExternal()
* @method static Builder|GoalAdvertisement forExternal()
* @method static Builder|GoalAdvertisement forNotExternal()
* @method static Builder|GoalAdvertisement forNotExternal()
* @method static Builder|GoalAdvertisement forNotReserveCreate()
* @method static Builder|GoalAdvertisement forNotReserveUpdate()
* @method static Builder|GoalAdvertisement needUpdated()
* @method static Builder|GoalAdvertisement needUpdated()
* @method static Builder|GoalAdvertisement newModelQuery()
* @method static Builder|GoalAdvertisement newModelQuery()
* @method static Builder|GoalAdvertisement newQuery()
* @method static Builder|GoalAdvertisement newQuery()
...
@@ -60,6 +62,7 @@ class GoalAdvertisement extends Pivot
...
@@ -60,6 +62,7 @@ class GoalAdvertisement extends Pivot
'external_updated_at'
,
'external_updated_at'
,
'updated_need'
,
'updated_need'
,
'reserve_create_at'
,
'reserve_create_at'
,
'reserve_update_at'
,
];
];
protected
$casts
=
[
protected
$casts
=
[
...
@@ -67,6 +70,7 @@ class GoalAdvertisement extends Pivot
...
@@ -67,6 +70,7 @@ class GoalAdvertisement extends Pivot
'external_updated_at'
=>
'datetime'
,
'external_updated_at'
=>
'datetime'
,
'updated_need'
=>
'datetime'
,
'updated_need'
=>
'datetime'
,
'reserve_create_at'
=>
'datetime'
,
'reserve_create_at'
=>
'datetime'
,
'reserve_update_at'
=>
'datetime'
,
];
];
public
$incrementing
=
true
;
public
$incrementing
=
true
;
...
@@ -84,6 +88,8 @@ class GoalAdvertisement extends Pivot
...
@@ -84,6 +88,8 @@ class GoalAdvertisement extends Pivot
'external_upload_at'
,
'external_upload_at'
,
'external_updated_at'
,
'external_updated_at'
,
'updated_need'
,
'updated_need'
,
'reserve_create_at'
,
'reserve_update_at'
,
];
];
}
}
...
@@ -109,6 +115,24 @@ class GoalAdvertisement extends Pivot
...
@@ -109,6 +115,24 @@ class GoalAdvertisement extends Pivot
* @param Builder $query
* @param Builder $query
* @return Builder
* @return Builder
*/
*/
public
function
scopeForNotReserveCreate
(
$query
)
{
return
$query
->
whereNull
(
'reserve_create_at'
);
}
/**
* @param Builder $query
* @return Builder
*/
public
function
scopeForNotReserveUpdate
(
$query
)
{
return
$query
->
whereNull
(
'reserve_update_at'
);
}
/**
* @param Builder $query
* @return Builder
*/
public
function
scopeNeedUpdated
(
$query
)
public
function
scopeNeedUpdated
(
$query
)
{
{
return
$query
->
whereNotNull
(
'updated_need'
);
return
$query
->
whereNotNull
(
'updated_need'
);
...
...
app/Models/Pivots/GoalBidModifier.php
View file @
1f978e1
...
@@ -25,6 +25,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
...
@@ -25,6 +25,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property-read BidModifier $bidModifier
* @property-read BidModifier $bidModifier
* @method static Builder|BidModifiers forExternal()
* @method static Builder|BidModifiers forExternal()
* @method static Builder|BidModifiers forNotExternal()
* @method static Builder|BidModifiers forNotExternal()
* @method static Builder|BidModifiers forNotReserveCreate()
* @method static Builder|BidModifiers needUpdated()
* @method static Builder|BidModifiers needUpdated()
* @method static Builder|BidModifiers newModelQuery()
* @method static Builder|BidModifiers newModelQuery()
* @method static Builder|BidModifiers newQuery()
* @method static Builder|BidModifiers newQuery()
...
@@ -79,6 +80,7 @@ class GoalBidModifier extends Pivot
...
@@ -79,6 +80,7 @@ class GoalBidModifier extends Pivot
'external_upload_at'
,
'external_upload_at'
,
'external_updated_at'
,
'external_updated_at'
,
'updated_need'
,
'updated_need'
,
'reserve_create_at'
,
];
];
protected
$casts
=
[
protected
$casts
=
[
...
@@ -90,6 +92,7 @@ class GoalBidModifier extends Pivot
...
@@ -90,6 +92,7 @@ class GoalBidModifier extends Pivot
'external_upload_at'
=>
'datetime'
,
'external_upload_at'
=>
'datetime'
,
'external_updated_at'
=>
'datetime'
,
'external_updated_at'
=>
'datetime'
,
'updated_need'
=>
'datetime'
,
'updated_need'
=>
'datetime'
,
'reserve_create_at'
=>
'datetime'
,
];
];
public
$incrementing
=
true
;
public
$incrementing
=
true
;
...
@@ -116,6 +119,7 @@ class GoalBidModifier extends Pivot
...
@@ -116,6 +119,7 @@ class GoalBidModifier extends Pivot
'external_upload_at'
,
'external_upload_at'
,
'external_updated_at'
,
'external_updated_at'
,
'updated_need'
,
'updated_need'
,
'reserve_create_at'
,
];
];
}
}
...
@@ -141,6 +145,15 @@ class GoalBidModifier extends Pivot
...
@@ -141,6 +145,15 @@ class GoalBidModifier extends Pivot
* @param Builder $query
* @param Builder $query
* @return Builder
* @return Builder
*/
*/
public
function
scopeForNotReserveCreate
(
$query
)
{
return
$query
->
whereNull
(
'reserve_create_at'
);
}
/**
* @param Builder $query
* @return Builder
*/
public
function
scopeNeedUpdated
(
$query
)
public
function
scopeNeedUpdated
(
$query
)
{
{
return
$query
->
whereNotNull
(
'updated_need'
);
return
$query
->
whereNotNull
(
'updated_need'
);
...
...
app/Models/Pivots/GoalKeyword.php
View file @
1f978e1
...
@@ -60,6 +60,7 @@ class GoalKeyword extends Pivot
...
@@ -60,6 +60,7 @@ class GoalKeyword extends Pivot
'external_updated_at'
,
'external_updated_at'
,
'updated_need'
,
'updated_need'
,
'reserve_create_at'
,
'reserve_create_at'
,
'reserve_update_at'
,
];
];
protected
$casts
=
[
protected
$casts
=
[
...
@@ -67,6 +68,7 @@ class GoalKeyword extends Pivot
...
@@ -67,6 +68,7 @@ class GoalKeyword extends Pivot
'external_updated_at'
=>
'datetime'
,
'external_updated_at'
=>
'datetime'
,
'updated_need'
=>
'datetime'
,
'updated_need'
=>
'datetime'
,
'reserve_create_at'
=>
'datetime'
,
'reserve_create_at'
=>
'datetime'
,
'reserve_update_at'
=>
'datetime'
,
];
];
public
$incrementing
=
true
;
public
$incrementing
=
true
;
...
@@ -84,6 +86,8 @@ class GoalKeyword extends Pivot
...
@@ -84,6 +86,8 @@ class GoalKeyword extends Pivot
'external_upload_at'
,
'external_upload_at'
,
'external_updated_at'
,
'external_updated_at'
,
'updated_need'
,
'updated_need'
,
'reserve_create_at'
,
'reserve_update_at'
,
];
];
}
}
...
...
app/Models/Tokens.php
View file @
1f978e1
...
@@ -40,13 +40,13 @@ use Illuminate\Database\Eloquent\Model;
...
@@ -40,13 +40,13 @@ use Illuminate\Database\Eloquent\Model;
* @property-read int|null $dictionary_campaigns_count
* @property-read int|null $dictionary_campaigns_count
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsForExternal
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsForExternal
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsForExternalWithTrashed
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsForExternalWithTrashed
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForNotExternal
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForNotExternal
ForNotReserveCreate
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsNotEnabledForExternalNotDisabled
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsNotEnabledForExternalNotDisabled
ForNotReserveSuspend
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForExternal
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForExternal
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForExternalUpdated
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForExternalUpdated
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForExternalDisabled
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForExternalDisabled
ForNotReserveResume
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForExternalSynchronized
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForExternalSynchronized
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
ForNotReserveUpdate
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForExternalSynchronizedUpdatedSelf
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForExternalSynchronizedUpdatedSelf
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForExternalSynchronizedUpdatedChildren
* @property-read \Illuminate\Database\Eloquent\Collection|DictionaryCampaign[] $dictionaryCampaignsEnabledForExternalSynchronizedUpdatedChildren
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Dictionary[] $campaignsForManaged
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Dictionary[] $campaignsForManaged
...
@@ -100,21 +100,21 @@ class Tokens extends Model
...
@@ -100,21 +100,21 @@ class Tokens extends Model
{
{
return
$this
->
check_changes
return
$this
->
check_changes
?
$this
->
check_changes
?
$this
->
check_changes
:
Carbon
::
now
()
->
addDays
(
-
1
)
;
:
Carbon
::
now
();
}
}
public
function
getCheckChangesCampaignAtAttribute
()
public
function
getCheckChangesCampaignAtAttribute
()
{
{
return
$this
->
check_changes_campaign
return
$this
->
check_changes_campaign
?
$this
->
check_changes_campaign
?
$this
->
check_changes_campaign
:
Carbon
::
now
()
->
addDays
(
-
1
)
;
:
Carbon
::
now
();
}
}
public
function
getCheckChangesAdGroupAtAttribute
()
public
function
getCheckChangesAdGroupAtAttribute
()
{
{
return
$this
->
check_changes_ad_group
return
$this
->
check_changes_ad_group
?
$this
->
check_changes_ad_group
?
$this
->
check_changes_ad_group
:
Carbon
::
now
()
->
addDays
(
-
1
)
;
:
Carbon
::
now
();
}
}
/**
/**
...
@@ -208,24 +208,24 @@ class Tokens extends Model
...
@@ -208,24 +208,24 @@ class Tokens extends Model
return
$this
->
dictionaryCampaigns
()
->
enabled
()
->
forExternal
()
->
forUpdated
();
return
$this
->
dictionaryCampaigns
()
->
enabled
()
->
forExternal
()
->
forUpdated
();
}
}
public
function
dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
()
public
function
dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
ForNotReserveUpdate
()
{
{
return
$this
->
dictionaryCampaigns
()
->
enabled
()
->
forExternal
()
->
forUpdated
()
->
needUpdated
();
return
$this
->
dictionaryCampaigns
()
->
enabled
()
->
forExternal
()
->
forUpdated
()
->
needUpdated
()
->
forNotReserveUpdate
()
;
}
}
public
function
dictionaryCampaignsEnabledForNotExternal
()
public
function
dictionaryCampaignsEnabledForNotExternal
ForNotReserveCreate
()
{
{
return
$this
->
dictionaryCampaigns
()
->
enabled
()
->
forNotExternal
();
return
$this
->
dictionaryCampaigns
()
->
enabled
()
->
forNotExternal
()
->
forNotReserveCreate
()
;
}
}
public
function
dictionaryCampaignsNotEnabledForExternalNotDisabled
()
public
function
dictionaryCampaignsNotEnabledForExternalNotDisabled
ForNotReserveSuspend
()
{
{
return
$this
->
dictionaryCampaigns
()
->
enabled
(
false
)
->
forExternal
()
->
notDisabled
();
return
$this
->
dictionaryCampaigns
()
->
enabled
(
false
)
->
forExternal
()
->
notDisabled
()
->
forNotReserveSuspend
()
;
}
}
public
function
dictionaryCampaignsEnabledForExternalDisabled
()
public
function
dictionaryCampaignsEnabledForExternalDisabled
ForNotReserveResume
()
{
{
return
$this
->
dictionaryCampaigns
()
->
enabled
()
->
forExternal
()
->
disabled
();
return
$this
->
dictionaryCampaigns
()
->
enabled
()
->
forExternal
()
->
disabled
()
->
forNotReserveResume
()
;
}
}
public
function
dictionaryCampaignsEnabledForExternalSynchronized
()
public
function
dictionaryCampaignsEnabledForExternalSynchronized
()
...
...
app/Service/Requests/Direct/AddAdGroups.php
View file @
1f978e1
...
@@ -69,6 +69,7 @@ class AddAdGroups extends DirectRequest
...
@@ -69,6 +69,7 @@ class AddAdGroups extends DirectRequest
$goalAdGroup
->
update
([
$goalAdGroup
->
update
([
'external_id'
=>
$external_id
,
'external_id'
=>
$external_id
,
'external_upload_at'
=>
Carbon
::
now
(),
'external_upload_at'
=>
Carbon
::
now
(),
'reserve_create_at'
=>
null
,
]);
]);
$goalAdGroup
->
goalKeywords
()
->
update
([
$goalAdGroup
->
goalKeywords
()
->
update
([
...
@@ -90,6 +91,14 @@ class AddAdGroups extends DirectRequest
...
@@ -90,6 +91,14 @@ class AddAdGroups extends DirectRequest
}
}
}
}
public
function
failed
()
{
GoalAdGroup
::
whereIn
(
'id'
,
$this
->
goalAdGroups
->
pluck
(
'id'
)
->
toArray
())
->
update
([
'reserve_create_at'
=>
null
,
]);
}
public
function
putParams
(
$params
)
public
function
putParams
(
$params
)
{
{
$this
->
goalAdGroups
=
$params
[
'goalAdGroups'
];
$this
->
goalAdGroups
=
$params
[
'goalAdGroups'
];
...
...
app/Service/Requests/Direct/AddAds.php
View file @
1f978e1
...
@@ -72,6 +72,7 @@ class AddAds extends DirectRequest
...
@@ -72,6 +72,7 @@ class AddAds extends DirectRequest
->
update
([
->
update
([
'external_id'
=>
$external_id
,
'external_id'
=>
$external_id
,
'external_upload_at'
=>
Carbon
::
now
(),
'external_upload_at'
=>
Carbon
::
now
(),
'reserve_create_at'
=>
null
,
]);
]);
}
}
...
@@ -81,6 +82,14 @@ class AddAds extends DirectRequest
...
@@ -81,6 +82,14 @@ class AddAds extends DirectRequest
}
}
}
}
public
function
failed
()
{
GoalAdvertisement
::
whereIn
(
'id'
,
$this
->
goalAds
->
pluck
(
'id'
)
->
toArray
())
->
update
([
'reserve_create_at'
=>
null
,
]);
}
public
function
putParams
(
$params
)
public
function
putParams
(
$params
)
{
{
$this
->
goalAds
=
$params
[
'goalAds'
];
$this
->
goalAds
=
$params
[
'goalAds'
];
...
...
app/Service/Requests/Direct/AddBidModifiers.php
View file @
1f978e1
...
@@ -71,6 +71,7 @@ class AddBidModifiers extends DirectRequest
...
@@ -71,6 +71,7 @@ class AddBidModifiers extends DirectRequest
->
update
([
->
update
([
'external_id'
=>
$external_id
,
'external_id'
=>
$external_id
,
'external_upload_at'
=>
Carbon
::
now
(),
'external_upload_at'
=>
Carbon
::
now
(),
'reserve_create_at'
=>
null
,
]);
]);
}
}
...
@@ -80,6 +81,14 @@ class AddBidModifiers extends DirectRequest
...
@@ -80,6 +81,14 @@ class AddBidModifiers extends DirectRequest
}
}
}
}
public
function
failed
()
{
GoalBidModifier
::
whereIn
(
'id'
,
$this
->
goalBidModifiers
->
pluck
(
'id'
)
->
toArray
())
->
update
([
'reserve_create_at'
=>
null
,
]);
}
public
function
putParams
(
$params
)
public
function
putParams
(
$params
)
{
{
$this
->
goalBidModifiers
=
$params
[
'goalBidModifiers'
];
$this
->
goalBidModifiers
=
$params
[
'goalBidModifiers'
];
...
...
app/Service/Requests/Direct/AddCampaigns.php
View file @
1f978e1
...
@@ -71,6 +71,7 @@ class AddCampaigns extends DirectRequest
...
@@ -71,6 +71,7 @@ class AddCampaigns extends DirectRequest
$dictionaryCampaign
->
update
([
$dictionaryCampaign
->
update
([
'external_id'
=>
$external_id
,
'external_id'
=>
$external_id
,
'external_upload_at'
=>
Carbon
::
now
(),
'external_upload_at'
=>
Carbon
::
now
(),
'reserve_create_at'
=>
null
,
]);
]);
$dictionaryCampaign
->
groups
()
->
update
([
$dictionaryCampaign
->
groups
()
->
update
([
...
@@ -96,6 +97,14 @@ class AddCampaigns extends DirectRequest
...
@@ -96,6 +97,14 @@ class AddCampaigns extends DirectRequest
}
}
}
}
public
function
failed
()
{
DictionaryCampaign
::
whereIn
(
'id'
,
$this
->
dictionaryCampaigns
->
pluck
(
'id'
)
->
toArray
())
->
update
([
'reserve_create_at'
=>
null
,
]);
}
public
function
putParams
(
$params
)
public
function
putParams
(
$params
)
{
{
$this
->
dictionaryCampaigns
=
$params
[
'dictionaryCampaigns'
];
$this
->
dictionaryCampaigns
=
$params
[
'dictionaryCampaigns'
];
...
...
app/Service/Requests/Direct/CheckCampaignsChanges.php
View file @
1f978e1
...
@@ -70,9 +70,16 @@ class CheckCampaignsChanges extends DirectRequest
...
@@ -70,9 +70,16 @@ class CheckCampaignsChanges extends DirectRequest
}
}
}
}
$check_changes_campaign
=
Carbon
::
parse
(
$response
[
'result'
][
'Timestamp'
]);
if
(
$this
->
getToken
()
->
check_changes_campaign
&&
$this
->
getToken
()
->
check_changes_campaign
->
diff
(
$check_changes_campaign
)
->
invert
)
{
$check_changes_campaign
=
$this
->
getToken
()
->
check_changes_campaign
;
}
$this
->
getToken
()
->
update
([
$this
->
getToken
()
->
update
([
'check_changes_campaign'
=>
Carbon
::
parse
(
$response
[
'result'
][
'Timestamp'
])
,
'check_changes_campaign'
=>
$check_changes_campaign
,
]);
]);
$this
->
setToken
(
$this
->
getToken
()
->
refresh
());
$this
->
setToken
(
$this
->
getToken
()
->
refresh
());
}
}
...
...
app/Service/Requests/Direct/GetAdGroups.php
View file @
1f978e1
...
@@ -84,8 +84,6 @@ class GetAdGroups extends DirectRequest
...
@@ -84,8 +84,6 @@ class GetAdGroups extends DirectRequest
$external_id
=
(
string
)
$ad_group
[
'CampaignId'
];
$external_id
=
(
string
)
$ad_group
[
'CampaignId'
];
//$campaigns->firstWhere('external_id', $external_id);
if
(
!
$campaign
=
$campaigns
[
$external_id
]
??
false
)
{
if
(
!
$campaign
=
$campaigns
[
$external_id
]
??
false
)
{
continue
;
continue
;
}
}
...
...
app/Service/Requests/Direct/ResumeCampaigns.php
View file @
1f978e1
...
@@ -43,17 +43,11 @@ class ResumeCampaigns extends DirectRequest
...
@@ -43,17 +43,11 @@ class ResumeCampaigns extends DirectRequest
$external_id
=
(
string
)
$resume_result
[
'Id'
];
$external_id
=
(
string
)
$resume_result
[
'Id'
];
if
(
$this
->
getToken
()
->
isMain
())
{
DictionaryCampaign
::
where
(
'external_id'
,
$external_id
)
Campaigns
::
where
(
'external_id'
,
$external_id
)
->
update
([
->
update
([
'disabled_at'
=>
null
,
'disabled_at'
=>
null
,
'reserve_resume_at'
=>
null
,
]);
]);
}
else
{
DictionaryCampaign
::
where
(
'external_id'
,
$external_id
)
->
update
([
'disabled_at'
=>
null
,
]);
}
}
}
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
Log
::
debug
(
$e
);
Log
::
debug
(
$e
);
...
@@ -61,6 +55,14 @@ class ResumeCampaigns extends DirectRequest
...
@@ -61,6 +55,14 @@ class ResumeCampaigns extends DirectRequest
}
}
}
}
public
function
failed
()
{
DictionaryCampaign
::
whereIn
(
'external_id'
,
array_column
(
$this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
],
'Id'
))
->
update
([
'reserve_resume_at'
=>
null
,
]);
}
private
function
requestPrepare
(
$filter
)
private
function
requestPrepare
(
$filter
)
{
{
$this
->
setService
(
'Campaigns'
);
$this
->
setService
(
'Campaigns'
);
...
...
app/Service/Requests/Direct/SuspendCampaigns.php
View file @
1f978e1
...
@@ -44,17 +44,11 @@ class SuspendCampaigns extends DirectRequest
...
@@ -44,17 +44,11 @@ class SuspendCampaigns extends DirectRequest
$external_id
=
(
string
)
$suspend_result
[
'Id'
];
$external_id
=
(
string
)
$suspend_result
[
'Id'
];
if
(
$this
->
getToken
()
->
isMain
())
{
DictionaryCampaign
::
where
(
'external_id'
,
$external_id
)
Campaigns
::
where
(
'external_id'
,
$external_id
)
->
update
([
->
update
([
'disabled_at'
=>
Carbon
::
now
(),
'disabled_at'
=>
Carbon
::
now
(),
'reserve_suspend_at'
=>
null
,
]);
]);
}
else
{
DictionaryCampaign
::
where
(
'external_id'
,
$external_id
)
->
update
([
'disabled_at'
=>
Carbon
::
now
(),
]);
}
}
}
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
Log
::
debug
(
$e
);
Log
::
debug
(
$e
);
...
@@ -62,6 +56,14 @@ class SuspendCampaigns extends DirectRequest
...
@@ -62,6 +56,14 @@ class SuspendCampaigns extends DirectRequest
}
}
}
}
public
function
failed
()
{
DictionaryCampaign
::
whereIn
(
'external_id'
,
array_column
(
$this
->
getParams
()[
'SelectionCriteria'
][
'Ids'
],
'Id'
))
->
update
([
'reserve_suspend_at'
=>
null
,
]);
}
private
function
requestPrepare
(
$filter
)
private
function
requestPrepare
(
$filter
)
{
{
$this
->
setService
(
'Campaigns'
);
$this
->
setService
(
'Campaigns'
);
...
...
app/Service/Requests/Direct/UpdateAdGroups.php
View file @
1f978e1
...
@@ -3,15 +3,12 @@
...
@@ -3,15 +3,12 @@
namespace
App\Service\Requests\Direct
;
namespace
App\Service\Requests\Direct
;
use
App\Jobs\ProcessCallLimitedAPI
;
use
App\Jobs\ProcessCallLimitedAPI
;
use
App\Models\Campaigns
;
use
App\Models\Pivots\DictionaryCampaign
;
use
App\Models\Pivots\GoalAdGroup
;
use
App\Models\Pivots\GoalAdGroup
;
use
App\Models\Variable
;
use
App\Models\Variable
;
use
App\Service\Contract\APIRequest
;
use
App\Service\Contract\APIRequest
;
use
App\Service\Requests\DirectRequest
;
use
App\Service\Requests\DirectRequest
;
use
App\Service\StrReplaceByVariables
;
use
App\Service\StrReplaceByVariables
;
use
Carbon\Carbon
;
use
Carbon\Carbon
;
use
Illuminate\Database\Eloquent\Collection
;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Facades\Log
;
class
UpdateAdGroups
extends
DirectRequest
class
UpdateAdGroups
extends
DirectRequest
...
@@ -58,15 +55,29 @@ class UpdateAdGroups extends DirectRequest
...
@@ -58,15 +55,29 @@ class UpdateAdGroups extends DirectRequest
->
where
(
'external_id'
,
$external_id
)
->
where
(
'external_id'
,
$external_id
)
->
update
([
->
update
([
'updated_need'
=>
null
,
'updated_need'
=>
null
,
'reserve_update_at'
=>
null
,
]);
]);
}
}
$this
->
getToken
()
->
update
([
'check_changes_ad_group'
=>
Carbon
::
now
()
->
addSeconds
(
5
),
]);
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
Log
::
debug
(
$e
);
Log
::
debug
(
$e
);
throw
$e
;
throw
$e
;
}
}
}
}
public
function
failed
()
{
GoalAdGroup
::
whereIn
(
'external_id'
,
array_column
(
$this
->
getParams
()[
'AdGroups'
],
'Id'
))
->
update
([
'reserve_update_at'
=>
null
,
]);
}
private
function
requestPrepare
(
$params
)
private
function
requestPrepare
(
$params
)
{
{
$this
->
setService
(
'AdGroups'
);
$this
->
setService
(
'AdGroups'
);
...
...
app/Service/Requests/Direct/UpdateAds.php
View file @
1f978e1
...
@@ -9,6 +9,7 @@ use App\Models\Variable;
...
@@ -9,6 +9,7 @@ use App\Models\Variable;
use
App\Service\Contract\APIRequest
;
use
App\Service\Contract\APIRequest
;
use
App\Service\Requests\DirectRequest
;
use
App\Service\Requests\DirectRequest
;
use
App\Service\StrReplaceByVariables
;
use
App\Service\StrReplaceByVariables
;
use
Carbon\Carbon
;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Facades\Log
;
class
UpdateAds
extends
DirectRequest
class
UpdateAds
extends
DirectRequest
...
@@ -55,15 +56,29 @@ class UpdateAds extends DirectRequest
...
@@ -55,15 +56,29 @@ class UpdateAds extends DirectRequest
->
where
(
'external_id'
,
$external_id
)
->
where
(
'external_id'
,
$external_id
)
->
update
([
->
update
([
'updated_need'
=>
null
,
'updated_need'
=>
null
,
'reserve_update_at'
=>
null
,
]);
]);
}
}
$this
->
getToken
()
->
update
([
'check_changes_ad_group'
=>
Carbon
::
now
()
->
addSeconds
(
5
),
]);
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
Log
::
debug
(
$e
);
Log
::
debug
(
$e
);
throw
$e
;
throw
$e
;
}
}
}
}
public
function
failed
()
{
GoalAdvertisement
::
whereIn
(
'external_id'
,
array_column
(
$this
->
getParams
()[
'Ads'
],
'Id'
))
->
update
([
'reserve_update_at'
=>
null
,
]);
}
private
function
requestPrepare
(
$params
)
private
function
requestPrepare
(
$params
)
{
{
$this
->
setService
(
'Ads'
);
$this
->
setService
(
'Ads'
);
...
...
app/Service/Requests/Direct/UpdateCampaigns.php
View file @
1f978e1
...
@@ -57,14 +57,28 @@ class UpdateCampaigns extends DirectRequest
...
@@ -57,14 +57,28 @@ class UpdateCampaigns extends DirectRequest
->
where
(
'external_id'
,
$external_id
)
->
where
(
'external_id'
,
$external_id
)
->
update
([
->
update
([
'updated_need'
=>
null
,
'updated_need'
=>
null
,
'reserve_update_at'
=>
null
,
]);
]);
}
}
$this
->
getToken
()
->
update
([
'check_changes_campaign'
=>
Carbon
::
now
()
->
addSeconds
(
5
),
]);
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
Log
::
debug
(
$e
);
Log
::
debug
(
$e
);
throw
$e
;
throw
$e
;
}
}
}
}
public
function
failed
()
{
DictionaryCampaign
::
whereIn
(
'external_id'
,
array_column
(
$this
->
getParams
()[
'Campaigns'
],
'Id'
))
->
update
([
'reserve_update_at'
=>
null
,
]);
}
private
function
requestPrepare
(
$params
)
private
function
requestPrepare
(
$params
)
{
{
$this
->
setService
(
'Campaigns'
);
$this
->
setService
(
'Campaigns'
);
...
...
app/Service/Requests/Direct/UpdateKeywords.php
View file @
1f978e1
...
@@ -56,6 +56,7 @@ class UpdateKeywords extends DirectRequest
...
@@ -56,6 +56,7 @@ class UpdateKeywords extends DirectRequest
->
where
(
'external_id'
,
$external_id
)
->
where
(
'external_id'
,
$external_id
)
->
update
([
->
update
([
'updated_need'
=>
null
,
'updated_need'
=>
null
,
'reserve_update_at'
=>
null
,
]);
]);
}
}
...
@@ -65,6 +66,14 @@ class UpdateKeywords extends DirectRequest
...
@@ -65,6 +66,14 @@ class UpdateKeywords extends DirectRequest
}
}
}
}
public
function
failed
()
{
GoalKeyword
::
whereIn
(
'external_id'
,
array_column
(
$this
->
getParams
()[
'goalKeywords'
],
'Id'
))
->
update
([
'reserve_update_at'
=>
null
,
]);
}
private
function
requestPrepare
(
$params
)
private
function
requestPrepare
(
$params
)
{
{
$this
->
setService
(
'Keywords'
);
$this
->
setService
(
'Keywords'
);
...
...
database/migrations/2021_06_29_131245_add_reserve_columns.php
0 → 100644
View file @
1f978e1
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
AddReserveColumns
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'dictionary_campaigns'
,
function
(
Blueprint
$table
)
{
$table
->
timestamp
(
'reserve_create_at'
)
->
nullable
();
$table
->
timestamp
(
'reserve_update_at'
)
->
nullable
();
$table
->
timestamp
(
'reserve_resume_at'
)
->
nullable
();
$table
->
timestamp
(
'reserve_suspend_at'
)
->
nullable
();
});
Schema
::
table
(
'goal_ad_groups'
,
function
(
Blueprint
$table
)
{
$table
->
timestamp
(
'reserve_create_at'
)
->
nullable
();
$table
->
timestamp
(
'reserve_update_at'
)
->
nullable
();
});
Schema
::
table
(
'goal_bid_modifiers'
,
function
(
Blueprint
$table
)
{
$table
->
timestamp
(
'reserve_create_at'
)
->
nullable
();
});
Schema
::
table
(
'goal_advertisements'
,
function
(
Blueprint
$table
)
{
$table
->
timestamp
(
'reserve_create_at'
)
->
nullable
();
$table
->
timestamp
(
'reserve_update_at'
)
->
nullable
();
});
Schema
::
table
(
'goal_keywords'
,
function
(
Blueprint
$table
)
{
$table
->
timestamp
(
'reserve_update_at'
)
->
nullable
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
//
}
}
resources/js/Pages/Tokens/CitySettings.vue
View file @
1f978e1
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
<th
class=
"px-6 pt-6 pb-4"
>
Включено?
</th>
<th
class=
"px-6 pt-6 pb-4"
>
Включено?
</th>
<th
class=
"px-6 pt-6 pb-4"
></th>
<th
class=
"px-6 pt-6 pb-4"
></th>
</tr>
</tr>
<tr
v-if=
"city.dictionary_campaigns.length"
:key=
"dictionary_campaign.id"
v-for=
"dictionary_campaign in city.dictionary_campaigns"
>
<tr
v-if=
"city.dictionary_campaigns.length"
:key=
"
city.id + '-' +
dictionary_campaign.id"
v-for=
"dictionary_campaign in city.dictionary_campaigns"
>
<td
class=
"border-t"
></td>
<td
class=
"border-t"
></td>
<td
class=
"border-t"
>
<td
class=
"border-t"
>
<span
class=
"px-6 py-4 flex items-center focus:text-indigo-500"
>
<span
class=
"px-6 py-4 flex items-center focus:text-indigo-500"
>
...
...
tests/Unit/AddAdGroupTest.php
View file @
1f978e1
...
@@ -81,7 +81,7 @@ class AddAdGroupTest extends TestCase
...
@@ -81,7 +81,7 @@ class AddAdGroupTest extends TestCase
$this
->
assertEquals
(
1
,
$this
->
dictionary
->
campaigns
->
count
());
$this
->
assertEquals
(
1
,
$this
->
dictionary
->
campaigns
->
count
());
$this
->
params
=
[
$this
->
params
=
[
'dictionaryCampaigns'
=>
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
,
'dictionaryCampaigns'
=>
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
ForNotReserveCreate
,
'variables'
=>
Variable
::
all
(),
'variables'
=>
Variable
::
all
(),
];
];
...
...
tests/Unit/AddCampaignsTest.php
View file @
1f978e1
...
@@ -75,7 +75,7 @@ class AddCampaignsTest extends TestCase
...
@@ -75,7 +75,7 @@ class AddCampaignsTest extends TestCase
$this
->
assertEquals
(
11
,
$this
->
dictionary
->
campaigns
->
count
());
$this
->
assertEquals
(
11
,
$this
->
dictionary
->
campaigns
->
count
());
$this
->
params
=
[
$this
->
params
=
[
'dictionaryCampaigns'
=>
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
,
'dictionaryCampaigns'
=>
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
ForNotReserveCreate
,
'variables'
=>
Variable
::
all
(),
'variables'
=>
Variable
::
all
(),
];
];
...
@@ -121,10 +121,10 @@ class AddCampaignsTest extends TestCase
...
@@ -121,10 +121,10 @@ class AddCampaignsTest extends TestCase
public
function
test_prepare_request_and_slice
(){
public
function
test_prepare_request_and_slice
(){
$this
->
assertEquals
(
11
,
$this
->
dictionary
->
campaigns
->
count
());
$this
->
assertEquals
(
11
,
$this
->
dictionary
->
campaigns
->
count
());
$this
->
assertEquals
(
11
,
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
->
count
());
$this
->
assertEquals
(
11
,
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
ForNotReserveCreate
->
count
());
$this
->
request
->
requestPrepare
([
$this
->
request
->
requestPrepare
([
'dictionaryCampaigns'
=>
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
,
'dictionaryCampaigns'
=>
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
ForNotReserveCreate
,
'variables'
=>
Variable
::
all
(),
'variables'
=>
Variable
::
all
(),
]);
]);
...
@@ -144,7 +144,7 @@ class AddCampaignsTest extends TestCase
...
@@ -144,7 +144,7 @@ class AddCampaignsTest extends TestCase
public
function
test_call_api
(){
public
function
test_call_api
(){
Queue
::
fake
();
Queue
::
fake
();
$this
->
request
->
call
([
$this
->
request
->
call
([
'dictionaryCampaigns'
=>
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
,
'dictionaryCampaigns'
=>
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
ForNotReserveCreate
,
'variables'
=>
Variable
::
all
(),
'variables'
=>
Variable
::
all
(),
]);
]);
...
...
tests/Unit/CheckChangesAdGroupsTest.php
View file @
1f978e1
...
@@ -181,7 +181,6 @@ class CheckChangesAdGroupsTest extends TestCase
...
@@ -181,7 +181,6 @@ class CheckChangesAdGroupsTest extends TestCase
$this
->
assertEquals
(
0
,
AdGroup
::
forUpdatedSelf
()
->
count
());
$this
->
assertEquals
(
0
,
AdGroup
::
forUpdatedSelf
()
->
count
());
$this
->
assertEquals
(
$this
->
ad_group_data
[
'result'
][
'AdGroups'
][
0
][
'Name'
],
$this
->
ad_group
->
name
);
$this
->
assertEquals
(
$this
->
ad_group_data
[
'result'
][
'AdGroups'
][
0
][
'Name'
],
$this
->
ad_group
->
name
);
$this
->
assertEquals
(
$this
->
ad_group_data
[
'result'
][
'AdGroups'
][
0
][
'Name'
],
GoalAdGroup
::
first
()
->
name
);
$this
->
assertEquals
(
1
,
GoalAdGroup
::
needUpdated
()
->
count
());
$this
->
assertEquals
(
1
,
GoalAdGroup
::
needUpdated
()
->
count
());
...
...
tests/Unit/LimitsTest.php
View file @
1f978e1
...
@@ -174,7 +174,7 @@ class LimitsTest extends TestCase
...
@@ -174,7 +174,7 @@ class LimitsTest extends TestCase
$requestCmpgn
=
$request
->
getRequest
(
'Campaigns'
,
'update'
);
$requestCmpgn
=
$request
->
getRequest
(
'Campaigns'
,
'update'
);
$this
->
token
->
limit
=
191
;
$this
->
token
->
limit
=
191
;
$requestCmpgn
->
call
([
$requestCmpgn
->
call
([
'dictionaryCampaigns'
=>
$this
->
token
->
dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
'dictionaryCampaigns'
=>
$this
->
token
->
dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
ForNotReserveUpdate
]);
]);
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$requestCmpgn
);
$objects
=
$this
->
limitService
->
countObjectsLimit
(
$requestCmpgn
);
$this
->
assertEquals
(
$objects
,
0
);
$this
->
assertEquals
(
$objects
,
0
);
...
...
tests/Unit/ProcessCallSliceTest.php
View file @
1f978e1
...
@@ -75,10 +75,10 @@ class ProcessCallSliceTest extends TestCase
...
@@ -75,10 +75,10 @@ class ProcessCallSliceTest extends TestCase
);
);
$this
->
assertEquals
(
$this
->
dictionaries_count
,
$this
->
campaign
->
dictionaries
()
->
count
());
$this
->
assertEquals
(
$this
->
dictionaries_count
,
$this
->
campaign
->
dictionaries
()
->
count
());
$this
->
assertEquals
(
$this
->
dictionaries_count
,
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
->
count
());
$this
->
assertEquals
(
$this
->
dictionaries_count
,
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
ForNotReserveCreate
->
count
());
$this
->
params
=
[
$this
->
params
=
[
'dictionaryCampaigns'
=>
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
,
'dictionaryCampaigns'
=>
$this
->
token
->
dictionaryCampaignsEnabledForNotExternal
ForNotReserveCreate
,
'variables'
=>
Variable
::
all
(),
'variables'
=>
Variable
::
all
(),
];
];
...
...
tests/Unit/UpdateCampaignsTest.php
View file @
1f978e1
...
@@ -81,16 +81,16 @@ class UpdateCampaignsTest extends TestCase
...
@@ -81,16 +81,16 @@ class UpdateCampaignsTest extends TestCase
$dictionaryCampaign
->
update
(
$data
);
$dictionaryCampaign
->
update
(
$data
);
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated'
)
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
ForNotReserveUpdate
'
)
->
with
(
'dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated.campaign'
)
->
with
(
'dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
ForNotReserveUpdate
.campaign'
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
get
();
->
get
();
Queue
::
fake
();
Queue
::
fake
();
foreach
(
$tokens
as
$token
)
{
foreach
(
$tokens
as
$token
)
{
$this
->
assertEquals
(
$dictionaryCampaign
->
toArray
()[
'external_id'
],
$token
->
dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
->
toArray
()[
0
][
'external_id'
]);
$this
->
assertEquals
(
$dictionaryCampaign
->
toArray
()[
'external_id'
],
$token
->
dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
ForNotReserveUpdate
->
toArray
()[
0
][
'external_id'
]);
$this
->
request
->
call
([
$this
->
request
->
call
([
'dictionaryCampaigns'
=>
$token
->
dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
,
'dictionaryCampaigns'
=>
$token
->
dictionaryCampaignsEnabledForExternalUpdatedNeedUpdated
ForNotReserveUpdate
,
]);
]);
Queue
::
assertPushed
(
ProcessCallLimitedAPI
::
class
);
Queue
::
assertPushed
(
ProcessCallLimitedAPI
::
class
);
}
}
...
...
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