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 a5d3b5fa
authored
May 31, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#19465 Реализация синхронизации данных по РК.
1 parent
60bbf67a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
11 deletions
app/Service/Requests/Direct/AddCampaigns.php
app/Service/Requests/Direct/CheckCampaignsChange.php
app/Service/Requests/Direct/ResumeCampaigns.php
app/Service/Requests/Direct/UpdateCampaigns.php
tests/Feature/CityTest.php
app/Service/Requests/Direct/AddCampaigns.php
View file @
a5d3b5f
...
...
@@ -113,14 +113,14 @@ class AddCampaigns extends DirectRequest
}
if
(
$dictionaryCampaign
->
campaign
->
relevant_keywords_setting_budget_percent
)
{
$data
[
'RelevantKeywords'
]
=
[
$data
[
'
TextCampaign'
][
'
RelevantKeywords'
]
=
[
'BudgetPercent'
=>
$dictionaryCampaign
->
campaign
->
relevant_keywords_setting_budget_percent
,
'OptimizeGoalId'
=>
$dictionaryCampaign
->
campaign
->
relevant_keywords_setting_optimize_goal_id
,
];
}
if
(
$dictionaryCampaign
->
campaign
->
attribution_model
)
{
$data
[
'AttributionModel'
]
=
$dictionaryCampaign
->
campaign
->
attribution_model
;
$data
[
'
TextCampaign'
][
'
AttributionModel'
]
=
$dictionaryCampaign
->
campaign
->
attribution_model
;
}
if
(
$dictionaryCampaign
->
campaign
->
settings
&&
count
(
$dictionaryCampaign
->
campaign
->
settings
))
{
...
...
app/Service/Requests/Direct/CheckCampaignsChange.php
View file @
a5d3b5f
...
...
@@ -5,8 +5,6 @@ namespace App\Service\Requests\Direct;
use
App\Jobs\ProcessCallLimitedAPI
;
use
App\Models\Campaigns
;
use
App\Models\Pivots\DictionaryCampaign
;
use
App\Service\API\API
;
use
App\Service\Requests\APIRequest
;
use
App\Service\Requests\DirectRequest
;
use
Carbon\Carbon
;
...
...
@@ -42,18 +40,25 @@ class CheckCampaignsChange extends DirectRequest
$external_id
=
$campaign_data
[
'CampaignId'
];
if
(
$this
->
getToken
()
->
isMain
())
{
$data
[
'external_id'
]
=
$external_id
;
$data
[
'token'
]
=
$this
->
getToken
()
->
getKey
();
Campaigns
::
firstOrCreate
([
Campaigns
::
updateOrCreate
([
'external_id'
=>
$external_id
],
$data
);
}
else
{
$dictionaryCampaign
=
DictionaryCampaign
::
synchronized
()
->
find
(
$external_id
);
if
(
$dictionaryCampaign
)
{
$data
[
'external_updated_at'
]
=
Carbon
::
now
();
$dictionaryCampaign
->
update
(
$data
);
}
}
\Log
::
debug
(
$data
);
}
}
$this
->
getToken
()
->
update
([
...
...
@@ -65,7 +70,7 @@ class CheckCampaignsChange extends DirectRequest
private
function
requestPrepare
(
$params
)
{
$this
->
setService
(
'changes'
);
$this
->
setMethod
(
'check
Dictionarie
s'
);
$this
->
setMethod
(
'check
Campaign
s'
);
$this
->
setParams
([
"Timestamp"
=>
$this
->
getToken
()
->
timestamp
]);
...
...
app/Service/Requests/Direct/ResumeCampaigns.php
View file @
a5d3b5f
...
...
@@ -6,7 +6,6 @@ use App\Jobs\ProcessCallLimitedAPI;
use
App\Models\Campaigns
;
use
App\Models\Pivots\DictionaryCampaign
;
use
App\Service\Requests\DirectRequest
;
use
Carbon\Carbon
;
use
Illuminate\Support\Facades\Log
;
class
ResumeCampaigns
extends
DirectRequest
...
...
app/Service/Requests/Direct/UpdateCampaigns.php
View file @
a5d3b5f
...
...
@@ -34,7 +34,8 @@ class UpdateCampaigns extends DirectRequest
$external_id
=
$add_result
[
'Id'
]
??
''
;
if
(
!
$external_id
)
{
Log
::
debug
(
"AddCampaigns, empty Id, [dictionary_campaigns.id =
{
$this
->
dictionaryCampaigns
->
get
(
$key
)
->
getKey
()
}
]"
,
$add_result
);
Log
::
debug
(
"AddCampaigns, empty Id, [dictionary_campaigns.id =
{
$this
->
dictionaryCampaigns
->
get
(
$key
)
->
getKey
()
}
]"
);
Log
::
debug
(
$add_result
);
continue
;
}
...
...
tests/Feature/CityTest.php
View file @
a5d3b5f
...
...
@@ -119,7 +119,7 @@ class CityTest extends TestCase
foreach
(
$this
->
token
->
cities
as
$city
)
{
foreach
(
$city
->
campaigns
as
$campaign
)
{
if
(
$campaign
->
id
==
$campaign_ids
[
0
])
{
$this
->
assertEquals
(
fals
e
,
$campaign
->
pivot
->
updated
);
$this
->
assertEquals
(
tru
e
,
$campaign
->
pivot
->
updated
);
$this
->
assertEquals
(
true
,
$campaign
->
pivot
->
synced
);
$this
->
assertEquals
(
1
,
$campaign
->
dictionaryCampaignVariables
->
count
());
}
else
{
...
...
@@ -160,10 +160,8 @@ class CityTest extends TestCase
foreach
(
$this
->
token
->
cities
as
$city
)
{
foreach
(
$city
->
campaigns
as
$campaign
)
{
if
(
$campaign
->
id
==
$campaign_ids
[
0
])
{
/* TODO: не проходит валидацию, атрибуты верные
$this
->
assertEquals
(
true
,
$campaign
->
pivot
->
updated
);
$this
->
assertEquals
(
false
,
$campaign
->
pivot
->
synced
);
*/
}
}
}
...
...
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