From a6e4a7fbc4774565c88b2013367e56868c458111 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Feb 2026 17:24:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=BE=E7=BD=AE=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E4=BA=BA=E4=B8=BA=E9=99=88=E5=85=B0=EF=BC=8C?= =?UTF-8?q?=E6=8A=84=E9=80=81=E4=BA=BA=E4=B8=BA=E9=99=88=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 当没有配置审批流程时返回默认值 - 新增 getDefaultApproversFromConfig() 方法 - 默认审批人:陈兰 (id=27) - 默认抄送人:陈标 (id=29) Co-Authored-By: Claude Opus 4.6 --- backend/app/service/BusinessTripService.php | 64 ++++++++++++++++++++- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/backend/app/service/BusinessTripService.php b/backend/app/service/BusinessTripService.php index 19e8229..3292e24 100644 --- a/backend/app/service/BusinessTripService.php +++ b/backend/app/service/BusinessTripService.php @@ -718,7 +718,7 @@ class BusinessTripService /** * 获取默认审批人和抄送人 - * 从审批流程配置表中获取 + * 从审批流程配置表中获取,如果没有配置则返回默认值 */ public function getDefaultApprovers(int $userId): array { @@ -728,9 +728,11 @@ class BusinessTripService ->first(); if (!$flow) { + // 没有配置流程时,返回默认审批人和抄送人 + $defaultApprovers = $this->getDefaultApproversFromConfig(); return [ - 'approvers' => [], - 'cc_users' => [], + 'approvers' => $defaultApprovers['approvers'], + 'cc_users' => $defaultApprovers['cc_users'], ]; } @@ -781,4 +783,60 @@ class BusinessTripService 'cc_users' => $ccUsers, ]; } + + /** + * 获取默认配置的审批人和抄送人 + * 当没有配置审批流程时使用 + */ + private function getDefaultApproversFromConfig(): array + { + // 默认审批人:陈兰 (id=27) + // 默认抄送人:陈标 (id=29) + $defaultApproverIds = [27]; + $defaultCcUserIds = [29]; + + $approvers = []; + $ccUsers = []; + + // 获取审批人信息 + if (!empty($defaultApproverIds)) { + $users = User::whereIn('id', $defaultApproverIds) + ->where('status', 1) + ->get(); + + foreach ($defaultApproverIds as $userId) { + $user = $users->firstWhere('id', $userId); + if ($user) { + $approvers[] = [ + 'id' => $user->id, + 'name' => $user->name, + 'avatar' => $user->avatar, + ]; + } + } + } + + // 获取抄送人信息 + if (!empty($defaultCcUserIds)) { + $users = User::whereIn('id', $defaultCcUserIds) + ->where('status', 1) + ->get(); + + foreach ($defaultCcUserIds as $userId) { + $user = $users->firstWhere('id', $userId); + if ($user) { + $ccUsers[] = [ + 'id' => $user->id, + 'name' => $user->name, + 'avatar' => $user->avatar, + ]; + } + } + } + + return [ + 'approvers' => $approvers, + 'cc_users' => $ccUsers, + ]; + } }