['name'], ]; } public function queryWhere(){ $where = []; // 用户余额 if (isset($this->params['goods_id']) && is_array($this->params['goods_id'])) { $where[] = ['goods_id', 'in',$this->params['goods_id']]; } return $where; } /** * @notes 获取列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2024/07/07 16:44 */ public function lists(): array { return HomeService::with('goods') ->where($this->searchWhere) ->where($this->queryWhere()) ->field(['id', 'name', 'goods_id', 'picture', 'sort']) ->limit($this->limitOffset, $this->limitLength) ->order(['sort' => 'desc','id' => 'desc']) ->select() ->toArray(); } /** * @notes 获取数量 * @return int * @author likeadmin * @date 2024/07/07 16:44 */ public function count(): int { return HomeService::where($this->searchWhere)->where($this->queryWhere())->count(); } }