|
|
@@ -166,7 +166,7 @@ class ScheduleService
|
|
|
}
|
|
|
|
|
|
$allowedTransitions = [
|
|
|
- 'pending' => ['accepted', 'rejected', 'cancelled'],
|
|
|
+ 'pending' => ['accepted', 'rejected', 'paid', 'cancelled'],
|
|
|
'accepted' => ['paid', 'cancelled'],
|
|
|
'paid' => ['cancelled', 'started'],
|
|
|
'started' => ['finished'],
|
|
|
@@ -182,6 +182,7 @@ class ScheduleService
|
|
|
}
|
|
|
|
|
|
if (! in_array($status, data_get($allowedTransitions, $currentStatus))) {
|
|
|
+ log::info("Transição de status inválida: {$currentStatus} para {$status}");
|
|
|
throw new ScheduleStatusTransitionException;
|
|
|
}
|
|
|
|
|
|
@@ -196,7 +197,6 @@ class ScheduleService
|
|
|
|
|
|
case 'accepted':
|
|
|
$notificationService = app(NotificationService::class);
|
|
|
-
|
|
|
switch (Auth::user()?->type) {
|
|
|
case UserTypeEnum::PROVIDER:
|
|
|
$notificationService->create([
|
|
|
@@ -315,25 +315,18 @@ class ScheduleService
|
|
|
|
|
|
case 'paid':
|
|
|
$notificationService = app(NotificationService::class);
|
|
|
-
|
|
|
- switch (Auth::user()?->type) {
|
|
|
- case UserTypeEnum::CLIENT:
|
|
|
- if ($schedule->provider_id) {
|
|
|
- $notificationService->create([
|
|
|
- 'title' => __('notifications.payment_confirmed_title'),
|
|
|
- 'description' => __('notifications.payment_confirmed_description'),
|
|
|
- 'origin' => 'schedule',
|
|
|
- 'origin_id' => $schedule->id,
|
|
|
- 'type' => NotificationTypeEnum::SCHEDULE_PROVIDER_START->value,
|
|
|
- 'user_id' => $schedule->provider->user_id,
|
|
|
- ]);
|
|
|
- }
|
|
|
- $this->sendClientPaymentPush($schedule);
|
|
|
- break;
|
|
|
-
|
|
|
- default:
|
|
|
- break;
|
|
|
+ if ($schedule->provider_id) {
|
|
|
+
|
|
|
+ $notificationService->create([
|
|
|
+ 'title' => __('notifications.payment_confirmed_title'),
|
|
|
+ 'description' => __('notifications.payment_confirmed_description'),
|
|
|
+ 'origin' => 'schedule',
|
|
|
+ 'origin_id' => $schedule->id,
|
|
|
+ 'type' => NotificationTypeEnum::SCHEDULE_PROVIDER_START->value,
|
|
|
+ 'user_id' => $schedule->provider->user_id,
|
|
|
+ ]);
|
|
|
}
|
|
|
+ $this->sendClientPaymentPush($schedule);
|
|
|
|
|
|
$date_cleaned = Carbon::parse($schedule->date)
|
|
|
->format('Y-m-d');
|
|
|
@@ -669,7 +662,6 @@ class ScheduleService
|
|
|
private function sendClientPaymentPush(Schedule $schedule): void
|
|
|
{
|
|
|
$user = $schedule->provider?->user;
|
|
|
-
|
|
|
if (! $user) {
|
|
|
Log::warning('Push de pagamento ignorado: prestador sem usuário', [
|
|
|
'schedule_id' => $schedule->id,
|
|
|
@@ -684,6 +676,7 @@ class ScheduleService
|
|
|
new ClienteEfetuouPagamentoPush(
|
|
|
$schedule->client?->user?->name ?? 'Cliente'
|
|
|
)
|
|
|
+
|
|
|
);
|
|
|
} catch (\Throwable $exception) {
|
|
|
Log::error('Falha ao enviar push de pagamento ao prestador', [
|