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 e1e10193
authored
Sep 07, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#20794 Сделать чтобы в целевых РК оставалась одна карточка
1 parent
a89e30f3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
93 additions
and
7 deletions
app/Console/Kernel.php
app/Jobs/ProcessCallAPI.php
app/Models/Pivots/GoalAdvertisement.php
app/Models/YandexError.php
app/Service/Requests/Direct/AddAds.php
database/migrations/2021_09_07_091521_create_yandex_errors_table.php
app/Console/Kernel.php
View file @
e1e1019
...
...
@@ -67,7 +67,7 @@ class Kernel extends ConsoleKernel
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected
function
schedule
(
Schedule
$schedule
)
protected
function
schedule
(
Schedule
$schedule
)
{
$schedule
->
command
(
DictionaryCampaignsSyncByCampaign
::
class
)
->
everyThirtyMinutes
();
...
...
@@ -109,12 +109,12 @@ class Kernel extends ConsoleKernel
$schedule
->
command
(
VCardsLoad
::
class
)
->
hourlyAt
(
25
);
$schedule
->
command
(
VCardsAdd
::
class
)
->
hourlyAt
(
35
);
$schedule
->
command
(
AdImagesAdd
::
class
)
->
hourlyAt
(
35
);
//
$schedule->command(AdImagesAdd::class)->hourlyAt(35);
$schedule
->
command
(
AdExtensionsAdd
::
class
)
->
hourlyAt
(
35
);
$schedule
->
command
(
SitelinksAdd
::
class
)
->
hourlyAt
(
35
);
$schedule
->
command
(
NegativeKeywordSharedSetsAdd
::
class
)
->
hourlyAt
(
35
);
$schedule
->
command
(
NegativeKeywordSharedSetsUpdate
::
class
)
->
hourlyAt
(
35
);
$schedule
->
command
(
RetargetinglistsAdd
::
class
)
->
hourlyAt
(
35
);
//
$schedule->command(RetargetinglistsAdd::class)->hourlyAt(35);
$schedule
->
command
(
RetargetinglistsUpdate
::
class
)
->
hourlyAt
(
35
);
$schedule
->
command
(
AdGroupsDelete
::
class
)
->
hourlyAt
(
30
);
...
...
@@ -130,7 +130,7 @@ class Kernel extends ConsoleKernel
$schedule
->
command
(
KeywordsUpdate
::
class
)
->
hourlyAt
(
40
);
$schedule
->
command
(
AdvertisementsAdd
::
class
)
->
hourlyAt
(
50
);
$schedule
->
command
(
AdvertisementsUpdate
::
class
)
->
hourlyAt
(
50
);
//
$schedule->command(AdvertisementsUpdate::class)->hourlyAt(50);
$schedule
->
command
(
AdvertisementsArchive
::
class
)
->
hourlyAt
(
50
);
$schedule
->
call
(
function
()
{
...
...
app/Jobs/ProcessCallAPI.php
View file @
e1e1019
...
...
@@ -75,9 +75,7 @@ class ProcessCallAPI implements ShouldQueue
//https://yandex.ru/dev/direct/doc/dg/concepts/errors.html
//Log::debug($this->api->getParams());
Log
::
debug
(
''
);
Log
::
debug
(
"Token id:
{
$this
->
api
->
getToken
()
->
getKey
()
}
"
);
Log
::
debug
(
"Service:
{
$this
->
api
->
getService
()
}
"
);
Log
::
debug
(
"Method:
{
$this
->
api
->
getMethod
()
}
"
);
Log
::
debug
(
"Exception in ProcessCallAPI, удаляем резервирование баллов. token_id
{
$this
->
api
->
getToken
()
->
getKey
()
}
, объектов
{
$this
->
api
->
getObjectsCount
()
}
{
$this
->
api
->
getService
()
}
{
$this
->
api
->
getMethod
()
}
"
);
$limits
->
removeRezerv
(
$this
->
limitId
);
throw
$e
;
}
...
...
app/Models/Pivots/GoalAdvertisement.php
View file @
e1e1019
...
...
@@ -3,6 +3,7 @@
namespace
App\Models\Pivots
;
use
App\Models\Advertisement
;
use
App\Models\YandexError
;
use
Illuminate\Database\Eloquent\Builder
;
use
Illuminate\Database\Eloquent\Relations\Pivot
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
...
...
@@ -277,4 +278,9 @@ class GoalAdvertisement extends Pivot
return
$this
->
goalAdExtensions
()
->
forNotExternal
();
}
public
function
errors
()
{
return
$this
->
morphMany
(
YandexError
::
class
,
'cause'
);
}
}
app/Models/YandexError.php
0 → 100644
View file @
e1e1019
<?php
namespace
App\Models
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
class
YandexError
extends
Model
{
use
SoftDeletes
;
protected
$table
=
'yandex_errors'
;
protected
$fillable
=
[
'token_id'
,
'cause_type'
,
'cause_id'
,
'errors'
,
];
public
function
token
()
{
return
$this
->
belongsTo
(
Tokens
::
class
,
'token_id'
);
}
public
function
cause
()
{
return
$this
->
morphTo
(
'cause'
);
}
}
app/Service/Requests/Direct/AddAds.php
View file @
e1e1019
...
...
@@ -113,6 +113,19 @@ class AddAds extends DirectRequest
continue
;
}
elseif
(
isset
(
$add_result
[
'Errors'
])
&&
count
(
$add_result
[
'Errors'
]))
{
$goalAd
->
errors
()
->
create
([
'token_id'
=>
$this
->
getToken
()
->
getKey
(),
'errors'
=>
$add_result
[
'Errors'
]
]);
GoalAdvertisement
::
whereId
(
$goalAd
->
id
)
->
update
([
'reserve_create_at'
=>
null
,
]);
continue
;
}
Log
::
debug
(
"AddAds, empty Id, token_id
{
$this
->
getToken
()
->
getKey
()
}
"
);
...
...
database/migrations/2021_09_07_091521_create_yandex_errors_table.php
0 → 100644
View file @
e1e1019
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateYandexErrorsTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'yandex_errors'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
bigInteger
(
'token_id'
)
->
unsigned
();
$table
->
morphs
(
'cause'
);
$table
->
json
(
'errors'
);
$table
->
foreign
(
'token_id'
)
->
references
(
'id'
)
->
on
(
'tokens'
)
->
cascadeOnDelete
();
$table
->
softDeletes
();
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'yandex_errors'
);
}
}
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