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',