fix: 添加订单状态检查和友好错误提示

- 检测订单已完成状态,返回友好提示
- 添加infoCard方法显示中性提示
- 优化自审批错误处理
This commit is contained in:
root
2026-02-28 14:30:35 +08:00
parent 719a93ba16
commit 34b294fd48
2 changed files with 29 additions and 2 deletions
+14 -1
View File
@@ -553,10 +553,23 @@ class ApprovalService
$currentNodeIds = $order->current_nodes ?? [];
error_log("🔄 自审批自动通过 - 当前节点: " . json_encode($currentNodeIds));
// 检查订单是否已经结束
if (empty($currentNodeIds)) {
error_log("❌ 自审批:订单已完成,current_nodes为空");
if ($order->status === ApprovalOrder::STATUS_APPROVED) {
throw new \Exception('该申请已通过,无需重复操作');
} else if ($order->status === ApprovalOrder::STATUS_REJECTED) {
throw new \Exception('该申请已被拒绝');
} else if ($order->status === ApprovalOrder::STATUS_CANCELLED) {
throw new \Exception('该申请已被撤销');
}
throw new \Exception('该申请已完成,无法重复操作');
}
$currentNode = ApprovalNode::whereIn('id', $currentNodeIds)->first();
if (!$currentNode) {
error_log("❌ 自审批:当前节点不存在");
error_log("❌ 自审批:当前节点不存在,IDs: " . json_encode($currentNodeIds));
throw new \Exception('当前节点不存在');
}