feat: [mng] develop 일괄 반영
- fire-shutter 가이드레일/셔터박스/3D 렌더링 - sales 가격시뮬레이터/프로모션 할인 - bim 뷰어/생성기, pmis 작업일보/출면일보 - demo-tenant 체험 관리 - 전표/급여/전자서명 버그 수정
This commit is contained in:
@@ -21,15 +21,22 @@ class SalesContractController extends Controller
|
||||
public function saveProducts(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'tenant_id' => 'nullable|exists:tenants,id',
|
||||
'prospect_id' => 'nullable|exists:tenant_prospects,id',
|
||||
'management_id' => 'nullable|exists:sales_tenant_managements,id',
|
||||
'category_id' => 'required|exists:sales_product_categories,id',
|
||||
'tenant_id' => 'nullable|exists:codebridge.tenants,id',
|
||||
'prospect_id' => 'nullable|exists:codebridge.tenant_prospects,id',
|
||||
'management_id' => 'nullable|exists:codebridge.sales_tenant_managements,id',
|
||||
'category_id' => 'required|exists:codebridge.sales_product_categories,id',
|
||||
'products' => 'required|array',
|
||||
'products.*.product_id' => 'required|exists:sales_products,id',
|
||||
'products.*.category_id' => 'required|exists:sales_product_categories,id',
|
||||
'products.*.product_id' => 'required|exists:codebridge.sales_products,id',
|
||||
'products.*.category_id' => 'required|exists:codebridge.sales_product_categories,id',
|
||||
'products.*.registration_fee' => 'required|numeric|min:0',
|
||||
'products.*.subscription_fee' => 'required|numeric|min:0',
|
||||
'promotion' => 'nullable|array',
|
||||
'promotion.dev_discount_type' => 'nullable|string|in:percent,amount',
|
||||
'promotion.dev_discount_amount' => 'nullable|numeric|min:0',
|
||||
'promotion.dev_waive' => 'nullable|boolean',
|
||||
'promotion.sub_discount_percent' => 'nullable|numeric|min:0|max:50',
|
||||
'promotion.free_trial' => 'nullable|boolean',
|
||||
'promotion.note' => 'nullable|string|max:200',
|
||||
]);
|
||||
|
||||
// tenant_id 또는 prospect_id 중 하나는 필수
|
||||
@@ -79,6 +86,16 @@ public function saveProducts(Request $request): JsonResponse
|
||||
$totalRegistrationFee = SalesContractProduct::where('management_id', $management->id)
|
||||
->sum('registration_fee');
|
||||
$management->update(['total_registration_fee' => $totalRegistrationFee]);
|
||||
|
||||
// 프로모션 저장
|
||||
if (! empty($validated['promotion'])) {
|
||||
$opts = $management->options ?? [];
|
||||
$opts['promotion'] = array_merge($validated['promotion'], [
|
||||
'applied_at' => now()->toDateTimeString(),
|
||||
'applied_by_user_id' => auth()->id(),
|
||||
]);
|
||||
$management->update(['options' => $opts]);
|
||||
}
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
|
||||
Reference in New Issue
Block a user