Commit 67fd3aba authored by zw's avatar zw

地图找房

parent bdc525c9
......@@ -16,6 +16,7 @@ use think\Request;
class MapFindHouse extends Basic
{
private $gHousesModel;
public function __construct(Request $request = null)
{
parent::__construct($request);
......@@ -31,37 +32,52 @@ class MapFindHouse extends Basic
public function getShopListByMap()
{
$params = $this->params;
/* $params = array(
"first_spot" => "1223,1213123",
"second_spot" => "1223,1213123",
"grade" => 1,//1 市,2区,3街道
"source" => 1,//来源 1b端,2c端
);*/
/* $params = array(
"first_spot" => "1223,1213123",
"second_spot" => "1223,1213123",
"grade" => 1,//1 区,2商圈,3街道
"source" => 1,//来源 1b端,2c端
);*/
$checkResult = $this->validate($params, "MapFindHouseValidate.getShopListByMap");
if (true !== $checkResult) {
return $this->response("101", $checkResult);
}
$first_spot_arr = explode($params["first_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", "坐标传入有误");
return $this->response("101", "坐标传入有误1");
}
$conditions = [];
$conditions["longitude"] = array("between",array($first_spot_arr[0],$second_spot_arr[0]));
$conditions["latitude"] = array("between",array($first_spot_arr[1],$second_spot_arr[1]));
/*switch ($params["grade"]){
case 1:
break;
case 2:
break;
case 3:
break;
default:
}*/
$conditions["longitude"] = array("between", array($first_spot_arr[0], $second_spot_arr[0]));
$conditions["latitude"] = array("between", array($first_spot_arr[1], $second_spot_arr[1]));
$field = "id,internal_title,longitude,latitude";
$result = $this->gHousesModel->getHousesListByMap( $field, $conditions);
return $this->response("200","success",$result);
$result = $this->gHousesModel->getHousesListByMap($field, $conditions);
return $this->response("200", "success", $result);
}
public function getCityInfoByMap(){
$params = $this->params;
/* $params = array(
"spot" => "1223,1213123",
"grade" => 1,//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){
}elseif ($params["grade"] == 2){
}
$field = "id,internal_title,longitude,latitude";
$result = $this->gHousesModel->getHousesListByMap($field, $conditions);
return $this->response("200", "success", $result);
}
......
......@@ -18,11 +18,15 @@ class MapFindHouseValidate extends Validate
'second_spot' => 'require',
'grade' => 'require|number|in:1,2,3',
'source' => 'require|number|in:1,2',
'spot' => 'require',
'city' => 'require',
];
protected $message = [
'first_spot.require' => '坐标为必传字段',
'second_spot.require' => '坐标为必传字段',
'spot.require' => '坐标为必传字段',
'city.require' => '城市为必传字段',
'grade.require' => '级别为必传',
'grade.number' => '级别为必传',
'grade.in' => '级别参数错误',
......@@ -32,6 +36,7 @@ class MapFindHouseValidate extends Validate
];
protected $scene = [
'getShopListByMap' => ['first_spot', 'second_spot', 'grade','source'],
'getShopListByMap' => ['first_spot', 'second_spot', 'grade', 'source'],
'getCityInfoByMap' => ['spot', 'city', 'grade', 'source'],
];
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment