2025-12-17 21:47:15 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
|
|
feat: 구독/결제 API 확장 (Plan, Subscription, Payment)
- Plan/Subscription/Payment 모델에 상태 상수, 스코프, 헬퍼 메서드 추가
- PlanService, SubscriptionService, PaymentService 생성
- PlanController, SubscriptionController, PaymentController 생성
- FormRequest 9개 생성 (Plan 3개, Subscription 3개, Payment 3개)
- Swagger 문서 3개 생성 (PlanApi, SubscriptionApi, PaymentApi)
- API 라우트 22개 등록 (Plan 7개, Subscription 8개, Payment 7개)
- Pint 코드 스타일 정리
2025-12-18 16:20:29 +09:00
|
|
|
use App\Helpers\ApiResponse;
|
2025-12-17 21:47:15 +09:00
|
|
|
use App\Http\Controllers\Controller;
|
2026-01-15 17:14:04 +09:00
|
|
|
use App\Http\Requests\BulkUpdateAccountCodeRequest;
|
2025-12-17 21:47:15 +09:00
|
|
|
use App\Http\Requests\V1\Deposit\StoreDepositRequest;
|
|
|
|
|
use App\Http\Requests\V1\Deposit\UpdateDepositRequest;
|
|
|
|
|
use App\Services\DepositService;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
|
|
class DepositController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public function __construct(
|
|
|
|
|
private readonly DepositService $service
|
|
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 입금 목록
|
|
|
|
|
*/
|
|
|
|
|
public function index(Request $request)
|
|
|
|
|
{
|
|
|
|
|
$params = $request->only([
|
|
|
|
|
'search',
|
|
|
|
|
'start_date',
|
|
|
|
|
'end_date',
|
|
|
|
|
'client_id',
|
|
|
|
|
'payment_method',
|
|
|
|
|
'bank_account_id',
|
|
|
|
|
'sort_by',
|
|
|
|
|
'sort_dir',
|
|
|
|
|
'per_page',
|
|
|
|
|
'page',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$deposits = $this->service->index($params);
|
|
|
|
|
|
2025-12-18 15:42:46 +09:00
|
|
|
return ApiResponse::success($deposits, __('message.fetched'));
|
2025-12-17 21:47:15 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 입금 등록
|
|
|
|
|
*/
|
|
|
|
|
public function store(StoreDepositRequest $request)
|
|
|
|
|
{
|
|
|
|
|
$deposit = $this->service->store($request->validated());
|
|
|
|
|
|
2025-12-18 15:42:46 +09:00
|
|
|
return ApiResponse::success($deposit, __('message.created'), [], 201);
|
2025-12-17 21:47:15 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 입금 상세
|
|
|
|
|
*/
|
|
|
|
|
public function show(int $id)
|
|
|
|
|
{
|
|
|
|
|
$deposit = $this->service->show($id);
|
|
|
|
|
|
2025-12-18 15:42:46 +09:00
|
|
|
return ApiResponse::success($deposit, __('message.fetched'));
|
2025-12-17 21:47:15 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 입금 수정
|
|
|
|
|
*/
|
|
|
|
|
public function update(int $id, UpdateDepositRequest $request)
|
|
|
|
|
{
|
|
|
|
|
$deposit = $this->service->update($id, $request->validated());
|
|
|
|
|
|
2025-12-18 15:42:46 +09:00
|
|
|
return ApiResponse::success($deposit, __('message.updated'));
|
2025-12-17 21:47:15 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 입금 삭제
|
|
|
|
|
*/
|
|
|
|
|
public function destroy(int $id)
|
|
|
|
|
{
|
|
|
|
|
$this->service->destroy($id);
|
|
|
|
|
|
2025-12-18 15:42:46 +09:00
|
|
|
return ApiResponse::success(null, __('message.deleted'));
|
2025-12-17 21:47:15 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 입금 요약 (기간별 합계)
|
|
|
|
|
*/
|
|
|
|
|
public function summary(Request $request)
|
|
|
|
|
{
|
|
|
|
|
$params = $request->only([
|
|
|
|
|
'start_date',
|
|
|
|
|
'end_date',
|
|
|
|
|
'client_id',
|
|
|
|
|
'payment_method',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$summary = $this->service->summary($params);
|
|
|
|
|
|
2025-12-18 15:42:46 +09:00
|
|
|
return ApiResponse::success($summary, __('message.fetched'));
|
2025-12-17 21:47:15 +09:00
|
|
|
}
|
2026-01-15 17:14:04 +09:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 계정과목 일괄 변경
|
|
|
|
|
*/
|
|
|
|
|
public function bulkUpdateAccountCode(BulkUpdateAccountCodeRequest $request)
|
|
|
|
|
{
|
|
|
|
|
$updatedCount = $this->service->bulkUpdateAccountCode(
|
|
|
|
|
$request->getIds(),
|
|
|
|
|
$request->getAccountCode()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return ApiResponse::success(
|
|
|
|
|
['updated_count' => $updatedCount],
|
|
|
|
|
__('message.bulk_updated')
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-12-17 21:47:15 +09:00
|
|
|
}
|