From 60c4256bd0453050b12b7233f65539de25634135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A0=EB=B3=91=EC=B2=A0?= Date: Mon, 9 Mar 2026 13:20:30 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[=EB=B3=B5=EB=A6=AC=ED=9B=84=EC=83=9D]?= =?UTF-8?q?=20=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20=EC=BB=A4=EC=8A=A4?= =?UTF-8?q?=ED=85=80=20=EB=82=A0=EC=A7=9C=20=EB=B2=94=EC=9C=84=20=ED=95=84?= =?UTF-8?q?=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - start_date, end_date 쿼리 파라미터 추가 - 커스텀 날짜 범위 지정 시 해당 범위로 일별 사용 내역 조회 - 미지정 시 기존 분기 기준 유지 Co-Authored-By: Claude Opus 4.6 --- app/Http/Controllers/Api/V1/WelfareController.php | 8 ++++++-- app/Services/WelfareService.php | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Api/V1/WelfareController.php b/app/Http/Controllers/Api/V1/WelfareController.php index 64795f48..055bfcdd 100644 --- a/app/Http/Controllers/Api/V1/WelfareController.php +++ b/app/Http/Controllers/Api/V1/WelfareController.php @@ -61,14 +61,18 @@ public function detail(Request $request): JsonResponse : 0.05; $year = $request->query('year') ? (int) $request->query('year') : null; $quarter = $request->query('quarter') ? (int) $request->query('quarter') : null; + $startDate = $request->query('start_date'); + $endDate = $request->query('end_date'); - return ApiResponse::handle(function () use ($calculationType, $fixedAmountPerMonth, $ratio, $year, $quarter) { + return ApiResponse::handle(function () use ($calculationType, $fixedAmountPerMonth, $ratio, $year, $quarter, $startDate, $endDate) { return $this->welfareService->getDetail( $calculationType, $fixedAmountPerMonth, $ratio, $year, - $quarter + $quarter, + $startDate, + $endDate ); }, __('message.fetched')); } diff --git a/app/Services/WelfareService.php b/app/Services/WelfareService.php index 6231f9f2..683ba0d5 100644 --- a/app/Services/WelfareService.php +++ b/app/Services/WelfareService.php @@ -498,7 +498,9 @@ public function getDetail( ?int $fixedAmountPerMonth = 200000, ?float $ratio = 0.05, ?int $year = null, - ?int $quarter = null + ?int $quarter = null, + ?string $startDate = null, + ?string $endDate = null ): array { $tenantId = $this->tenantId(); $now = Carbon::now(); @@ -562,8 +564,10 @@ public function getDetail( // 3. 항목별 분포 $categoryDistribution = $this->getCategoryDistribution($tenantId, $annualStartDate, $annualEndDate); - // 4. 일별 사용 내역 - $transactions = $this->getTransactions($tenantId, $quarterStartDate, $quarterEndDate); + // 4. 일별 사용 내역 (커스텀 날짜 범위가 있으면 해당 범위, 없으면 분기 기준) + $txStartDate = $startDate ?? $quarterStartDate; + $txEndDate = $endDate ?? $quarterEndDate; + $transactions = $this->getTransactions($tenantId, $txStartDate, $txEndDate); // 5. 계산 정보 $calculation = [