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
87f283ae
Commit
87f283ae
authored
Nov 27, 2018
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
周报日报重写
parent
dcbd7678
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
117 additions
and
12 deletions
+117
-12
Statement.php
application/api_broker/controller/Statement.php
+3
-9
StatementService.php
application/api_broker/service/StatementService.php
+103
-2
AAgents.php
application/model/AAgents.php
+11
-1
No files found.
application/api_broker/controller/Statement.php
View file @
87f283ae
...
...
@@ -38,17 +38,11 @@ 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"
,
"请求参数错误"
);
...
...
@@ -216,7 +210,7 @@ class Statement extends Basic
$params
=
$this
->
params
;
$params
=
array
(
"agent_id"
=>
5741
,
//5739 总监 5740店长 5741总监
"type"
=>
0
,
//0 日报 1 周报
"type"
=>
1
,
//0 日报 1 周报
);
if
(
!
isset
(
$params
[
"agent_id"
])
||
!
isset
(
$params
[
"type"
])
)
{
...
...
@@ -251,8 +245,8 @@ class Statement extends Basic
$agent_level
=
2
;
if
(
$params
[
"type"
]
==
0
){
//日报
$result
=
$this
->
service_
->
selectStatementForDistrictWithDay
(
$params
[
"agent_id"
],
$agent_level
,
$store_id
,
$district_id
);
}
else
{
//
todo
周报
}
else
{
// 周报
$result
=
$this
->
service_
->
selectStatementForDistrictWithWeek
(
$params
[
"agent_id"
],
$agent_level
,
$store_id
,
$district_id
);
}
}
...
...
application/api_broker/service/StatementService.php
View file @
87f283ae
...
...
@@ -445,8 +445,9 @@ class StatementService
$conditions_
=
$conditions
;
$conditions_
[
"district_id"
]
=
$district_id
;
//本周人数
$results
=
$this
->
agentModel
->
countAgentNum
(
$conditions_
);
//dump($results);
$last_week_total
=
0
;
foreach
(
$results
as
$key
=>
$value
)
{
...
...
@@ -781,11 +782,111 @@ class StatementService
* @param $agent_level
* @param $store_id
* @param $district_id
* @return mixed
*/
public
function
selectStatementForDistrictWithWeek
(
$agent_id
,
$agent_level
,
$store_id
,
$district_id
)
{
//todo
$agent_res
=
$this
->
getAgentIDsByDistrictId
(
$district_id
,
$agent_level
);
$conditions
[
'agent_id'
]
=
array
(
"in"
,
$agent_res
[
'agent_ids'
]
);
/*上周时间*/
$start_time
=
date
(
"Y-m-d"
,
strtotime
(
"-14 day"
));
$end_time
=
date
(
"Y-m-d"
,
strtotime
(
"-7 day"
));
$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
[
"performance_for_last_week"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
// 上周人数
$params
[
'id'
]
=
array
(
"in"
,
$agent_res
[
'agent_ids'
]
);
$params
[
'create_time'
]
=
$conditions
[
'create_time'
]
;
$agentsCount
=
$this
->
agentModel
->
getAgentsCountByStoreId
(
$params
);
$result
[
"district_team_num_for_last_week"
]
=
isset
(
$agentsCount
)
?
$agentsCount
:
0
;
/*本周时间*/
$start_time
=
date
(
"Y-m-d"
,
strtotime
(
"-7 day"
));
$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
[
"performance_for_week"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
// 本周人数
$params
[
'id'
]
=
array
(
"in"
,
$agent_res
[
'agent_ids'
]
);
$params
[
'create_time'
]
=
$conditions
[
'create_time'
]
;
$agentsCount
=
$this
->
agentModel
->
getAgentsCountByStoreId
(
$params
);
$result
[
"district_team_num_for_week"
]
=
isset
(
$agentsCount
)
?
$agentsCount
:
0
;
/*本月时间*/
$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
[
"performance_for_month"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
// 本月完成单数
$performanceSum
=
$this
->
bargainModel
->
getAddBargainNumV2
(
$conditions
,
3
);
//1表示业绩 2表示实收
$result
[
"bargain_sum_for_month"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
/**查询总监旗下门店数据**/
$conditions_
[
"a.district_id"
]
=
$district_id
;
$conditions_
[
"a.level"
]
=
array
(
"in"
,
[
20
,
40
]
);
$conditions_
[
"a.status"
]
=
0
;
$agent_res
=
$this
->
agentModel
->
getAgentsByStoreIdV2
(
$conditions_
);
foreach
(
$agent_res
as
$k
=>
$v
)
{
$district_list
[
'store_id'
]
=
$v
[
'store_id'
];
$district_list
[
'name'
]
=
$v
[
'name'
];
$district_list
[
'store_name'
]
=
$v
[
'store_name'
];
$agent_res
=
$this
->
getAgentIDsByDistrictId
(
$v
[
'store_id'
],
1
);
$conditions
[
'agent_id'
]
=
array
(
"in"
,
$agent_res
[
'agent_ids'
]
);
/*上周时间*/
$start_time
=
date
(
"Y-m-d"
,
strtotime
(
"-14 day"
));
$end_time
=
date
(
"Y-m-d"
,
strtotime
(
"-7 day"
));
$conditions
[
'create_time'
]
=
array
(
'between'
,
array
(
$start_time
.
" 00:00:00"
,
$end_time
.
" 23:59:59"
)
);
// 上周业绩
$performanceSum
=
$this
->
bargainModel
->
getAddBargainNum
(
$conditions
,
1
);
//1表示业绩 2表示实收
$district_list
[
"performance_for_last_week"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
// 上周人数
$params
[
'id'
]
=
array
(
"in"
,
$agent_res
[
'agent_ids'
]
);
$params
[
'create_time'
]
=
$conditions
[
'create_time'
]
;
$agentsCount
=
$this
->
agentModel
->
getAgentsCountByStoreId
(
$params
);
$district_list
[
"team_num_for_last_week"
]
=
isset
(
$agentsCount
)
?
$agentsCount
:
0
;
/*本周时间*/
$start_time
=
date
(
"Y-m-d"
,
strtotime
(
"-7 day"
));
$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表示实收
$district_list
[
"performance_for_week"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
// 本周人数
$params
[
'id'
]
=
array
(
"in"
,
$agent_res
[
'agent_ids'
]
);
$params
[
'create_time'
]
=
$conditions
[
'create_time'
]
;
$agentsCount
=
$this
->
agentModel
->
getAgentsCountByStoreId
(
$params
);
$district_list
[
"team_num_for_week"
]
=
isset
(
$agentsCount
)
?
$agentsCount
:
0
;
/*本月时间*/
$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表示实收
$district_list
[
"performance_for_month"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
// 本月完成单数
$performanceSum
=
$this
->
bargainModel
->
getAddBargainNumV2
(
$conditions
,
3
);
//1表示业绩 2表示实收
$district_list
[
"bargain_sum_for_month"
]
=
isset
(
$performanceSum
[
0
][
"num"
])
?
$performanceSum
[
0
][
"num"
]
:
0
;
$district_list_
[]
=
$district_list
;
}
$result
[
"district_list"
]
=
$district_list_
;
return
$result
;
}
/**
...
...
application/model/AAgents.php
View file @
87f283ae
...
...
@@ -488,11 +488,21 @@ class AAgents extends BaseModel
->
field
(
"id,name,status"
)
->
where
(
$params
)
->
select
();
//echo Db::table($this->table)->getLastSql();
//dump($this->getLastSql());
return
$result
;
}
public
function
getAgentsByStoreIdV2
(
$params
)
{
$result
=
Db
::
table
(
$this
->
table
)
->
alias
(
"a"
)
->
field
(
"a.id,a.name,a.status,a.store_id,b.store_name"
)
->
join
(
"a_store b"
,
"a.store_id=b.id"
,
"left"
)
->
where
(
$params
)
->
select
();
//dump($this->getLastSql());
return
$result
;
}
/**
* @param $params
* @return false|\PDOStatement|string|\think\Collection
...
...
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