where("agent_id",$data['account'])->findOrEmpty(); $config['version'] = "res"; if ($config->isEmpty()) return true; $page = 1; $mode = (new HxStorePoi); while ($hasMore) { $result = (new Store)->config($config->toArray())->token()->getStoreData($config['account'],$page); if (empty($result)) { $hasMore = false; break; } if (empty($result['total'])) { $hasMore = false; echo getDateFull()."==第{$page}页==数据获取结束\n"; break; } $totalPage = ceil($result['total'] / 2); if ($page >= $totalPage) { $hasMore = false; } foreach ($result['pois'] as $key=>$val) { $poi = $mode->where("poi_id",$val['poi']['poi_id'])->findOrEmpty(); $inData = $val['poi']; $inData['agent_id'] = $data['account']; if ($poi->isEmpty()) { $inData['poi_address'] = $val['poi']['address']; $inData['order_start'] = "08:00"; $inData['order_end'] = "22:00"; $inData['poi_account_id'] = $val['account']['poi_account']['account_id']; echo "写入新数据===".getDateFull()."===".$inData['poi_id']."\n"; $poi->strict(false)->insertGetId($inData); } else { echo "更新数据===".getDateFull()."===".$inData['poi_id']."\n"; $poi->update_at = getDateFull(); $poi->poi_address = $val['poi']['address']; $poi->latitude = $inData['latitude']; $poi->longitude = $inData['longitude']; $poi->poi_name = $inData['poi_name']; $poi->save(); } } echo getDateFull()."-页码:{$page}\n"; $page ++; } } catch (\Throwable $throwable) { echo getDateFull()."==获取POI失败\n"; echo $throwable->getMessage()."\n"; echo $throwable->getFile()."【".$throwable->getLine()."】\n"; } return true; } }