searchWhere = [ ['user_id', '=', $this->userId], ['send_type', '=', NoticeEnum::SYSTEM] ]; // 系统通知 if (isset($this->params['type']) && $this->params['type'] == 'system') { $this->searchWhere[] = [ ['scene_id', '<>', NoticeEnum::EARNINGS_NOTICE] ]; } // 收益通知 if (isset($this->params['type']) && $this->params['type'] == 'earnings') { $this->searchWhere[] = [ ['scene_id', '=', NoticeEnum::EARNINGS_NOTICE] ]; } } /** * @notes 列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author Tab * @date 2021/8/25 10:39 */ public function lists(): array { $this->setSearch(); $lists = Notice::field('id,title,content,create_time') ->where($this->searchWhere) ->order('id', 'desc') ->limit($this->limitOffset, $this->limitLength) ->select() ->toArray(); return $lists; } /** * @notes 记录数 * @return int * @author Tab * @date 2021/8/25 10:39 */ public function count(): int { $this->setSearch(); $count = Notice::where($this->searchWhere)->count(); return $count; } }