Commit 0edc209e by Vladislav

Исправление ошибку при удалении, выставление флага на архивирование

1 parent d048b0ba
...@@ -240,7 +240,9 @@ class GoalAdvertisement extends Pivot ...@@ -240,7 +240,9 @@ class GoalAdvertisement extends Pivot
->whereColumn('goal_advertisements.goal_ad_group_id', 'goal_ad_groups.id'); ->whereColumn('goal_advertisements.goal_ad_group_id', 'goal_ad_groups.id');
}); });
}); });
})->whereNull('goal_advertisements.deleted_at'); })->whereNull('goal_advertisements.deleted_at')
->whereNull('goal_advertisements.archive_at')
->whereNull('goal_advertisements.archived_need');
} }
/** /**
......
...@@ -8,6 +8,7 @@ use App\Models\Pivots\GoalAdvertisement; ...@@ -8,6 +8,7 @@ use App\Models\Pivots\GoalAdvertisement;
use App\Service\Contract\APIRequest; use App\Service\Contract\APIRequest;
use App\Service\DirectResponseHelper; use App\Service\DirectResponseHelper;
use App\Service\Requests\DirectRequest; use App\Service\Requests\DirectRequest;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class DeleteAds extends DirectRequest class DeleteAds extends DirectRequest
...@@ -73,7 +74,27 @@ class DeleteAds extends DirectRequest ...@@ -73,7 +74,27 @@ class DeleteAds extends DirectRequest
continue; continue;
} elseif (isset($delete_result['Errors']) && count($delete_result['Errors'])) { } elseif (
isset($delete_result['Errors'][0]['Code'])
&&
$delete_result['Errors'][0]['Code'] == 8300
) {
if ($this->getToken()->isMain()) {
Advertisement::where('external_id', $external_id)
->update([
'archived_need' => Carbon::now()
]);
} else {
GoalAdvertisement::where('external_id', $external_id)
->update([
'archived_need' => Carbon::now()
]);
}
continue;
}elseif (isset($delete_result['Errors']) && count($delete_result['Errors'])) {
$goalAd = GoalAdvertisement::whereExternalId($external_id)->first(); $goalAd = GoalAdvertisement::whereExternalId($external_id)->first();
if ($goalAd) { if ($goalAd) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!