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
71a8c772
Commit
71a8c772
authored
Apr 01, 2018
by
zw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日报周报
parent
f2a7055c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
33 deletions
+114
-33
Statement.php
application/api_broker/controller/Statement.php
+5
-5
StatementService.php
application/api_broker/service/StatementService.php
+78
-26
AAgents.php
application/model/AAgents.php
+31
-2
No files found.
application/api_broker/controller/Statement.php
View file @
71a8c772
...
@@ -31,11 +31,11 @@ class Statement extends Basic
...
@@ -31,11 +31,11 @@ class Statement extends Basic
{
{
header
(
'Access-Control-Allow-Origin:*'
);
header
(
'Access-Control-Allow-Origin:*'
);
$params
=
$this
->
params
;
$params
=
$this
->
params
;
/*
$params = array(
/*$params = array(
"agent_id" => 1
,
"agent_id" => 3
,
"time_start" => date("Y-m-d", time()),
"time_start" => date("Y-m-d", time()),
"time_end" => date("Y-m-d", time()) . " 23:59:59",
"time_end" => date("Y-m-d", time()) . " 23:59:59",
);*/
);*/
if
(
!
isset
(
$params
[
"agent_id"
])
||
!
isset
(
$params
[
"time_start"
])
||
!
isset
(
$params
[
"time_end"
]))
{
if
(
!
isset
(
$params
[
"agent_id"
])
||
!
isset
(
$params
[
"time_start"
])
||
!
isset
(
$params
[
"time_end"
]))
{
return
$this
->
response
(
"101"
,
"请求参数错误"
);
return
$this
->
response
(
"101"
,
"请求参数错误"
);
}
}
...
...
application/api_broker/service/StatementService.php
View file @
71a8c772
<?php
<?php
namespace
app\api_broker\service
;
namespace
app\api_broker\service
;
use
app\model\AAgents
;
use
app\model\AAgents
;
use
app\model\FollowUpLogModel
;
use
app\model\FollowUpLogModel
;
use
app\model\GHouses
;
use
app\model\GHouses
;
...
@@ -12,7 +14,8 @@ use app\model\Users;
...
@@ -12,7 +14,8 @@ use app\model\Users;
* Time : 上午11:33
* Time : 上午11:33
* Intro:
* Intro:
*/
*/
class
StatementService
{
class
StatementService
{
private
$agentModel
;
private
$agentModel
;
private
$houseModel
;
private
$houseModel
;
...
@@ -25,9 +28,9 @@ class StatementService {
...
@@ -25,9 +28,9 @@ class StatementService {
function
__construct
()
function
__construct
()
{
{
$this
->
agentModel
=
new
AAgents
();
$this
->
agentModel
=
new
AAgents
();
$this
->
houseModel
=
new
GHouses
();
$this
->
houseModel
=
new
GHouses
();
$this
->
userModel
=
new
Users
();
$this
->
userModel
=
new
Users
();
$this
->
followUpModel
=
new
FollowUpLogModel
();
$this
->
followUpModel
=
new
FollowUpLogModel
();
}
}
...
@@ -40,36 +43,37 @@ class StatementService {
...
@@ -40,36 +43,37 @@ class StatementService {
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
selectStatementByAgentId
(
$agent_id
,
$time_start
,
$time_end
){
public
function
selectStatementByAgentId
(
$agent_id
,
$time_start
,
$time_end
)
{
$field
=
"id,store_id,district_id,level,name,phone,sex,status"
;
$field
=
"id,store_id,district_id,level,name,phone,sex,status"
;
$agent_result
=
$this
->
agentModel
->
getAgentById
(
$field
,
$agent_id
);
$agent_result
=
$this
->
agentModel
->
getAgentById
(
$field
,
[
"agent_id"
=>
$agent_id
]
);
if
(
count
(
$agent_result
)
<=
0
)
{
if
(
count
(
$agent_result
)
<=
0
)
{
return
null
;
return
null
;
}
}
$user_type
=
self
::
USER_LEVEL_FIST
;
//经纪人权限,0经纪人 1店长 2总监
$user_type
=
self
::
USER_LEVEL_FIST
;
//经纪人权限,0经纪人 1店长 2总监
if
(
$agent_result
[
0
][
"level"
]
==
20
)
{
if
(
$agent_result
[
0
][
"level"
]
==
20
){
$user_type
=
self
::
USER_LEVEL_SECOND
;
$user_type
=
self
::
USER_LEVEL_SECOND
;
}
elseif
(
$agent_result
[
0
][
"level"
]
==
30
||
$agent_result
[
0
][
"level"
]
==
40
)
{
}
elseif
(
$agent_result
[
0
][
"level"
]
==
30
||
$agent_result
[
0
][
"level"
]
==
40
)
{
$user_type
=
self
::
USER_LEVEL_THIRD
;
$user_type
=
self
::
USER_LEVEL_THIRD
;
}
}
$store_id
=
$agent_result
[
0
][
"store_id"
];
$store_id
=
$agent_result
[
0
][
"store_id"
];
$district_id
=
$agent_result
[
0
][
"district_id"
];
$district_id
=
$agent_result
[
0
][
"district_id"
];
$conditions
[
"agent_id"
]
=
$agent_id
;
$conditions
[
"agent_id"
]
=
$agent_id
;
$conditions
[
'create_time'
]
=
array
(
'between'
,
array
(
$time_start
,
$time_end
)
);
$conditions
[
'create_time'
]
=
array
(
'between'
,
array
(
$time_start
,
$time_end
)
);
return
$this
->
selectStatement
(
$conditions
,
$user_type
,
$store_id
,
$district_id
);
return
$this
->
selectStatement
(
$conditions
,
$user_type
,
$store_id
,
$district_id
);
}
}
private
function
selectStatement
(
$conditions
,
$user_type
,
$store_id
,
$district_id
){
private
function
selectStatement
(
$conditions
,
$user_type
,
$store_id
,
$district_id
)
{
$result
=
$params
=
[];
$result
=
$params
=
[];
switch
(
$user_type
){
switch
(
$user_type
)
{
case
0
:
case
0
:
//todo
//todo
break
;
break
;
...
@@ -80,34 +84,81 @@ class StatementService {
...
@@ -80,34 +84,81 @@ class StatementService {
break
;
break
;
case
2
:
case
2
:
$params
[
"district_id"
]
=
$district_id
;
$params
[
"district_id"
]
=
$district_id
;
$params
[
"status"
]
=
0
;
//只查询正常状态的经纪人
$params
[
"status"
]
=
0
;
//只查询正常状态的经纪人
break
;
break
;
}
}
$agent_total
=
1
;
//进到这里的经纪人肯定都存在所以默认此经纪人数量为1
$agent_total
=
1
;
//进到这里的经纪人肯定都存在所以默认此经纪人数量为1
if
(
!
empty
(
$params
)){
$store_list
=
$district_list
=
[];
$agentsArr
=
$this
->
agentModel
->
getAgentsByStoreId
(
$params
);
if
(
!
empty
(
$params
))
{
$agentsArr
=
$this
->
agentModel
->
getAgentsByStoreId
(
$params
);
$agent_total
=
count
(
$agentsArr
);
$agent_total
=
count
(
$agentsArr
);
//dump($agentsArr);
if
(
$agent_total
>
0
)
{
if
(
$agent_total
>
0
)
{
$agentIds
=
""
;
$agentIds
=
""
;
foreach
(
$agentsArr
as
$key
=>
$value
){
foreach
(
$agentsArr
as
$key
=>
$value
)
{
$agentIds
.=
$value
[
"id"
]
.
","
;
$agentIds
.=
$value
[
"id"
]
.
","
;
if
(
$user_type
==
1
)
{
$store_list
=
$this
->
getStoreList
(
$conditions
,
$value
[
"id"
],
$value
[
"name"
],
$key
);
}
}
$agentIds
=
rtrim
(
$agentIds
,
","
);
$conditions
[
"agent_id"
]
=
array
(
"in"
,
$agentIds
);
if
(
$user_type
==
2
){
$district_lists
=
$this
->
getDistrictList
(
$conditions
,
$district_id
);
$district_list
=
$district_lists
[
"district_list"
];
$result
[
"last_week_total"
]
=
$district_lists
[
"last_week_total"
];
}
}
$agentIds
=
rtrim
(
$agentIds
,
","
);
$conditions
[
"agent_id"
]
=
array
(
"in"
,
$agentIds
);
}
}
}
}
$result
[
"agent_total"
]
=
$agent_total
;
$result
[
"agent_total"
]
=
$agent_total
;
$result
[
"house_num"
]
=
$this
->
houseModel
->
getAddHouseNumByAgentId
(
$conditions
);
$result
[
"house_num"
]
=
$this
->
houseModel
->
getAddHouseNumByAgentId
(
$conditions
);
$result
[
"user_num"
]
=
$this
->
userModel
->
getAddUserNumByAgentId
(
$conditions
);
$result
[
"user_num"
]
=
$this
->
userModel
->
getAddUserNumByAgentId
(
$conditions
);
$result
[
"follow_up_num"
]
=
$this
->
followUpModel
->
getAddFollowUpNumByAgentId
(
$conditions
);
$result
[
"follow_up_num"
]
=
$this
->
followUpModel
->
getAddFollowUpNumByAgentId
(
$conditions
);
//todo
$result
[
"store_list"
]
=
$store_list
;
$result
[
"district_list"
]
=
$district_list
;
return
$result
;
return
$result
;
}
}
private
function
getStoreList
(
$conditions
,
$agent_id
,
$agent_name
,
$key
){
$conditions_
=
$conditions
;
$conditions_
[
"agent_id"
]
=
$agent_id
;
//是门店 统计个人业绩
$store_list
[
$key
][
"agent_id"
]
=
$agent_id
;
$store_list
[
$key
][
"agent_name"
]
=
$agent_name
;
$store_list
[
$key
][
"house_num"
]
=
$this
->
houseModel
->
getAddHouseNumByAgentId
(
$conditions_
);
$store_list
[
$key
][
"user_num"
]
=
$this
->
userModel
->
getAddUserNumByAgentId
(
$conditions_
);
$store_list
[
$key
][
"follow_up_num"
]
=
$this
->
followUpModel
->
getAddFollowUpNumByAgentId
(
$conditions_
);
return
$store_list
;
}
private
function
getDistrictList
(
$conditions
,
$district_id
){
//根据门店统计本周人数和上周人数
$time_start
=
$conditions
[
'time_start'
];
$last_week_start_time
=
date
(
"Y-m-d"
.
" 00:00:00"
,
strtotime
(
"
$time_start
-1 week"
));
$last_week_end_time
=
date
(
"Y-m-d"
.
" 23:59:59"
,
strtotime
(
"
$time_start
-1 day"
));
$where_
[
"quit_time"
]
=
array
(
'between'
,
array
(
$last_week_start_time
,
$last_week_end_time
)
);
$where_
[
"district_id"
]
=
$district_id
;
$result
=
$this
->
agentModel
->
countAgentNum
(
$where_
);
$last_week_total
=
0
;
foreach
(
$result
as
$key
=>
$value
){
$last_week_total
+=
$value
[
"agent_num"
];
$paramArr
[
"store_id"
]
=
$value
[
"store_id"
];
$paramArr
[
"level"
]
=
array
(
"in"
,[
20
,
40
]);
$agentsResult
=
$this
->
agentModel
->
getAgentsByStoreId
(
$paramArr
);
$result
[
$key
][
"name"
]
=
count
(
$agentsResult
)
>
0
?
$agentsResult
[
0
][
"name"
]
:
null
;
}
$district_list
[
"last_week_total"
]
=
$last_week_total
;
$district_list
[
"district_list"
]
=
$result
;
return
$district_list
;
}
}
}
\ No newline at end of file
application/model/AAgents.php
View file @
71a8c772
...
@@ -286,9 +286,11 @@ class AAgents extends BaseModel
...
@@ -286,9 +286,11 @@ class AAgents extends BaseModel
$where_
[
"id"
]
=
$params
[
"agent_id"
];
$where_
[
"id"
]
=
$params
[
"agent_id"
];
}
}
return
$this
->
field
(
$field
)
$result
=
$this
->
field
(
$field
)
->
where
(
$where_
)
->
where
(
$where_
)
->
select
();
->
select
();
// echo $this->getLastSql();
return
$result
;
}
}
/**
/**
...
@@ -385,13 +387,40 @@ class AAgents extends BaseModel
...
@@ -385,13 +387,40 @@ class AAgents extends BaseModel
public
function
getAgentsByStoreId
(
$params
)
public
function
getAgentsByStoreId
(
$params
)
{
{
$result
=
Db
::
table
(
$this
->
table
)
$result
=
Db
::
table
(
$this
->
table
)
->
field
(
"id"
)
->
field
(
"id
,name
"
)
->
where
(
$params
)
->
where
(
$params
)
->
select
();
->
select
();
//echo Db::table($this->table)->getLastSql();
//echo Db::table($this->table)->getLastSql();
return
$result
;
return
$result
;
}
}
public
function
countAgentNum
(
$params
){
$where_
=
$whereOr_
=
[];
if
(
isset
(
$params
[
"quit_time"
])){
$whereOr_
[
"a.quit_time"
]
=
$params
[
"quit_time"
];
$whereOr_
[
"a.status"
]
=
3
;
}
if
(
isset
(
$params
[
"district_id"
])){
$where_
[
"a.district_id"
]
=
$params
[
"district_id"
];
$where_
[
"a.status"
]
=
0
;
}
$result
=
Db
::
table
(
$this
->
table
)
->
field
(
"a.id,a.store_id ,b.store_name,count(a.id) as agent_num"
)
->
alias
(
"a"
)
->
join
(
"a_store b"
,
"a.store_id = b.id"
,
"left"
)
->
where
(
$where_
)
->
whereOr
(
function
(
$query
)
use
(
$whereOr_
)
{
$query
->
where
(
$whereOr_
);
})
->
group
(
"a.store_id"
)
->
select
();
// echo Db::table($this->table)->getLastSql();
return
$result
;
}
public
function
getAgentsInfoByAgentId
(
$field
,
$params
)
public
function
getAgentsInfoByAgentId
(
$field
,
$params
)
{
{
$where_
=
[];
$where_
=
[];
...
...
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