Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tj_tool
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
牟俊洁
tj_tool
Commits
83df13eb
Commit
83df13eb
authored
Nov 05, 2025
by
白满斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
周边
parent
09297445
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
32 deletions
+21
-32
SchoolService.php
app/Http/Services/SchoolService.php
+21
-32
No files found.
app/Http/Services/SchoolService.php
View file @
83df13eb
...
...
@@ -30,17 +30,17 @@ use Illuminate\Support\Facades\Http;
class
SchoolService
extends
BaseService
{
public
static
$local
=
'https://
restapi.amap.com/v3/geocode/geo
?'
;
public
static
$localAround
=
'https://
restapi.amap.com/v5/place/around
?'
;
public
static
$local
=
'https://
apis.map.qq.com/ws/geocoder/v1/
?'
;
public
static
$localAround
=
'https://
apis.map.qq.com/ws/place/v1/search
?'
;
public
static
$around
=
[
'美食'
=>
'
05
0000'
,
'住宿'
=>
'
10
0000'
,
'文具'
=>
'
0600
00'
,
'打印'
=>
'
0700
00'
,
'充电'
=>
'
010000
'
,
'公厕'
=>
'2
0030
0'
,
'交通'
=>
'
150104|150200
'
,
'美食'
=>
'
10
0000'
,
'住宿'
=>
'
21
0000'
,
'文具'
=>
'
1334
00'
,
'打印'
=>
'
1334
00'
,
'充电'
=>
'
191014
'
,
'公厕'
=>
'2
7111
0'
,
'交通'
=>
'
271016
'
,
];
...
...
@@ -50,13 +50,10 @@ class SchoolService extends BaseService{
//专业对应检索条件
$response
=
Http
::
get
(
$url
);
$bodyData
=
$response
->
json
();
// 如果响应是 JSON 格式,解析为数组或对象
if
(
$bodyData
[
'status'
]
=
=
0
){
if
(
$bodyData
[
'status'
]
!
=
0
){
return
[
'code'
=>
20001
,
'msg'
=>
'地图数据请求失败'
,
'data'
=>
$bodyData
];
}
if
(
$bodyData
[
'info'
]
!=
'OK'
){
return
[
'code'
=>
20001
,
'msg'
=>
'地图信息获取失败'
,
'data'
=>
$bodyData
];
}
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
$bodyData
[
'geocodes'
]];
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
$bodyData
[
'result'
]];
}
catch
(
\Exception
$e
)
{
return
[
'code'
=>
20009
,
'msg'
=>
$e
->
getMessage
(),
'data'
=>
[]];
...
...
@@ -68,13 +65,10 @@ class SchoolService extends BaseService{
//专业对应检索条件
$response
=
Http
::
get
(
$url
);
$bodyData
=
$response
->
json
();
// 如果响应是 JSON 格式,解析为数组或对象
if
(
$bodyData
[
'status'
]
==
0
){
return
[
'code'
=>
20001
,
'msg'
=>
'地图数据请求失败'
,
'data'
=>
$bodyData
];
}
if
(
$bodyData
[
'info'
]
!=
'OK'
){
return
[
'code'
=>
20001
,
'msg'
=>
'地图信息获取失败'
,
'data'
=>
$bodyData
];
if
(
$bodyData
[
'status'
]
!=
0
){
return
[
'code'
=>
20001
,
'msg'
=>
'周边数据请求失败'
,
'data'
=>
$bodyData
];
}
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
$bodyData
[
'
pois
'
]];
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
$bodyData
[
'
data
'
]];
}
catch
(
\Exception
$e
)
{
return
[
'code'
=>
20009
,
'msg'
=>
$e
->
getMessage
(),
'data'
=>
[]];
...
...
@@ -121,7 +115,7 @@ class SchoolService extends BaseService{
$location
=
$res
[
'location'
];
//获取周边信息,美食、住宿、文具、打印、充电、公厕、交通
if
(
$res
[
'location'
]
==
""
){
$url
=
self
::
$local
.
'key='
.
$gdKey
.
'&address=
'
.
$res
[
'name'
]
.
'&city='
.
$res
[
'p_cod
e'
];
$url
=
self
::
$local
.
'key='
.
$gdKey
.
'&address=
天津市'
.
$res
[
'nam
e'
];
$requestRet
=
self
::
sendGet
(
$url
);
if
(
$requestRet
[
'code'
]
!=
0
){
return
$requestRet
;
...
...
@@ -129,10 +123,10 @@ class SchoolService extends BaseService{
if
(
empty
(
$requestRet
[
'data'
])){
return
[
'code'
=>
10001
,
'msg'
=>
'暂未获取到地址信息'
,
'data'
=>
[]];
}
$location
=
$requestRet
[
'data'
][
0
][
'location'
];
if
(
empty
(
$location
)){
if
(
empty
(
$requestRet
[
'data'
][
'location'
])){
return
[
'code'
=>
10002
,
'msg'
=>
'位置获取失败'
,
'data'
=>
[]];
}
$location
=
$requestRet
[
'data'
][
'location'
][
'lat'
]
.
','
.
$requestRet
[
'data'
][
'location'
][
'lng'
];
$PlaceModel
->
updateData
([
'id'
=>
$placeid
],
[
'location'
=>
$location
]);
}
...
...
@@ -149,14 +143,10 @@ class SchoolService extends BaseService{
}
//么有就去获取
if
(
$aroundName
==
'交通'
){
$aroundUrl
=
self
::
$localAround
.
'key='
.
$gdKey
.
'&keywords=火车站'
.
'&types='
.
self
::
$around
[
$aroundName
]
.
'&location='
.
$location
.
'&radius=50000®ion='
.
$res
[
'p_code'
]
.
'&city_limit=true&page_size=10&page_num=1&show_fields=children,business,navi'
;
$requestRetAround
=
self
::
sendGetAround
(
$aroundUrl
);
}
else
{
$aroundUrl
=
self
::
$localAround
.
'key='
.
$gdKey
.
'&keywords='
.
$aroundName
.
'&types='
.
self
::
$around
[
$aroundName
]
.
'&location='
.
$location
.
'&radius=20000®ion='
.
$res
[
'p_code'
]
.
'&city_limit=true&show_fields=children,business,navi'
;
$requestRetAround
=
self
::
sendGetAround
(
$aroundUrl
);
}
$keyword
=
$aroundName
==
'打印'
?
'打印店'
:
$aroundName
;
$boundary
=
'nearby('
.
$location
.
',50000,1)'
;
$aroundUrl
=
self
::
$localAround
.
'key='
.
$gdKey
.
'&keyword='
.
$keyword
.
'&boundary='
.
$boundary
.
'&filter=category='
.
self
::
$around
[
$aroundName
];
$requestRetAround
=
self
::
sendGetAround
(
$aroundUrl
);
$aroundData
=
[
'place_id'
=>
$placeid
,
'name'
=>
$aroundName
,
...
...
@@ -164,7 +154,6 @@ class SchoolService extends BaseService{
];
$PlaceAroundModel
->
insertData
(
$aroundData
);
$data
[
'around'
]
=
$requestRetAround
[
'data'
];
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
$data
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment