From aa7678c3580e59d38c28265c9d44eb82b3c15bad 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 09:29:19 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=88=98=EB=8F=99=20=ED=92=88=EB=AA=A9?= =?UTF-8?q?=20=EB=8B=A8=EA=B0=80=20=EC=A1=B0=ED=9A=8C=20API=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=EB=94=94=EB=B2=84=EA=B7=B8=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - QuoteController에 getItemPrices 엔드포인트 추가 - QuoteCalculationService에 품목 코드 배열로 단가 조회 기능 추가 - 불필요한 디버그 로그 제거 Co-Authored-By: Claude Opus 4.5 --- .../Controllers/Api/V1/QuoteController.php | 33 +++++++++++-------- .../Quote/QuoteCalculationService.php | 30 +++++++++++++++++ app/Services/Quote/QuoteService.php | 1 + 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/Api/V1/QuoteController.php b/app/Http/Controllers/Api/V1/QuoteController.php index 1527f76..2221218 100644 --- a/app/Http/Controllers/Api/V1/QuoteController.php +++ b/app/Http/Controllers/Api/V1/QuoteController.php @@ -81,19 +81,8 @@ public function store(QuoteStoreRequest $request) */ public function update(QuoteUpdateRequest $request, int $id) { - $validated = $request->validated(); - - // 🔍 디버깅: 요청 데이터 확인 - \Log::info('🔍 [QuoteController::update] 요청 수신', [ - 'id' => $id, - 'raw_options_keys' => $request->input('options') ? array_keys($request->input('options')) : null, - 'raw_options_detail_items_count' => $request->input('options.detail_items') ? count($request->input('options.detail_items')) : 0, - 'validated_options_keys' => isset($validated['options']) ? array_keys($validated['options']) : null, - 'validated_options_detail_items_count' => isset($validated['options']['detail_items']) ? count($validated['options']['detail_items']) : 0, - ]); - - return ApiResponse::handle(function () use ($validated, $id) { - return $this->quoteService->update($id, $validated); + return ApiResponse::handle(function () use ($request, $id) { + return $this->quoteService->update($id, $request->validated()); }, __('message.quote.updated')); } @@ -270,4 +259,22 @@ public function sendHistory(int $id) return $this->documentService->getSendHistory($id); }, __('message.fetched')); } + + /** + * 품목 단가 조회 + * + * 품목 코드 배열을 받아 단가를 조회합니다. + * 수동 품목 추가 시 단가를 조회하여 견적금액에 반영합니다. + */ + public function getItemPrices(\Illuminate\Http\Request $request) + { + $request->validate([ + 'item_codes' => 'required|array|min:1', + 'item_codes.*' => 'required|string', + ]); + + return ApiResponse::handle(function () use ($request) { + return $this->calculationService->getItemPrices($request->input('item_codes')); + }, __('message.fetched')); + } } diff --git a/app/Services/Quote/QuoteCalculationService.php b/app/Services/Quote/QuoteCalculationService.php index e28a98e..48a27fb 100644 --- a/app/Services/Quote/QuoteCalculationService.php +++ b/app/Services/Quote/QuoteCalculationService.php @@ -455,4 +455,34 @@ private function getDefaultInputSchema(?string $productCategory = null): array return $commonSchema; } + + /** + * 품목 단가 조회 + * + * 품목 코드 배열을 받아 단가를 조회합니다. + * FormulaEvaluatorService의 getItemPrice 로직을 활용합니다. + * + * @param array $itemCodes 품목 코드 배열 + * @return array 품목별 단가 정보 [item_code => ['unit_price' => number, 'item_name' => string]] + */ + public function getItemPrices(array $itemCodes): array + { + $tenantId = $this->tenantId(); + + if (! $tenantId) { + return []; + } + + $result = []; + + foreach ($itemCodes as $itemCode) { + $price = $this->formulaEvaluator->getItemPrice($itemCode, $tenantId); + $result[$itemCode] = [ + 'item_code' => $itemCode, + 'unit_price' => $price, + ]; + } + + return $result; + } } diff --git a/app/Services/Quote/QuoteService.php b/app/Services/Quote/QuoteService.php index bfb7a88..7e5a74a 100644 --- a/app/Services/Quote/QuoteService.php +++ b/app/Services/Quote/QuoteService.php @@ -13,6 +13,7 @@ use App\Services\Service; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;