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
9954ccc3
Commit
9954ccc3
authored
Dec 07, 2017
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
商铺list
parent
0497c3e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
35 deletions
+80
-35
Shop.php
application/api/controller/Shop.php
+72
-27
HouseInfos.php
application/model/HouseInfos.php
+8
-8
No files found.
application/api/controller/Shop.php
View file @
9954ccc3
<?php
namespace
app\api\controller
;
/**
* Created by PhpStorm.
* User : zw
...
...
@@ -9,60 +11,102 @@ namespace app\api\controller;
*/
use
app\common\Basic
;
use
app\model\HouseInfos
;
class
Shop
extends
Basic
{
class
Shop
extends
Basic
{
/** 获取商铺列表
* @param $params
*/
public
function
getShopList
()
{
/* $params['carefully_chosen']; //是否精选 0是1否
$params['shangpu_type']; //商铺类型 0商场,1街铺
$params
=
array
(
"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'];//商铺标签
//-------
$params['show_all'];//是否公开0是1否
$params['title'];//商铺名 模糊查询
$params['city'];//市
$params['disc']; //区域 如 黄埔区
$field
=
"id,agent_id,title,address,city,disc,disccircles,sales,yetai,room_area2,shangpu_type,is_test,room_num_left,
shangpu_tags,carefully_chosen,price"
;
$params['site_area'];//来源1app首页 2搜索*/
$params
=
array
(
"site_area"
=>
1
,
"carefully_chosen"
=>
1
);
$conditions
=
array
();
$conditions
=
[];
if
(
empty
(
$params
[
'site_area'
]))
{
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'
])
{
case
1
:
if
(
!
empty
(
$params
[
'carefully_chosen'
])
&&
$params
[
'carefully_chosen'
]
==
0
)
{
$conditions
[
'carefully_chosen'
]
=
$params
[
'carefully_chosen'
];
if
(
isset
(
$params
[
'carefully_chosen'
])
&&
$params
[
'carefully_chosen'
]
==
0
)
{
$conditions
[
'carefully_chosen'
]
=
array
(
'eq'
,
$params
[
'carefully_chosen'
]
);
$order_
=
"rate1 desc"
;
}
break
;
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
;
default
:
return
$this
->
response
(
"101"
,
"请求数据异常"
);
$this
->
response
(
"101"
,
"请求数据异常"
);
}
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
();
$result
=
$HouseInfos
->
getHouseInfoList
(
1
,
15
,
$conditions
);
$result
=
$HouseInfos
->
getHouseInfoList
(
$pageNo
,
$pageSize
,
$order_
,
$field
,
$conditions
);
if
(
empty
(
$result
))
{
return
$this
->
response
(
"200"
,
"此条件没有找到数据"
);
}
return
$this
->
response
(
"200"
,
''
,
$result
);
return
$this
->
response
(
"200"
,
''
,
$result
);
}
}
\ No newline at end of file
application/model/HouseInfos.php
View file @
9954ccc3
...
...
@@ -15,16 +15,16 @@ class HouseInfos extends Model
$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_ = "";
if (!empty($params['carefully_chosen'])) {
$where_ .= "carefully_chosen = :carefully_chosen";
}*/
return
$this
->
dbHouseInfo
->
where
(
"carefully_chosen =: id"
)
->
bind
([
"id"
=>
'0'
])
return
$data
=
$this
->
dbHouseInfo
->
field
(
$field
)
->
where
(
$params
)
->
order
(
$order_
)
->
limit
(
$pageSize
)
->
page
(
$pageNo
)
->
select
();
}
}
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