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
6429e1ef
Commit
6429e1ef
authored
Mar 05, 2019
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
部门列表
parent
9e98f772
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
51 deletions
+24
-51
District.php
application/index/controller/District.php
+20
-2
ADistrict.php
application/model/ADistrict.php
+1
-47
BaseModel.php
application/model/BaseModel.php
+3
-2
No files found.
application/index/controller/District.php
View file @
6429e1ef
...
...
@@ -9,7 +9,10 @@
namespace
app\index\controller
;
use
app\index\extend\Basic
;
use
app\model\AAgents
;
use
app\model\ADistrict
;
use
app\model\AStore
;
class
District
extends
Basic
{
protected
$code
=
200
;
...
...
@@ -30,7 +33,6 @@ class District extends Basic
return
view
(
'index'
);
}
$data
[
'status'
]
=
200
;
$data
[
'data'
]
=
''
;
$data
[
'msg'
]
=
''
;
$pageNo
=
empty
(
$this
->
params
[
'pageNo'
])
?
1
:
$this
->
params
[
'pageNo'
];
$pageSize
=
empty
(
$this
->
params
[
'pageSize'
])
?
10
:
$this
->
params
[
'pageSize'
];
...
...
@@ -58,7 +60,23 @@ class District extends Basic
$where
[
'a.site_id'
]
=
$this
->
params
[
'site_id'
];
}
$data
[
'list'
]
=
$agents
->
getListDistrict
(
$pageNo
,
$pageSize
,
'id DESC'
,
$field
,
$where
,
$join
);
$list
=
$agents
->
getListDistrict
(
$pageNo
,
$pageSize
,
'id DESC'
,
$field
,
$where
,
$join
);
$m_agent
=
new
AAgents
();
$m_store
=
new
AStore
();
$agent_where
[
'level'
]
=
[
'in'
,
'30,40'
];
$status_arr
=
[
0
=>
'正常'
,
1
=>
'长假'
,
2
=>
'离职'
,
3
=>
'转勤'
,
4
=>
'黑名单'
,
5
=>
'冻结'
];
foreach
(
$list
as
$k
=>
$v
)
{
$agent_where
[
'district_id'
]
=
$v
[
'id'
];
$agent_data
=
$m_agent
->
getStoreIdByAgentId
(
'name,phone,status'
,
$agent_where
);
$agent_name
=
''
;
foreach
(
$agent_data
as
$k2
=>
$v2
)
{
$agent_name
.=
$v2
[
'name'
]
.
'-'
.
$v2
[
'phone'
]
.
'('
.
$status_arr
[
$v2
[
'status'
]]
.
')-'
;
}
$list
[
$k
][
'name'
]
=
rtrim
(
$agent_name
,
'-'
);
$list
[
$k
][
'store_num'
]
=
$m_store
->
getTotal
([
'district_id'
=>
$v
[
'id'
],
'status'
=>
0
]);
}
$data
[
'list'
]
=
$list
;
$data
[
'total'
]
=
$agents
->
getListDistrictTotal
(
$where
,
$join
);
return
$this
->
response
(
$data
[
'status'
],
$data
[
'msg'
],
$data
);
}
...
...
application/model/ADistrict.php
View file @
6429e1ef
...
...
@@ -116,7 +116,6 @@ class ADistrict extends BaseModel
$data
[
'city'
]
=
Db
::
table
(
'a_site'
)
->
where
(
'id'
,
$district
[
'site_id'
])
->
value
(
'city'
);
$agents
=
Db
::
table
(
'a_agents'
)
->
field
(
'name,phone'
)
->
where
([
'status'
=>
0
,
'level'
=>
[
'in'
,[
30
,
40
]],
'district_id'
=>
$id
])
->
find
();
...
...
@@ -153,30 +152,6 @@ class ADistrict extends BaseModel
->
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'
=>
[
'in'
,
'0,3'
],
'district_id'
=>
$v
->
id
,
'level'
=>
[
'in'
,
'30,40'
]
])
->
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'
]
=
''
;
}
}
if
(
$v
[
'site_id'
])
{
$result
[
$k
][
'city'
]
=
Db
::
table
(
'a_site'
)
->
where
(
'id'
,
$v
[
'site_id'
])
->
value
(
'city'
);
}
else
{
$result
[
$k
][
'city'
]
=
""
;
}
}
}
else
{
$data
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'a_agents b'
,
'a.id=b.district_id'
,
'left'
)
...
...
@@ -185,30 +160,9 @@ class ADistrict extends BaseModel
->
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'
=>
[
'in'
,
'0,3'
],
'district_id'
=>
$v
->
id
])
->
count
(
'store_name'
);
}
else
{
$result
[
$k
][
'store_num'
]
=
''
;
}
}
if
(
$v
[
'site_id'
])
{
$result
[
$k
][
'city'
]
=
Db
::
table
(
'a_site'
)
->
where
(
'id'
,
$v
[
'site_id'
])
->
value
(
'city'
);
}
else
{
$result
[
$k
][
'city'
]
=
""
;
}
}
}
return
$result
;
return
$data
;
}
/**
...
...
application/model/BaseModel.php
View file @
6429e1ef
...
...
@@ -17,11 +17,12 @@ class BaseModel extends Model
* 记录总数
*
* @param $params
* @param string $field
* @return int|string
*/
public
function
getTotal
(
$params
)
public
function
getTotal
(
$params
,
$field
=
'id'
)
{
return
$this
->
where
(
$params
)
->
count
();
return
$this
->
where
(
$params
)
->
count
(
$field
);
}
/**
...
...
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