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
ca6ddbbf
Commit
ca6ddbbf
authored
Feb 08, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
部门列表搜索
parent
c99efa29
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
10 deletions
+104
-10
District.php
application/index/controller/District.php
+19
-10
ADistrict.php
application/model/ADistrict.php
+85
-0
No files found.
application/index/controller/District.php
View file @
ca6ddbbf
...
...
@@ -9,7 +9,6 @@
namespace
app\index\controller
;
use
app\index\extend\Basic
;
use
app\model\AAgents
;
use
app\model\ADistrict
;
class
District
extends
Basic
{
...
...
@@ -31,18 +30,28 @@ class District extends Basic
$data
[
'msg'
]
=
''
;
$pageNo
=
empty
(
$this
->
params
[
'pageNo'
])
?
1
:
$this
->
params
[
'pageNo'
];
$pageSize
=
empty
(
$this
->
params
[
'pageSize'
])
?
10
:
$this
->
params
[
'pageSize'
];
$search
=
$this
->
params
[
'search'
];
$agents
=
new
AAgents
();
$field
=
'district_id,id,name,create_time,phone'
;
$where
=
''
;
$where
.=
'level in (30,40) AND status=0'
;
$agents
=
new
ADistrict
();
if
(
$search
!=
NULL
)
{
$where
.=
" AND (phone like '
{
$search
}
%' or name like '
{
$search
}
%')"
;
$where
=
''
;
$join
=
0
;
if
(
$this
->
params
[
'search'
]
!=
NULL
)
{
$field
=
'a.id,a.district_name,a.create_time,b.name,b.phone'
;
$where
.=
"a.status=0 AND (phone like '
{
$this
->
params
[
'search'
]
}
%' or name like '
{
$this
->
params
[
'search'
]
}
%')"
;
$join
=
1
;
}
$data
[
'list'
]
=
$agents
->
getListDistrict
(
$pageNo
,
$pageSize
,
'id DESC'
,
$field
,
$where
);
$data
[
'total'
]
=
$agents
->
getListDistrictTotal
(
$where
);
if
(
$this
->
params
[
'district_name'
]
!=
NULL
)
{
if
(
$join
==
0
)
{
$field
=
'a.id,a.district_name,a.create_time'
;
$where
[
'status'
]
=
0
;
$where
[
'district_name'
]
=
[
'LIKE'
,
$this
->
params
[
'district_name'
]
.
'%'
];
}
else
{
$where
.=
" AND district_name LIKE '
{
$this
->
params
[
'district_name'
]
}
%'"
;
}
}
$data
[
'list'
]
=
$agents
->
getListDistrict
(
$pageNo
,
$pageSize
,
'id DESC'
,
$field
,
$where
,
$join
);
$data
[
'total'
]
=
$agents
->
getListDistrictTotal
(
$where
,
$join
);
return
$this
->
response
(
$data
[
'status'
],
$data
[
'msg'
],
$data
);
}
...
...
application/model/ADistrict.php
View file @
ca6ddbbf
...
...
@@ -94,4 +94,88 @@ class ADistrict extends BaseModel
return
$data
;
}
/**
* 部门列表
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getListDistrict
(
$pageNo
=
1
,
$pageSize
=
15
,
$order_
=
'id desc'
,
$field
=
''
,
$params
=
''
,
$join
=
0
)
{
if
(
$join
==
0
)
{
$data
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
where
(
$params
)
->
order
(
$order_
)
->
limit
(
$pageSize
)
->
page
(
$pageNo
)
->
select
();
$result
=
array
();
foreach
(
$data
as
$k
=>
$v
){
$result
[
$k
]
=
$v
;
if
(
isset
(
$v
->
id
))
{
if
(
$result
[
$k
][
'district_name'
])
{
$agents
=
Db
::
table
(
'a_agents'
)
->
field
(
'name,phone'
)
->
where
([
'status'
=>
0
,
'district_id'
=>
$v
->
id
])
->
find
();
$result
[
$k
][
'name'
]
=
$agents
[
'name'
]
.
'-'
.
$agents
[
'phone'
];
$result
[
$k
][
'store_num'
]
=
Db
::
table
(
'a_store'
)
->
where
([
'status'
=>
0
,
'district_id'
=>
$v
->
id
])
->
count
(
'store_name'
);
}
else
{
$result
[
$k
][
'store_num'
]
=
''
;
}
}
}
}
else
{
$data
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'a_agents b'
,
'a.id=b.district_id'
,
'left'
)
->
where
(
$params
)
->
order
(
$order_
)
->
limit
(
$pageSize
)
->
page
(
$pageNo
)
->
select
();
$result
=
array
();
foreach
(
$data
as
$k
=>
$v
){
$result
[
$k
]
=
$v
;
if
(
isset
(
$v
->
id
))
{
if
(
$result
[
$k
][
'district_name'
])
{
$result
[
$k
][
'name'
]
=
$v
[
'name'
]
.
'-'
.
$v
[
'phone'
];
$result
[
$k
][
'store_num'
]
=
Db
::
table
(
'a_store'
)
->
where
([
'status'
=>
0
,
'district_id'
=>
$v
->
id
])
->
count
(
'store_name'
);
}
else
{
$result
[
$k
][
'store_num'
]
=
''
;
}
}
}
}
return
$result
;
}
/**
* 总监列表总数
*
* @param $params
* @param int $join
* @return int|string
*/
public
function
getListDistrictTotal
(
$params
,
$join
=
0
){
if
(
$join
==
0
)
{
$data
=
$this
->
where
(
$params
)
->
count
();
}
else
{
$data
=
$this
->
alias
(
'a'
)
->
join
(
'a_agents b'
,
'a.id=b.district_id'
,
'left'
)
->
where
(
$params
)
->
count
();
}
return
$data
;
}
}
\ No newline at end of file
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