Commit b1b1fa7c authored by clone's avatar clone

优化搜素

parent 84fdc257
......@@ -37,21 +37,21 @@ class Shop extends Basic
public function getShopList()
{
/* $params = array(
"site_area" => 2, //来源 1首页 2搜索
"title" => "尚美",
"carefully_chosen" => 0, //精选商铺--0是1否
"shangpu_type"=> 0, //商铺类型(0商场,1街铺)
"disc" => "黄浦区",
"yetai" => "休闲娱乐",
"area_start" => 45,//面积起始范围 room_area2
"area_end" => 65,//面积结束范围
"money_start" => 1000,//租金 price2
"money_end" => 10000,//租金
"shangpu_tags" => "临近地铁,",
"pageNo" => "1",
"pageSize" => 15
);*/
/* $params = array(
"site_area" => 2, //来源 1首页 2搜索
"title" => "尚美",
"carefully_chosen" => 0, //精选商铺--0是1否
"shangpu_type" => 0, //商铺类型(0商场,1街铺)
"disc" => "黄浦区",
"yetai" => "休闲娱乐",
"area_start" => 45,//面积起始范围 room_area2
"area_end" => 65,//面积结束范围
"money_start" => 1000,//租金 price2
"money_end" => 10000,//租金
"shangpu_tags" => "临近地铁,临近地铁2",
"pageNo" => "1",
"pageSize" => 15
);*/
$params = $this->params;
$field = "id,agent_id,title,address,city,disc,disccircles,sales,yetai,room_area,room_area2,shangpu_type,is_test,
room_num_left,shangpu_tags,carefully_chosen,price";
......@@ -68,6 +68,7 @@ class Shop extends Basic
$conditions['title'] = array( "like", "%" . trim($params['title']) . "%" );
}
$order_ = "";
$spTagArr = array();
switch ($params['site_area']) {
case 1:
if (isset($params['carefully_chosen']) && $params['carefully_chosen'] == 0) {
......@@ -105,10 +106,10 @@ class Shop extends Basic
if (isset($params['shangpu_tags']) && $params['shangpu_tags'] != "全部") { //商铺标签
$shangpuTagsArr = array_filter(explode(',', $params['shangpu_tags']));
if (count($shangpuTagsArr) == 1) {
$conditions['shangpu_tags'] = array( 'like', "%" . trim($shangpuTagsArr[0]) . "%" );
$spTagArr['shangpu_tags'] = array( 'like', "%" . trim($shangpuTagsArr[0]) . "%" );
} else {
foreach ($shangpuTagsArr as $key => $val) {
$conditions['shangpu_tags'][] = array( 'like', "%" . trim($val) . "%" );
$spTagArr['shangpu_tags'][] = array( 'like', "%" . trim($val) . "%" );
}
}
}
......@@ -125,7 +126,7 @@ class Shop extends Basic
$conditions['show_all'] = array( 'eq', 0 ); //只显示公开的楼盘
}
$result = $this->db->getHouseInfoList($pageNo, $pageSize, $order_, $field, $conditions);
$result = $this->db->getHouseInfoList($pageNo, $pageSize, $order_, $field, $conditions, $spTagArr);
//获取图片信息
foreach ($result as $key => $val) {
......
......@@ -25,11 +25,14 @@ class HouseInfos extends Model
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
function getHouseInfoList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params)
function getHouseInfoList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $spTagsArr)
{
return $data = $this->dbHouseInfo
return $this->dbHouseInfo
->field($field)
->where($params)
->where(function ($query) use ($spTagsArr) {
$query->whereOr($spTagsArr);
})
->order($order_)
->limit($pageSize)
->page($pageNo)
......@@ -73,7 +76,7 @@ class HouseInfos extends Model
}
function getCityList( $field, $params, $group)
function getCityList($field, $params, $group)
{
return $data = $this->dbHouseInfo
->field($field)
......
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