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
a61c63be
Commit
a61c63be
authored
Nov 23, 2018
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
业绩日报周报重写
parent
4948c360
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
120 additions
and
24 deletions
+120
-24
Statement.php
application/api_broker/controller/Statement.php
+46
-7
StatementService.php
application/api_broker/service/StatementService.php
+69
-17
route.php
application/route.php
+5
-0
No files found.
application/api_broker/controller/Statement.php
View file @
a61c63be
...
...
@@ -4,6 +4,7 @@ namespace app\api_broker\controller;
use
app\api_broker\extend\Basic
;
use
app\api_broker\service\StatementService
;
use
app\model\AAgents
;
use
app\model\RAgentNote
;
use
app\model\RAgentReport
;
use
think\Exception
;
...
...
@@ -37,11 +38,17 @@ class Statement extends Basic
header
(
'Access-Control-Allow-Origin:*'
);
$params
=
$this
->
params
;
Log
::
write
(
$params
,
'zhuwei'
);
//记录日志
/*$params = array(
"agent_id" => 3742,//5739 总监 5740店长
"time_start" => date("Y-m-d", time()),
"time_end" => date("Y-m-d", time()),
);*/
$params
=
array
(
'agent_id'
=>
'5739'
,
'time_start'
=>
'2018-11-23'
,
'time_end'
=>
'2018-11-23'
,
);
if
(
!
isset
(
$params
[
"agent_id"
])
||
!
isset
(
$params
[
"time_start"
])
||
!
isset
(
$params
[
"time_end"
]))
{
return
$this
->
response
(
"101"
,
"请求参数错误"
);
...
...
@@ -208,20 +215,52 @@ class Statement extends Basic
header
(
'Access-Control-Allow-Origin:*'
);
$params
=
$this
->
params
;
/*$params = array(
"agent_id" => 3742,//5739 总监 5740店长
"time_start" => date("Y-m-d", time()),
"time_end" => date("Y-m-d", time()),
"agent_id" => 5739,//5739 总监 5740店长
"day_or_week" => 0,//0 日报 1 周报
);*/
if
(
!
isset
(
$params
[
"agent_id"
])
||
!
isset
(
$params
[
"time_start"
])
||
!
isset
(
$params
[
"time_end"
]))
{
return
$this
->
response
(
"101"
,
"请求参数错误"
);
}
$day_or_week
=
$params
[
"time_start"
]
==
$params
[
"time_end"
]
?
'day'
:
'week'
;
$time_end
=
$params
[
"time_end"
]
.
" 23:59:59"
;
$result
=
$this
->
service_
->
selectStatementByAgentId
(
$params
[
"agent_id"
],
$params
[
"time_start"
],
$time_end
,
$day_or_week
);
#当前登录人角色 0经纪人 1店长 2总监
$field
=
"id,store_id,district_id,level,name,phone,sex,status"
;
$agentModel
=
new
AAgents
();
$agent_result
=
$agentModel
->
getAgentById
(
$field
,
[
"agent_id"
=>
$params
[
"agent_id"
]
]);
if
(
!
$agent_result
){
return
$this
->
response
(
"200"
,
"request is null"
);
}
if
(
count
(
$result
)
>
0
)
{
$store_id
=
$agent_result
[
0
][
"store_id"
];
$district_id
=
$agent_result
[
0
][
"district_id"
];
if
(
$agent_result
[
0
][
"level"
]
==
10
)
{
//todo 业务员 Clerk
$agent_level
=
0
;
$result
=
$this
->
service_
->
selectStatementForClerk
(
$params
[
"agent_id"
],
$agent_level
,
$store_id
,
$district_id
);
}
elseif
(
$agent_result
[
0
][
"level"
]
==
20
)
{
//todo 1店长
$agent_level
=
1
;
if
(
$params
[
"day_or_week"
]
==
0
){
//todo 日报
}
else
{
//todo 周报
}
}
else
{
//todo 2总监
$agent_level
=
2
;
if
(
$params
[
"day_or_week"
]
==
0
){
//todo 日报
}
else
{
//todo 周报
}
}
if
(
$result
)
{
return
$this
->
response
(
"200"
,
"request success"
,
$result
);
}
else
{
return
$this
->
response
(
"200"
,
"request is null"
);
...
...
application/api_broker/service/StatementService.php
View file @
a61c63be
...
...
@@ -28,6 +28,7 @@ class StatementService
private
$followUpModel
;
private
$reportModel
;
private
$marchInModel
;
private
$bargainModel
;
const
USER_LEVEL_FIST
=
0
;
//经纪人
const
USER_LEVEL_SECOND
=
1
;
//店长
...
...
@@ -42,6 +43,8 @@ class StatementService
$this
->
followUpModel
=
new
FollowUpLogModel
();
$this
->
reportModel
=
new
OReportModel
();
$this
->
marchInModel
=
new
OMarchInModel
();
$this
->
bargainModel
=
new
OBargainModel
();
}
/**
...
...
@@ -143,7 +146,7 @@ class StatementService
$result
[
"agent_total"
]
=
$agent_total
;
$result
[
"house_num"
]
=
$this
->
housesToAgents
->
getAddHouseNumByAgentId
(
$conditions
);
//
dump($conditions);
dump
(
$conditions
);
$result
[
"user_num"
]
=
$this
->
userModel
->
getAddUserNumByAgentId
(
$conditions
);
//dump($conditions);
//本周带看(报备)
...
...
@@ -163,15 +166,15 @@ class StatementService
$where_
[
'create_time'
]
=
array
(
'between'
,
array
(
$start_time
.
" 00:00:00"
,
$end_time
.
" 23:59:59"
)
);
$where_
[
'status'
]
=
array
(
"in"
,
'10, 11, 13, 20'
);
$obargain
=
new
OBargainModel
();
$performanceSum
=
$
obargain
->
getAddBargainNum
(
$where_
,
1
);
//1表示业绩 2表示实收
//
$obargain = new OBargainModel();
$performanceSum
=
$
this
->
bargainModel
->
getAddBargainNum
(
$where_
,
1
);
//1表示业绩 2表示实收
$result
[
"performance_month"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
//本周业绩
$start_time
=
date
(
"Y-m-d"
,
strtotime
(
"-7 day"
));
$where_
[
'create_time'
]
=
$conditions
[
'create_time'
];
$performanceSum
=
$
obargain
->
getAddBargainNum
(
$where_
,
1
);
//1表示业绩 2表示实收
$performanceSum
=
$
this
->
bargainModel
->
getAddBargainNum
(
$where_
,
1
);
//1表示业绩 2表示实收
$result
[
"performance_week"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
//本周客源
...
...
@@ -192,7 +195,7 @@ class StatementService
}
$where_
[
'create_time'
]
=
array
(
'between'
,
array
(
$start_time
.
" 00:00:00"
,
$end_time
.
" 23:59:59"
)
);
$performanceSum
=
$
obargain
->
getAddBargainNumV2
(
$where_
,
3
);
//1表示业绩 2表示实收
$performanceSum
=
$
this
->
bargainModel
->
getAddBargainNumV2
(
$where_
,
3
);
//1表示业绩 2表示实收
//dump($where_);exit;
$result
[
"bargain_sum"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
...
...
@@ -211,7 +214,7 @@ class StatementService
$where_
[
"agent_id"
]
=
array
(
"in"
,
$agentIds
);
}
$where_
[
'create_time'
]
=
array
(
'between'
,
array
(
$start_time
.
" 00:00:00"
,
$end_time
.
" 23:59:59"
)
);
$performanceSum
=
$
obargain
->
getAddBargainNum
(
$where_
,
1
);
//1表示业绩 2表示实收
$performanceSum
=
$
this
->
bargainModel
->
getAddBargainNum
(
$where_
,
1
);
//1表示业绩 2表示实收
$result
[
"performance_day"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
...
...
@@ -229,7 +232,7 @@ class StatementService
$where_
[
"agent_id"
]
=
$agent_id
;
$where_
[
'create_time'
]
=
array
(
'between'
,
array
(
$start_time
.
" 00:00:00"
,
$end_time
.
" 23:59:59"
)
);
// dump($where_);
$performanceSum
=
$
obargain
->
getAddBargainNum
(
$where_
,
3
);
//1表示业绩 2表示实收
$performanceSum
=
$
this
->
bargainModel
->
getAddBargainNum
(
$where_
,
3
);
//1表示业绩 2表示实收
$result
[
"bargain_sum_store"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
...
...
@@ -262,8 +265,8 @@ class StatementService
//$where_["district_id"] = $district_id;
$where_
[
"agent_id"
]
=
$conditions
[
"agent_id"
];
$where_
[
'create_time'
]
=
array
(
'between'
,
array
(
$start_time
.
" 00:00:00"
,
$end_time
.
" 23:59:59"
)
);
$obargain
=
new
OBargainModel
();
$performanceSum
=
$
obargain
->
getAddBargainNum
(
$where_
,
1
);
//1表示业绩 2表示实收
//
$obargain = new OBargainModel();
$performanceSum
=
$
this
->
bargainModel
->
getAddBargainNum
(
$where_
,
1
);
//1表示业绩 2表示实收
$result
[
"director_performance_month"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
//todo 完成单数
...
...
@@ -275,7 +278,7 @@ class StatementService
$where_
[
'create_time'
]
=
array
(
'between'
,
array
(
$start_time
.
" 00:00:00"
,
$end_time
.
" 23:59:59"
)
);
$performanceSum
=
$
obargain
->
getAddBargainNumV2
(
$where_
,
3
);
//1表示业绩 2表示实收
$performanceSum
=
$
this
->
bargainModel
->
getAddBargainNumV2
(
$where_
,
3
);
//1表示业绩 2表示实收
$result
[
"director_bargain_sum_store"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
}
else
{
//周报
...
...
@@ -287,8 +290,8 @@ class StatementService
$where_
[
"agent_id"
]
=
$conditions
[
"agent_id"
];
$where_
[
'create_time'
]
=
array
(
'between'
,
array
(
$start_time
.
" 00:00:00"
,
$end_time
.
" 23:59:59"
)
);
$obargain
=
new
OBargainModel
();
$performanceSum
=
$
obargain
->
getAddBargainNum
(
$where_
,
1
);
//1表示业绩 2表示实收
//
$obargain = new OBargainModel();
$performanceSum
=
$
this
->
bargainModel
->
getAddBargainNum
(
$where_
,
1
);
//1表示业绩 2表示实收
$result
[
"director_performance_month"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
//todo 上周业绩
...
...
@@ -298,9 +301,9 @@ class StatementService
// $where_["district_id"] = $district_id;
$where_
[
"agent_id"
]
=
$conditions
[
"agent_id"
];
$where_
[
'create_time'
]
=
array
(
'between'
,
array
(
$start_time
.
" 00:00:00"
,
$end_time
.
" 23:59:59"
)
);
$obargain
=
new
OBargainModel
();
//
$obargain = new OBargainModel();
$performanceSum
=
$
obargain
->
getAddBargainNum
(
$where_
,
1
);
//1表示业绩 2表示实收
$performanceSum
=
$
this
->
bargainModel
->
getAddBargainNum
(
$where_
,
1
);
//1表示业绩 2表示实收
$result
[
"director_last_week_performance_num"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
//todo 本周周业绩
$where_
=
[];
...
...
@@ -309,9 +312,9 @@ class StatementService
// $where_["district_id"] = $district_id;
$where_
[
"agent_id"
]
=
$conditions
[
"agent_id"
];
$where_
[
'create_time'
]
=
array
(
'between'
,
array
(
$start_time
.
" 00:00:00"
,
$end_time
.
" 23:59:59"
)
);
$obargain
=
new
OBargainModel
();
//
$obargain = new OBargainModel();
$performanceSum
=
$
obargain
->
getAddBargainNum
(
$where_
,
1
);
//1表示业绩 2表示实收
$performanceSum
=
$
this
->
bargainModel
->
getAddBargainNum
(
$where_
,
1
);
//1表示业绩 2表示实收
$result
[
"director_week_performance_num"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
// 本月业绩
//todo 本月完成单数
...
...
@@ -323,7 +326,7 @@ class StatementService
$where_
[
'create_time'
]
=
array
(
'between'
,
array
(
$start_time
.
" 00:00:00"
,
$end_time
.
" 23:59:59"
)
);
$performanceSum
=
$
obargain
->
getAddBargainNumV2
(
$where_
,
3
);
//1表示业绩 2表示实收
$performanceSum
=
$
this
->
bargainModel
->
getAddBargainNumV2
(
$where_
,
3
);
//1表示业绩 2表示实收
$result
[
"director_bargain_sum_store"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
//todo 上周人数
$start_time
=
date
(
"Y-m-d"
,
strtotime
(
"-14 day"
));
...
...
@@ -540,4 +543,52 @@ class StatementService
}
/**
* 查询业务员日报数据
* @param $agent_id
* @param $agent_level
* @param $store_id
* @param $district_id
* user 朱伟
* time 2018-11-23 11:15:02
*/
public
function
selectStatementForClerk
(
$agent_id
,
$agent_level
,
$store_id
,
$district_id
)
{
$start_time
=
date
(
"Y-m-01"
,
time
());
$end_time
=
date
(
"Y-m-d"
,
time
());
$conditions
[
'agent_id'
]
=
$agent_id
;
$conditions
[
'create_time'
]
=
array
(
'between'
,
array
(
$start_time
.
" 00:00:00"
,
$end_time
.
" 23:59:59"
)
);
//todo 房源
$result
[
"house_num"
]
=
$this
->
housesToAgents
->
getAddHouseNumByAgentId
(
$conditions
);
//todo 客源
$result
[
"user_num"
]
=
$this
->
userModel
->
getAddUserNumByAgentId
(
$conditions
);
//todo 带看 (报备)
$addMarchInNum
=
$this
->
marchInModel
->
getAddMarchInNum
(
$conditions
);
$result
[
"follow_up_num"
]
=
isset
(
$addMarchInNum
[
0
][
"num"
])
?
$addMarchInNum
[
0
][
"num"
]
:
0
;
//todo 业绩
$performanceSum
=
$this
->
bargainModel
->
getAddBargainNum
(
$conditions
,
1
);
//1表示业绩 2表示实收
$result
[
"performance"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
//todo 本月-业绩
$start_time
=
date
(
"Y-m-01"
,
time
());
$end_time
=
date
(
"Y-m-d"
,
time
());
$conditions
[
'create_time'
]
=
array
(
'between'
,
array
(
$start_time
.
" 00:00:00"
,
$end_time
.
" 23:59:59"
)
);
$performanceSum
=
$this
->
bargainModel
->
getAddBargainNum
(
$conditions
,
1
);
//1表示业绩 2表示实收
$result
[
"director_performance_month"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
//todo 本月-成交单数
$performanceSum
=
$this
->
bargainModel
->
getAddBargainNumV2
(
$conditions
,
3
);
//1表示业绩 2表示实收
//dump($where_);exit;
$result
[
"bargain_sum"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
return
$result
;
}
}
\ No newline at end of file
application/route.php
View file @
a61c63be
...
...
@@ -706,6 +706,10 @@ Route::group('broker', [
'getVolume'
=>
[
'api_broker/SpreadUser/getVolume'
,
[
'method'
=>
'get'
]
],
'getHouseAddress'
=>
[
'api_broker/shop/getHouseAddress'
,
[
'method'
=>
'get'
]
]
//搜索商铺地址
//业绩日报周报重写
'dayStatement'
=>
[
'api_broker/Statement/dayStatement'
,
[
'method'
=>
'get|post'
]],
]);
//Route::miss('api/index/miss');//处理错误的url
\ 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