|
@@ -118,7 +118,7 @@ class OrderService
|
|
|
// 验证技师信息
|
|
|
[$coach, $location] = $this->validateCoach($user);
|
|
|
|
|
|
- // 获取技师项目信息
|
|
|
+ // 获取技师项目信���
|
|
|
$coachProjects = $coach->projects;
|
|
|
$coachProjectIds = $coachProjects->pluck('project_id')->toArray();
|
|
|
|
|
@@ -859,7 +859,7 @@ class OrderService
|
|
|
/**
|
|
|
* 技师撤离
|
|
|
*
|
|
|
- * @param int $userId 技师用户ID
|
|
|
+ * @param int $userId 技师���户ID
|
|
|
* @param int $orderId 订单ID
|
|
|
*
|
|
|
* @throws \Exception
|
|
@@ -1014,6 +1014,38 @@ class OrderService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 验证服务时间是否在技师可服务时间段内
|
|
|
+ *
|
|
|
+ * @param int $coachId 技师ID
|
|
|
+ * @param string $serviceTime 服务时间
|
|
|
+ */
|
|
|
+ public function validateServiceTime(int $coachId, string $serviceTime): bool
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ // 获取技师可服务时间段
|
|
|
+ $availableTimeSlots = app(CoachService::class)->getSchedule($coachId);
|
|
|
+ abort_if(empty($availableTimeSlots), 400, '技师无可用时间段');
|
|
|
+
|
|
|
+ // 检测订单服务时间是否在技师可服务时间段内
|
|
|
+ foreach ($availableTimeSlots as $timeSlot) {
|
|
|
+ if ($serviceTime >= $timeSlot['start_time'] && $serviceTime <= $timeSlot['end_time']) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ abort(400, '服务时间不在技师可服务时间段内');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Log::error('验证技师服务时间失败', [
|
|
|
+ 'coach_id' => $coachId,
|
|
|
+ 'service_time' => $serviceTime,
|
|
|
+ 'error' => $e->getMessage(),
|
|
|
+ 'trace' => $e->getTraceAsString(),
|
|
|
+ ]);
|
|
|
+ throw $e;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 订单设置
|
|
|
*
|