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 a2e3a823
authored
Jun 16, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix add Keywords
1 parent
ae81013d
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
35 deletions
app/Console/Commands/KeywordsAdd.php
app/Service/Requests/Direct/AddAdGroups.php
app/Service/Requests/Direct/AddCampaigns.php
app/Service/Requests/Direct/AddKeywords.php
app/Service/Requests/Direct/DeleteKeywords.php
app/Service/Requests/Direct/UpdateAdGroups.php
app/Service/Requests/Direct/UpdateCampaigns.php
app/Service/Requests/Direct/UpdateKeywords.php
app/Console/Commands/KeywordsAdd.php
View file @
a2e3a82
...
@@ -6,6 +6,7 @@ use App\Models\Tokens;
...
@@ -6,6 +6,7 @@ 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
Illuminate\Console\Command
;
use
Illuminate\Console\Command
;
use
Illuminate\Database\Eloquent\Relations\HasMany
;
class
KeywordsAdd
extends
Command
class
KeywordsAdd
extends
Command
{
{
...
@@ -40,21 +41,27 @@ class KeywordsAdd extends Command
...
@@ -40,21 +41,27 @@ class KeywordsAdd extends Command
*/
*/
public
function
handle
()
public
function
handle
()
{
{
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForExternalSynchronized.goalKeywordsForNotExternal'
)
$tokens
=
Tokens
::
whereHas
(
'dictionaryCampaignsEnabledForExternalSynchronized.goalKeywordsForNotExternal
.keyword
'
)
->
with
([
->
with
([
'dictionaryCampaignsEnabledForExternalSynchronized.goalKeywordsForNotExternal.keyword'
,
'dictionaryCampaignsEnabledForExternalSynchronized.goalKeywordsForNotExternal'
=>
function
(
HasMany
$query
)
{
return
$query
->
has
(
'keyword'
);
},
'dictionaryCampaignsEnabledForExternalSynchronized.goalKeywordsForNotExternal.keyword'
])
])
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
where
(
'type'
,
'!='
,
Tokens
::
MAIN
)
->
get
();
->
get
();
foreach
(
$tokens
as
$token
)
{
foreach
(
$tokens
as
$token
)
{
$goalKeywords
=
$token
->
dictionaryCampaignsEnabledForExternalSynchronized
->
pluck
(
'goalKeywordsForNotExternal'
)
->
collapse
();
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
->
setToken
(
$token
);
$factory
->
setToken
(
$token
);
$factory
->
getRequest
(
'Keywords'
,
'add'
)
$factory
->
getRequest
(
'Keywords'
,
'add'
)
->
call
([
->
call
([
'goalKeywords'
=>
$token
->
dictionaryCampaignsEnabledForExternalSynchronized
->
pluck
(
'goalKeywordsForNotExternal'
)
'goalKeywords'
=>
$goalKeywords
,
->
collapse
(),
]);
]);
}
}
...
...
app/Service/Requests/Direct/AddAdGroups.php
View file @
a2e3a82
...
@@ -52,16 +52,15 @@ class AddAdGroups extends DirectRequest
...
@@ -52,16 +52,15 @@ class AddAdGroups extends DirectRequest
public
function
handle
(
$response
)
public
function
handle
(
$response
)
{
{
try
{
try
{
if
(
!
isset
(
$response
[
'result'
]))
{
Log
::
debug
(
$response
);
Log
::
debug
(
$this
->
getParams
());
}
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
Log
::
debug
(
$this
->
getParams
());
}
}
if
(
!
isset
(
$response
[
'result'
][
'AddResults'
]))
{
return
;
}
foreach
(
$response
[
'result'
][
'AddResults'
]
as
$key
=>
$add_result
)
{
foreach
(
$response
[
'result'
][
'AddResults'
]
as
$key
=>
$add_result
)
{
if
(
!
isset
(
$add_result
[
'Id'
]))
{
if
(
!
isset
(
$add_result
[
'Id'
]))
{
Log
::
debug
(
"AddAdGroup, empty Id"
);
Log
::
debug
(
"AddAdGroup, empty Id"
);
...
...
app/Service/Requests/Direct/AddCampaigns.php
View file @
a2e3a82
...
@@ -52,16 +52,15 @@ class AddCampaigns extends DirectRequest
...
@@ -52,16 +52,15 @@ class AddCampaigns extends DirectRequest
public
function
handle
(
$response
)
public
function
handle
(
$response
)
{
{
try
{
try
{
if
(
!
isset
(
$response
[
'result'
]))
{
Log
::
debug
(
$response
);
Log
::
debug
(
$this
->
getParams
());
}
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
Log
::
debug
(
$this
->
getParams
());
}
}
if
(
!
isset
(
$response
[
'result'
][
'AddResults'
]))
{
return
;
}
foreach
(
$response
[
'result'
][
'AddResults'
]
as
$key
=>
$add_result
)
{
foreach
(
$response
[
'result'
][
'AddResults'
]
as
$key
=>
$add_result
)
{
if
(
!
isset
(
$add_result
[
'Id'
]))
{
if
(
!
isset
(
$add_result
[
'Id'
]))
{
Log
::
debug
(
"AddCampaigns, empty Id"
);
Log
::
debug
(
"AddCampaigns, empty Id"
);
...
...
app/Service/Requests/Direct/AddKeywords.php
View file @
a2e3a82
...
@@ -50,17 +50,16 @@ class AddKeywords extends DirectRequest
...
@@ -50,17 +50,16 @@ class AddKeywords extends DirectRequest
public
function
handle
(
$response
)
public
function
handle
(
$response
)
{
{
try
{
try
{
Log
::
debug
(
$response
);
if
(
!
isset
(
$response
[
'result'
][
'AddResults'
]))
{
Log
::
debug
(
$response
);
Log
::
debug
(
$this
->
getParams
());
}
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
Log
::
debug
(
$this
->
getParams
());
}
}
if
(
!
isset
(
$response
[
'result'
][
'AddResults'
]))
{
return
;
}
foreach
(
$response
[
'result'
][
'AddResults'
]
as
$key
=>
$add_result
)
{
foreach
(
$response
[
'result'
][
'AddResults'
]
as
$key
=>
$add_result
)
{
if
(
!
isset
(
$add_result
[
'Id'
]))
{
if
(
!
isset
(
$add_result
[
'Id'
]))
{
Log
::
debug
(
"AddKeywords, empty Id"
);
Log
::
debug
(
"AddKeywords, empty Id"
);
...
@@ -77,7 +76,6 @@ class AddKeywords extends DirectRequest
...
@@ -77,7 +76,6 @@ class AddKeywords extends DirectRequest
'external_id'
=>
$external_id
,
'external_id'
=>
$external_id
,
'external_upload_at'
=>
Carbon
::
now
(),
'external_upload_at'
=>
Carbon
::
now
(),
]);
]);
}
}
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
Log
::
debug
(
$e
);
Log
::
debug
(
$e
);
...
...
app/Service/Requests/Direct/DeleteKeywords.php
View file @
a2e3a82
...
@@ -41,16 +41,15 @@ class DeleteKeywords extends DirectRequest
...
@@ -41,16 +41,15 @@ class DeleteKeywords extends DirectRequest
public
function
handle
(
$response
)
public
function
handle
(
$response
)
{
{
try
{
try
{
if
(
!
isset
(
$response
[
'result'
][
'DeleteResults'
]))
{
Log
::
debug
(
$response
);
Log
::
debug
(
$this
->
getParams
());
}
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
Log
::
debug
(
$this
->
getParams
());
}
}
if
(
!
isset
(
$response
[
'result'
][
'DeleteResults'
]))
{
return
;
}
foreach
(
$response
[
'result'
][
'DeleteResults'
]
as
$key
=>
$delete_result
)
{
foreach
(
$response
[
'result'
][
'DeleteResults'
]
as
$key
=>
$delete_result
)
{
if
(
!
isset
(
$delete_result
[
'Id'
]))
{
if
(
!
isset
(
$delete_result
[
'Id'
]))
{
Log
::
debug
(
"DeleteKeywords, empty Id"
);
Log
::
debug
(
"DeleteKeywords, empty Id"
);
...
...
app/Service/Requests/Direct/UpdateAdGroups.php
View file @
a2e3a82
...
@@ -42,16 +42,15 @@ class UpdateAdGroups extends DirectRequest
...
@@ -42,16 +42,15 @@ class UpdateAdGroups extends DirectRequest
public
function
handle
(
$response
)
public
function
handle
(
$response
)
{
{
try
{
try
{
if
(
!
isset
(
$response
[
'result'
][
'UpdateResults'
]))
{
Log
::
debug
(
$response
);
Log
::
debug
(
$this
->
getParams
());
}
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
Log
::
debug
(
$this
->
getParams
());
}
}
if
(
!
isset
(
$response
[
'result'
][
'UpdateResults'
]))
{
return
;
}
foreach
(
$response
[
'result'
][
'UpdateResults'
]
as
$key
=>
$update_result
)
{
foreach
(
$response
[
'result'
][
'UpdateResults'
]
as
$key
=>
$update_result
)
{
if
(
!
isset
(
$update_result
[
'Id'
]))
{
if
(
!
isset
(
$update_result
[
'Id'
]))
{
Log
::
debug
(
"UpdateAdGroup, empty Id"
);
Log
::
debug
(
"UpdateAdGroup, empty Id"
);
...
...
app/Service/Requests/Direct/UpdateCampaigns.php
View file @
a2e3a82
...
@@ -11,6 +11,7 @@ use App\Service\Requests\DirectRequest;
...
@@ -11,6 +11,7 @@ use App\Service\Requests\DirectRequest;
use
App\Service\StrReplaceByVariables
;
use
App\Service\StrReplaceByVariables
;
use
Carbon\Carbon
;
use
Carbon\Carbon
;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Facades\Log
;
use
phpDocumentor\Reflection\DocBlock\Tags\Return_
;
class
UpdateCampaigns
extends
DirectRequest
class
UpdateCampaigns
extends
DirectRequest
{
{
...
@@ -43,6 +44,10 @@ class UpdateCampaigns extends DirectRequest
...
@@ -43,6 +44,10 @@ class UpdateCampaigns extends DirectRequest
Log
::
debug
(
$this
->
getParams
());
Log
::
debug
(
$this
->
getParams
());
}
}
if
(
isset
(
$response
[
'result'
][
'UpdateResults'
]))
{
return
;
}
foreach
(
$response
[
'result'
][
'UpdateResults'
]
as
$key
=>
$add_result
)
{
foreach
(
$response
[
'result'
][
'UpdateResults'
]
as
$key
=>
$add_result
)
{
if
(
!
isset
(
$add_result
[
'Id'
]))
{
if
(
!
isset
(
$add_result
[
'Id'
]))
{
Log
::
debug
(
"UpdateCampaigns, empty Id"
);
Log
::
debug
(
"UpdateCampaigns, empty Id"
);
...
...
app/Service/Requests/Direct/UpdateKeywords.php
View file @
a2e3a82
...
@@ -39,16 +39,15 @@ class UpdateKeywords extends DirectRequest
...
@@ -39,16 +39,15 @@ class UpdateKeywords extends DirectRequest
public
function
handle
(
$response
)
public
function
handle
(
$response
)
{
{
try
{
try
{
if
(
!
isset
(
$response
[
'result'
][
'UpdateResults'
]))
{
Log
::
debug
(
$response
);
Log
::
debug
(
$this
->
getParams
());
}
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
if
(
isset
(
$response
[
'result'
][
'Errors'
]))
{
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$response
[
'Errors'
]);
Log
::
debug
(
$this
->
getParams
());
Log
::
debug
(
$this
->
getParams
());
}
}
if
(
!
isset
(
$response
[
'result'
][
'UpdateResults'
]))
{
return
;
}
foreach
(
$response
[
'result'
][
'UpdateResults'
]
as
$key
=>
$update_result
)
{
foreach
(
$response
[
'result'
][
'UpdateResults'
]
as
$key
=>
$update_result
)
{
if
(
!
isset
(
$update_result
[
'Id'
]))
{
if
(
!
isset
(
$update_result
[
'Id'
]))
{
Log
::
debug
(
"UpdateKeywords, empty Id"
);
Log
::
debug
(
"UpdateKeywords, empty Id"
);
...
...
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