From 0aa5b3abeff899717e23851ad810344ab32e8596 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 28 Feb 2026 14:10:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E9=A3=9E=E4=B9=A6?= =?UTF-8?q?=E5=8D=A1=E7=89=87=E5=9B=9E=E8=B0=83=E8=B0=83=E8=AF=95=E6=97=A5?= =?UTF-8?q?=E5=BF=97=EF=BC=8C=E8=BF=BD=E8=B8=AA200671=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/controller/FeishuCardController.php | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/backend/app/controller/FeishuCardController.php b/backend/app/controller/FeishuCardController.php index 5f72bac..e4e6d2c 100644 --- a/backend/app/controller/FeishuCardController.php +++ b/backend/app/controller/FeishuCardController.php @@ -192,17 +192,22 @@ class FeishuCardController extends BaseController // 检查用户是否有权限审批 $order = \app\model\ApprovalOrder::find($orderId); if (!$order) { + error_log('❌ 审批单不存在: order_id=' . $orderId); return $this->errorCard('审批单不存在'); } + error_log('📝 开始审批通过: order_id=' . $orderId . ', user_id=' . $user->id . ', remark=' . $remark); + // 执行审批通过 $approvalService->approve($orderId, $user->id, $remark); - error_log('✅ 审批通过成功: order_id=' . $orderId . ', remark=' . $remark); - return $this->successCard('审批通过', $this->buildApproveContent($user, $order, $remark)); + error_log('✅ 审批通过成功,准备返回卡片'); + $response = $this->successCard('审批通过', $this->buildApproveContent($user, $order, $remark)); + error_log('✅ 卡片响应已生成'); + return $response; } catch (\Exception $e) { - error_log('❌ 审批通过异常: ' . $e->getMessage()); + error_log('❌ 审批通过异常: ' . $e->getMessage() . ', file: ' . $e->getFile() . ', line: ' . $e->getLine()); return $this->errorCard('审批失败: ' . $e->getMessage()); } } @@ -273,17 +278,22 @@ class FeishuCardController extends BaseController // 检查用户是否有权限审批 $order = \app\model\ApprovalOrder::find($orderId); if (!$order) { + error_log('❌ 审批单不存在: order_id=' . $orderId); return $this->errorCard('审批单不存在'); } + error_log('📝 开始审批拒绝: order_id=' . $orderId . ', user_id=' . $user->id . ', reason=' . $reason); + // 执行审批拒绝 $approvalService->reject($orderId, $user->id, $reason); - error_log('✅ 审批拒绝成功: order_id=' . $orderId . ', reason=' . $reason); - return $this->successCard('已拒绝', $this->buildRejectContent($user, $order, $reason)); + error_log('✅ 审批拒绝成功,准备返回卡片'); + $response = $this->successCard('已拒绝', $this->buildRejectContent($user, $order, $reason)); + error_log('✅ 卡片响应已生成'); + return $response; } catch (\Exception $e) { - error_log('❌ 审批拒绝异常: ' . $e->getMessage()); + error_log('❌ 审批拒绝异常: ' . $e->getMessage() . ', file: ' . $e->getFile() . ', line: ' . $e->getLine()); return $this->errorCard('审批失败: ' . $e->getMessage()); } } @@ -417,10 +427,16 @@ class FeishuCardController extends BaseController */ private function json(array $data): Response { + $json = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + + error_log('📤 飞书卡片响应: ' . $json); + return new \Webman\Http\Response( 200, - ['Content-Type' => 'application/json; charset=utf-8'], - json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) + [ + 'Content-Type' => 'application/json; charset=utf-8', + ], + $json ); } }