feat:바로빌 과금 정책 DB 관리 기능 추가

- BarobillPricingPolicy 모델 추가
- BarobillPricingPolicySeeder 추가 (초기 정책 데이터)
- 과금관리 페이지에 정책 관리 탭 추가 (본사 전용)
- 정책 수정 모달 및 API 엔드포인트 추가
- BarobillUsageService에서 DB 정책 사용하도록 수정

정책 항목:
- 법인카드 등록: 기본 3장, 추가 1장당 5,000원
- 계산서 발행: 기본 100건, 추가 50건당 5,000원
- 계좌조회 수집: 기본 1계좌, 추가 1계좌당 10,000원

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
pro
2026-01-27 15:17:25 +09:00
parent a050904fc3
commit d036be1ec3
7 changed files with 659 additions and 43 deletions

View File

@@ -6,6 +6,7 @@
use App\Models\Barobill\BarobillBillingRecord;
use App\Models\Barobill\BarobillMember;
use App\Models\Barobill\BarobillMonthlySummary;
use App\Models\Barobill\BarobillPricingPolicy;
use App\Models\Barobill\BarobillSubscription;
use App\Services\Barobill\BarobillBillingService;
use Illuminate\Http\JsonResponse;
@@ -376,4 +377,83 @@ public function export(Request $request)
return response()->stream($callback, 200, $headers);
}
// ========================================
// 과금 정책 관리
// ========================================
/**
* 과금 정책 목록 조회
*/
public function pricingPolicies(Request $request): JsonResponse|Response
{
$policies = BarobillPricingPolicy::orderBy('sort_order')->get();
if ($request->header('HX-Request')) {
return response(
view('barobill.billing.partials.pricing-policies-table', [
'policies' => $policies,
])->render(),
200,
['Content-Type' => 'text/html']
);
}
return response()->json([
'success' => true,
'data' => $policies,
]);
}
/**
* 과금 정책 수정
*/
public function updatePricingPolicy(Request $request, int $id): JsonResponse
{
$policy = BarobillPricingPolicy::find($id);
if (!$policy) {
return response()->json([
'success' => false,
'message' => '정책을 찾을 수 없습니다.',
], 404);
}
$validated = $request->validate([
'name' => 'nullable|string|max:100',
'description' => 'nullable|string|max:255',
'free_quota' => 'nullable|integer|min:0',
'free_quota_unit' => 'nullable|string|max:20',
'additional_unit' => 'nullable|integer|min:1',
'additional_unit_label' => 'nullable|string|max:20',
'additional_price' => 'nullable|integer|min:0',
'is_active' => 'nullable|boolean',
]);
$policy->update($validated);
return response()->json([
'success' => true,
'message' => '정책이 수정되었습니다.',
'data' => $policy->fresh(),
]);
}
/**
* 과금 정책 단일 조회
*/
public function getPricingPolicy(int $id): JsonResponse
{
$policy = BarobillPricingPolicy::find($id);
if (!$policy) {
return response()->json([
'success' => false,
'message' => '정책을 찾을 수 없습니다.',
], 404);
}
return response()->json([
'success' => true,
'data' => $policy,
]);
}
}