getTable() . " order by distance asc ) as a where status=1 "; } else { $sql = "select * from " . (new HousingEstate)->getTable() . " where status=1 "; } $sql .= " and `weid` = " . weid(); if (trim($keyword)) { $sql .= " and `title` LIKE '%" . $keyword . "%'"; } if ($configtuanzhang['is_city_housingestate'] == 1) { if (!empty($this->userInfo['cityinfo']['province_name'])) { $sql .= " and `province_name` = '" . $this->userInfo['cityinfo']['province_name']."'"; } if (!empty($this->userInfo['cityinfo']['city_name'])) { $sql .= " and `city_name` = '" . $this->userInfo['cityinfo']['city_name']."'"; } if (!empty($this->userInfo['cityinfo']['district_name'])) { $sql .= " and `district_name` = '" . $this->userInfo['cityinfo']['district_name']."'"; } } $data = Db::query($sql); foreach ($data as &$vo) { if (!empty($vo['tzid'])) { $Tuanzhang = Tuanzhang::find($vo['tzid']); if (!empty($Tuanzhang)) { $vo['tz_touxiang'] = toimg($Tuanzhang['touxiang']); $vo['community_title'] = $Tuanzhang['community_title']; $vo['tz_title'] = $Tuanzhang['title']; $vo['tz_tel'] = $Tuanzhang['tel']; } } $vo['image'] = toimg($vo['image']); $vo['distance'] = round(($vo['distance']) / 1000, 1); } $res['sql'] = $sql; $res['data'] = $data; return $this->json(['data' => $res]); } }