params['id'] ?? 0; $isCoach = $this->params['is_coach'] ?? 0; $where[] = ['audit_status','=',GoodsEnum::AUDIT_STATUS_PASS]; $shopId = Coach::where(['id'=>$this->coachId])->value('shop_id'); if($shopId){ $where[] = ['shop_id','in',[$shopId,0]]; }else{ $where[] = ['shop_id','=',0]; } if($id){ $goodsIds = GoodsSkillIndex::where(['skill_id'=>$id])->column('goods_id'); empty($goodsIds) && $goodsIds = []; $where[] = ['id','in',implode(',',$goodsIds)]; } if($isCoach){ $goodsIds = CoachGoodsIndex::where(['coach_id'=>$this->coachId])->column('goods_id'); empty($goodsIds) && $goodsIds = []; $where[] = ['id','in',implode(',',$goodsIds)]; } return $where; } public function lists(): array { $lists = Goods::where($this->setWhere()) ->field('id,name,image,price') ->limit($this->limitOffset, $this->limitLength) ->select()->toArray(); return $lists; } public function count(): int { return Goods::where(['status'=>1]) ->where($this->setWhere()) ->count(); } }