Browse Source

fixed:客户端-结束订单

刘学玺 4 months ago
parent
commit
105cf1a320
1 changed files with 5 additions and 24 deletions
  1. 5 24
      app/Services/Client/OrderService.php

+ 5 - 24
app/Services/Client/OrderService.php

@@ -508,14 +508,11 @@ class OrderService
             try {
                 // 1. 验证用户和订单
                 $order = $this->validateOrderForFinish($userId, $orderId);
-                abort_if($order->state == 'service_end', 400, '订单已完成');
+                abort_if($order->state == OrderStatus::FINISHED->value, 400, '订单已完成');
 
                 // 2. 验证技师状态
                 $coach = $this->validateCoach($order->coach_id);
 
-                // 3. 验证服务时长
-                $this->validateServiceDuration($order);
-
                 // 4. 完成订单
                 $this->completeOrder($order, $userId);
 
@@ -537,34 +534,19 @@ class OrderService
     {
         // 验证用户状态
         $user = MemberUser::where('id', $userId)
-            ->where('state', 'enable')
+            ->where('state', UserStatus::OPEN->value)
             ->firstOrFail();
 
         // 验证订单状态
         $order = Order::where('user_id', $userId)
             ->where('id', $orderId)
-            ->where('state', 'service_ing')
+            ->where('state', OrderStatus::SERVING->value)
             ->lockForUpdate()
             ->firstOrFail();
 
         return $order;
     }
 
-    /**
-     * 验证服务时长
-     */
-    private function validateServiceDuration(Order $order): void
-    {
-        // 计算服务时长
-        $serviceStartTime = $order->service_start_time ?? $order->created_at;
-        $serviceDuration = now()->diffInMinutes($serviceStartTime);
-
-        // 获取项目要求的最短服务时长
-        $minDuration = $order->project->duration ?? 0;
-
-        abort_if($serviceDuration < $minDuration, 400, "服务时长不足{$minDuration}分钟");
-    }
-
     /**
      * 完成订单
      */
@@ -575,13 +557,12 @@ class OrderService
             'order_id' => $order->id,
             'object_id' => $userId,
             'object_type' => MemberUser::class,
-            'state' => 'finish',
+            'state' => OrderRecordStatus::COMPLETED->value,
             'remark' => '服务完成',
         ]);
 
         // 2. 更新订单状态
-        $order->state = 'service_end';
-        $order->finish_time = now();
+        $order->state = OrderStatus::FINISHED->value;
         $order->save();
     }