From 8b37d6313eee811d78e8529d0fa232cdc7ca3616 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Feb 2026 18:19:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E5=AE=A1=E6=89=B9?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E8=B0=83=E8=AF=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加详细的调试日志来追踪审批流程: 1. approve() 方法开始时的参数日志 2. 节点类型和完成状态的日志 3. 下一节点查询和跳过逻辑的日志 Co-Authored-By: Claude Opus 4.6 --- backend/app/service/BusinessTripService.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/app/service/BusinessTripService.php b/backend/app/service/BusinessTripService.php index bb7fa01..e5b260f 100644 --- a/backend/app/service/BusinessTripService.php +++ b/backend/app/service/BusinessTripService.php @@ -682,6 +682,8 @@ class BusinessTripService */ public function approve(int $userId, int $businessTripId, string $action, string $comment = ''): BusinessTrip { + error_log("📝 approve() 开始: userId={$userId}, businessTripId={$businessTripId}, action={$action}"); + return $this->db->transaction(function () use ($userId, $businessTripId, $action, $comment) { $businessTrip = BusinessTrip::with(['itineraries', 'approvalOrder'])->findOrFail($businessTripId); @@ -744,22 +746,28 @@ class BusinessTripService // 更新审批单状态 if ($action === 'reject') { // 拒绝:直接结束流程 + error_log("❌ 审批拒绝,结束流程"); $approvalOrder->status = ApprovalOrder::STATUS_REJECTED; $approvalOrder->current_nodes = []; $businessTrip->status = BusinessTrip::STATUS_REJECTED; } else { + error_log("✅ 审批同意,检查节点完成状态"); // 同意:检查当前节点是否完成,并处理流程流转 $nodeCompleted = false; if ($currentNodeId) { $node = ApprovalNode::find($currentNodeId); + error_log("🔍 当前节点: id={$currentNodeId}, type=" . ($node ? $node->type : 'null')); + if ($node) { // 根据节点类型判断是否完成 if ($node->type === 'approver') { // 单人审批:一人通过即完成 + error_log("✅ 单人审批节点,一人通过即完成"); $nodeCompleted = true; } elseif ($node->type === 'or_approve') { // 或签:一人通过即完成 + error_log("✅ 或签节点,一人通过即完成"); $nodeCompleted = true; } elseif ($node->type === 'and_approve') { // 会签:需要所有人都通过 @@ -767,6 +775,7 @@ class BusinessTripService ->where('node_id', $currentNodeId) ->where('action', 'approve') ->count(); + error_log("🔍 会签节点: approvedCount={$approvedCount}, totalApprovers=" . count($approverIds)); if ($approvedCount >= count($approverIds)) { $nodeCompleted = true; } @@ -774,6 +783,8 @@ class BusinessTripService } } + error_log("🔍 nodeCompleted: " . ($nodeCompleted ? 'true' : 'false')); + if ($nodeCompleted) { // 当前节点完成,查找下一个节点 error_log("✅ 节点 {$currentNodeId} 已完成,查找下一节点");