From e372b9543b252a639cc750d64ab7c158aaba8e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Tue, 10 Mar 2026 11:35:58 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[stats]=20QuoteStatService=EC=97=90?= =?UTF-8?q?=EC=84=9C=20codebridge=20=ED=85=8C=EC=9D=B4=EB=B8=94=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - sales_prospect_consultations, sales_prospects 쿼리 제거 - codebridge DB에 이관된 테이블이며 tenant_id 없어 테넌트별 집계 불가 - prospect_*, consultation_count 필드는 DB default(0) 처리 Co-Authored-By: Claude Opus 4.6 --- app/Services/Stats/QuoteStatService.php | 26 +++---------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/app/Services/Stats/QuoteStatService.php b/app/Services/Stats/QuoteStatService.php index c802787..8d5e2e8 100644 --- a/app/Services/Stats/QuoteStatService.php +++ b/app/Services/Stats/QuoteStatService.php @@ -44,23 +44,8 @@ public function aggregateDaily(int $tenantId, Carbon $date): int ") ->first(); - // 상담 (sales_prospect_consultations) - codebridge DB로 이관됨 - $consultationCount = DB::connection('codebridge') - ->table('sales_prospect_consultations') - ->whereDate('created_at', $dateStr) - ->count(); - - // 영업 기회 (sales_prospects) - codebridge DB로 이관됨 - $prospectStats = DB::connection('codebridge') - ->table('sales_prospects') - ->whereDate('created_at', $dateStr) - ->whereNull('deleted_at') - ->selectRaw(" - COUNT(*) as created_count, - SUM(CASE WHEN status = 'contracted' THEN 1 ELSE 0 END) as won_count, - SUM(CASE WHEN status = 'lost' THEN 1 ELSE 0 END) as lost_count - ") - ->first(); + // sales_prospect_consultations, sales_prospects는 codebridge DB에 이관되었고 + // tenant_id가 없어 테넌트별 집계 불가 → 제외 StatQuotePipelineDaily::updateOrCreate( ['tenant_id' => $tenantId, 'stat_date' => $dateStr], @@ -71,14 +56,9 @@ public function aggregateDaily(int $tenantId, Carbon $date): int 'quote_rejected_count' => $quoteStats->rejected_count ?? 0, 'quote_conversion_count' => $conversionCount, 'quote_conversion_rate' => $conversionRate, - 'prospect_created_count' => $prospectStats->created_count ?? 0, - 'prospect_won_count' => $prospectStats->won_count ?? 0, - 'prospect_lost_count' => $prospectStats->lost_count ?? 0, - 'prospect_amount' => 0, 'bidding_count' => $biddingStats->cnt ?? 0, 'bidding_won_count' => $biddingStats->won_count ?? 0, 'bidding_amount' => $biddingStats->total_amount ?? 0, - 'consultation_count' => $consultationCount, ] ); @@ -90,4 +70,4 @@ public function aggregateMonthly(int $tenantId, int $year, int $month): int // 견적 도메인은 일간 테이블만 운영 (월간은 Phase 4에서 필요시 추가) return 0; } -} +} \ No newline at end of file