Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
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
hujun
tl_estate
Commits
96b6d393
Commit
96b6d393
authored
Oct 18, 2018
by
zw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
地图找房
parent
aeec4442
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
16 deletions
+76
-16
MapFindHouse.php
application/api_broker/controller/MapFindHouse.php
+38
-16
GBusinessDistrict.php
application/model/GBusinessDistrict.php
+7
-0
GHouses.php
application/model/GHouses.php
+19
-0
Regions.php
application/model/Regions.php
+11
-0
route.php
application/route.php
+1
-0
No files found.
application/api_broker/controller/MapFindHouse.php
View file @
96b6d393
...
...
@@ -3,7 +3,9 @@
namespace
app\api_broker\controller
;
use
app\api_broker\extend\Basic
;
use
app\model\GBusinessDistrict
;
use
app\model\GHouses
;
use
app\model\Regions
;
use
think\Request
;
/**
...
...
@@ -16,11 +18,13 @@ use think\Request;
class
MapFindHouse
extends
Basic
{
private
$gHousesModel
;
private
$regionsModel
;
public
function
__construct
(
Request
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
gHousesModel
=
new
GHouses
();
$this
->
regionsModel
=
new
Regions
();
}
/**
...
...
@@ -42,41 +46,59 @@ class MapFindHouse extends Basic
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"101"
,
$checkResult
);
}
$first_spot_arr
=
explode
(
","
,
$params
[
"first_spot"
]);
$second_spot_arr
=
explode
(
","
,
$params
[
"second_spot"
]
);
$first_spot_arr
=
explode
(
","
,
$params
[
"first_spot"
]);
$second_spot_arr
=
explode
(
","
,
$params
[
"second_spot"
]
);
if
(
count
(
$first_spot_arr
)
<
2
||
count
(
$second_spot_arr
)
<
2
)
{
return
$this
->
response
(
"101"
,
"坐标传入有误1"
);
}
$conditions
=
[];
$conditions
[
"latitude"
]
=
array
(
"between"
,
array
(
$second_spot_arr
[
0
],
$first_spot_arr
[
0
]));
$conditions
[
"longitude"
]
=
array
(
"between"
,
array
(
$second_spot_arr
[
1
],
$first_spot_arr
[
1
]));
$conditions
[
"latitude"
]
=
array
(
"between"
,
array
(
$second_spot_arr
[
0
],
$first_spot_arr
[
0
]));
$conditions
[
"longitude"
]
=
array
(
"between"
,
array
(
$second_spot_arr
[
1
],
$first_spot_arr
[
1
]));
$field
=
"id,internal_title,longitude,latitude"
;
$result
=
$this
->
gHousesModel
->
getHousesListByMap
(
$field
,
$conditions
);
return
$this
->
response
(
"200"
,
"success"
,
$result
);
}
public
function
getCityInfoByMap
(){
public
function
getCityInfoByMap
()
{
$params
=
$this
->
params
;
/*
$params = array(
"spot"
=> "1223,1213123",
"grade" => 1
,//1 区,2商圈,3街道
"source"
=> 1,//来源 1b端,2c端
"city"
=> "上海市"//传城市就好了
);*/
/*
$params = array(
"spot"
=> "1223,1213123",
"grade" => 2
,//1 区,2商圈,3街道
"source"
=> 1,//来源 1b端,2c端
"city"
=> "上海市"//传城市就好了
);*/
$checkResult
=
$this
->
validate
(
$params
,
"MapFindHouseValidate.getCityInfoByMap"
);
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"101"
,
$checkResult
);
}
$conditions
=
[];
if
(
$params
[
"grade"
]
==
1
){
$result
=
[];
$result
[
"grade"
]
=
$params
[
"grade"
];
}
elseif
(
$params
[
"grade"
]
==
2
){
$disc
=
$this
->
regionsModel
->
getDiscByCity
(
$params
[
"city"
]);
$disc_str
=
""
;
foreach
(
$disc
as
$item
)
{
$disc_str
.=
$item
[
"name"
]
.
","
;
}
$disc_str
=
rtrim
(
$disc_str
,
","
);
if
(
$params
[
"grade"
]
==
1
)
{
$shop_arr
=
$this
->
gHousesModel
->
getHouseNumByDisc
(
$disc_str
);
foreach
(
$disc
as
$key
=>
$item
)
{
foreach
(
$shop_arr
as
$i
=>
$j
)
{
if
(
$item
[
"name"
]
==
$j
[
"disc"
])
{
$disc
[
$key
][
"num"
]
=
$j
[
"num"
];
}
}
$field
=
"id,internal_title,longitude,latitude"
;
$result
=
$this
->
gHousesModel
->
getHousesListByMap
(
$field
,
$conditions
);
}
}
$result
[
"list"
]
=
$disc
;
}
elseif
(
$params
[
"grade"
]
==
2
)
{
$businessModel
=
new
GBusinessDistrict
();
$result
[
"list"
]
=
$businessModel
->
getListByMap
(
$params
[
"city"
]);
}
return
$this
->
response
(
"200"
,
"success"
,
$result
);
}
...
...
application/model/GBusinessDistrict.php
View file @
96b6d393
...
...
@@ -34,4 +34,11 @@ class GBusinessDistrict extends BaseModel
return
$result
;
}
public
function
getListByMap
(
$city
){
$sql
=
"select a.id,a.`name`,a.longitude,a.latitude,count(b.id) as num
from g_business_district as a left join g_houses as b on b.business_district_id=a.id
where a.city='"
.
$city
.
"' and a.longitude <> '' GROUP BY b.business_district_id HAVING num > 0"
;
return
$this
->
query
(
$sql
);
}
}
application/model/GHouses.php
View file @
96b6d393
...
...
@@ -1583,4 +1583,23 @@ class GHouses extends BaseModel
return
$result
;
}
/**
* @param $disc_str
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getHouseNumByDisc
(
$disc_str
){
$params
[
"a.disc"
]
=
array
(
"in"
,
$disc_str
);
$result
=
Db
::
table
(
$this
->
table
)
->
field
(
"a.id,a.disc,count(1) as num"
)
->
alias
(
"a"
)
->
where
(
$params
)
->
group
(
"a.disc"
)
->
select
();
//echo $this->getLastSql();
return
$result
;
}
}
application/model/Regions.php
View file @
96b6d393
...
...
@@ -2,6 +2,7 @@
namespace
app\model
;
use
think\Db
;
use
think\Model
;
class
Regions
extends
Model
...
...
@@ -117,6 +118,8 @@ class Regions extends Model
}
return
$data
;
}
/**
* 根据区code获取省市区中文
*
...
...
@@ -134,4 +137,12 @@ class Regions extends Model
$data
=
$province
[
'fullName'
]
.
'-'
.
$city
[
'fullName'
]
.
'-'
.
$disc
[
'fullName'
];
return
$data
;
}
public
function
getDiscByCity
(
$city
){
$sql
=
"select fullName as name,longitude,latitude,code as id from regions
where parentCode = (select code from regions where fullName='"
.
$city
.
"' and type =2) "
;
return
$this
->
query
(
$sql
);
}
}
application/route.php
View file @
96b6d393
...
...
@@ -521,6 +521,7 @@ Route::group('broker', [
//商铺
'getShopList'
=>
[
'api_broker/Shop/getShopList'
,
[
'method'
=>
'get|post'
]
],
'getShopListByMap'
=>
[
'api_broker/MapFindHouse/getShopListByMap'
,
[
'method'
=>
'get|post'
]
],
'getCityInfoByMap'
=>
[
'api_broker/MapFindHouse/getCityInfoByMap'
,
[
'method'
=>
'get|post'
]
],
'getShopDetail'
=>
[
'api_broker/Shop/getShopDetail'
,
[
'method'
=>
'get'
]
],
'addShopFollowUp'
=>
[
'api_broker/Shop/addShopFollowUp'
,
[
'method'
=>
'post'
]
],
//新增商铺跟进记录
...
...
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