Commit e1e10193 by Vladislav

#20794 Сделать чтобы в целевых РК оставалась одна карточка

1 parent a89e30f3
......@@ -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 () {
......
......@@ -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;
}
......
......@@ -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');
}
}
<?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');
}
}
......@@ -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()}");
......
<?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');
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!