feat(автоподбор): тумблер deep_study + проброс is_federal в шаг 2

This commit is contained in:
Дмитрий
2026-07-03 22:43:58 +03:00
parent 2907a02d45
commit afed14b0bd
3 changed files with 35 additions and 0 deletions
@@ -71,6 +71,7 @@ class RunAutopodborStudyJob implements ShouldQueue
'name' => $comp->name,
'site_url' => $comp->site_url,
'directory_urls' => $comp->directory_urls ?? [],
'is_federal' => (bool) $comp->is_federal,
],
regionCode: (int) $run->region_code,
));
+10
View File
@@ -24,4 +24,14 @@ return [
|
*/
'node_bin' => env('AUTOPODBOR_NODE_BIN', 'node'),
/*
|--------------------------------------------------------------------------
| Глубокий шаг 2 (движок «глобального сбора источников»)
|--------------------------------------------------------------------------
| true studyCompetitor сам доищет след (EXA площадки якорный фильтр
| 2ГИС по имени Яндекс Playwright). false старый путь по site_url +
| directory_urls из шага 1. По умолчанию ВЫКЛ включается осознанно.
*/
'deep_study' => env('AUTOPODBOR_DEEP_STUDY', false),
];
@@ -59,3 +59,27 @@ it('пустой результат: status=empty, без списания', fun
->and($run->fresh()->price_rub_charged)->toBeNull()
->and((string) $tenant->fresh()->balance_rub)->toBe('100000.00');
});
it('джоба передаёт is_federal в StudyCompetitorRequest', function () {
$captured = null;
$spy = new class($captured) implements CompetitorAgent {
public function __construct(public &$captured) {}
public function findCompetitors(\App\Services\Autopodbor\Agent\Dto\FindCompetitorsRequest $r): \App\Services\Autopodbor\Agent\Dto\FindCompetitorsResult { throw new \LogicException('n/a'); }
public function resolveByName(\App\Services\Autopodbor\Agent\Dto\ResolveByNameRequest $r): \App\Services\Autopodbor\Agent\Dto\ResolveByNameResult { throw new \LogicException('n/a'); }
public function studyCompetitor(\App\Services\Autopodbor\Agent\Dto\StudyCompetitorRequest $r): \App\Services\Autopodbor\Agent\Dto\StudyCompetitorResult {
$this->captured = $r->competitor;
return new \App\Services\Autopodbor\Agent\Dto\StudyCompetitorResult([]);
}
};
app()->instance(CompetitorAgent::class, $spy);
$tenant = Tenant::factory()->create(['balance_rub' => '100000.00']);
DB::statement('SET app.current_tenant_id = '.$tenant->id);
SystemSetting::updateOrCreate(['key' => 'autopodbor_price_study_rub'], ['value' => '900', 'type' => 'decimal']);
$searchRun = AutopodborRun::create(['tenant_id' => $tenant->id, 'kind' => 'search', 'status' => 'done', 'region_code' => 29, 'params' => []]);
$comp = AutopodborCompetitor::create(['tenant_id' => $tenant->id, 'search_run_id' => $searchRun->id, 'name' => 'Банк ДОМ.РФ', 'dedup_key' => 'site:domrfbank.ru', 'site_url' => 'domrfbank.ru', 'is_federal' => true]);
$run = AutopodborRun::create(['tenant_id' => $tenant->id, 'kind' => 'study', 'status' => 'queued', 'region_code' => 29, 'competitor_id' => $comp->id, 'params' => []]);
app()->call([new RunAutopodborStudyJob($run->id), 'handle']);
expect($spy->captured['is_federal'])->toBeTrue();
});