['spare_status'], 'in' => ['goods_category_id'], '%like%' => ['spare_name'] ]; } public function queryWhere() { $where = []; if (!empty($this->params['goods_category_id'])) { $goodsCategoryId = end($this->params['goods_category_id']); $where[] = ['goods_category_id','=' ,$goodsCategoryId]; } return $where; } /** * @notes 获取列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2024/09/14 15:08 */ public function lists(): array { return SparePart::with('goodsCategory')->where($this->searchWhere) ->where($this->queryWhere()) ->field(['id', 'goods_category_id', 'spare_name', 'spare_image', 'spare_number', 'spare_unit', 'company_price', 'original_price', 'offering_price', 'spare_status']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select() ->toArray(); } /** * @notes 获取数量 * @return int * @author likeadmin * @date 2024/09/14 15:08 */ public function count(): int { return SparePart::where($this->searchWhere)->count(); } }