Просмотр исходного кода

feat: :sparkles: feat(agendamento-sob-medida) ajustado validação de preço por periodo

Adiciona validação do preço do prestador conforme o período selecionado para a listagem no agendamento

fase:dev | origin:escopo
kayo henrique 1 неделя назад
Родитель
Сommit
91f27d9994

+ 14 - 1
app/Rules/ScheduleBusinessRules.php

@@ -121,25 +121,38 @@ class ScheduleBusinessRules
       }
 
       $provider = Provider::find($provider_id);
+      $min_price_proportional = 0 ;
+      $max_price_proportional = 0; 
+
       $provider_price_period = 0;
       switch ($period_type):
         case '2': //2 horas
           $provider_price_period = $provider->daily_price_2h;
+          $min_price_proportional = $min_price * 0.30;
+          $max_price_proportional = $max_price * 0.30;
           break;
         case '4': //4 horas
           $provider_price_period = $provider->daily_price_4h;
+          $min_price_proportional = $min_price * 0.55;
+          $max_price_proportional = $max_price * 0.55;
           break;
         case '6': //6 horas
           $provider_price_period = $provider->daily_price_6h;
+          $min_price_proportional = $min_price * 0.85;
+          $max_price_proportional = $max_price * 0.85;
+
           break;
         case '8': //8 horas
           $provider_price_period = $provider->daily_price_8h;
+          $min_price_proportional = $min_price;
+          $max_price_proportional = $max_price;
+
           break;
         default:
           throw new \Exception(__('validation.custom.schedule.invalid_period_type'));
         endswitch;
 
-      if ($provider_price_period < $min_price || $provider_price_period > $max_price) {
+      if ($provider_price_period < $min_price_proportional || $provider_price_period > $max_price_proportional) {
         throw new \Exception(__('validation.custom.schedule.price_not_in_range'));
       }
 

+ 2 - 2
app/Services/ScheduleService.php

@@ -271,10 +271,10 @@ class ScheduleService
           $date_cleaned = Carbon::parse($schedule->date)->format('Y-m-d');
           $date_time_dispatch = Carbon::parse($date_cleaned . ' ' . $schedule->start_time);
 
-          StartScheduleJob::dispatch($schedule->id)->delay($date_time_dispatch);
+          // StartScheduleJob::dispatch($schedule->id)->delay($date_time_dispatch);
 
           // dispatch de teste em local
-          // StartScheduleJob::dispatch($schedule->id)->delay(now()->addSeconds(15));
+          StartScheduleJob::dispatch($schedule->id)->delay(now()->addSeconds(15));
           break;
         case 'cancelled':
           break;

+ 29 - 0
database/migrations/2026_04_20_100127_alter_clients_set_average_rating_default_0.php

@@ -0,0 +1,29 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::table('clients', function (Blueprint $table) {
+         $table->decimal('average_rating', 2, 1)->nullable()->default(0.0)->change();
+
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::table('clients', function (Blueprint $table) {
+                  $table->decimal('average_rating', 2, 1)->nullable()->change();
+        });
+    }
+};

+ 28 - 0
database/migrations/2026_04_20_100221_alter_providers_set_average_rating_default_0.php

@@ -0,0 +1,28 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::table('providers', function (Blueprint $table) {
+            $table->decimal('average_rating', 2, 1)->nullable()->default(0.0)->change();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::table('providers', function (Blueprint $table) {
+            $table->decimal('average_rating', 2, 1)->nullable()->change();
+        });
+    }
+};