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 fbb8704d
authored
Jun 03, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#19472 Синхронизация групп с целевыми
1 parent
95745322
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
110 additions
and
95 deletions
app/Console/Commands/AdGroupsAdd.php
app/Models/AdGroup.php
app/Models/Pivots/GoalAdGroup.php
app/Service/Requests/Direct/AddAdGroup.php
app/Service/Requests/Direct/AddCampaigns.php
app/Service/Requests/Direct/GetAdGroups.php
database/migrations/2021_05_14_094834_create_ad_groups_table.php
database/migrations/2021_06_02_10638_create_goal_ad_groups_table.php
app/Console/Commands/AdGroupsAdd.php
View file @
fbb8704
...
@@ -43,7 +43,10 @@ class AdGroupsAdd extends Command
...
@@ -43,7 +43,10 @@ class AdGroupsAdd extends Command
public
function
handle
()
public
function
handle
()
{
{
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForExternal.groupsForNotExternal'
)
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForExternal.groupsForNotExternal'
)
->
with
(
'dictionaryCampaignsEnabledForExternal.groupsForNotExternal'
)
->
with
([
'dictionaryCampaignsEnabledForExternal.groupsForNotExternal.dictionaryCampaign'
,
'dictionaryCampaignsEnabledForExternal.groupsForNotExternal.group'
,
])
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
get
();
->
get
();
...
@@ -54,7 +57,8 @@ class AdGroupsAdd extends Command
...
@@ -54,7 +57,8 @@ class AdGroupsAdd extends Command
$factory
->
getRequest
(
'AdGroup'
,
'add'
)
$factory
->
getRequest
(
'AdGroup'
,
'add'
)
->
call
([
->
call
([
'goalAdGroups'
=>
$token
->
dictionaryCampaignsEnabledForExternal
->
pluck
(
'groupsForNotExternal'
),
'goalAdGroups'
=>
$token
->
dictionaryCampaignsEnabledForExternal
->
pluck
(
'groupsForNotExternal'
)
->
collapse
(),
]);
]);
}
}
...
...
app/Models/AdGroup.php
View file @
fbb8704
...
@@ -78,15 +78,21 @@ class AdGroup extends Model
...
@@ -78,15 +78,21 @@ class AdGroup extends Model
'external_id'
,
'external_id'
,
'campaign_external_id'
,
'campaign_external_id'
,
'name'
,
'name'
,
'region_ids'
,
'negative_keywords'
,
'negative_keyword_shared_set_ids'
,
'tracking_params'
,
'mobile_app_ad_group'
,
'dynamic_text_ad_group'
,
'dynamic_text_feed_ad_group'
,
'cpm_banner_user_profile_ad_group'
,
'cpm_video_ad_group'
,
'smart_ad_group'
,
'status'
,
'status'
,
'type'
,
'type'
,
'sub_type'
,
'sub_type'
,
'serving_status'
,
'serving_status'
,
'restricted_region_ids'
,
'restricted_region_ids'
,
'region_ids'
,
'negative_keywords'
,
'negative_keyword_shared_set_ids'
,
'tracking_params'
,
'updated_self'
,
'updated_self'
,
];
];
...
@@ -94,10 +100,16 @@ class AdGroup extends Model
...
@@ -94,10 +100,16 @@ class AdGroup extends Model
'campaign_id'
=>
'int'
,
'campaign_id'
=>
'int'
,
'external_id'
=>
'int'
,
'external_id'
=>
'int'
,
'campaign_external_id'
=>
'int'
,
'campaign_external_id'
=>
'int'
,
'restricted_region_ids'
=>
'json'
,
'region_ids'
=>
'array'
,
'region_ids'
=>
'array'
,
'negative_keywords'
=>
'json'
,
'negative_keywords'
=>
'json'
,
'negative_keyword_shared_set_ids'
=>
'json'
,
'negative_keyword_shared_set_ids'
=>
'json'
,
'mobile_app_ad_group'
=>
'json'
,
'dynamic_text_ad_group'
=>
'json'
,
'dynamic_text_feed_ad_group'
=>
'json'
,
'cpm_banner_user_profile_ad_group'
=>
'json'
,
'cpm_video_ad_group'
=>
'json'
,
'smart_ad_group'
=>
'json'
,
'restricted_region_ids'
=>
'json'
,
'updated_self'
=>
'datetime'
,
'updated_self'
=>
'datetime'
,
];
];
...
...
app/Models/Pivots/GoalAdGroup.php
View file @
fbb8704
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
namespace
App\Models\Pivots
;
namespace
App\Models\Pivots
;
use
App\Models\AdGroup
;
use
App\Models\AdGroup
;
use
App\Models\Campaigns
;
use
App\Models\Variable
;
use
App\Models\Variable
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Database\Eloquent\Relations\Pivot
;
use
Illuminate\Database\Eloquent\Relations\Pivot
;
...
@@ -17,6 +16,7 @@ class GoalAdGroup extends Pivot
...
@@ -17,6 +16,7 @@ class GoalAdGroup extends Pivot
protected
$fillable
=
[
protected
$fillable
=
[
'external_id'
,
'external_id'
,
'campaign_external_id'
,
'campaign_external_id'
,
'ad_group_id'
,
'dictionary_campaign_id'
,
'dictionary_campaign_id'
,
'name'
,
'name'
,
'negative_keywords'
,
'negative_keywords'
,
...
@@ -27,9 +27,10 @@ class GoalAdGroup extends Pivot
...
@@ -27,9 +27,10 @@ class GoalAdGroup extends Pivot
];
];
protected
$casts
=
[
protected
$casts
=
[
'dictionary_campaign_id'
=>
'int'
,
'external_id'
=>
'int'
,
'external_id'
=>
'int'
,
'campaign_external_id'
=>
'int'
,
'campaign_external_id'
=>
'int'
,
'ad_group_id'
=>
'int'
,
'dictionary_campaign_id'
=>
'int'
,
'negative_keywords'
=>
'array'
,
'negative_keywords'
=>
'array'
,
'external_upload_at'
=>
'datetime'
,
'external_upload_at'
=>
'datetime'
,
'external_updated_at'
=>
'datetime'
,
'external_updated_at'
=>
'datetime'
,
...
@@ -43,6 +44,7 @@ class GoalAdGroup extends Pivot
...
@@ -43,6 +44,7 @@ class GoalAdGroup extends Pivot
'id'
,
'id'
,
'external_id'
,
'external_id'
,
'campaign_external_id'
,
'campaign_external_id'
,
'ad_group_id'
,
'dictionary_campaign_id'
,
'dictionary_campaign_id'
,
'name'
,
'name'
,
'negative_keywords'
,
'negative_keywords'
,
...
@@ -82,9 +84,10 @@ class GoalAdGroup extends Pivot
...
@@ -82,9 +84,10 @@ class GoalAdGroup extends Pivot
return
[
return
[
$property_name
=>
$value
$property_name
=>
$value
];
];
})
->
flatMap
(
function
(
$val
)
{
})
return
$val
;
->
collapse
()
})
->
all
();
->
put
(
'ad_group_id'
,
$ad_group
[
AdGroup
::
getModel
()
->
getKeyName
()])
->
all
();
}
}
public
function
scopeForExternal
(
Builder
$query
)
public
function
scopeForExternal
(
Builder
$query
)
...
@@ -107,9 +110,14 @@ class GoalAdGroup extends Pivot
...
@@ -107,9 +110,14 @@ class GoalAdGroup extends Pivot
$query
->
whereNotNull
(
'updated_self'
);
$query
->
whereNotNull
(
'updated_self'
);
}
}
public
function
group
()
{
return
$this
->
belongsTo
(
AdGroup
::
class
,
'ad_group_id'
);
}
public
function
dictionaryCampaign
()
public
function
dictionaryCampaign
()
{
{
return
$this
->
belongsTo
(
Campaigns
::
class
,
'dictionary_campaign_id'
);
return
$this
->
belongsTo
(
DictionaryCampaign
::
class
,
'dictionary_campaign_id'
);
}
}
public
function
dictionaryCampaignVariables
()
public
function
dictionaryCampaignVariables
()
...
...
app/Service/Requests/Direct/AddAdGroup.php
View file @
fbb8704
...
@@ -5,6 +5,7 @@ namespace App\Service\Requests\Direct;
...
@@ -5,6 +5,7 @@ namespace App\Service\Requests\Direct;
use
App\Jobs\ProcessCallLimitedAPI
;
use
App\Jobs\ProcessCallLimitedAPI
;
use
App\Models\Campaigns
;
use
App\Models\Campaigns
;
use
App\Models\Pivots\DictionaryCampaign
;
use
App\Models\Pivots\DictionaryCampaign
;
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
;
...
@@ -15,13 +16,11 @@ use Illuminate\Support\Facades\Log;
...
@@ -15,13 +16,11 @@ use Illuminate\Support\Facades\Log;
class
AddAdGroup
extends
DirectRequest
class
AddAdGroup
extends
DirectRequest
{
{
CONST
MAX_COUNT
=
1
0
;
protected
$max_count
=
100
0
;
protected
$timestamp
;
protected
$timestamp
;
/* @var Collection|DictionaryCampaign[] $dictionaryCampaigns */
/* @var Collection|GoalAdGroup[] */
protected
$dictionaryCampaigns
;
protected
$goalAdGroups
;
/* @var Collection|Variable[] $dictionaryCampaigns */
protected
$variables
;
public
function
call
(
$params
=
null
)
public
function
call
(
$params
=
null
)
{
{
...
@@ -32,7 +31,7 @@ class AddAdGroup extends DirectRequest
...
@@ -32,7 +31,7 @@ class AddAdGroup extends DirectRequest
public
function
getObjectsCount
()
public
function
getObjectsCount
()
{
{
return
count
(
$this
->
getParams
()[
'
Campaign
s'
]);
return
count
(
$this
->
getParams
()[
'
AdGroup
s'
]);
}
}
public
function
slice
(
$maxObjects
)
:
?
APIRequest
public
function
slice
(
$maxObjects
)
:
?
APIRequest
...
@@ -40,11 +39,11 @@ class AddAdGroup extends DirectRequest
...
@@ -40,11 +39,11 @@ class AddAdGroup extends DirectRequest
$splinter
=
$this
->
sliceByKey
(
$maxObjects
,
'Campaigns'
);
$splinter
=
$this
->
sliceByKey
(
$maxObjects
,
'Campaigns'
);
$splinter
->
putParams
([
$splinter
->
putParams
([
'
dictionaryCampaigns'
=>
$this
->
dictionaryCampaign
s
->
slice
(
$maxObjects
)
->
values
(),
'
goalAdGroups'
=>
$this
->
goalAdGroup
s
->
slice
(
$maxObjects
)
->
values
(),
]);
]);
$this
->
putParams
([
$this
->
putParams
([
'
dictionaryCampaigns'
=>
$this
->
dictionaryCampaign
s
->
slice
(
0
,
$maxObjects
),
'
goalAdGroups'
=>
$this
->
goalAdGroup
s
->
slice
(
0
,
$maxObjects
),
]);
]);
return
$splinter
;
return
$splinter
;
...
@@ -62,23 +61,19 @@ class AddAdGroup extends DirectRequest
...
@@ -62,23 +61,19 @@ class AddAdGroup extends DirectRequest
$external_id
=
$add_result
[
'Id'
]
??
''
;
$external_id
=
$add_result
[
'Id'
]
??
''
;
if
(
!
$external_id
)
{
if
(
!
$external_id
)
{
Log
::
debug
(
"Add
Campaigns
, empty Id"
);
Log
::
debug
(
"Add
AdGroup
, empty Id"
);
Log
::
debug
(
$add_result
);
Log
::
debug
(
$add_result
);
Log
::
debug
(
$this
->
getParams
());
Log
::
debug
(
$this
->
getParams
());
continue
;
continue
;
}
}
$
dictionaryCampaign
=
$this
->
dictionaryCampaign
s
->
get
(
$key
);
$
goalAdGroup
=
$this
->
goalAdGroup
s
->
get
(
$key
);
$
dictionaryCampaign
->
update
([
$
goalAdGroup
->
update
([
'external_id'
=>
$external_id
,
'external_id'
=>
$external_id
,
'external_upload_at'
=>
Carbon
::
now
(),
'external_upload_at'
=>
Carbon
::
now
(),
]);
]);
$dictionaryCampaign
->
groups
()
->
update
([
'campaign_external_id'
=>
$external_id
,
]);
}
}
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
Log
::
debug
(
$e
);
Log
::
debug
(
$e
);
...
@@ -87,12 +82,12 @@ class AddAdGroup extends DirectRequest
...
@@ -87,12 +82,12 @@ class AddAdGroup extends DirectRequest
public
function
putParams
(
$params
)
public
function
putParams
(
$params
)
{
{
$this
->
dictionaryCampaigns
=
$params
[
'dictionaryCampaign
s'
];
$this
->
goalAdGroups
=
$params
[
'goalAdGroup
s'
];
}
}
private
function
requestPrepare
(
$params
)
private
function
requestPrepare
(
$params
)
{
{
$this
->
setService
(
'
Campaign
s'
);
$this
->
setService
(
'
AdGroup
s'
);
$this
->
setMethod
(
'add'
);
$this
->
setMethod
(
'add'
);
$this
->
putParams
(
$params
);
$this
->
putParams
(
$params
);
...
@@ -100,77 +95,59 @@ class AddAdGroup extends DirectRequest
...
@@ -100,77 +95,59 @@ class AddAdGroup extends DirectRequest
$variables
=
Variable
::
all
();
$variables
=
Variable
::
all
();
$this
->
setParams
([
$this
->
setParams
([
'
Campaigns'
=>
$this
->
dictionaryCampaigns
->
map
(
function
(
DictionaryCampaign
$dictionaryCampaign
)
use
(
$variables
)
{
'
AdGroups'
=>
$this
->
goalAdGroups
->
map
(
function
(
GoalAdGroup
$goalAdGroup
)
use
(
$variables
)
{
$list
=
Variable
::
getListVariablesByDictionaryCampaign
(
$dictionaryCampaign
,
$variables
);
$list
=
Variable
::
getListVariablesByDictionaryCampaign
(
$
goalAdGroup
->
dictionaryCampaign
,
$variables
);
$data
=
[
$data
=
[
'Name'
=>
StrReplaceByVariables
::
getInstance
(
$dictionaryCampaign
->
name
,
$list
)
->
get
(),
'Name'
=>
StrReplaceByVariables
::
getInstance
(
$goalAdGroup
->
name
,
$list
)
->
get
(),
'StartDate'
=>
Carbon
::
now
()
->
format
(
'Y-m-d'
),
'CampaignId'
=>
$goalAdGroup
->
campaign_external_id
,
'TextCampaign'
=>
[
'RegionIds'
=>
$goalAdGroup
->
group
->
region_ids
,
'BiddingStrategy'
=>
$dictionaryCampaign
->
campaign
->
bidding_strategy
,
],
];
];
if
(
$
dictionaryCampaign
->
campaign
->
priority_goals
&&
count
(
$dictionaryCampaign
->
campaign
->
priority_goals
)
)
{
if
(
$
goalAdGroup
->
group
->
tracking_params
)
{
$data
[
'
PriorityGoals'
]
=
$dictionaryCampaign
->
campaign
->
priority_goal
s
;
$data
[
'
TrackingParams'
]
=
$goalAdGroup
->
group
->
tracking_param
s
;
}
}
if
(
$
dictionaryCampaign
->
campaign
->
daily_budget
&&
count
(
$dictionaryCampaign
->
campaign
->
daily_budget
))
{
if
(
$
goalAdGroup
->
group
->
mobile_app_ad_group
&&
count
(
$goalAdGroup
->
group
->
mobile_app_ad_group
))
{
$data
[
'
DailyBudget'
]
=
$dictionaryCampaign
->
campaign
->
daily_budget
;
$data
[
'
MobileAppAdGroup'
]
=
$goalAdGroup
->
group
->
mobile_app_ad_group
;
}
}
if
(
$dictionaryCampaign
->
negative_keywords
&&
count
(
$dictionaryCampaign
->
negative_keywords
))
{
if
(
$goalAdGroup
->
group
->
dynamic_text_ad_group
&&
count
(
$goalAdGroup
->
group
->
dynamic_text_ad_group
))
{
$data
[
'NegativeKeywords'
]
=
[
$data
[
'DynamicTextAdGroup'
]
=
$goalAdGroup
->
group
->
dynamic_text_ad_group
;
'Items'
=>
array_map
(
function
(
$value
)
use
(
$list
)
{
return
StrReplaceByVariables
::
getInstance
(
$value
,
$list
)
->
get
();
},
$dictionaryCampaign
->
negative_keywords
),
];
}
}
if
(
$dictionaryCampaign
->
campaign
->
blocked_ips
&&
count
(
$dictionaryCampaign
->
campaign
->
blocked_ips
))
{
if
(
$goalAdGroup
->
group
->
dynamic_text_feed_ad_group
&&
count
(
$goalAdGroup
->
group
->
dynamic_text_feed_ad_group
))
{
$data
[
'BlockedIps'
]
=
[
$data
[
'DynamicTextFeedAdGroup'
]
=
$goalAdGroup
->
group
->
dynamic_text_feed_ad_group
;
'Items'
=>
$dictionaryCampaign
->
campaign
->
blocked_ips
,
];
}
}
if
(
$dictionaryCampaign
->
excluded_sites
&&
count
(
$dictionaryCampaign
->
excluded_sites
))
{
/* TODO При создании есть параметр при получении в директ нет
$data
[
'ExcludedSites'
]
=
[
* $data['CpmBannerKeywordsAdGroup']
'Items'
=>
array_map
(
function
(
$value
)
use
(
$list
)
{
*/
return
StrReplaceByVariables
::
getInstance
(
$value
,
$list
)
->
get
();
},
$dictionaryCampaign
->
excluded_sites
),
];
}
if
(
$
dictionaryCampaign
->
campaign
->
relevant_keywords
)
{
if
(
$
goalAdGroup
->
group
->
cpm_banner_user_profile_ad_group
&&
count
(
$goalAdGroup
->
group
->
cpm_banner_user_profile_ad_group
)
)
{
$data
[
'
TextCampaign'
][
'RelevantKeywords'
]
=
$dictionaryCampaign
->
campaign
->
relevant_keywords
;
$data
[
'
CpmBannerUserProfileAdGroup'
]
=
$goalAdGroup
->
group
->
cpm_banner_user_profile_ad_group
;
}
}
if
(
$
dictionaryCampaign
->
campaign
->
attribution_model
)
{
if
(
$
goalAdGroup
->
group
->
cpm_video_ad_group
&&
count
(
$goalAdGroup
->
group
->
cpm_video_ad_group
)
)
{
$data
[
'
TextCampaign'
][
'AttributionModel'
]
=
$dictionaryCampaign
->
campaign
->
attribution_model
;
$data
[
'
CpmVideoAdGroup'
]
=
$goalAdGroup
->
group
->
cpm_video_ad_group
;
}
}
if
(
$dictionaryCampaign
->
campaign
->
settings
&&
count
(
$dictionaryCampaign
->
campaign
->
settings
))
{
if
(
$goalAdGroup
->
group
->
smart_ad_group
&&
count
(
$goalAdGroup
->
group
->
smart_ad_group
))
{
$data
[
'SmartAdGroup'
]
=
$goalAdGroup
->
group
->
smart_ad_group
;
$settingsAllow
=
Campaigns
::
getSettingOptionsAllow
();
}
$settings
=
[];
foreach
(
$dictionaryCampaign
->
campaign
->
settings
as
$setting
)
{
if
(
isset
(
$setting
[
'Option'
])
&&
in_array
(
$setting
[
'Option'
],
$settingsAllow
))
{
$settings
[]
=
$setting
;
}
}
if
(
count
(
$settings
))
{
$data
[
'TextCampaign'
][
'Settings'
]
=
$settings
;
}
if
(
$goalAdGroup
->
negative_keywords
&&
count
(
$goalAdGroup
->
negative_keywords
))
{
$data
[
'NegativeKeywords'
]
=
[
'Items'
=>
array_map
(
function
(
$value
)
use
(
$list
)
{
return
StrReplaceByVariables
::
getInstance
(
$value
,
$list
)
->
get
();
},
$goalAdGroup
->
negative_keywords
),
];
}
}
if
(
$
dictionaryCampaign
->
campaign
->
counter_ids
&&
count
(
$dictionaryCampaign
->
campaign
->
counter
_ids
))
{
if
(
$
goalAdGroup
->
group
->
negative_keyword_shared_set_ids
&&
count
(
$goalAdGroup
->
group
->
negative_keyword_shared_set
_ids
))
{
$data
[
'
TextCampaign'
][
'Counter
Ids'
]
=
[
$data
[
'
NegativeKeywordSharedSet
Ids'
]
=
[
'Items'
=>
$
dictionaryCampaign
->
campaign
->
counter
_ids
,
'Items'
=>
$
goalAdGroup
->
group
->
negative_keyword_shared_set
_ids
,
];
];
}
}
...
...
app/Service/Requests/Direct/AddCampaigns.php
View file @
fbb8704
...
@@ -19,10 +19,8 @@ class AddCampaigns extends DirectRequest
...
@@ -19,10 +19,8 @@ class AddCampaigns extends DirectRequest
protected
$max_count
=
10
;
protected
$max_count
=
10
;
protected
$timestamp
;
protected
$timestamp
;
/* @var Collection|DictionaryCampaign[]
$dictionaryCampaigns
*/
/* @var Collection|DictionaryCampaign[] */
protected
$dictionaryCampaigns
;
protected
$dictionaryCampaigns
;
/* @var Collection|Variable[] $dictionaryCampaigns */
protected
$variables
;
public
function
call
(
$params
=
null
)
public
function
call
(
$params
=
null
)
{
{
...
...
app/Service/Requests/Direct/GetAdGroups.php
View file @
fbb8704
...
@@ -6,6 +6,7 @@ use App\Jobs\ProcessCallLimitedAPI;
...
@@ -6,6 +6,7 @@ use App\Jobs\ProcessCallLimitedAPI;
use
App\Models\AdGroup
;
use
App\Models\AdGroup
;
use
App\Models\Campaigns
;
use
App\Models\Campaigns
;
use
App\Models\Pivots\DictionaryCampaign
;
use
App\Models\Pivots\DictionaryCampaign
;
use
App\Models\Pivots\GoalAdGroup
;
use
App\Service\Requests\DirectRequest
;
use
App\Service\Requests\DirectRequest
;
use
Carbon\Carbon
;
use
Carbon\Carbon
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
...
@@ -64,15 +65,22 @@ class GetAdGroups extends DirectRequest
...
@@ -64,15 +65,22 @@ class GetAdGroups extends DirectRequest
'external_id'
=>
$external_id
,
'external_id'
=>
$external_id
,
'campaign_external_id'
=>
$ad_group
[
'CampaignId'
],
'campaign_external_id'
=>
$ad_group
[
'CampaignId'
],
'name'
=>
$ad_group
[
'Name'
],
'name'
=>
$ad_group
[
'Name'
],
'region_ids'
=>
$ad_group
[
'RegionIds'
],
'negative_keywords'
=>
$ad_group
[
'NegativeKeywords'
],
'negative_keyword_shared_set_ids'
=>
$ad_group
[
'NegativeKeywordSharedSetIds'
],
'tracking_params'
=>
$ad_group
[
'TrackingParams'
],
'mobile_app_ad_group'
=>
$ad_group
[
'MobileAppAdGroup'
]
??
null
,
'dynamic_text_ad_group'
=>
$ad_group
[
'DynamicTextAdGroup'
]
??
null
,
'dynamic_text_feed_ad_group'
=>
$ad_group
[
'DynamicTextFeedAdGroup'
]
??
null
,
'cpm_banner_user_profile_ad_group'
=>
$ad_group
[
'CpmBannerUserProfileAdGroup'
]
??
null
,
'cpm_video_ad_group'
=>
$ad_group
[
'CpmVideoAdGroup'
]
??
null
,
'smart_ad_group'
=>
$ad_group
[
'SmartAdGroup'
]
??
null
,
'status'
=>
$ad_group
[
'Status'
],
'status'
=>
$ad_group
[
'Status'
],
'type'
=>
$ad_group
[
'Type'
],
'type'
=>
$ad_group
[
'Type'
],
'sub_type'
=>
$ad_group
[
'Subtype'
],
'sub_type'
=>
$ad_group
[
'Subtype'
],
'serving_status'
=>
$ad_group
[
'ServingStatus'
],
'serving_status'
=>
$ad_group
[
'ServingStatus'
],
'restricted_region_ids'
=>
$ad_group
[
'RestrictedRegionIds'
],
'restricted_region_ids'
=>
$ad_group
[
'RestrictedRegionIds'
],
'region_ids'
=>
$ad_group
[
'RegionIds'
],
'negative_keywords'
=>
$ad_group
[
'NegativeKeywords'
],
'negative_keyword_shared_set_ids'
=>
$ad_group
[
'NegativeKeywordSharedSetIds'
],
'tracking_params'
=>
$ad_group
[
'TrackingParams'
],
'updated_self'
=>
null
,
'updated_self'
=>
null
,
];
];
...
@@ -82,14 +90,13 @@ class GetAdGroups extends DirectRequest
...
@@ -82,14 +90,13 @@ class GetAdGroups extends DirectRequest
'external_id'
=>
$external_id
'external_id'
=>
$external_id
],
$data
);
],
$data
);
}
else
{
}
else
{
$dictionaryCampaign
=
DictionaryCampaign
::
synchronized
()
$goalAdGroup
=
GoalAdGroup
::
find
(
$external_id
);
->
find
(
$external_id
);
if
(
!
$
dictionaryCampaign
)
if
(
!
$
goalAdGroup
)
continue
;
continue
;
$
dictionaryCampaign
->
update
(
$
goalAdGroup
->
update
(
$
dictionaryCampaign
::
copyPropertyFromMain
(
$campaign_
data
)
$
goalAdGroup
::
copyPropertyFromMain
(
$
data
)
);
);
}
}
...
...
database/migrations/2021_05_14_094834_create_ad_groups_table.php
View file @
fbb8704
...
@@ -20,7 +20,16 @@ class CreateAdGroupsTable extends Migration
...
@@ -20,7 +20,16 @@ class CreateAdGroupsTable extends Migration
$table
->
bigInteger
(
'external_id'
)
->
unique
();
$table
->
bigInteger
(
'external_id'
)
->
unique
();
$table
->
bigInteger
(
'campaign_external_id'
);
$table
->
bigInteger
(
'campaign_external_id'
);
$table
->
string
(
'name'
,
255
)
->
nullable
();
$table
->
string
(
'name'
,
255
)
->
nullable
();
$table
->
json
(
'region_ids'
)
->
nullable
();
$table
->
json
(
'negative_keywords'
)
->
nullable
();
$table
->
json
(
'negative_keyword_shared_set_ids'
)
->
nullable
();
$table
->
string
(
'tracking_params'
,
255
)
->
nullable
();
$table
->
string
(
'tracking_params'
,
255
)
->
nullable
();
$table
->
json
(
'mobile_app_ad_group'
)
->
nullable
();
$table
->
json
(
'dynamic_text_ad_group'
)
->
nullable
();
$table
->
json
(
'dynamic_text_feed_ad_group'
)
->
nullable
();
$table
->
json
(
'cpm_banner_user_profile_ad_group'
)
->
nullable
();
$table
->
json
(
'cpm_video_ad_group'
)
->
nullable
();
$table
->
json
(
'smart_ad_group'
)
->
nullable
();
$table
->
enum
(
'status'
,
[
$table
->
enum
(
'status'
,
[
AdGroup
::
STATUS_ACCEPTED
,
AdGroup
::
STATUS_ACCEPTED
,
AdGroup
::
STATUS_DRAFT
,
AdGroup
::
STATUS_DRAFT
,
...
@@ -48,9 +57,6 @@ class CreateAdGroupsTable extends Migration
...
@@ -48,9 +57,6 @@ class CreateAdGroupsTable extends Migration
AdGroup
::
SUB_TYPE_USER_PROFILE
,
AdGroup
::
SUB_TYPE_USER_PROFILE
,
])
->
nullable
();
])
->
nullable
();
$table
->
json
(
'restricted_region_ids'
)
->
nullable
();
$table
->
json
(
'restricted_region_ids'
)
->
nullable
();
$table
->
json
(
'region_ids'
)
->
nullable
();
$table
->
json
(
'negative_keywords'
)
->
nullable
();
$table
->
json
(
'negative_keyword_shared_set_ids'
)
->
nullable
();
$table
->
timestamp
(
'updated_self'
)
->
nullable
();
$table
->
timestamp
(
'updated_self'
)
->
nullable
();
$table
->
timestamps
();
$table
->
timestamps
();
...
...
database/migrations/2021_06_02_10638_create_goal_ad_groups_table.php
View file @
fbb8704
...
@@ -17,6 +17,7 @@ class CreateGoalAdGroupsTable extends Migration
...
@@ -17,6 +17,7 @@ class CreateGoalAdGroupsTable extends Migration
$table
->
id
();
$table
->
id
();
$table
->
bigInteger
(
'external_id'
)
->
nullable
();
$table
->
bigInteger
(
'external_id'
)
->
nullable
();
$table
->
bigInteger
(
'campaign_external_id'
)
->
nullable
();
$table
->
bigInteger
(
'campaign_external_id'
)
->
nullable
();
$table
->
bigInteger
(
'ad_group_id'
)
->
unsigned
();
$table
->
bigInteger
(
'dictionary_campaign_id'
)
->
unsigned
();
$table
->
bigInteger
(
'dictionary_campaign_id'
)
->
unsigned
();
$table
->
string
(
'name'
,
255
)
->
nullable
();
$table
->
string
(
'name'
,
255
)
->
nullable
();
$table
->
text
(
'negative_keywords'
)
->
nullable
();
$table
->
text
(
'negative_keywords'
)
->
nullable
();
...
@@ -29,6 +30,8 @@ class CreateGoalAdGroupsTable extends Migration
...
@@ -29,6 +30,8 @@ class CreateGoalAdGroupsTable extends Migration
$table
->
foreign
(
'dictionary_campaign_id'
)
->
references
(
'id'
)
->
on
(
'dictionary_campaigns'
)
$table
->
foreign
(
'dictionary_campaign_id'
)
->
references
(
'id'
)
->
on
(
'dictionary_campaigns'
)
->
cascadeOnDelete
();
->
cascadeOnDelete
();
$table
->
foreign
(
'ad_group_id'
)
->
references
(
'id'
)
->
on
(
'ad_groups'
)
->
cascadeOnDelete
();
});
});
}
}
...
...
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