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
dcdc6ee9
Commit
dcdc6ee9
authored
Feb 06, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
门店列表和搜索
parent
ecccbecf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
8 deletions
+92
-8
Store.php
application/index/controller/Store.php
+40
-8
AStore.php
application/model/AStore.php
+52
-0
No files found.
application/index/controller/Store.php
View file @
dcdc6ee9
...
@@ -17,15 +17,49 @@ class Store extends Basic
...
@@ -17,15 +17,49 @@ class Store extends Basic
protected
$data
;
protected
$data
;
protected
$code
=
200
;
protected
$code
=
200
;
protected
$msg
=
''
;
protected
$msg
=
''
;
/**
/**
* @return \think\response\View
* 门店列表
*
* @return string|\think\response\View
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
*/
public
function
index
()
{
public
function
index
()
{
$result
[
'code'
]
=
200
;
$result
[
'msg'
]
=
''
;
if
(
$this
->
request
->
isAjax
())
{
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
;
//门店名
if
(
!
empty
(
$this
->
params
[
'store_name'
]))
{
$where
[
'store_name'
]
=
[
'LIKE'
,
$this
->
params
[
'store_name'
]
.
'%'
];
}
if
(
!
empty
(
$this
->
params
[
'city'
]))
{
$where
[
'city'
]
=
$this
->
params
[
'city'
];
}
if
(
!
empty
(
$this
->
params
[
'district'
]))
{
$where
[
'district'
]
=
$this
->
params
[
'district'
];
}
//店长姓名
if
(
!
empty
(
$this
->
params
[
'agents_name'
]))
{
$where
[
'b.name'
]
=
[
'LIKE'
,
$this
->
params
[
'agents_name'
]
.
'%'
];
$join
=
1
;
//连表查询店长名
}
//店长手机号
if
(
!
empty
(
$this
->
params
[
'agents_phone'
]))
{
$where
[
'b.phone'
]
=
[
'LIKE'
,
$this
->
params
[
'agents_phone'
]
.
'%'
];
$join
=
1
;
}
$store
=
new
AStore
();
$this
->
data
=
$this
->
data
=
$store
->
getStoreList
(
$pageNo
,
$pageSize
,
'id DESC'
,
$field
,
$where
,
$join
);
$return
=
$this
->
response
(
$this
->
code
,
$this
->
msg
,
$this
->
data
);
}
else
{
}
else
{
//总监列表
//总监列表
$return
=
view
(
'index'
);
$return
=
view
(
'index'
);
...
@@ -37,10 +71,8 @@ class Store extends Basic
...
@@ -37,10 +71,8 @@ class Store extends Basic
* 添加门店
* 添加门店
*
*
* @return \think\Response
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \Exception
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\PDOException3
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
*/
public
function
addStore
()
{
public
function
addStore
()
{
$district
=
new
AStore
();
$district
=
new
AStore
();
...
...
application/model/AStore.php
View file @
dcdc6ee9
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
namespace
app\model
;
namespace
app\model
;
use
think\Db
;
class
AStore
extends
BaseModel
class
AStore
extends
BaseModel
{
{
/**
/**
...
@@ -79,4 +81,53 @@ class AStore extends BaseModel
...
@@ -79,4 +81,53 @@ class AStore extends BaseModel
$data
[
'agents_name'
]
=
$agents_name
[
'name'
]
.
'-'
.
$agents_name
[
'phone'
];
$data
[
'agents_name'
]
=
$agents_name
[
'name'
]
.
'-'
.
$agents_name
[
'phone'
];
return
$data
;
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
getStoreList
(
$pageNo
=
1
,
$pageSize
=
15
,
$order_
=
'id desc'
,
$field
=
''
,
$params
=
''
,
$join
=
0
){
$data
=
array
();
if
(
$join
)
{
$field
.=
',b.name,b.phone'
;
$where
[
'b.status'
]
=
0
;
$where
[
'b.level'
]
=
20
;
$store_data
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'a_agents b'
,
'a.id=b.store_id'
,
'left'
)
->
where
(
$params
)
->
order
(
$order_
)
->
limit
(
$pageSize
)
->
page
(
$pageNo
)
->
select
();
foreach
(
$store_data
as
$k
=>
$v
)
{
$data
[
$k
]
=
$v
;
$data
[
$k
][
'district_name'
]
=
Db
::
table
(
'a_district'
)
->
where
(
'id'
,
$v
[
'district_id'
])
->
value
(
'district_name'
);
$data
[
$k
][
'agents_name'
]
=
$v
[
'name'
]
.
'-'
.
$v
[
'phone'
];
$data
[
$k
][
'agents_total'
]
=
Db
::
table
(
'a_agents'
)
->
where
([
'status'
=>
0
,
'store_id'
=>
$v
[
'id'
]])
->
count
();
}
}
else
{
$store_data
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
where
(
$params
)
->
order
(
$order_
)
->
limit
(
$pageSize
)
->
page
(
$pageNo
)
->
select
();
foreach
(
$store_data
as
$k
=>
$v
)
{
$data
[
$k
]
=
$v
;
$data
[
$k
][
'district_name'
]
=
Db
::
table
(
'a_district'
)
->
where
(
'id'
,
$v
->
district_id
)
->
value
(
'district_name'
);
$data
[
$k
][
'agents_name'
]
=
Db
::
table
(
'a_agents'
)
->
field
(
'concat_ws("-",name,phone) as name'
)
->
where
([
'status'
=>
0
,
'level'
=>
20
,
'store_id'
=>
$v
->
id
])
->
find
();
$data
[
$k
][
'agents_name'
]
=
$data
[
$k
][
'agents_name'
][
'name'
]
?
$data
[
$k
][
'agents_name'
][
'name'
]
:
""
;
$data
[
$k
][
'agents_total'
]
=
Db
::
table
(
'a_agents'
)
->
where
([
'status'
=>
0
,
'store_id'
=>
$v
->
id
])
->
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