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 ); } }