diff --git a/app/Services/Quote/Handlers/KyungdongFormulaHandler.php b/app/Services/Quote/Handlers/KyungdongFormulaHandler.php index 32aa24d..0cf544a 100644 --- a/app/Services/Quote/Handlers/KyungdongFormulaHandler.php +++ b/app/Services/Quote/Handlers/KyungdongFormulaHandler.php @@ -385,7 +385,7 @@ public function calculateSteelItems(array $params): array $caseCapSpec = $this->convertToCaseCapSpec($caseSpec); $caseCapPrice = $this->priceService->getCaseCapPrice($caseCapSpec); if ($caseCapPrice > 0) { - $capQty = 2 * $quantity; // 좌우 2개 + $capQty = $quantity; // 5130: maguriPrices × $su (수량) $items[] = [ 'category' => 'steel', 'item_name' => '케이스 마구리', @@ -618,20 +618,47 @@ public function calculatePartItems(array $params): array ]; } - // 2. 각파이프 + // 2. 각파이프 (5130: col68=3000mm 수량, col69=6000mm 수량) $pipeThickness = '1.4'; - $pipeLength = $width > 3000 ? 6000 : 3000; - $pipePrice = $this->getPipePrice($pipeThickness, $pipeLength); - if ($pipePrice > 0) { - $items[] = [ - 'category' => 'parts', - 'item_name' => '각파이프', - 'specification' => "{$pipeThickness}T {$pipeLength}mm", - 'unit' => 'EA', - 'quantity' => $quantity, - 'unit_price' => $pipePrice, - 'total_price' => $pipePrice * $quantity, - ]; + $pipe3000Qty = (int) ($params['pipe_3000_qty'] ?? 0); + $pipe6000Qty = (int) ($params['pipe_6000_qty'] ?? 0); + + // 기본값: 둘 다 0이면 레거시 로직 (W0 기준 자동 결정) + if ($pipe3000Qty === 0 && $pipe6000Qty === 0) { + if ($width > 3000) { + $pipe6000Qty = 1; + } else { + $pipe3000Qty = 1; + } + } + + if ($pipe3000Qty > 0) { + $pipe3000Price = $this->getPipePrice($pipeThickness, 3000); + if ($pipe3000Price > 0) { + $items[] = [ + 'category' => 'parts', + 'item_name' => '각파이프', + 'specification' => "{$pipeThickness}T 3000mm", + 'unit' => 'EA', + 'quantity' => $pipe3000Qty, + 'unit_price' => $pipe3000Price, + 'total_price' => $pipe3000Price * $pipe3000Qty, + ]; + } + } + if ($pipe6000Qty > 0) { + $pipe6000Price = $this->getPipePrice($pipeThickness, 6000); + if ($pipe6000Price > 0) { + $items[] = [ + 'category' => 'parts', + 'item_name' => '각파이프', + 'specification' => "{$pipeThickness}T 6000mm", + 'unit' => 'EA', + 'quantity' => $pipe6000Qty, + 'unit_price' => $pipe6000Price, + 'total_price' => $pipe6000Price * $pipe6000Qty, + ]; + } } // 3. 모터 받침용 앵글 (bracket angle)