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 27516d79
authored
Jul 07, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#19496 Запрос измененных объявлений
1 parent
7be069a6
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
70 additions
and
13 deletions
app/Console/Commands/AdvertisementsAdd.php
app/Console/Commands/AdvertisementsUpdate.php
app/Console/Commands/DictionaryCampaignsSyncByCampaign.php
app/Models/Advertisement.php
app/Models/Pivots/GoalAdvertisement.php
app/Models/VCard.php
app/Service/Requests/Direct/AddAds.php
app/Service/Requests/Direct/AddVCards.php
app/Service/Requests/Direct/GetAds.php
app/Service/Requests/Direct/UpdateAds.php
database/migrations/2021_07_07_075439_change_advertisements_column_v_card_id.php
app/Console/Commands/AdvertisementsAdd.php
View file @
27516d7
...
...
@@ -83,7 +83,7 @@ class AdvertisementsAdd extends Command
'advertisements.title2 as title2'
,
'advertisements.href as href'
,
'advertisements.display_url_path as display_url_path'
,
'advertisements.v_card_
id as v_card
_id'
,
'advertisements.v_card_
external_id as v_card_external
_id'
,
'advertisements.ad_image_hash as ad_image_hash'
,
'advertisements.site_link_set_id as site_link_set_id'
,
DB
::
raw
(
'JSON_ARRAYAGG(goal_ad_extensions.external_id) as ad_extension_ids'
),
...
...
app/Console/Commands/AdvertisementsUpdate.php
View file @
27516d7
...
...
@@ -73,7 +73,7 @@ class AdvertisementsUpdate extends Command
'advertisements.title2 as title2'
,
'advertisements.href as href'
,
'advertisements.display_url_path as display_url_path'
,
'advertisements.v_card_
id as v_card
_id'
,
'advertisements.v_card_
external_id as v_card_external
_id'
,
'advertisements.ad_image_hash as ad_image_hash'
,
'advertisements.site_link_set_id as site_link_set_id'
,
DB
::
raw
(
"JSON_OBJECTAGG('AdExtensionId', goal_ad_extensions.external_id, 'Operation', 'SET') as ad_extensions"
),
...
...
app/Console/Commands/DictionaryCampaignsSyncByCampaign.php
View file @
27516d7
...
...
@@ -167,13 +167,15 @@ class DictionaryCampaignsSyncByCampaign extends Command
//грузим объявления которых по какой то причне нет в целевых.
DB
::
insert
(
"
INSERT INTO goal_advertisements(dictionary_campaign_external_id, goal_ad_group_external_id, dictionary_campaign_id,
goal_ad_group_id, advertisement_id, created_at, updated_at)
SELECT gag.dictionary_campaign_external_id, gag.external_id, gag.dictionary_campaign_id, gag.id, ad.id, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
goal_ad_group_id, advertisement_id,
goal_v_card_id, goal_v_card_external_id,
created_at, updated_at)
SELECT gag.dictionary_campaign_external_id, gag.external_id, gag.dictionary_campaign_id, gag.id, ad.id,
gvc.id, gvc.external_id,
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
FROM advertisements ad
INNER JOIN ad_groups ag on ad.ad_group_id = ag.id
INNER JOIN goal_ad_groups gag on ag.id = gag.ad_group_id
LEFT JOIN goal_advertisements gad on ad.id = gad.advertisement_id AND gad.goal_ad_group_id=gag.id
WHERE gad.advertisement_id is null and ad.campaign_id is not null
LEFT JOIN v_cards vc on ad.v_card_external_id = vc.external_id
LEFT JOIN goal_v_cards gvc on vc.id = gvc.v_card_id and gag.dictionary_campaign_id = gvc.dictionary_campaign_id
WHERE gad.advertisement_id is null and ad.campaign_id is not null
"
);
//грузим связь объевлений к расширения которых по какой то причне нет в целевых.
...
...
app/Models/Advertisement.php
View file @
27516d7
...
...
@@ -83,7 +83,7 @@ class Advertisement extends Model
'mobile'
,
'display_domain'
,
'display_url_path'
,
'v_card_id'
,
'v_card_
external_
id'
,
'ad_image_hash'
,
'site_link_set_id'
,
'display_url_path_moderation'
,
...
...
@@ -128,7 +128,7 @@ class Advertisement extends Model
'text'
,
'href'
,
'display_url_path'
,
'v_card_id'
,
'v_card_
external_
id'
,
'ad_image_hash'
,
'site_link_set_id'
,
'ad_extensions'
,
...
...
app/Models/Pivots/GoalAdvertisement.php
View file @
27516d7
...
...
@@ -12,9 +12,11 @@ use Illuminate\Database\Eloquent\SoftDeletes;
*
* @property int $id
* @property int|null $external_id
* @property int|null $goal_v_card_external_id
* @property int|null $dictionary_campaign_external_id
* @property int|null $goal_ad_group_external_id
* @property int $dictionary_campaign_id
* @property int|null $goal_v_card_id
* @property int $goal_ad_group_id
* @property int $advertisement_id
* @property \Illuminate\Support\Carbon|null $external_upload_at
...
...
@@ -53,8 +55,10 @@ class GoalAdvertisement extends Pivot
protected
$fillable
=
[
'external_id'
,
'goal_v_card_external_id'
,
'goal_ad_group_external_id'
,
'dictionary_campaign_external_id'
,
'goal_v_card_id'
,
'goal_ad_group_id'
,
'dictionary_campaign_id'
,
'advertisement_id'
,
...
...
@@ -80,8 +84,10 @@ class GoalAdvertisement extends Pivot
return
[
'id'
,
'external_id'
,
'goal_v_card_external_id'
,
'goal_ad_group_external_id'
,
'dictionary_campaign_external_id'
,
'goal_v_card_id'
,
'goal_ad_group_id'
,
'dictionary_campaign_id'
,
'advertisement_id'
,
...
...
@@ -148,6 +154,11 @@ class GoalAdvertisement extends Pivot
return
$this
->
belongsTo
(
DictionaryCampaign
::
class
,
'dictionary_campaign_id'
);
}
public
function
goalVCard
()
{
return
$this
->
belongsTo
(
GoalVCard
::
class
,
'goal_v_card_id'
);
}
public
function
goalAdExtensions
()
{
return
$this
->
belongsToMany
(
GoalAdExtension
::
class
,
GoalAdvertisementGoalAdExtension
::
getModel
()
->
getTable
(),
'goal_advertisement_id'
,
'goal_ad_extension_id'
)
...
...
app/Models/VCard.php
View file @
27516d7
...
...
@@ -2,7 +2,7 @@
namespace
App\Models
;
use
App\Models\Pivots\Goal
NegativeKeywordSharedSe
t
;
use
App\Models\Pivots\Goal
Advertisemen
t
;
use
App\Models\Pivots\GoalVCard
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
...
...
@@ -72,4 +72,9 @@ class VCard extends Model
return
$this
->
hasMany
(
GoalVCard
::
class
,
'v_card_id'
);
}
public
function
goalAdvertisement
()
{
return
$this
->
hasMany
(
GoalAdvertisement
::
class
,
'v_card_id'
);
}
}
app/Service/Requests/Direct/AddAds.php
View file @
27516d7
...
...
@@ -146,8 +146,8 @@ class AddAds extends DirectRequest
$data
[
'TextAd'
][
'DisplayUrlPath'
]
=
$goalAdvertisement
->
display_url_path
;
}
if
(
$goalAdvertisement
->
v_card_id
)
{
$data
[
'TextAd'
][
'VCardId'
]
=
$goalAdvertisement
->
v_card_id
;
if
(
$goalAdvertisement
->
v_card_
external_
id
)
{
$data
[
'TextAd'
][
'VCardId'
]
=
$goalAdvertisement
->
v_card_
external_
id
;
}
if
(
$goalAdvertisement
->
ad_image_hash
)
{
...
...
app/Service/Requests/Direct/AddVCards.php
View file @
27516d7
...
...
@@ -80,6 +80,10 @@ class AddVCards extends DirectRequest
'reserve_create_at'
=>
null
,
]);
$goalVCard
->
goalAdvertisement
()
->
update
([
''
]);
}
}
catch
(
\Exception
$e
)
{
Log
::
debug
(
$e
);
...
...
app/Service/Requests/Direct/GetAds.php
View file @
27516d7
...
...
@@ -122,7 +122,7 @@ class GetAds extends DirectRequest
'mobile'
=>
$ad
[
'TextAd'
][
'Mobile'
]
===
'YES'
,
'display_domain'
=>
$ad
[
'TextAd'
][
'DisplayDomain'
],
'display_url_path'
=>
$ad
[
'TextAd'
][
'DisplayUrlPath'
],
'v_card_id'
=>
$ad
[
'TextAd'
][
'VCardId'
],
'v_card_
external_
id'
=>
$ad
[
'TextAd'
][
'VCardId'
],
'ad_image_hash'
=>
$ad
[
'TextAd'
][
'AdImageHash'
],
'site_link_set_id'
=>
$ad
[
'TextAd'
][
'SitelinkSetId'
],
'display_url_path_moderation'
=>
$ad
[
'TextAd'
][
'DisplayUrlPathModeration'
],
...
...
app/Service/Requests/Direct/UpdateAds.php
View file @
27516d7
...
...
@@ -130,8 +130,8 @@ class UpdateAds extends DirectRequest
$data
[
'TextAd'
][
'DisplayUrlPath'
]
=
StrReplaceByVariables
::
getInstance
(
$goalAdvertisement
->
display_url_path
,
$list
)
->
get
();
}
if
(
$goalAdvertisement
->
v_card_id
)
{
$data
[
'TextAd'
][
'VCardId'
]
=
$goalAdvertisement
->
v_card_id
;
if
(
$goalAdvertisement
->
v_card_
external_
id
)
{
$data
[
'TextAd'
][
'VCardId'
]
=
$goalAdvertisement
->
v_card_
external_
id
;
}
if
(
$goalAdvertisement
->
ad_image_hash
)
{
...
...
database/migrations/2021_07_07_075439_change_advertisements_column_v_card_id.php
0 → 100644
View file @
27516d7
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
ChangeAdvertisementsColumnVCardId
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'advertisements'
,
function
(
Blueprint
$table
)
{
$table
->
renameColumn
(
'v_card_id'
,
'v_card_external_id'
);
});
Schema
::
table
(
'goal_advertisements'
,
function
(
Blueprint
$table
)
{
$table
->
bigInteger
(
'goal_v_card_id'
)
->
nullable
();
$table
->
bigInteger
(
'goal_v_card_external_id'
)
->
nullable
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
//
}
}
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