params['goods_name']) && $this->params['goods_name'] != '') { $this->searchWhere[] = ['name', 'like', '%' . $this->params['goods_name'] . '%']; } // 销售状态 if (isset($this->params['status']) && in_array($this->params['status'], [GoodsEnum::STATUS_STORAGE, GoodsEnum::STATUS_SELL])) { $this->searchWhere[] = ['status', '=', $this->params['status']]; } // 配送方式 if (isset($this->params['delivery_type']) && $this->params['delivery_type'] == DeliveryEnum::EXPRESS_DELIVERY) { $this->searchWhere[] = ['is_express', '=', YesNoEnum::YES]; } if (isset($this->params['delivery_type']) && $this->params['delivery_type'] == DeliveryEnum::SELF_DELIVERY) { $this->searchWhere[] = ['is_selffetch', '=', YesNoEnum::YES]; } } public function lists(): array { $this->setSearch(); $field = [ 'id', 'image', 'name', 'spec_type', 'min_price', 'max_price', 'total_stock', 'sales_num', 'status', 'create_time', ]; $lists = Goods::field($field) ->append(['price_text', 'category_text', 'status_text', 'comment_text']) ->withSearch(['category_id'], $this->params) ->where($this->searchWhere) ->order('id', 'desc') ->limit($this->limitOffset, $this->limitLength) ->select() ->toArray(); return $lists; } public function count(): int { $this->setSearch(); $field = [ 'id', 'image', 'name', 'spec_type', 'min_price', 'max_price', 'total_stock', 'sales_num', 'status', 'create_time', ]; $count = Goods::field($field) ->append(['price_text', 'category_text', 'status_text', 'comment_text']) ->where($this->searchWhere) ->count(); return $count; } }