<?php
/*
 本代码由 口号帮 创建
 创建时间 2019-05-06 16:50:44
 技术支持 口号帮
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace App\Http\Controllers\Api\V1;use App\Http\Controllers\BaseController;use App\Models\City;use App\Models\District;use App\Models\HotCity;use Illuminate\Http\Request;use App\Http\Controllers\Controller;use Illuminate\Support\Facades\Redis;class DistrictController extends BaseController{public function index(Request $request){$O280=$request->type=='sort';if($O280)goto O28Bodyx2;goto O28Nextx2;O28Bodyx2:$O280=!Redis::exists('city_sort');if($O280)goto O28Bodyx4;goto O28Nextx4;O28Bodyx4:$cities=District::where(['level'=>'city'])->orderBy('initials','asc')->get(['id','adcode','name','initials']);$O280=$cities->count()==0;if($O280)goto O28Bodyx6;goto O28Nextx6;O28Bodyx6:$this->set('type',$this->noContent);$this->set('info','暂无城市数据');goto O28x5;O28Nextx6:$O28AC0=array();$city_sort=$O28AC0;foreach($cities as $city){$city->citys=District::where(['level'=>'city','initials'=>$city->initials])->get(['id','adcode','name','initials']);$O28AC0=array();$O28AC0['initial']=$city->initials;$O28AC0['cities']=$city->citys;$city_sort[$city->initials]=$O28AC0;}Redis::set('city_sort',json_encode($city_sort,JSON_UNESCAPED_UNICODE));O28x5:$data=Redis::get('city_sort');goto O28x3;O28Nextx4:$data=Redis::get('city_sort');O28x3:goto O28x1;O28Nextx2:$O280=!Redis::exists('linkage');if($O280)goto O28Bodyx8;goto O28Nextx8;O28Bodyx8:$provinces=District::select('id','adcode','name','level')->where('level','province')->get();$O280=$provinces->count()==0;if($O280)goto O28Bodyxa;goto O28Nextxa;O28Bodyxa:$this->set('type',$this->noContent);$this->set('info','暂无城市数据');goto O28x9;O28Nextxa:foreach($provinces as $province){$province->cities=District::select('id','adcode','name','level')->where('level','city')->where('adcode','like',mb_substr($province->adcode,0,2). '%00')->get();foreach($province->cities as $city){$city->areas=District::select('id','adcode','name','level')->where('level','district')->where('adcode','like',mb_substr($city->adcode,0,4). '%')->get();foreach($city->areas as $street){$street->street=District::select('id','adcode','name','level')->where('level','street')->where('adcode','like',$street->adcode)->get();}}}Redis::set('linkage',json_encode($provinces,JSON_UNESCAPED_UNICODE));O28x9:$data=Redis::get('linkage');goto O28x7;O28Nextx8:$data=Redis::get('linkage');O28x7:O28x1:$this->set('data',json_decode($data));return $this->jsonResponse();}public function hotCity(){$hot_ids=HotCity::orderBy('sort','desc')->pluck('city_id')->all();$hot_cities=District::whereIn('id',$hot_ids)->pluck('name')->all();$A__A__A__="count";$O28AC0=$A__A__A__($hot_cities);if($O28AC0)goto O28Bodyxc;goto O28Nextxc;O28Bodyxc:foreach($hot_cities as&$hot_city){$A__A__A_A="str_replace";$O28AC0=$A__A__A_A('城区','市',$hot_city);$hot_city=$O28AC0;}goto O28xb;O28Nextxc:$this->set('data',null);O28xb:$this->set('data',$hot_cities);return $this->jsonResponse();}}
?>