/** * Execute the job. * * @return void */ public function handle() { $obj = new Model(); $obj->name = $this->data['areaName']; $obj->city_id = $this->data['city_id']; $obj->save(); $c = new JdClient(); $c->setAppKey(env('JD_APP_ID')); $c->setAppSecret(env('JD_APP_SECRET')); $req = new AreasTownGetRequest(); $req->setParentId($this->data['areaId']); $resp = $c->execute($req); if (isset($resp['zh_desc'])) { Log::error($resp['zh_desc']); } $data = $resp['baseAreaServiceResponse']['data']; if (!$data) { return true; } foreach ($data as $key => $item) { $item['county_id'] = $obj->id; $event = new Town($item); Event::fire($event); } }
/** * Execute the console command. * * @return mixed */ public function handle() { $c = new JdClient(); $c->setAppKey(env('JD_APP_ID')); $c->setAppSecret(env('JD_APP_SECRET')); $req = new AreasProvinceGetRequest(); $resp = $c->execute($req); $data = $resp['baseAreaServiceResponse']['data']; foreach ($data as $key => $item) { Event::fire('jd.province', [$item]); } $this->info('success'); }
/** * Execute the job. * * @return void */ public function handle() { $obj = new Model(); $obj->name = $this->data['areaName']; $obj->save(); $c = new JdClient(); $c->setAppKey(env('JD_APP_ID')); $c->setAppSecret(env('JD_APP_SECRET')); $req = new AreasCityGetRequest(); $req->setParentId($this->data['areaId']); $resp = $c->execute($req); $data = $resp['baseAreaServiceResponse']['data']; foreach ($data as $key => $item) { $item['province_id'] = $obj->id; $event = new City($item); Event::fire($event); } }