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;