From ca2dd44567444d56b45b65acb4fdbfb075a04478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Thu, 29 Jan 2026 22:55:40 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=99=98=EB=B4=89=C2=B7=EA=B0=81?= =?UTF-8?q?=ED=8C=8C=EC=9D=B4=ED=94=84=205130=20=EC=9E=90=EB=8F=99?= =?UTF-8?q?=EA=B3=84=EC=82=B0=20=EA=B3=B5=EC=8B=9D=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 환봉: W0 기준 자동계산 (≤3000→1, ≤6000→2, ≤9000→3, ≤12000→4 × 수량) - 각파이프: col67(케이스길이+3000×연결수) 기준 3000mm/6000mm 수량 자동계산 - 기존 하드코딩(각파이프 1개, 환봉 0개) 제거 Co-Authored-By: Claude Opus 4.5 --- .../Handlers/KyungdongFormulaHandler.php | 51 ++++++++++++++++--- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/app/Services/Quote/Handlers/KyungdongFormulaHandler.php b/app/Services/Quote/Handlers/KyungdongFormulaHandler.php index 0cf544a..1d6fe4d 100644 --- a/app/Services/Quote/Handlers/KyungdongFormulaHandler.php +++ b/app/Services/Quote/Handlers/KyungdongFormulaHandler.php @@ -348,7 +348,22 @@ public function calculateSteelItems(array $params): array $lbarLength = (float) ($params['lbar_length'] ?? ($width + 220)) / 1000; // m 단위 (레거시: W0+220) $flatBarLength = (float) ($params['flatbar_length'] ?? ($width + 220)) / 1000; // m 단위 (레거시: W0+220) $weightPlateQty = (int) ($params['weight_plate_qty'] ?? 0); // 무게평철 수량 - $roundBarQty = (int) ($params['round_bar_qty'] ?? 0); // 환봉 수량 + // 환봉 수량: 5130 자동계산 (col10=폭 기준) + // ≤3000→1, ≤6000→2, ≤9000→3, ≤12000→4 (× 수량) + $roundBarQty = (int) ($params['round_bar_qty'] ?? -1); + if ($roundBarQty < 0) { + if ($width <= 3000) { + $roundBarQty = 1 * $quantity; + } elseif ($width <= 6000) { + $roundBarQty = 2 * $quantity; + } elseif ($width <= 9000) { + $roundBarQty = 3 * $quantity; + } elseif ($width <= 12000) { + $roundBarQty = 4 * $quantity; + } else { + $roundBarQty = 0; + } + } // 1. 케이스 (단가/1000 × 길이mm × 수량) $casePrice = $this->priceService->getCasePrice($caseSpec); @@ -618,17 +633,39 @@ public function calculatePartItems(array $params): array ]; } - // 2. 각파이프 (5130: col68=3000mm 수량, col69=6000mm 수량) + // 2. 각파이프 (5130: col67 = col37 + 3000 × col66, col68/col69 자동계산) $pipeThickness = '1.4'; + $caseLength = (float) ($params['case_length'] ?? ($width + 220)); // col37 (mm) + $connectionCount = (int) ($params['connection_count'] ?? 0); // col66 (연결 수) + $pipeBaseLength = $caseLength + 3000 * $connectionCount; // col67 + + // 5130 자동계산 공식: col67 기준 $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; + // col68: 3000mm 파이프 수량 + if ($pipeBaseLength <= 9000) { + $pipe3000Qty = 3 * $quantity; + } elseif ($pipeBaseLength <= 12000) { + $pipe3000Qty = 4 * $quantity; + } elseif ($pipeBaseLength <= 15000) { + $pipe3000Qty = 5 * $quantity; + } elseif ($pipeBaseLength <= 18000) { + $pipe3000Qty = 6 * $quantity; + } + + // col69: 6000mm 파이프 수량 (18000 초과 시) + if ($pipeBaseLength > 18000 && $pipeBaseLength <= 24000) { + $pipe6000Qty = 4 * $quantity; + } elseif ($pipeBaseLength > 24000 && $pipeBaseLength <= 30000) { + $pipe6000Qty = 5 * $quantity; + } elseif ($pipeBaseLength > 30000 && $pipeBaseLength <= 36000) { + $pipe6000Qty = 6 * $quantity; + } elseif ($pipeBaseLength > 36000 && $pipeBaseLength <= 42000) { + $pipe6000Qty = 7 * $quantity; + } elseif ($pipeBaseLength > 42000 && $pipeBaseLength <= 48000) { + $pipe6000Qty = 8 * $quantity; } }