areaCode = $this->request->param('areaCode', ''); $this->streetCode = $this->request->param('streetCode', ''); if ($this->areaCode == '') { throw new ValidateException('未获取到位置信息'); } } // 溯源产品统计 public function plantProductCount() { $list = LandPlant::alias('lp')->join('land l', 'l.id=lp.land_id')->field('lp.kind,lp.qr_code') ->where(function ($query) { if ($this->streetCode != '') { $query->where('l.town_code', $this->streetCode); } else { $query->where('l.county_code', $this->areaCode); } })->limit(30)->select(); return $this->success('成功', compact('list')); } // 智能预警数据 public function landCollectionList() { $list = LandCollection::alias('lc') ->field('lc.*,l.title') ->join('land l', 'l.id=lc.land_id') ->where(function ($query) { if ($this->streetCode != '') { $query->where('l.town_code', $this->streetCode); } else { $query->where('l.county_code', $this->areaCode); } })->limit(30)->select(); return $this->success('成功', compact('list')); } }