style: Pint 포맷팅 적용
This commit is contained in:
@@ -25,7 +25,7 @@ class AdminProspectController extends Controller
|
||||
*/
|
||||
private function checkAdminAccess(): void
|
||||
{
|
||||
if (!auth()->user()->isAdmin() && !auth()->user()->isSuperAdmin()) {
|
||||
if (! auth()->user()->isAdmin() && ! auth()->user()->isSuperAdmin()) {
|
||||
abort(403, '관리자만 접근할 수 있습니다.');
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ private function getPaymentTypeForField(string $field): string
|
||||
*/
|
||||
private function loadMergedCommission(?SalesTenantManagement $management): ?object
|
||||
{
|
||||
if (!$management) {
|
||||
if (! $management) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -58,12 +58,12 @@ private function loadMergedCommission(?SalesTenantManagement $management): ?obje
|
||||
$balance = $commissions->firstWhere('payment_type', SalesCommission::PAYMENT_BALANCE);
|
||||
|
||||
// balance 레코드가 없으면 기존 단일 레코드 그대로 반환 (하위호환)
|
||||
if (!$balance) {
|
||||
if (! $balance) {
|
||||
return $deposit ?? $commissions->first();
|
||||
}
|
||||
|
||||
// 1차 필드는 deposit, 2차 필드는 balance에서 가져옴
|
||||
$merged = new \stdClass();
|
||||
$merged = new \stdClass;
|
||||
$merged->first_payment_at = $deposit?->first_payment_at;
|
||||
$merged->first_partner_paid_at = $deposit?->first_partner_paid_at;
|
||||
$merged->second_payment_at = $balance->second_payment_at;
|
||||
@@ -118,7 +118,7 @@ public function modalShow(int $id): View
|
||||
|
||||
// 파트너 타입
|
||||
$partnerType = $management->salesPartner?->partner_type;
|
||||
if (!$partnerType && $prospect->registered_by) {
|
||||
if (! $partnerType && $prospect->registered_by) {
|
||||
$partnerType = SalesPartner::where('user_id', $prospect->registered_by)->value('partner_type');
|
||||
}
|
||||
$partnerType = $partnerType ?? 'individual';
|
||||
@@ -161,7 +161,7 @@ private function getIndexData(Request $request): array
|
||||
$query = TenantProspect::with(['registeredBy', 'tenant']);
|
||||
|
||||
// 검색
|
||||
if (!empty($filters['search'])) {
|
||||
if (! empty($filters['search'])) {
|
||||
$search = $filters['search'];
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('company_name', 'like', "%{$search}%")
|
||||
@@ -174,7 +174,7 @@ private function getIndexData(Request $request): array
|
||||
// 상태 필터
|
||||
$isProgressCompleteFilter = ($filters['status'] === 'progress_complete');
|
||||
$isHandoverFilter = ($filters['status'] === 'handover');
|
||||
if (!empty($filters['status']) && !$isProgressCompleteFilter && !$isHandoverFilter) {
|
||||
if (! empty($filters['status']) && ! $isProgressCompleteFilter && ! $isHandoverFilter) {
|
||||
$query->where('status', $filters['status']);
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ private function getIndexData(Request $request): array
|
||||
}
|
||||
|
||||
// 영업파트너 필터
|
||||
if (!empty($filters['registered_by'])) {
|
||||
if (! empty($filters['registered_by'])) {
|
||||
$query->where('registered_by', $filters['registered_by']);
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ private function getIndexData(Request $request): array
|
||||
|
||||
// 파트너 타입: management → registered_by 순으로 조회
|
||||
$partnerType = $management?->salesPartner?->partner_type;
|
||||
if (!$partnerType && $prospect->registered_by) {
|
||||
if (! $partnerType && $prospect->registered_by) {
|
||||
$partnerType = SalesPartner::where('user_id', $prospect->registered_by)->value('partner_type');
|
||||
}
|
||||
$prospect->partner_type = $partnerType ?? 'individual';
|
||||
@@ -264,7 +264,7 @@ private function getIndexData(Request $request): array
|
||||
|
||||
// 파트너 타입: management → registered_by 순으로 조회
|
||||
$partnerType = $management?->salesPartner?->partner_type;
|
||||
if (!$partnerType && $prospect->registered_by) {
|
||||
if (! $partnerType && $prospect->registered_by) {
|
||||
$partnerType = SalesPartner::where('user_id', $prospect->registered_by)->value('partner_type');
|
||||
}
|
||||
$prospect->partner_type = $partnerType ?? 'individual';
|
||||
@@ -314,7 +314,7 @@ public function updateHqStatus(int $id, Request $request)
|
||||
$this->checkAdminAccess();
|
||||
|
||||
$request->validate([
|
||||
'hq_status' => 'required|in:' . implode(',', array_keys(SalesTenantManagement::$hqStatusLabels)),
|
||||
'hq_status' => 'required|in:'.implode(',', array_keys(SalesTenantManagement::$hqStatusLabels)),
|
||||
]);
|
||||
|
||||
$prospect = TenantProspect::findOrFail($id);
|
||||
@@ -410,7 +410,7 @@ public function updateCommissionDate(int $id, Request $request)
|
||||
|
||||
// 파트너 resolve → 요율 결정
|
||||
$partner = $management->salesPartner;
|
||||
if (!$partner && $prospect->registered_by) {
|
||||
if (! $partner && $prospect->registered_by) {
|
||||
$partner = SalesPartner::where('user_id', $prospect->registered_by)->first();
|
||||
}
|
||||
$isGroup = $partner?->isGroup() ?? false;
|
||||
@@ -557,7 +557,7 @@ public function updateReferrerCommission(int $id, Request $request)
|
||||
|
||||
// 단체 파트너는 수동 수정 불가
|
||||
$partner = $management->salesPartner;
|
||||
if (!$partner && $prospect->registered_by) {
|
||||
if (! $partner && $prospect->registered_by) {
|
||||
$partner = SalesPartner::where('user_id', $prospect->registered_by)->first();
|
||||
}
|
||||
if ($partner && $partner->isGroup()) {
|
||||
@@ -619,7 +619,7 @@ public function clearCommissionDate(int $id, Request $request)
|
||||
$prospect = TenantProspect::findOrFail($id);
|
||||
$management = SalesTenantManagement::where('tenant_prospect_id', $prospect->id)->first();
|
||||
|
||||
if (!$management) {
|
||||
if (! $management) {
|
||||
return response()->json(['success' => false, 'message' => '관리 정보가 없습니다.']);
|
||||
}
|
||||
|
||||
@@ -632,7 +632,7 @@ public function clearCommissionDate(int $id, Request $request)
|
||||
->where('payment_type', $paymentType)
|
||||
->first();
|
||||
|
||||
if (!$commission) {
|
||||
if (! $commission) {
|
||||
return response()->json(['success' => false, 'message' => '수당 정보가 없습니다.']);
|
||||
}
|
||||
$updateData = [$field => null];
|
||||
|
||||
@@ -114,7 +114,7 @@ public function uploadAudio(Request $request, GoogleCloudStorageService $gcs): J
|
||||
|
||||
// 파일 저장
|
||||
$file = $request->file('audio');
|
||||
$fileName = 'audio_' . now()->format('Ymd_His') . '_' . uniqid() . '.' . $file->getClientOriginalExtension();
|
||||
$fileName = 'audio_'.now()->format('Ymd_His').'_'.uniqid().'.'.$file->getClientOriginalExtension();
|
||||
$localPath = $file->storeAs("tenant/consultations/{$tenantId}", $fileName, 'local');
|
||||
$fileSize = $file->getSize();
|
||||
|
||||
@@ -154,7 +154,7 @@ public function uploadAudio(Request $request, GoogleCloudStorageService $gcs): J
|
||||
'formatted_duration' => $consultation->formatted_duration,
|
||||
'created_by_name' => $consultation->creator->name,
|
||||
'created_at' => $consultation->created_at->format('Y-m-d H:i'),
|
||||
'has_gcs' => !empty($gcsUri),
|
||||
'has_gcs' => ! empty($gcsUri),
|
||||
],
|
||||
]);
|
||||
}
|
||||
@@ -178,7 +178,7 @@ public function uploadFile(Request $request): JsonResponse
|
||||
// 파일 저장
|
||||
$file = $request->file('file');
|
||||
$originalName = $file->getClientOriginalName();
|
||||
$fileName = now()->format('Ymd_His') . '_' . uniqid() . '_' . $originalName;
|
||||
$fileName = now()->format('Ymd_His').'_'.uniqid().'_'.$originalName;
|
||||
$path = $file->storeAs("tenant/attachments/{$tenantId}", $fileName, 'local');
|
||||
|
||||
// DB에 저장
|
||||
@@ -229,7 +229,7 @@ public function downloadAudio(int $consultationId, GoogleCloudStorageService $gc
|
||||
|
||||
// GCS에 저장된 경우 서명된 URL로 리다이렉트
|
||||
if ($consultation->gcs_uri) {
|
||||
$objectName = str_replace('gs://' . $gcs->getBucketName() . '/', '', $consultation->gcs_uri);
|
||||
$objectName = str_replace('gs://'.$gcs->getBucketName().'/', '', $consultation->gcs_uri);
|
||||
$signedUrl = $gcs->getSignedUrl($objectName, 60);
|
||||
|
||||
if ($signedUrl) {
|
||||
@@ -240,7 +240,7 @@ public function downloadAudio(int $consultationId, GoogleCloudStorageService $gc
|
||||
// 로컬 파일 다운로드
|
||||
$localPath = Storage::disk('local')->path($consultation->file_path);
|
||||
|
||||
if (!file_exists($localPath)) {
|
||||
if (! file_exists($localPath)) {
|
||||
abort(404, '파일을 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
@@ -250,11 +250,11 @@ public function downloadAudio(int $consultationId, GoogleCloudStorageService $gc
|
||||
'wav' => 'audio/wav',
|
||||
'mp3' => 'audio/mpeg',
|
||||
'ogg' => 'audio/ogg',
|
||||
'm4a' => 'audio/mp4'
|
||||
'm4a' => 'audio/mp4',
|
||||
];
|
||||
$contentType = $mimeTypes[$extension] ?? 'audio/webm';
|
||||
|
||||
$downloadFileName = '상담녹음_' . $consultation->created_at->format('Ymd_His') . '.' . $extension;
|
||||
$downloadFileName = '상담녹음_'.$consultation->created_at->format('Ymd_His').'.'.$extension;
|
||||
|
||||
return response()->download($localPath, $downloadFileName, [
|
||||
'Content-Type' => $contentType,
|
||||
@@ -274,7 +274,7 @@ public function downloadFile(int $consultationId): BinaryFileResponse
|
||||
|
||||
$localPath = Storage::disk('local')->path($consultation->file_path);
|
||||
|
||||
if (!file_exists($localPath)) {
|
||||
if (! file_exists($localPath)) {
|
||||
abort(404, '파일을 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ public function prospectUploadAudio(Request $request, GoogleCloudStorageService
|
||||
$duration = $request->input('duration');
|
||||
|
||||
$file = $request->file('audio');
|
||||
$fileName = 'audio_' . now()->format('Ymd_His') . '_' . uniqid() . '.' . $file->getClientOriginalExtension();
|
||||
$fileName = 'audio_'.now()->format('Ymd_His').'_'.uniqid().'.'.$file->getClientOriginalExtension();
|
||||
$localPath = $file->storeAs("prospect/consultations/{$prospectId}", $fileName, 'local');
|
||||
$fileSize = $file->getSize();
|
||||
|
||||
@@ -397,7 +397,7 @@ public function prospectUploadAudio(Request $request, GoogleCloudStorageService
|
||||
'formatted_duration' => $consultation->formatted_duration,
|
||||
'created_by_name' => $consultation->creator->name,
|
||||
'created_at' => $consultation->created_at->format('Y-m-d H:i'),
|
||||
'has_gcs' => !empty($gcsUri),
|
||||
'has_gcs' => ! empty($gcsUri),
|
||||
],
|
||||
]);
|
||||
}
|
||||
@@ -420,7 +420,7 @@ public function prospectUploadFile(Request $request): JsonResponse
|
||||
|
||||
$file = $request->file('file');
|
||||
$originalName = $file->getClientOriginalName();
|
||||
$fileName = now()->format('Ymd_His') . '_' . uniqid() . '_' . $originalName;
|
||||
$fileName = now()->format('Ymd_His').'_'.uniqid().'_'.$originalName;
|
||||
$path = $file->storeAs("prospect/attachments/{$prospectId}", $fileName, 'local');
|
||||
|
||||
$consultation = SalesConsultation::createFileByProspect(
|
||||
|
||||
@@ -89,7 +89,7 @@ public function saveProducts(Request $request): JsonResponse
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => '저장 중 오류가 발생했습니다: ' . $e->getMessage(),
|
||||
'message' => '저장 중 오류가 발생했습니다: '.$e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ private function getDashboardData(Request $request): array
|
||||
],
|
||||
];
|
||||
|
||||
if (!$isGroupPartner) {
|
||||
if (! $isGroupPartner) {
|
||||
$commissionByRole[] = [
|
||||
'name' => '관리자',
|
||||
'rate' => null, // 1개월 구독료 (퍼센트가 아닌 고정 금액)
|
||||
@@ -181,7 +181,7 @@ private function getDashboardData(Request $request): array
|
||||
|
||||
// 수당 계산: 개발비 × 요율% (개인 20%, 단체 30%) - 1차/2차 분할은 calculateExpectedCommissionSummary에서 처리
|
||||
$handoverPartnerRate = $isGroupPartner ? 0.30 : 0.20;
|
||||
$handoverPartnerCommission = (int)($handoverTotalRegFee * $handoverPartnerRate);
|
||||
$handoverPartnerCommission = (int) ($handoverTotalRegFee * $handoverPartnerRate);
|
||||
|
||||
// 내가 매니저로 지정된 인계 완료 건의 수당 계산
|
||||
$managedHandoverManagements = SalesTenantManagement::where('manager_user_id', $currentUserId)
|
||||
@@ -190,7 +190,7 @@ private function getDashboardData(Request $request): array
|
||||
$managedHandoverManagementIds = $managedHandoverManagements->pluck('id')->toArray();
|
||||
|
||||
// 매니저 수당: 1개월 구독료 (퍼센트가 아닌 고정 금액)
|
||||
$handoverManagerCommission = (int)SalesContractProduct::whereIn('management_id', $managedHandoverManagementIds)
|
||||
$handoverManagerCommission = (int) SalesContractProduct::whereIn('management_id', $managedHandoverManagementIds)
|
||||
->sum('subscription_fee');
|
||||
|
||||
// 기존 수당에 인계 완료 수당 추가
|
||||
@@ -202,7 +202,7 @@ private function getDashboardData(Request $request): array
|
||||
// 역할별 수당 업데이트 (실제 지급된 수당 기준)
|
||||
// 참고: 예상 수당은 나중에 $totalExpectedCommission으로 별도 계산됨
|
||||
$commissionByRole[0]['amount'] = $partnerCommissionTotal;
|
||||
if (!$isGroupPartner) {
|
||||
if (! $isGroupPartner) {
|
||||
$commissionByRole[1]['amount'] = $managerCommissionTotal;
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ private function getDashboardData(Request $request): array
|
||||
->toArray();
|
||||
$devInProgressRegFee = SalesContractProduct::whereIn('management_id', $devInProgressManagementIds)
|
||||
->sum('registration_fee');
|
||||
$expectedFromDevInProgress = (int)($devInProgressRegFee * $handoverPartnerRate); // 개발비 × 요율 (개인 20%, 단체 30%)
|
||||
$expectedFromDevInProgress = (int) ($devInProgressRegFee * $handoverPartnerRate); // 개발비 × 요율 (개인 20%, 단체 30%)
|
||||
|
||||
// 2) 인계 완료 중 지급 미완료 건
|
||||
$handoverUnpaidRegFee = SalesContractProduct::whereIn('management_id', $handoverManagementIds)
|
||||
@@ -288,7 +288,7 @@ private function getDashboardData(Request $request): array
|
||||
->whereIn('management_id', $handoverManagementIds)
|
||||
->where('status', SalesCommission::STATUS_PAID)
|
||||
->sum('partner_commission');
|
||||
$expectedFromHandover = (int)($handoverUnpaidRegFee * $handoverPartnerRate) - $paidCommissionFromHandover;
|
||||
$expectedFromHandover = (int) ($handoverUnpaidRegFee * $handoverPartnerRate) - $paidCommissionFromHandover;
|
||||
$expectedFromHandover = max(0, $expectedFromHandover);
|
||||
|
||||
// 총 예상 수당 (지급 완료 제외)
|
||||
@@ -383,7 +383,7 @@ public function assignManager(int $tenantId, Request $request): JsonResponse
|
||||
} else {
|
||||
// 특정 매니저 지정
|
||||
$manager = User::find($managerId);
|
||||
if (!$manager) {
|
||||
if (! $manager) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => '매니저를 찾을 수 없습니다.',
|
||||
@@ -428,7 +428,7 @@ public function assignProspectManager(int $prospectId, Request $request): JsonRe
|
||||
} else {
|
||||
// 특정 매니저 지정
|
||||
$manager = User::find($managerId);
|
||||
if (!$manager) {
|
||||
if (! $manager) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => '매니저를 찾을 수 없습니다.',
|
||||
@@ -581,7 +581,7 @@ private function getManagerOnlyProspects(int $currentUserId): array
|
||||
$prospect = $management->tenantProspect;
|
||||
|
||||
// 내가 등록한 건은 제외 (순수하게 매니저로만 참여한 건만)
|
||||
if (!$prospect || $prospect->registered_by === $currentUserId) {
|
||||
if (! $prospect || $prospect->registered_by === $currentUserId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -615,7 +615,7 @@ private function getManagerOnlyProspects(int $currentUserId): array
|
||||
|
||||
foreach ($tenantManagements as $management) {
|
||||
$tenant = $management->tenant;
|
||||
if (!$tenant) {
|
||||
if (! $tenant) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -676,12 +676,12 @@ private function calculatePartnerSummaryStats(array $partnerIds, int $currentUse
|
||||
// 개인 파트너 예상 수당: 1개월 구독료
|
||||
$individualProspectIds = TenantProspect::whereIn('registered_by', $individualPartnerIds)->pluck('id')->toArray();
|
||||
$individualMgmtIds = SalesTenantManagement::whereIn('tenant_prospect_id', $individualProspectIds)->pluck('id')->toArray();
|
||||
$individualExpected = (int)SalesContractProduct::whereIn('management_id', $individualMgmtIds)->sum('subscription_fee');
|
||||
$individualExpected = (int) SalesContractProduct::whereIn('management_id', $individualMgmtIds)->sum('subscription_fee');
|
||||
|
||||
// 단체 파트너 예상 수당: 개발비 × 3%
|
||||
$groupProspectIds = TenantProspect::whereIn('registered_by', $groupPartnerUserIds)->pluck('id')->toArray();
|
||||
$groupMgmtIds = SalesTenantManagement::whereIn('tenant_prospect_id', $groupProspectIds)->pluck('id')->toArray();
|
||||
$groupExpected = (int)(SalesContractProduct::whereIn('management_id', $groupMgmtIds)->sum('registration_fee') * 0.03);
|
||||
$groupExpected = (int) (SalesContractProduct::whereIn('management_id', $groupMgmtIds)->sum('registration_fee') * 0.03);
|
||||
|
||||
$expectedFromFee = $individualExpected + $groupExpected;
|
||||
|
||||
@@ -727,16 +727,16 @@ private function calculatePartnerSummaryStats(array $partnerIds, int $currentUse
|
||||
'expected_commission' => $expectedCommission,
|
||||
'paid_commission' => $paidManagerCommission,
|
||||
'first_commission' => [
|
||||
'total' => (int)$halfExpected,
|
||||
'pending' => (int)$halfPending,
|
||||
'scheduled' => (int)$halfScheduled,
|
||||
'paid' => (int)$halfPaid,
|
||||
'total' => (int) $halfExpected,
|
||||
'pending' => (int) $halfPending,
|
||||
'scheduled' => (int) $halfScheduled,
|
||||
'paid' => (int) $halfPaid,
|
||||
],
|
||||
'second_commission' => [
|
||||
'total' => (int)$halfExpected,
|
||||
'pending' => (int)$halfPending,
|
||||
'scheduled' => (int)$halfScheduled,
|
||||
'paid' => (int)$halfPaid,
|
||||
'total' => (int) $halfExpected,
|
||||
'pending' => (int) $halfPending,
|
||||
'scheduled' => (int) $halfScheduled,
|
||||
'paid' => (int) $halfPaid,
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -782,8 +782,8 @@ private function getPartnerActivitiesDetail($recruitedPartners, int $currentUser
|
||||
// 단체 파트너: 협업지원금(개발비 × 3%), 개인 파트너: 관리자 수당(1개월 구독료)
|
||||
$isRecruitedGroupPartner = $salesPartner && $salesPartner->isGroup();
|
||||
$expectedCommission = $isRecruitedGroupPartner
|
||||
? (int)($totalRegistrationFee * 0.03)
|
||||
: (int)$totalSubscriptionFee;
|
||||
? (int) ($totalRegistrationFee * 0.03)
|
||||
: (int) $totalSubscriptionFee;
|
||||
|
||||
// 최종 수당 (확정 + 예상 중 큰 값)
|
||||
$managerCommission = max($confirmedCommission, $expectedCommission);
|
||||
@@ -864,7 +864,7 @@ private function getPartnerActivitiesDetail($recruitedPartners, int $currentUser
|
||||
|
||||
// 역할 정보
|
||||
$roles = $partner->userRoles->pluck('role.name')->filter()->toArray();
|
||||
$roleLabel = !empty($roles) ? implode(', ', $roles) : '영업';
|
||||
$roleLabel = ! empty($roles) ? implode(', ', $roles) : '영업';
|
||||
|
||||
$activities[] = [
|
||||
'partner' => $partner,
|
||||
@@ -912,7 +912,7 @@ private function getCommissionData(): array
|
||||
*/
|
||||
private function getAllManagerUsers()
|
||||
{
|
||||
return User::whereHas('userRoles.role', fn($q) => $q->where('name', 'manager'))
|
||||
return User::whereHas('userRoles.role', fn ($q) => $q->where('name', 'manager'))
|
||||
->where('is_active', true)
|
||||
->where('id', '!=', auth()->id()) // 본인 제외
|
||||
->get(['id', 'name', 'email']);
|
||||
@@ -930,7 +930,7 @@ public function searchManagers(Request $request): JsonResponse
|
||||
// 디버깅: SQL 쿼리 로깅
|
||||
\DB::enableQueryLog();
|
||||
|
||||
$managers = User::whereHas('userRoles.role', fn($q) => $q->where('name', 'manager'))
|
||||
$managers = User::whereHas('userRoles.role', fn ($q) => $q->where('name', 'manager'))
|
||||
->where('is_active', true)
|
||||
->where('id', '!=', $authId)
|
||||
->when($query, function ($q) use ($query) {
|
||||
@@ -1012,24 +1012,24 @@ private function calculateExpectedCommissionSummary($commissions, int $totalExpe
|
||||
return [
|
||||
'scheduled_this_month' => $commissions
|
||||
->where('status', SalesCommission::STATUS_APPROVED)
|
||||
->filter(fn($c) => $c->scheduled_payment_date?->format('Y-m') === $thisMonth)
|
||||
->filter(fn ($c) => $c->scheduled_payment_date?->format('Y-m') === $thisMonth)
|
||||
->sum('partner_commission'),
|
||||
'total_received' => $paidCommission,
|
||||
'pending_amount' => $pendingAmount,
|
||||
'contracts_this_month' => $commissions
|
||||
->filter(fn($c) => $c->payment_date >= $thisMonthStart && $c->payment_date <= $thisMonthEnd)
|
||||
->filter(fn ($c) => $c->payment_date >= $thisMonthStart && $c->payment_date <= $thisMonthEnd)
|
||||
->count(),
|
||||
'first_commission' => [
|
||||
'total' => (int)$halfExpected,
|
||||
'pending' => (int)$halfPending,
|
||||
'scheduled' => (int)$halfScheduled,
|
||||
'paid' => (int)$halfPaid,
|
||||
'total' => (int) $halfExpected,
|
||||
'pending' => (int) $halfPending,
|
||||
'scheduled' => (int) $halfScheduled,
|
||||
'paid' => (int) $halfPaid,
|
||||
],
|
||||
'second_commission' => [
|
||||
'total' => (int)$halfExpected,
|
||||
'pending' => (int)$halfPending,
|
||||
'scheduled' => (int)$halfScheduled,
|
||||
'paid' => (int)$halfPaid,
|
||||
'total' => (int) $halfExpected,
|
||||
'pending' => (int) $halfPending,
|
||||
'scheduled' => (int) $halfScheduled,
|
||||
'paid' => (int) $halfPaid,
|
||||
],
|
||||
'total_commission' => $totalExpectedCommission,
|
||||
];
|
||||
@@ -1053,7 +1053,7 @@ private function calculateCommissionSummaryFromCollection($commissions): array
|
||||
return [
|
||||
'scheduled_this_month' => $commissions
|
||||
->where('status', SalesCommission::STATUS_APPROVED)
|
||||
->filter(fn($c) => $c->scheduled_payment_date?->format('Y-m') === $thisMonth)
|
||||
->filter(fn ($c) => $c->scheduled_payment_date?->format('Y-m') === $thisMonth)
|
||||
->sum('partner_commission'),
|
||||
'total_received' => $commissions
|
||||
->where('status', SalesCommission::STATUS_PAID)
|
||||
@@ -1062,7 +1062,7 @@ private function calculateCommissionSummaryFromCollection($commissions): array
|
||||
->where('status', SalesCommission::STATUS_PENDING)
|
||||
->sum('partner_commission'),
|
||||
'contracts_this_month' => $commissions
|
||||
->filter(fn($c) => $c->payment_date >= $thisMonthStart && $c->payment_date <= $thisMonthEnd)
|
||||
->filter(fn ($c) => $c->payment_date >= $thisMonthStart && $c->payment_date <= $thisMonthEnd)
|
||||
->count(),
|
||||
'first_commission' => $firstCommission,
|
||||
'second_commission' => $secondCommission,
|
||||
|
||||
@@ -24,7 +24,7 @@ public function __construct(
|
||||
public function index(Request $request): View|Response
|
||||
{
|
||||
// 권한 체크: admin 역할만 접근 가능
|
||||
if (!auth()->user()->isAdmin()) {
|
||||
if (! auth()->user()->isAdmin()) {
|
||||
abort(403, '접근 권한이 없습니다.');
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public function index(Request $request): View|Response
|
||||
public function approve(Request $request, int $id)
|
||||
{
|
||||
// 권한 체크
|
||||
if (!auth()->user()->isAdmin()) {
|
||||
if (! auth()->user()->isAdmin()) {
|
||||
abort(403, '접근 권한이 없습니다.');
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public function approve(Request $request, int $id)
|
||||
public function reject(Request $request, int $id)
|
||||
{
|
||||
// 권한 체크
|
||||
if (!auth()->user()->isAdmin()) {
|
||||
if (! auth()->user()->isAdmin()) {
|
||||
abort(403, '접근 권한이 없습니다.');
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public function reject(Request $request, int $id)
|
||||
public function updateStatus(Request $request, int $id)
|
||||
{
|
||||
// 권한 체크
|
||||
if (!auth()->user()->isAdmin()) {
|
||||
if (! auth()->user()->isAdmin()) {
|
||||
abort(403, '접근 권한이 없습니다.');
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ public function updateStatus(Request $request, int $id)
|
||||
public function revertToPending(Request $request, int $id)
|
||||
{
|
||||
// 권한 체크
|
||||
if (!auth()->user()->isAdmin()) {
|
||||
if (! auth()->user()->isAdmin()) {
|
||||
abort(403, '접근 권한이 없습니다.');
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ public function revertToPending(Request $request, int $id)
|
||||
public function detail(int $id): View
|
||||
{
|
||||
// 권한 체크
|
||||
if (!auth()->user()->isAdmin()) {
|
||||
if (! auth()->user()->isAdmin()) {
|
||||
abort(403, '접근 권한이 없습니다.');
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ public function update(Request $request, int $id)
|
||||
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:100',
|
||||
'email' => 'required|email|max:255|unique:users,email,' . $id,
|
||||
'email' => 'required|email|max:255|unique:users,email,'.$id,
|
||||
'phone' => 'nullable|string|max:20',
|
||||
'password' => 'nullable|string|min:4|confirmed',
|
||||
'role_ids' => 'required|array|min:1',
|
||||
@@ -242,7 +242,7 @@ public function update(Request $request, int $id)
|
||||
public function destroy(int $id)
|
||||
{
|
||||
// 권한 체크: admin 역할만 삭제 가능
|
||||
if (!auth()->user()->isAdmin()) {
|
||||
if (! auth()->user()->isAdmin()) {
|
||||
abort(403, '삭제 권한이 없습니다.');
|
||||
}
|
||||
|
||||
@@ -298,6 +298,7 @@ public function delegateRole(Request $request, int $id)
|
||||
$this->service->delegateRole($fromUser, $toUser, $validated['role_name']);
|
||||
|
||||
$roleLabel = '상담매니저';
|
||||
|
||||
return redirect()->back()
|
||||
->with('success', "{$roleLabel} 역할이 {$toUser->name}님에게 위임되었습니다.");
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
@@ -319,6 +320,7 @@ public function assignRole(Request $request, int $id)
|
||||
$this->service->assignRole($partner, $validated['role_name']);
|
||||
|
||||
$roleLabels = ['sales' => '영업파트너', 'manager' => '상담매니저'];
|
||||
|
||||
return redirect()->back()
|
||||
->with('success', "{$roleLabels[$validated['role_name']]} 역할이 부여되었습니다.");
|
||||
}
|
||||
@@ -336,6 +338,7 @@ public function removeRole(Request $request, int $id)
|
||||
$this->service->removeRole($partner, $validated['role_name']);
|
||||
|
||||
$roleLabels = ['sales' => '영업파트너', 'manager' => '상담매니저'];
|
||||
|
||||
return redirect()->back()
|
||||
->with('success', "{$roleLabels[$validated['role_name']]} 역할이 제거되었습니다.");
|
||||
}
|
||||
@@ -371,7 +374,7 @@ public function deleteDocument(int $id, int $documentId)
|
||||
public function approvals(Request $request): View|Response
|
||||
{
|
||||
// 권한 체크: admin 역할만 접근 가능
|
||||
if (!auth()->user()->isAdmin()) {
|
||||
if (! auth()->user()->isAdmin()) {
|
||||
abort(403, '접근 권한이 없습니다.');
|
||||
}
|
||||
|
||||
@@ -404,7 +407,7 @@ public function approvals(Request $request): View|Response
|
||||
public function approveFromList(Request $request, int $id)
|
||||
{
|
||||
// 권한 체크
|
||||
if (!auth()->user()->isAdmin()) {
|
||||
if (! auth()->user()->isAdmin()) {
|
||||
abort(403, '접근 권한이 없습니다.');
|
||||
}
|
||||
|
||||
@@ -428,7 +431,7 @@ public function approveFromList(Request $request, int $id)
|
||||
public function rejectFromList(Request $request, int $id)
|
||||
{
|
||||
// 권한 체크
|
||||
if (!auth()->user()->isAdmin()) {
|
||||
if (! auth()->user()->isAdmin()) {
|
||||
abort(403, '접근 권한이 없습니다.');
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public function index(Request $request): View|Response
|
||||
|
||||
$categories = SalesProductCategory::active()
|
||||
->ordered()
|
||||
->with(['products' => fn($q) => $q->ordered()])
|
||||
->with(['products' => fn ($q) => $q->ordered()])
|
||||
->get();
|
||||
|
||||
$currentCategoryCode = $request->input('category', $categories->first()?->code);
|
||||
@@ -43,7 +43,7 @@ public function productList(Request $request): View
|
||||
{
|
||||
$categoryCode = $request->input('category');
|
||||
$category = SalesProductCategory::where('code', $categoryCode)
|
||||
->with(['products' => fn($q) => $q->ordered()])
|
||||
->with(['products' => fn ($q) => $q->ordered()])
|
||||
->first();
|
||||
|
||||
return view('sales.products.partials.product-list', compact('category'));
|
||||
@@ -144,7 +144,7 @@ public function destroy(int $id): JsonResponse
|
||||
public function toggleActive(int $id): JsonResponse
|
||||
{
|
||||
$product = SalesProduct::findOrFail($id);
|
||||
$product->update(['is_active' => !$product->is_active]);
|
||||
$product->update(['is_active' => ! $product->is_active]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
@@ -268,7 +268,7 @@ public function getProductsApi(): JsonResponse
|
||||
{
|
||||
$categories = SalesProductCategory::active()
|
||||
->ordered()
|
||||
->with(['products' => fn($q) => $q->active()->ordered()])
|
||||
->with(['products' => fn ($q) => $q->active()->ordered()])
|
||||
->get();
|
||||
|
||||
return response()->json([
|
||||
|
||||
@@ -99,19 +99,19 @@ public function store(Request $request)
|
||||
]);
|
||||
|
||||
// 명함 이미지 저장 (Base64)
|
||||
if (!empty($validated['business_card_image_data'])) {
|
||||
if (! empty($validated['business_card_image_data'])) {
|
||||
$validated['business_card_image'] = $this->saveBase64Image($validated['business_card_image_data'], 'business-cards');
|
||||
}
|
||||
unset($validated['business_card_image_data']);
|
||||
|
||||
// 신분증 이미지 저장 (Base64)
|
||||
if (!empty($validated['id_card_image_data'])) {
|
||||
if (! empty($validated['id_card_image_data'])) {
|
||||
$validated['id_card_image'] = $this->saveBase64Image($validated['id_card_image_data'], 'id-cards');
|
||||
}
|
||||
unset($validated['id_card_image_data']);
|
||||
|
||||
// 통장사본 이미지 저장 (Base64)
|
||||
if (!empty($validated['bankbook_image_data'])) {
|
||||
if (! empty($validated['bankbook_image_data'])) {
|
||||
$validated['bankbook_image'] = $this->saveBase64Image($validated['bankbook_image_data'], 'bankbooks');
|
||||
}
|
||||
unset($validated['bankbook_image_data']);
|
||||
@@ -132,7 +132,7 @@ public function show(int $id): View
|
||||
'salesManager',
|
||||
'products',
|
||||
'scenarios',
|
||||
'consultations.manager'
|
||||
'consultations.manager',
|
||||
])->findOrFail($id);
|
||||
|
||||
$managers = SalesManager::active()
|
||||
@@ -250,7 +250,7 @@ private function saveBase64Image(string $base64Data, string $folder): ?string
|
||||
return null;
|
||||
}
|
||||
|
||||
$filename = $folder . '/' . date('Ymd') . '_' . uniqid() . '.' . $extension;
|
||||
$filename = $folder.'/'.date('Ymd').'_'.uniqid().'.'.$extension;
|
||||
Storage::disk('public')->put($filename, $imageData);
|
||||
|
||||
return $filename;
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
use App\Models\Sales\SalesTenantManagement;
|
||||
use App\Models\Sales\TenantProspect;
|
||||
use App\Models\Tenants\Tenant;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,7 +71,7 @@ public function store(Request $request)
|
||||
|
||||
// 등록 가능 여부 확인
|
||||
$checkResult = $this->service->canRegister($validated['business_number']);
|
||||
if (!$checkResult['can_register']) {
|
||||
if (! $checkResult['can_register']) {
|
||||
return redirect()->back()
|
||||
->withInput()
|
||||
->with('error', $checkResult['reason']);
|
||||
@@ -172,7 +172,7 @@ public function destroy(int $id)
|
||||
}
|
||||
|
||||
// 관리자만 삭제 가능
|
||||
if (!auth()->user()->isAdmin()) {
|
||||
if (! auth()->user()->isAdmin()) {
|
||||
return redirect()->route('sales.prospects.index')
|
||||
->with('error', '삭제 권한이 없습니다. 본사 운영팀에 문의하세요.');
|
||||
}
|
||||
@@ -257,7 +257,7 @@ public function deleteAttachment(Request $request, int $id)
|
||||
$type = $request->get('type');
|
||||
$allowedTypes = ['business_card', 'id_card', 'bankbook'];
|
||||
|
||||
if (!in_array($type, $allowedTypes)) {
|
||||
if (! in_array($type, $allowedTypes)) {
|
||||
return response()->json(['success' => false, 'message' => '잘못된 요청입니다.'], 400);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user