fix: [상품관리] 최저가 설정을 상품별로 변경
- 카테고리 레벨 최저가 → 상품별 최저가로 변경 - 상품 추가/수정 모달에 최저 개발비, 최저 구독료 입력 필드 추가 - 빨간 잠금 아이콘 + '절대 이 금액 이하로 내릴 수 없음' 경고 표시 - 상품 카드에 최저가 정보 표시 (설정된 경우)
This commit is contained in:
@@ -62,19 +62,14 @@ public function store(Request $request): JsonResponse
|
||||
'development_fee' => 'required|numeric|min:0',
|
||||
'registration_fee' => 'required|numeric|min:0',
|
||||
'subscription_fee' => 'required|numeric|min:0',
|
||||
'min_development_fee' => 'nullable|numeric|min:0',
|
||||
'min_subscription_fee' => 'nullable|numeric|min:0',
|
||||
'partner_commission_rate' => 'nullable|numeric|min:0|max:100',
|
||||
'manager_commission_rate' => 'nullable|numeric|min:0|max:100',
|
||||
'allow_flexible_pricing' => 'boolean',
|
||||
'is_required' => 'boolean',
|
||||
]);
|
||||
|
||||
// 최저가 검증
|
||||
$category = SalesProductCategory::findOrFail($validated['category_id']);
|
||||
$minFeeErrors = $this->validateMinFees($category, $validated);
|
||||
if ($minFeeErrors) {
|
||||
return response()->json(['success' => false, 'message' => $minFeeErrors], 422);
|
||||
}
|
||||
|
||||
// 코드 중복 체크
|
||||
$exists = SalesProduct::where('category_id', $validated['category_id'])
|
||||
->where('code', $validated['code'])
|
||||
@@ -115,6 +110,8 @@ public function update(Request $request, int $id): JsonResponse
|
||||
'development_fee' => 'sometimes|numeric|min:0',
|
||||
'registration_fee' => 'sometimes|numeric|min:0',
|
||||
'subscription_fee' => 'sometimes|numeric|min:0',
|
||||
'min_development_fee' => 'nullable|numeric|min:0',
|
||||
'min_subscription_fee' => 'nullable|numeric|min:0',
|
||||
'partner_commission_rate' => 'nullable|numeric|min:0|max:100',
|
||||
'manager_commission_rate' => 'nullable|numeric|min:0|max:100',
|
||||
'allow_flexible_pricing' => 'boolean',
|
||||
@@ -122,14 +119,6 @@ public function update(Request $request, int $id): JsonResponse
|
||||
'is_active' => 'boolean',
|
||||
]);
|
||||
|
||||
// 최저가 검증
|
||||
$category = $product->category;
|
||||
$checkData = array_merge($product->toArray(), $validated);
|
||||
$minFeeErrors = $this->validateMinFees($category, $checkData);
|
||||
if ($minFeeErrors) {
|
||||
return response()->json(['success' => false, 'message' => $minFeeErrors], 422);
|
||||
}
|
||||
|
||||
$product->update($validated);
|
||||
|
||||
return response()->json([
|
||||
@@ -276,30 +265,6 @@ public function deleteCategory(int $id): JsonResponse
|
||||
]);
|
||||
}
|
||||
|
||||
// ==================== 내부 헬퍼 ====================
|
||||
|
||||
/**
|
||||
* 최저가 검증
|
||||
*/
|
||||
private function validateMinFees(SalesProductCategory $category, array $data): ?string
|
||||
{
|
||||
$errors = [];
|
||||
|
||||
if ($category->min_development_fee > 0 && isset($data['registration_fee'])) {
|
||||
if ($data['registration_fee'] < $category->min_development_fee) {
|
||||
$errors[] = '개발비(할인가)는 최저 개발비 ₩'.number_format($category->min_development_fee).' 이상이어야 합니다.';
|
||||
}
|
||||
}
|
||||
|
||||
if ($category->min_subscription_fee > 0 && isset($data['subscription_fee'])) {
|
||||
if ($data['subscription_fee'] < $category->min_subscription_fee) {
|
||||
$errors[] = '월 구독료는 최저 구독료 ₩'.number_format($category->min_subscription_fee).' 이상이어야 합니다.';
|
||||
}
|
||||
}
|
||||
|
||||
return $errors ? implode(' ', $errors) : null;
|
||||
}
|
||||
|
||||
// ==================== API (영업 시나리오용) ====================
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user