getUserInfo('companyId'); } catch (\Exception $e) { return ResponseHelper::error($e->getMessage(), $e->getCode() ?: 401); } if (empty($companyId)) { return ResponseHelper::error('请先登录', 401); } $page = max(1, intval($this->request->param('page', 1))); $limit = max(1, intval($this->request->param('limit', 10))); $keyword = trim((string)$this->request->param('keyword', '')); $query = Db::table('s2_company_account') ->alias('a') ->where([ ['a.departmentId', '=', $companyId], ['a.status', '=', 0], ]) ->whereNotLike('a.userName', '%_offline') ->whereNotLike('a.userName', '%_delete'); if ($keyword !== '') { $query->where(function ($subQuery) use ($keyword) { $likeKeyword = '%' . $keyword . '%'; $subQuery->whereLike('a.userName', $likeKeyword) ->whereOrLike('a.realName', $likeKeyword) ->whereOrLike('a.nickname', $likeKeyword); }); } $total = (clone $query)->count(); $list = $query->field([ 'a.id', 'a.userName', 'a.realName', 'a.nickname', 'a.departmentId', 'a.departmentName', 'a.avatar' ]) ->order('a.id', 'desc') ->page($page, $limit) ->select(); return ResponseHelper::success([ 'total' => $total, 'list' => $list, ]); } }