Browse Source

fixed:用户端-下单(兼容抢单类型)

刘学玺 4 months ago
parent
commit
02548a8091
1 changed files with 7 additions and 2 deletions
  1. 7 2
      app/Services/Coach/OrderService.php

+ 7 - 2
app/Services/Coach/OrderService.php

@@ -190,6 +190,7 @@ class OrderService
      */
     private function getNearbyOrders($location, float $maxDistance = 40): array
     {
+
         $nearbyOrders = Redis::georadius(
             'order_locations',
             $location->longitude,
@@ -603,8 +604,12 @@ class OrderService
                 // 检查是否是该技师的订单
                 abort_if($order->coach_id !== $user->coach->id, 403, '无权操作此订单');
 
-                // 检查订单状态是否为已分配技师
-                abort_if($order->state != OrderStatus::ASSIGNED->value && $order->state != OrderStatus::ACCEPTED->value, 400, '订单状态不正确');
+                // 根据订单类型判断订单状态
+                if ($order->type == OrderType::VISIT->value) {
+                    abort_if($order->state != OrderStatus::ACCEPTED->value, 400, '订单状态不正确');
+                } elseif ($order->type == OrderType::GRAB->value) {
+                    abort_if($order->state != OrderStatus::PAID->value, 400, '订单状态不正确');
+                }
 
                 // 更新订单状态为技师出发
                 $order->state = OrderStatus::DEPARTED->value;