diff --git a/app/Http/Controllers/Admin/PlatformLeadController.php b/app/Http/Controllers/Admin/PlatformLeadController.php
index 29a356b..a836466 100644
--- a/app/Http/Controllers/Admin/PlatformLeadController.php
+++ b/app/Http/Controllers/Admin/PlatformLeadController.php
@@ -22,11 +22,18 @@ class PlatformLeadController extends Controller
$filters = [
'status' => trim((string) $request->query('status', '')),
'keyword' => trim((string) $request->query('keyword', '')),
+ // 精确过滤:线索ID(用于从订单/运营动作回溯到某条线索)
+ 'lead_id' => trim((string) $request->query('lead_id', '')),
];
$query = PlatformLead::query();
$query->when($filters['status'] !== '', fn (Builder $b) => $b->where('status', $filters['status']));
+
+ $query->when($filters['lead_id'] !== '' && ctype_digit($filters['lead_id']), function (Builder $b) use ($filters) {
+ $b->where('id', (int) $filters['lead_id']);
+ });
+
$query->when($filters['keyword'] !== '', function (Builder $b) use ($filters) {
$kw = $filters['keyword'];
$b->where(function (Builder $q) use ($kw) {
diff --git a/resources/views/admin/platform_leads/index.blade.php b/resources/views/admin/platform_leads/index.blade.php
index a436e7f..dcdd974 100644
--- a/resources/views/admin/platform_leads/index.blade.php
+++ b/resources/views/admin/platform_leads/index.blade.php
@@ -63,6 +63,7 @@
@endforeach
+
diff --git a/tests/Feature/AdminPlatformLeadIndexLeadIdFilterTest.php b/tests/Feature/AdminPlatformLeadIndexLeadIdFilterTest.php
new file mode 100644
index 0000000..60ca03e
--- /dev/null
+++ b/tests/Feature/AdminPlatformLeadIndexLeadIdFilterTest.php
@@ -0,0 +1,64 @@
+seed();
+
+ $this->post('/admin/login', [
+ 'email' => 'platform.admin@demo.local',
+ 'password' => 'Platform@123456',
+ ])->assertRedirect('/admin');
+ }
+
+ public function test_index_should_render_lead_id_filter_field(): void
+ {
+ $this->loginAsPlatformAdmin();
+
+ $res = $this->get('/admin/platform-leads');
+ $res->assertOk();
+ $res->assertSee('name="lead_id"', false);
+ }
+
+ public function test_index_should_filter_by_lead_id(): void
+ {
+ $this->loginAsPlatformAdmin();
+
+ $a = PlatformLead::query()->create([
+ 'name' => '线索A',
+ 'mobile' => '',
+ 'email' => '',
+ 'company' => '',
+ 'source' => 'test',
+ 'status' => 'new',
+ 'plan_id' => null,
+ 'meta' => ['from' => 'test'],
+ ]);
+
+ PlatformLead::query()->create([
+ 'name' => '线索B',
+ 'mobile' => '',
+ 'email' => '',
+ 'company' => '',
+ 'source' => 'test',
+ 'status' => 'new',
+ 'plan_id' => null,
+ 'meta' => ['from' => 'test'],
+ ]);
+
+ $res = $this->get('/admin/platform-leads?lead_id=' . $a->id);
+ $res->assertOk();
+ $res->assertSee((string) $a->id);
+ $res->assertSee('线索A');
+ $res->assertDontSee('线索B');
+ }
+}