Commit ce34f5fe authored by clone's avatar clone

商铺list

parent 5f8c1215
<?php
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\model\GHouses;
use app\model\GHousesImgs;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/2/26
* Time : 10:36
* Intro:
*/
class Shop extends Basic
{
private $gHousesModel;
private $gHousesImgModel;
function __construct($request = null)
{
parent::__construct($request);
$this->gHousesModel = new GHouses();
$this->gHousesImgModel = new GHousesImgs();
}
/**查询商品列表 b c端公用
* @return \think\Response
*/
public function getShopList()
{
$params = array(
"site_area" => 1, //来源 1c首页 2c搜索 3b首页 4b搜索
"title" => "vv", //1,2 external_title ,3,4internal_title
/*"is_carefully_chosen" => 0, //精选商铺--0否1是
"shop_type" => 0, //商铺类型(0商场,1街铺)
"disc" => "黄浦区",
"industry_type" => "休闲娱乐",
"shop_area_start" => 45,//面积起始范围 街铺start和end面积一样
"shop_area_end" => 65,//面积结束范围
"rent_price_start" => 1000,//租金 rent_price
"rent_price_end" => 10000,//租金
"shop_sign" => "临近地铁,临近地铁2",
"pageNo" => 1,
"pageSize" => 15*/
);
//$params = $this->params;
$conditions = [];
if (empty($params['site_area'])) {
return $this->response("101", "请求来源不能为空");
}
if ($params['site_area'] == 1 || $params['site_area'] == 2) {
$field = "id,external_title as title,external_address as address,city,disc,business_district_id,status,industry_type
,shop_area_start,shop_area_end,shop_type,residue_num,shop_sign,is_carefully_chosen,rent_type,rent_price";
} else {
$field = "id,internal_title as title,internal_address as address,city,disc,business_district_id,status,industry_type
,shop_area_start,shop_area_end,shop_type,residue_num,shop_sign,is_carefully_chosen,rent_type,rent_price";
}
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
//c端查对外的名字 b端查对内的名字
if (isset($params['title']) && $params['site_area'] == 1 || $params['site_area'] == 2) {
$conditions['external_title'] = array( "like", "%" . trim($params['title']) . "%" );
} else if (isset($params['title'])) {
$conditions['internal_title'] = array( "like", "%" . trim($params['title']) . "%" );
}
$order_ = "";
$spTagArr = array();
switch ($params['site_area']) {
case 1:
case 3:
if (isset($params['is_carefully_chosen']) && $params['is_carefully_chosen'] == 1) {
$conditions['is_carefully_chosen'] = array( 'eq', $params['is_carefully_chosen'] );
$order_ = "home_page_sort desc, id desc";
}
break;
case 2:
case 4:
if (isset($params['disc'])) { //区域
$conditions['disc'] = array( 'eq', trim($params['disc']) );
}
if (isset($params['industry_type'])) { //业态
$conditions['industry_type'] = array( 'like', "%" . trim($params['industry_type']) . "%" );
}
if (isset($params['shop_type'])) { //商铺类型
$conditions['shop_type'] = array( "eq", $params['shop_type'] );
}
$area_start = isset($params['shop_area_start']) ? $params['shop_area_start'] : -1;
$area_end = isset($params['shop_area_end']) ? $params['shop_area_end'] : -1;
if ($area_start >= 0 && $area_end >= 0) { //面积
$conditions['shop_area_start'] = array( 'between', array( $area_start * 10000, $area_end * 10000 ) );
$conditions['shop_area_end'] = array( 'between', array( $area_start * 10000, $area_end * 10000 ) );
} else if ($area_start >= 0 && $area_end < 0) { //100米以上不用传结束面积
$conditions['shop_area_start'] = array( 'egt', $area_start * 10000 );
$conditions['shop_area_end'] = array( 'egt', $area_start * 10000 );
}
$price_start = isset($params['rent_price_start']) ? $params['rent_price_start'] : -1;
$price_end = isset($params['rent_price_end']) ? $params['rent_price_end'] : -1;
if ($price_start >= 0 && $price_end >= 0) { //金额
$conditions['rent_price'] = array( 'between', array( $price_start * 100, $price_end * 100 ) );
} else if ($price_start >= 0 && $price_end < 0) {
$conditions['rent_price'] = array( 'egt', $price_start * 100 );
}
if (isset($params['shop_sign']) && $params['shop_sign'] != "全部") { //商铺标签
$shopTagsArr = array_filter(explode(',', $params['shop_sign']));
if (count($shopTagsArr) == 1) {
$spTagArr['shop_sign'] = array( 'like', "%" . trim($shopTagsArr[0]) . "%" );
} else {
foreach ($shopTagsArr as $key => $val) {
$spTagArr['shop_sign'][] = array( 'like', "%" . trim($val) . "%" );
}
}
}
$order_ = "id desc";
break;
default:
$this->response("101", "请求数据异常");
}
if (!empty($conditions)) {
$conditions['status'] = array( 'eq', 1 ); //只显示上架
if ($params['site_area'] == 1 || $params['site_area'] == 2)
$conditions['is_show'] = array( 'eq', 0 ); //c端只显示可显示的楼盘
}
$result = $this->gHousesModel->getHousesList($pageNo, $pageSize, $order_, $field, $conditions, $spTagArr);
//获取图片信息
foreach ($result as $key => $val) {
$result[$key]["api_path"] = CK_IMG_URL;
$param["house_id"] = $val["id"];
$param["img_type"] = 1; //默认主图
$result[$key]["images"] = $this->gHousesImgModel->getHouseImages($param, 1);
}
if (empty($result)) {
return $this->response("200", "此条件没有找到数据");
}
return $this->response("200", 'request success', $result);
}
}
\ No newline at end of file
This diff is collapsed.
<?php
namespace app\model;
/**
* Created by PhpStorm.
* User: fuju
* Date: 2018/1/19
* Time: 11:33
*/
use think\Db;
namespace app\model;
class GHousesImgs extends BaseModel
......@@ -176,4 +177,23 @@ class GHousesImgs extends BaseModel
$this->add($params, $house_id);
return $this->saveAll($house_img_edit);
}
/****** zw start *******/
/**
* 查询图片
* @param $param
* @param $limit_
* @return mixed
*/
public function getHouseImages($param,$limit_)
{
//rank
return Db::table($this->table)
->field("id,house_id,img_type,img_name,img_status")
->where($param)
->limit($limit_)
->select();
}
/****** zw end *******/
}
\ No newline at end of file
......@@ -237,6 +237,9 @@ Route::group('broker', [
'agentsUnBind' => [ 'api_broker/CellPhone/agentsUnBind', [ 'method' => 'post' ] ],//解除绑定关系
'callLog' => [ 'api_broker/CellPhone/callLog', [ 'method' => 'get' ] ],//通话记录
'getShopList' => ['api_broker/Shop/getShopList', [ 'method' => 'get' ] ],
]);
//Route::miss('api/index/miss');//处理错误的url
\ 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