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
7621cdd3
Commit
7621cdd3
authored
Jan 22, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
楼盘列表搜索
parent
1bf7e43e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
202 additions
and
29 deletions
+202
-29
Houses.php
application/index/controller/Houses.php
+91
-5
GHouses.php
application/model/GHouses.php
+111
-24
No files found.
application/index/controller/Houses.php
View file @
7621cdd3
...
...
@@ -13,7 +13,6 @@ use app\index\extend\Basic;
use
app\model\GHouses
;
use
app\model\GHousesExt
;
use
app\model\GHousesImgs
;
use
app\model\HouseInfos
;
class
Houses
extends
Basic
...
...
@@ -94,9 +93,12 @@ class Houses extends Basic
}
/**
*
获取商铺
列表
*
楼盘
列表
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getHouseList
()
{
$data
[
'status'
]
=
200
;
...
...
@@ -106,10 +108,94 @@ class Houses extends Basic
$pageSize
=
empty
(
$params
[
'pageSize'
])
?
15
:
$params
[
'pageSize'
];
$house
=
new
GHouses
();
$where
=
'status <> 2'
;
$fields
=
''
;
$data
[
'data'
][
'list'
]
=
$house
->
getHouseList
(
$pageNo
,
$pageSize
,
'id DESC'
,
$fields
,
$where
);
$data
[
'data'
][
'total'
]
=
$house
->
getTotal
(
$where
);
/*精选商铺--0是1否*/
if
(
$params
[
'is_carefully_chosen'
]
!=
NULL
)
{
$where
[
'is_carefully_chosen'
]
=
$params
[
'is_carefully_chosen'
];
}
/*0是1否显示在c端用户*/
if
(
$params
[
'is_show'
]
!=
NULL
)
{
$where
[
'is_show'
]
=
$params
[
'is_show'
];
}
/*商铺类型(0商场,1街铺)*/
if
(
$params
[
'shop_type'
]
!=
NULL
)
{
$where
[
'shop_type'
]
=
$params
[
'shop_type'
];
}
/*所在城市*/
if
(
$params
[
'city'
]
!=
NULL
)
{
$where
[
'city'
]
=
$params
[
'city'
];
}
/*所在区*/
if
(
$params
[
'disc'
]
!=
NULL
)
{
$where
[
'disc'
]
=
$params
[
'disc'
];
}
/*状态 0待审批 1上架 2下架 3回收*/
if
(
$params
[
'status'
]
!=
NULL
)
{
$where
[
'status'
]
=
$params
[
'status'
];
}
/*价格 -1表示营业额扣点 存分*/
if
(
$params
[
'rent_price'
]
!=
NULL
)
{
switch
(
$params
[
'rent_price'
])
{
case
1
:
$where
[
'rent_price'
]
=
[
'>'
,
10000
];
break
;
case
2
:
$where
[
'rent_price'
]
=
[
'between'
,
'10000,30000'
];
break
;
default
:
$where
[
'rent_price'
]
=
[
'>'
,
'30000'
];
}
}
/*对内楼盘名*/
if
(
$params
[
'internal_title'
]
!=
NULL
)
{
$where
[
'internal_title'
]
=
[
'LIKE'
,
$params
[
'internal_title'
]
.
'%'
];
}
/*是否独家0否1是*/
if
(
$params
[
'is_exclusive_type'
]
!=
NULL
)
{
$where
[
'is_exclusive_type'
]
=
[
'LIKE'
,
$params
[
'is_exclusive_type'
]
.
'%'
];
}
/*开始时间*/
if
(
$params
[
'start_date'
]
!=
NULL
)
{
$where
[
'create_time'
]
=
[
'> time'
,
$params
[
'start_date'
]
.
' 00:00:00'
];
}
/*结束时间*/
if
(
$params
[
'end_date'
]
!=
NULL
)
{
$where
[
'create_time'
]
=
[
'< time'
,
$params
[
'end_date'
]
.
' 23:59:59'
];
}
/*开始结束时间*/
if
(
$params
[
'start_date'
]
!=
NULL
&&
$params
[
'end_date'
]
!=
NULL
)
{
$where
[
'create_time'
]
=
[
'between time'
,[
$params
[
'start_date'
]
.
' 00:00:00'
],
$params
[
'end_date'
]
.
' 23:59:59'
];
}
if
(
empty
(
$params
[
'dish'
]))
{
/*楼盘编号*/
if
(
$params
[
'id'
]
!=
NULL
)
{
$where
[
'id'
]
=
$params
[
'id'
];
}
$where
[
'status'
]
=
[
'<>'
,
2
];
$data
[
'data'
][
'list'
]
=
$house
->
getHouseList
(
$pageNo
,
$pageSize
,
'id DESC'
,
$fields
,
$where
);
$data
[
'data'
][
'total'
]
=
$house
->
getTotal
(
$where
);
}
else
{
/*楼盘编号*/
if
(
$params
[
'id'
]
!=
NULL
)
{
$where
[
'a.id'
]
=
$params
[
'id'
];
}
$where
[
'a.status'
]
=
[
'<>'
,
2
];
$where
[
'c.name'
]
=
[
'LIKE'
,
$params
[
'dish'
]
.
'%'
];
$data
[
'data'
][
'list'
]
=
$house
->
getHouseListDish
(
$pageNo
,
$pageSize
,
'a.id DESC'
,
$fields
,
$where
);
$data
[
'data'
][
'total'
]
=
$house
->
getHouseListDishTotal
(
$where
);
}
return
$this
->
response
(
$data
[
'status'
],
$data
[
'msg'
],
$data
[
'data'
]);
}
...
...
application/model/GHouses.php
View file @
7621cdd3
...
...
@@ -69,39 +69,126 @@ class GHouses extends BaseModel
$house_id
[
$k
]
=
$v
[
'id'
];
}
/*案场权限人*/
$house_agents
=
Db
::
table
(
'g_houses_to_agents'
)
->
alias
(
'a'
)
->
field
(
'a.houses_id,b.id,b.name,b.phone'
)
->
join
(
'a_agents b'
,
'a.agents_id=b.id'
,
'left'
)
->
where
(
'a.houses_id'
,
'IN'
,
implode
(
','
,
$house_id
))
->
select
();
$result
=
array
();
if
(
empty
(
$house_id
))
{
$result
=
$data
;
}
else
{
/*案场权限人*/
$house_agents
=
Db
::
table
(
'g_houses_to_agents'
)
->
alias
(
'a'
)
->
field
(
'a.houses_id,b.id,b.name,b.phone'
)
->
join
(
'a_agents b'
,
'a.agents_id=b.id'
,
'left'
)
->
where
(
'a.houses_id'
,
'IN'
,
implode
(
','
,
$house_id
))
->
select
();
/*盘方*/
$house_dish
=
Db
::
table
(
'g_houses_dish'
)
->
alias
(
'a'
)
->
field
(
'a.houses_id,b.id,b.name,b.phone'
)
->
join
(
'a_agents b'
,
'a.agents_id=b.id'
,
'left'
)
->
where
(
'a.houses_id'
,
'IN'
,
implode
(
','
,
$house_id
))
->
select
();
/*盘方*/
$house_dish
=
Db
::
table
(
'g_houses_dish'
)
->
alias
(
'a'
)
->
field
(
'a.houses_id,b.id,b.name,b.phone'
)
->
join
(
'a_agents b'
,
'a.agents_id=b.id'
,
'left'
)
->
where
(
'a.houses_id'
,
'IN'
,
implode
(
','
,
$house_id
))
foreach
(
$data
as
$k
=>
$v
)
{
$result
[
$k
]
=
$v
->
toArray
();
foreach
(
$house_agents
as
$k2
=>
$v2
)
{
if
(
$v
->
id
==
$v2
[
'houses_id'
])
{
$result
[
$k
][
'agents_name'
][
$k2
][
'id'
]
=
$v2
[
'id'
];
$result
[
$k
][
'agents_name'
][
$k2
][
'name'
]
=
$v2
[
'name'
];
$result
[
$k
][
'agents_name'
][
$k2
][
'phone'
]
=
$v2
[
'phone'
];
}
}
foreach
(
$house_dish
as
$k3
=>
$v3
)
{
if
(
$v
->
id
==
$v3
[
'houses_id'
])
{
$result
[
$k
][
'dish_name'
][
$k3
][
'id'
]
=
$v3
[
'id'
];
$result
[
$k
][
'dish_name'
][
$k3
][
'name'
]
=
$v3
[
'name'
];
$result
[
$k
][
'dish_name'
][
$k3
][
'phone'
]
=
$v3
[
'phone'
];
}
}
}
}
return
$result
;
}
/**
* 查询属于盘方的商铺列表
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @return array|false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getHouseListDish
(
$pageNo
=
1
,
$pageSize
=
15
,
$order_
=
'id desc'
,
$field
=
''
,
$params
=
''
)
{
$data
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'g_houses_dish b'
,
'a.id=b.houses_id'
,
'left'
)
->
join
(
'a_agents c'
,
'b.agents_id=c.id'
,
'left'
)
->
where
(
$params
)
->
order
(
$order_
)
->
limit
(
$pageSize
)
->
page
(
$pageNo
)
->
select
();
$house_id
=
array
();
foreach
(
$data
as
$k
=>
$v
)
{
$house_id
[
$k
]
=
$v
[
'id'
];
}
$result
=
array
();
foreach
(
$data
as
$k
=>
$v
)
{
$result
[
$k
]
=
$v
->
toArray
();
foreach
(
$house_agents
as
$k2
=>
$v2
)
{
if
(
$v
->
id
==
$v2
[
'houses_id'
])
{
$result
[
$k
][
'agents_name'
][
$k2
][
'id'
]
=
$v2
[
'id'
];
$result
[
$k
][
'agents_name'
][
$k2
][
'name'
]
=
$v2
[
'name'
];
$result
[
$k
][
'agents_name'
][
$k2
][
'phone'
]
=
$v2
[
'phone'
];
if
(
empty
(
$house_id
))
{
$result
=
$data
;
}
else
{
/*案场权限人*/
$house_agents
=
Db
::
table
(
'g_houses_to_agents'
)
->
alias
(
'a'
)
->
field
(
'a.houses_id,b.id,b.name,b.phone'
)
->
join
(
'a_agents b'
,
'a.agents_id=b.id'
,
'left'
)
->
where
(
'a.houses_id'
,
'IN'
,
implode
(
','
,
$house_id
))
->
select
();
/*盘方*/
$house_dish
=
Db
::
table
(
'g_houses_dish'
)
->
alias
(
'a'
)
->
field
(
'a.houses_id,b.id,b.name,b.phone'
)
->
join
(
'a_agents b'
,
'a.agents_id=b.id'
,
'left'
)
->
where
(
'a.houses_id'
,
'IN'
,
implode
(
','
,
$house_id
))
->
select
();
foreach
(
$data
as
$k
=>
$v
)
{
$result
[
$k
]
=
$v
->
toArray
();
foreach
(
$house_agents
as
$k2
=>
$v2
)
{
if
(
$v
->
id
==
$v2
[
'houses_id'
])
{
$result
[
$k
][
'agents_name'
][
$k2
][
'id'
]
=
$v2
[
'id'
];
$result
[
$k
][
'agents_name'
][
$k2
][
'name'
]
=
$v2
[
'name'
];
$result
[
$k
][
'agents_name'
][
$k2
][
'phone'
]
=
$v2
[
'phone'
];
}
}
}
foreach
(
$house_dish
as
$k3
=>
$v3
)
{
if
(
$v
->
id
==
$v3
[
'houses_id'
])
{
$result
[
$k
][
'dish_name'
][
$k3
][
'id'
]
=
$v3
[
'id'
];
$result
[
$k
][
'dish_name'
][
$k3
][
'name'
]
=
$v3
[
'name'
];
$result
[
$k
][
'dish_name'
][
$k3
][
'phone'
]
=
$v3
[
'phone'
];
foreach
(
$house_dish
as
$k3
=>
$v3
)
{
if
(
$v
->
id
==
$v3
[
'houses_id'
])
{
$result
[
$k
][
'dish_name'
][
$k3
][
'id'
]
=
$v3
[
'id'
];
$result
[
$k
][
'dish_name'
][
$k3
][
'name'
]
=
$v3
[
'name'
];
$result
[
$k
][
'dish_name'
][
$k3
][
'phone'
]
=
$v3
[
'phone'
];
}
}
}
}
return
$result
;
}
/**
* 查询属于盘方的商铺列表总记录数
*
* @param string $params
* @return int|string
*/
public
function
getHouseListDishTotal
(
$params
=
''
)
{
$data
=
$this
->
alias
(
'a'
)
->
join
(
'g_houses_dish b'
,
'a.id=b.houses_id'
,
'left'
)
->
join
(
'a_agents c'
,
'b.agents_id=c.id'
,
'left'
)
->
where
(
$params
)
->
count
();
return
$data
;
}
}
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