feat:상품 수정 시 개발비/가입비 분리 입력 지원

This commit is contained in:
pro
2026-01-29 16:31:59 +09:00
parent ca3073adee
commit ac8afef985
4 changed files with 39 additions and 8 deletions

View File

@@ -60,6 +60,7 @@ public function store(Request $request): JsonResponse
'name' => 'required|string|max:100',
'description' => 'nullable|string',
'development_fee' => 'required|numeric|min:0',
'registration_fee' => 'required|numeric|min:0',
'subscription_fee' => 'required|numeric|min:0',
'partner_commission_rate' => 'nullable|numeric|min:0|max:100',
'manager_commission_rate' => 'nullable|numeric|min:0|max:100',
@@ -105,6 +106,7 @@ public function update(Request $request, int $id): JsonResponse
'name' => 'sometimes|string|max:100',
'description' => 'nullable|string',
'development_fee' => 'sometimes|numeric|min:0',
'registration_fee' => 'sometimes|numeric|min:0',
'subscription_fee' => 'sometimes|numeric|min:0',
'partner_commission_rate' => 'nullable|numeric|min:0|max:100',
'manager_commission_rate' => 'nullable|numeric|min:0|max:100',

View File

@@ -15,6 +15,7 @@
* @property string $name
* @property string|null $description
* @property float $development_fee
* @property float $registration_fee
* @property float $subscription_fee
* @property float $partner_commission_rate
* @property float $manager_commission_rate
@@ -35,6 +36,7 @@ class SalesProduct extends Model
'name',
'description',
'development_fee',
'registration_fee',
'subscription_fee',
'partner_commission_rate',
'manager_commission_rate',
@@ -47,6 +49,7 @@ class SalesProduct extends Model
protected $casts = [
'category_id' => 'integer',
'development_fee' => 'decimal:2',
'registration_fee' => 'decimal:2',
'subscription_fee' => 'decimal:2',
'partner_commission_rate' => 'decimal:2',
'manager_commission_rate' => 'decimal:2',
@@ -104,6 +107,14 @@ public function getFormattedDevelopmentFeeAttribute(): string
return '₩' . number_format($this->development_fee);
}
/**
* 포맷된 가입비
*/
public function getFormattedRegistrationFeeAttribute(): string
{
return '₩' . number_format($this->registration_fee);
}
/**
* 포맷된 구독료
*/

View File

@@ -117,22 +117,31 @@ class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:rin
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">개발비 (입비)</label>
<label class="block text-sm font-medium text-gray-700 mb-1">개발비 ()</label>
<input type="text"
:value="formatNumber(productForm.development_fee)"
x-on:input="productForm.development_fee = parseNumber($event.target.value); $event.target.value = formatNumber(productForm.development_fee)"
x-on:input="updateDevelopmentFee($event.target.value)"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 text-right"
placeholder="0" required>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1"> 구독료</label>
<label class="block text-sm font-medium text-gray-700 mb-1">가입비 (할인가)</label>
<input type="text"
:value="formatNumber(productForm.subscription_fee)"
x-on:input="productForm.subscription_fee = parseNumber($event.target.value); $event.target.value = formatNumber(productForm.subscription_fee)"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 text-right"
:value="formatNumber(productForm.registration_fee)"
x-on:input="productForm.registration_fee = parseNumber($event.target.value); $event.target.value = formatNumber(productForm.registration_fee)"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 text-right bg-indigo-50"
placeholder="0" required>
<p class="text-xs text-gray-500 mt-1">기본: 개발비의 25%</p>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1"> 구독료</label>
<input type="text"
:value="formatNumber(productForm.subscription_fee)"
x-on:input="productForm.subscription_fee = parseNumber($event.target.value); $event.target.value = formatNumber(productForm.subscription_fee)"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 text-right"
placeholder="0" required>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">영업파트너 수당 (%)</label>
@@ -245,6 +254,7 @@ function productManager() {
name: '',
description: '',
development_fee: 0,
registration_fee: 0,
subscription_fee: 0,
partner_commission_rate: 20,
manager_commission_rate: 5,
@@ -280,6 +290,7 @@ function productManager() {
name: '',
description: '',
development_fee: 0,
registration_fee: 0,
subscription_fee: 0,
partner_commission_rate: 20,
manager_commission_rate: 5,
@@ -392,6 +403,13 @@ function productManager() {
parseNumber(value) {
if (!value) return 0;
return parseInt(String(value).replace(/[^\d]/g, ''), 10) || 0;
},
updateDevelopmentFee(value) {
const fee = this.parseNumber(value);
this.productForm.development_fee = fee;
// 가입비 자동 계산 (개발비의 25%)
this.productForm.registration_fee = Math.floor(fee * 0.25);
}
};
}

View File

@@ -34,8 +34,8 @@ class="p-1 text-gray-400 hover:text-indigo-600 transition-colors">
<div class="flex items-center justify-between">
<span class="text-sm text-gray-500">가입비</span>
<div class="text-right">
<span class="text-sm text-gray-400 line-through">{{ number_format($product->development_fee) }}</span>
<span class="ml-2 font-bold text-indigo-600">{{ number_format($product->development_fee * 0.25) }}</span>
<span class="text-sm text-gray-400 line-through">{{ $product->formatted_development_fee }}</span>
<span class="ml-2 font-bold text-indigo-600">{{ $product->formatted_registration_fee }}</span>
</div>
</div>
<div class="flex items-center justify-between">