From 22f72f1bbc058f7a84c9271a3dc002c1aea9a9bb 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 09:40:55 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[stats]=20QuoteStatService=20codebridge?= =?UTF-8?q?=20DB=20=EC=BB=A4=EB=84=A5=EC=85=98=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - codebridge DB로 이관된 테이블(sales_prospect_consultations, sales_prospects) 커넥션을 mysql → codebridge로 변경 - config/database.php에 codebridge 커넥션 추가 - quote_daily 집계 실패 해결 Co-Authored-By: Claude Opus 4.6 --- app/Services/Stats/QuoteStatService.php | 10 +++++----- config/database.php | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/Services/Stats/QuoteStatService.php b/app/Services/Stats/QuoteStatService.php index 49c6694..c802787 100644 --- a/app/Services/Stats/QuoteStatService.php +++ b/app/Services/Stats/QuoteStatService.php @@ -44,14 +44,14 @@ public function aggregateDaily(int $tenantId, Carbon $date): int ") ->first(); - // 상담 (sales_prospect_consultations) - $consultationCount = DB::connection('mysql') + // 상담 (sales_prospect_consultations) - codebridge DB로 이관됨 + $consultationCount = DB::connection('codebridge') ->table('sales_prospect_consultations') ->whereDate('created_at', $dateStr) ->count(); - // 영업 기회 (sales_prospects - tenant_id 없음, created_at 기반) - $prospectStats = DB::connection('mysql') + // 영업 기회 (sales_prospects) - codebridge DB로 이관됨 + $prospectStats = DB::connection('codebridge') ->table('sales_prospects') ->whereDate('created_at', $dateStr) ->whereNull('deleted_at') @@ -74,7 +74,7 @@ public function aggregateDaily(int $tenantId, Carbon $date): int 'prospect_created_count' => $prospectStats->created_count ?? 0, 'prospect_won_count' => $prospectStats->won_count ?? 0, 'prospect_lost_count' => $prospectStats->lost_count ?? 0, - 'prospect_amount' => 0, // sales_prospects에 금액 컬럼 없음 + 'prospect_amount' => 0, 'bidding_count' => $biddingStats->cnt ?? 0, 'bidding_won_count' => $biddingStats->won_count ?? 0, 'bidding_amount' => $biddingStats->total_amount ?? 0, diff --git a/config/database.php b/config/database.php index 82a16ef..8a59ad0 100644 --- a/config/database.php +++ b/config/database.php @@ -82,6 +82,26 @@ ]) : [], ], + // Codebridge DB (이관된 Sales/Finance/Admin 등) + 'codebridge' => [ + 'driver' => 'mysql', + 'host' => env('CODEBRIDGE_DB_HOST', env('DB_HOST', '127.0.0.1')), + 'port' => env('CODEBRIDGE_DB_PORT', env('DB_PORT', '3306')), + 'database' => env('CODEBRIDGE_DB_DATABASE', 'codebridge'), + 'username' => env('CODEBRIDGE_DB_USERNAME', env('DB_USERNAME', 'root')), + 'password' => env('CODEBRIDGE_DB_PASSWORD', env('DB_PASSWORD', '')), + 'unix_socket' => env('DB_SOCKET', ''), + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', + 'prefix_indexes' => true, + 'strict' => true, + 'engine' => null, + 'options' => extension_loaded('pdo_mysql') ? array_filter([ + PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), + ]) : [], + ], + // 5130 레거시 DB (chandj) 'chandj' => [ 'driver' => 'mysql',