$this->request->param('page', 1, 'intval'), "limit" => $this->request->param('limit', 20, 'intval'), "operator_id" => $this->request->param('operator_id', null), "status" => $this->request->param('status', null), "searchKeyword" => $this->request->param('search', null), "sortOrder" => $this->request->param('sort_order', 'desc'), ]; $staffId = (int) Session::get('user_info.id'); // 若没有,则为0 if ($staffId <= 0) { return $this->error('无法获取当前员工信息'); } $page = max(($params['page'] ?? 1), 1); $limit = min(max(($params['limit'] ?? 20), 1), 100); $order = strtolower($params['sortOrder'] ?? 'desc') === 'asc' ? 'asc' : 'desc'; try { $result = $TicketService->queryTickets($params, $page, $limit, $order, TicketScope::staff($staffId)); } catch (\Exception $e) { return $this->error($e->getMessage()); } return $this->success('查询成功', $result); } /** * 更新工单(员工调用) */ public function updateTicket(TicketService $ticketService, $id) { $isUser = Session::get('user_info.role') === 'user'; $data = $this->request->post(); $allowFields = ['datanum', 'progress', 'status', 'remark', 'lock_time', 'user_id']; try { $result = $ticketService->updateTicket($id, $data, $allowFields, $isUser, false); return $this->success('更新成功', $result); } catch (\Exception $e) { return $this->error($e->getMessage()); } } }