/** * Execute the console command. * * @return mixed */ public function fire() { $path = $this->best->downloadDictionaryToFile('DestinationPlace'); $importer = new DestinationPoints(); $count = $importer->truncate()->importFile($path); $importer->swapTempAndMainTables(); $this->info('Imported ' . $count . ' destination points'); DB::table('destination_points')->join('agent_points', 'destination_points.point_id', '=', 'agent_points.id')->update(['destination_points.name' => DB::raw('agent_points.name'), 'destination_points.address' => DB::raw('agent_points.address'), 'destination_points.address_crc' => DB::raw('agent_points.address_crc')]); DestinationPoint::whereNull('address')->delete(); DestinationPoint::where('address', '')->delete(); DestinationPoint::where('address', '.')->delete(); DestinationPoint::where('address', '-')->delete(); DestinationPoint::where('name', 'LIKE', '%PayDirect%')->delete(); //Временно оставляем только unistream //DestinationPoint::where('system_id', '<>', 19)->delete(); }
/** * Возвращает список точек в городе в прямоугольнике с заданными координатами * левой верхней и правой нижней точек. * * @param Illuminate\Http\Request $request * @param string $format Формат, в котором необходимо вернуть ответ * @param int $city_id (optional) Идентификатор искомого города * @return Illuminate\Http\Response */ public function getPointsInRectangle(Request $request, $format, $city_id = null) { $input = $request->all(); $latlong1 = static::validateLatLongParam($input['latlong1']); $latlong2 = static::validateLatLongParam($input['latlong2']); if ($latlong1 !== false && $latlong2 !== false) { list($lat1, $long1) = $latlong1; list($lat2, $long2) = $latlong2; $points_query = DestinationPoint::where('is_published', 1)->where('latitude', '>', $lat1)->where('latitude', '<', $lat2)->where('longitude', '>', $long1)->where('longitude', '<', $long2); $system_id = $request->get('system_id', false); if ($system_id !== false) { $points_query = $points_query->where('system_id', $system_id); } if (is_null($city_id)) { $city_id = $request->get('city_id', null); } if (!is_null($city_id)) { $points_query = $points_query->where('city_id', $city_id); } $points = $points_query->get(); return static::response($points->toArray(), 200, $format); } return static::response(['code' => 400, 'message' => "Bad request"], 404, $format); }