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
b2e0da38
Commit
b2e0da38
authored
Aug 07, 2019
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
门店列表
parent
18157b7d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
35 deletions
+98
-35
Store.php
application/index/controller/Store.php
+51
-35
ADistrict.php
application/model/ADistrict.php
+11
-0
AStore.php
application/model/AStore.php
+36
-0
No files found.
application/index/controller/Store.php
View file @
b2e0da38
...
...
@@ -12,6 +12,7 @@ namespace app\index\controller;
use
app\api_broker\service\RedisCacheService
;
use
app\index\extend\Basic
;
use
app\index\validate\StoreValidate
;
use
app\model\AAgents
;
use
app\model\ADistrict
;
use
app\model\AStore
;
...
...
@@ -24,51 +25,66 @@ class Store extends Basic
/**
* 门店列表
*
* @return
string
|\think\response\View
* @return
\think\Response
|\think\response\View
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
index
()
{
if
(
$this
->
request
->
isAjax
())
{
$pageNo
=
empty
(
$this
->
params
[
'pageNo'
])
?
1
:
$this
->
params
[
'pageNo'
];
$pageSize
=
empty
(
$this
->
params
[
'pageSize'
])
?
10
:
$this
->
params
[
'pageSize'
];
$field
=
'a.id,a.district_id,a.store_name,a.create_time'
;
$where
[
'a.status'
]
=
0
;
$join
=
0
;
//门店名
if
(
!
empty
(
$this
->
params
[
'store_id'
]))
{
$where
[
'a.id'
]
=
$this
->
params
[
'store_id'
];
}
public
function
index
()
{
if
(
!
$this
->
request
->
isAjax
())
{
return
view
(
'index'
);
}
if
(
!
empty
(
$this
->
params
[
'city'
]))
{
$where
[
'a.city'
]
=
$this
->
params
[
'city'
];
}
$pageNo
=
empty
(
$this
->
params
[
'pageNo'
])
?
1
:
$this
->
params
[
'pageNo'
];
$pageSize
=
empty
(
$this
->
params
[
'pageSize'
])
?
10
:
$this
->
params
[
'pageSize'
];
$field
=
'a.id,a.district_id,a.store_name,a.create_time'
;
$where
[
'a.status'
]
=
0
;
$where
[
'b.level'
]
=
[
'in'
,
'20,40'
];
//门店名
if
(
!
empty
(
$this
->
params
[
'store_id'
]))
{
$where
[
'a.id'
]
=
$this
->
params
[
'store_id'
];
}
if
(
!
empty
(
$this
->
params
[
'district_id
'
]))
{
$where
[
'a.district_id'
]
=
$this
->
params
[
'district_id
'
];
}
if
(
!
empty
(
$this
->
params
[
'city
'
]))
{
$where
[
'a.city'
]
=
$this
->
params
[
'city
'
];
}
//店长姓名
if
(
!
empty
(
$this
->
params
[
'agents_name'
]))
{
$where
[
'b.name'
]
=
[
'LIKE'
,
'%'
.
$this
->
params
[
'agents_name'
]
.
'%'
];
$join
=
1
;
//连表查询店长名
}
if
(
!
empty
(
$this
->
params
[
'district_id'
]))
{
$where
[
'a.district_id'
]
=
$this
->
params
[
'district_id'
];
}
//店长手机号
if
(
!
empty
(
$this
->
params
[
'agents_phone'
]))
{
$where
[
'b.phone'
]
=
[
'LIKE'
,
$this
->
params
[
'agents_phone'
]
.
'%'
];
$join
=
1
;
//店长姓名
if
(
!
empty
(
$this
->
params
[
'agents_name'
]))
{
$where
[
'b.name'
]
=
[
'LIKE'
,
'%'
.
$this
->
params
[
'agents_name'
]
.
'%'
];
}
//店长手机号
if
(
!
empty
(
$this
->
params
[
'agents_phone'
]))
{
$where
[
'b.phone'
]
=
[
'LIKE'
,
$this
->
params
[
'agents_phone'
]
.
'%'
];
}
$store
=
new
AStore
();
$m_agent
=
new
AAgents
();
$m_district
=
new
ADistrict
();
$list
=
$store
->
getStoreAgentList
(
$pageNo
,
$pageSize
,
'id DESC'
,
$field
,
$where
);
$this
->
data
[
'total'
]
=
$store
->
getStoreAgentListTotal
(
$where
);
$agent_where
[
'level'
]
=
20
;
$status_arr
=
[
0
=>
'正常'
,
1
=>
'长假'
,
2
=>
'离职'
,
3
=>
'转勤'
,
4
=>
'黑名单'
,
5
=>
'冻结'
];
$district_data
=
$m_district
->
getDistrictColumn
(
'id,district_name'
,
[
'status'
=>
0
]);
foreach
(
$list
as
$k
=>
$v
)
{
$list
[
$k
][
'district_name'
]
=
$district_data
[
$v
[
'district_id'
]];
$list
[
$k
][
'agents_total'
]
=
$m_agent
->
getListDistrictTotal
([
'store_id'
=>
$v
[
'id'
],
'level'
=>
10
]);
$agent_where
[
'store_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'
]]
.
'),'
;
}
$store
=
new
AStore
();
$this
->
data
[
'list'
]
=
$store
->
getStoreList
(
$pageNo
,
$pageSize
,
'id DESC'
,
$field
,
$where
,
$join
);
$this
->
data
[
'total'
]
=
$store
->
getStoreListTotal
(
$where
,
$join
);
$return
=
$this
->
response
(
$this
->
code
,
$this
->
msg
,
$this
->
data
);
}
else
{
//总监列表
$return
=
view
(
'index'
);
$list
[
$k
][
'agents_name'
]
=
rtrim
(
$agent_name
,
','
);
}
return
$return
;
$this
->
data
[
'list'
]
=
$list
;
return
$this
->
response
(
$this
->
code
,
$this
->
msg
,
$this
->
data
);
}
/**
...
...
application/model/ADistrict.php
View file @
b2e0da38
...
...
@@ -216,4 +216,14 @@ class ADistrict extends BaseModel
return
$result
;
}
/**
* @param $field
* @param $where
* @return array
*/
public
function
getDistrictColumn
(
$field
,
$where
)
{
return
$this
->
where
(
$where
)
->
column
(
$field
);
}
}
\ No newline at end of file
application/model/AStore.php
View file @
b2e0da38
...
...
@@ -176,6 +176,42 @@ class AStore extends BaseModel
return
$data
;
}
/**
* 门店列表
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getStoreAgentList
(
$pageNo
=
1
,
$pageSize
=
15
,
$order_
=
'id desc'
,
$field
=
''
,
$params
=
''
)
{
return
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'a_agents b'
,
'a.id = b.store_id'
,
'left'
)
->
where
(
$params
)
->
order
(
$order_
)
->
limit
(
$pageSize
)
->
page
(
$pageNo
)
->
select
();
}
/**
* @param string $params
* @return int|string
*/
public
function
getStoreAgentListTotal
(
$params
=
''
)
{
return
$this
->
alias
(
'a'
)
->
join
(
'a_agents b'
,
'a.id = b.store_id'
,
'left'
)
->
where
(
$params
)
->
count
(
'a.id'
);
}
/**
* 门店列表总数
*
...
...
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