Commit 9954ccc3 authored by clone's avatar clone

商铺list

parent 0497c3e8
<?php <?php
namespace app\api\controller; namespace app\api\controller;
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User : zw * User : zw
...@@ -9,60 +11,102 @@ namespace app\api\controller; ...@@ -9,60 +11,102 @@ namespace app\api\controller;
*/ */
use app\common\Basic; use app\common\Basic;
use app\model\HouseInfos; use app\model\HouseInfos;
class Shop extends Basic{
class Shop extends Basic
{
/** 获取商铺列表 /** 获取商铺列表
* @param $params * @param $params
*/ */
public function getShopList() public function getShopList()
{ {
/* $params['carefully_chosen']; //是否精选 0是1否 $params = array(
$params['shangpu_type']; //商铺类型 0商场,1街铺 "site_area" => 2, //来源 1首页 2搜索
"title" => "尚美",
"carefully_chosen" => 0,
"yetai" => "休闲娱乐",
"area_start" => 45,//面积起始范围 room_area2
"area_end" => 65,//面积结束范围
"money_start" => 1000,//租金 price2
"money_end" => 10000,//租金
"shangpu_tags" => "临近地铁,"
);
$params['yetai']; //业态
$params['area_start'];//面积起始范围 room_area2
$params['area_end'];//面积结束范围
$params['sales'];//0上2下架
$params['money_start'];//price2 租金
$params['money_end'];//price2 租金 范围
$params['shangpu_tags'];//商铺标签
//------- $field = "id,agent_id,title,address,city,disc,disccircles,sales,yetai,room_area2,shangpu_type,is_test,room_num_left,
$params['show_all'];//是否公开0是1否 shangpu_tags,carefully_chosen,price";
$params['title'];//商铺名 模糊查询
$params['city'];//市
$params['disc']; //区域 如 黄埔区
$params['site_area'];//来源1app首页 2搜索*/ $conditions = [];
$params = array(
"site_area" => 1,
"carefully_chosen" =>1
);
$conditions = array();
if (empty($params['site_area'])) { if (empty($params['site_area'])) {
return $this->response("101", "请求来源不能为空"); return $this->response("101", "请求来源不能为空");
} }
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
if (isset($params['title'])) {
$conditions['title'] = array( "like", "%" . trim($params['title']) . "%" );
}
$order_ = "";
switch ($params['site_area']) { switch ($params['site_area']) {
case 1: case 1:
if (!empty($params['carefully_chosen']) && $params['carefully_chosen'] == 0) { if (isset($params['carefully_chosen']) && $params['carefully_chosen'] == 0) {
$conditions['carefully_chosen'] = $params['carefully_chosen']; $conditions['carefully_chosen'] = array( 'eq', $params['carefully_chosen'] );
$order_ = "rate1 desc";
} }
break; break;
case 2: case 2:
if (isset($params['disc'])) { //区域
$conditions['disc'] = array( 'eq', trim($params['disc']) );
}
if (isset($params['yetai'])) { //业态
$conditions['yetai'] = array( 'like', "%" . trim($params['yetai']) . "%" );
}
//面积 room_area最小面积 room_area2最大面积 参考老版本
if (isset($params['area_start']) && isset($params['area_end'])) {
$conditions['room_area'] = array( 'between', array( $params['area_start'], $params['area_end'] ) );
$conditions['room_area2'] = array( 'between', array( $params['area_start'], $params['area_end'] ) );
} else if (isset($params['area_start']) && !isset($params['area_end'])) { //100米以上不用传结束面积
$conditions['room_area'] = array( 'egt', $params['area_start'] );
$conditions['room_area2'] = array( 'egt', $params['area_start'] );
}
if (isset($params['money_start']) && isset($params['money_end'])) { //面积
$conditions['price'] = array( 'between', array( $params['money_start'], $params['money_end'] ) );
} else if (isset($params['money_start']) && !isset($params['money_end'])) { //100米以上不用传结束面积
$conditions['price'] = array( 'egt', $params['money_start'] );
}
if (isset($params['shangpu_tags'])) { //商铺标签
$shangpuTagsArr = array_filter(explode(',', $params['shangpu_tags']));
if (count($shangpuTagsArr) == 1) {
$conditions['shangpu_tags'] = array( 'like', "%" . trim($shangpuTagsArr[0]) . "%" );
} else {
foreach ($shangpuTagsArr as $key => $val) {
$conditions['shangpu_tags'][] = array( 'like', "%" . trim($val) . "%" );
}
}
}
$order_ = "id desc";
break; break;
default: default:
return $this->response("101", "请求数据异常"); $this->response("101", "请求数据异常");
} }
if (!empty($conditions)) { if (!empty($conditions)) {
$conditions['sales'] = 0; //排除下架的店铺 //todo 测试数据?
$conditions['id'] = array( '<>', 16 );
//todo sales下架字段并没用处 根据room_num_left剩余铺数来判断 为0 表示下架
$conditions['room_num_left'] = array( '<>', 0 );
} }
$HouseInfos = new HouseInfos(); $HouseInfos = new HouseInfos();
$result = $HouseInfos->getHouseInfoList(1,15,$conditions); $result = $HouseInfos->getHouseInfoList($pageNo, $pageSize, $order_, $field, $conditions);
if (empty($result)) { if (empty($result)) {
return $this->response("200", "此条件没有找到数据"); return $this->response("200", "此条件没有找到数据");
} }
return $this->response("200", '', $result); return $this->response("200", '', $result);
} }
} }
\ No newline at end of file
...@@ -15,16 +15,16 @@ class HouseInfos extends Model ...@@ -15,16 +15,16 @@ class HouseInfos extends Model
$this->dbHouseInfo = Db::table($this->table); $this->dbHouseInfo = Db::table($this->table);
} }
function getHouseInfoList($pageNo = 1, $pageSize = 15, $params) function getHouseInfoList($pageNo = 1, $pageSize = 15, $order_ = 'id desc' , $field, $params)
{ {
/* $where_ = ""; return $data = $this->dbHouseInfo
if (!empty($params['carefully_chosen'])) { ->field($field)
$where_ .= "carefully_chosen = :carefully_chosen"; ->where($params)
}*/ ->order($order_)
return $this->dbHouseInfo ->limit($pageSize)
->where("carefully_chosen =: id") ->page($pageNo)
->bind(["id" => '0'])
->select(); ->select();
} }
} }
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