diff --git a/app/Services/Quote/Handlers/KyungdongFormulaHandler.php b/app/Services/Quote/Handlers/KyungdongFormulaHandler.php index 1d6fe4d..151daa9 100644 --- a/app/Services/Quote/Handlers/KyungdongFormulaHandler.php +++ b/app/Services/Quote/Handlers/KyungdongFormulaHandler.php @@ -336,7 +336,9 @@ public function calculateSteelItems(array $params): array $height = (float) ($params['H0'] ?? 0); $quantity = (int) ($params['QTY'] ?? 1); $modelName = $params['model_name'] ?? $params['product_model'] ?? 'KSS01'; - $finishingType = $params['finishing_type'] ?? 'SUS'; + $rawFinish = $params['finishing_type'] ?? 'SUS'; + // DB에는 'SUS', 'EGI'로 저장 → 'SUS마감' → 'SUS' 변환 + $finishingType = str_replace('마감', '', $rawFinish); // 절곡품 관련 파라미터 $caseSpec = $params['case_spec'] ?? '500*380'; @@ -515,6 +517,23 @@ public function calculateSteelItems(array $params): array * @param int $quantity 수량 * @return array 가이드레일 항목 배열 */ + /** + * 모델별 가이드레일 규격 매핑 + * + * BDmodels 테이블 기준: + * KSS01/02, KSE01, KWE01 → 120*70 / 120*120 + * KTE01, KQTS01 → 130*75 / 130*125 + * KDSS01 → 150*150 / 150*212 + */ + private function getGuideRailSpecs(string $modelName): array + { + return match ($modelName) { + 'KTE01', 'KQTS01' => ['wall' => '130*75', 'side' => '130*125'], + 'KDSS01' => ['wall' => '150*150', 'side' => '150*212'], + default => ['wall' => '120*70', 'side' => '120*120'], + }; + } + private function calculateGuideRails( string $modelName, string $finishingType, @@ -529,16 +548,19 @@ private function calculateGuideRails( return $items; } + $specs = $this->getGuideRailSpecs($modelName); + $wallSpec = $specs['wall']; + $sideSpec = $specs['side']; + switch ($guideType) { case '벽면형': - // 120*70 × 2개 - $price = $this->priceService->getGuideRailPrice($modelName, $finishingType, '120*70'); + $price = $this->priceService->getGuideRailPrice($modelName, $finishingType, $wallSpec); if ($price > 0) { $guideQty = 2 * $quantity; $items[] = [ 'category' => 'steel', 'item_name' => '가이드레일', - 'specification' => "{$modelName} {$finishingType} 120*70 {$guideLength}m × 2", + 'specification' => "{$modelName} {$finishingType} {$wallSpec} {$guideLength}m × 2", 'unit' => 'm', 'quantity' => $guideLength * $guideQty, 'unit_price' => $price, @@ -548,14 +570,13 @@ private function calculateGuideRails( break; case '측면형': - // 120*100 × 2개 - $price = $this->priceService->getGuideRailPrice($modelName, $finishingType, '120*100'); + $price = $this->priceService->getGuideRailPrice($modelName, $finishingType, $sideSpec); if ($price > 0) { $guideQty = 2 * $quantity; $items[] = [ 'category' => 'steel', 'item_name' => '가이드레일', - 'specification' => "{$modelName} {$finishingType} 120*100 {$guideLength}m × 2", + 'specification' => "{$modelName} {$finishingType} {$sideSpec} {$guideLength}m × 2", 'unit' => 'm', 'quantity' => $guideLength * $guideQty, 'unit_price' => $price, @@ -565,30 +586,29 @@ private function calculateGuideRails( break; case '혼합형': - // 120*70 × 1개 + 120*100 × 1개 - $price70 = $this->priceService->getGuideRailPrice($modelName, $finishingType, '120*70'); - $price100 = $this->priceService->getGuideRailPrice($modelName, $finishingType, '120*100'); + $priceWall = $this->priceService->getGuideRailPrice($modelName, $finishingType, $wallSpec); + $priceSide = $this->priceService->getGuideRailPrice($modelName, $finishingType, $sideSpec); - if ($price70 > 0) { + if ($priceWall > 0) { $items[] = [ 'category' => 'steel', 'item_name' => '가이드레일', - 'specification' => "{$modelName} {$finishingType} 120*70 {$guideLength}m", + 'specification' => "{$modelName} {$finishingType} {$wallSpec} {$guideLength}m", 'unit' => 'm', 'quantity' => $guideLength * $quantity, - 'unit_price' => $price70, - 'total_price' => round($price70 * $guideLength * $quantity), + 'unit_price' => $priceWall, + 'total_price' => round($priceWall * $guideLength * $quantity), ]; } - if ($price100 > 0) { + if ($priceSide > 0) { $items[] = [ 'category' => 'steel', 'item_name' => '가이드레일', - 'specification' => "{$modelName} {$finishingType} 120*100 {$guideLength}m", + 'specification' => "{$modelName} {$finishingType} {$sideSpec} {$guideLength}m", 'unit' => 'm', 'quantity' => $guideLength * $quantity, - 'unit_price' => $price100, - 'total_price' => round($price100 * $guideLength * $quantity), + 'unit_price' => $priceSide, + 'total_price' => round($priceSide * $guideLength * $quantity), ]; } break;