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
9bd8fd70
Commit
9bd8fd70
authored
Dec 03, 2018
by
zw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化下分区代码
parent
4a1d1177
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
55 deletions
+47
-55
RankingList.php
application/index/controller/RankingList.php
+17
-2
RankingListService.php
application/index/service/RankingListService.php
+30
-53
No files found.
application/index/controller/RankingList.php
View file @
9bd8fd70
...
...
@@ -25,6 +25,9 @@ class RankingList extends Basic{
/**
* 查询分区业绩pk
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getRandKingList
(){
$params
=
$this
->
params
;
...
...
@@ -40,9 +43,12 @@ class RankingList extends Basic{
return
$this
->
response
(
"200"
,
"request null"
);
}
/**
*
门店业绩pk
/**
门店业绩pk
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getStoreRandKingList
(){
$params
=
$this
->
params
;
...
...
@@ -57,6 +63,9 @@ class RankingList extends Basic{
/**
* 导出分区pk榜
* @return string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
exportReport
(){
$params
=
$this
->
params
;
...
...
@@ -73,6 +82,9 @@ class RankingList extends Basic{
/**
* 导出门店pk榜
* @return string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
exportReportStore
(){
$params
=
$this
->
params
;
...
...
@@ -89,6 +101,9 @@ class RankingList extends Basic{
/**
* pk榜门店业绩和个人业绩排序显示前五
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
selectPkSortByTime
()
{
...
...
application/index/service/RankingListService.php
View file @
9bd8fd70
...
...
@@ -58,38 +58,7 @@ class RankingListService
}
//分组
$total
=
count
(
$resultArr
);
$total_page
=
floor
(
$total
/
$this
->
crewNum
);
$residue
=
$total
%
$this
->
crewNum
;
$full
=
$total_page
*
(
$this
->
crewNumMax
-
$this
->
crewNum
);
$x
=
$this
->
crewNum
;
$y
=
$total_page
;
if
(
$full
<
$residue
)
{
$y
=
$y
+
1
;
}
else
{
$x
=
ceil
(
$residue
/
$total_page
)
+
$this
->
crewNum
;
}
$result
=
[];
$i
=
0
;
$k
=
0
;
foreach
(
$resultArr
as
$key
=>
$item
)
{
$result
[
$i
][
$k
++
]
=
$item
;
if
(
$y
==
$total_page
)
{
if
((
$k
==
$x
-
1
)
&&
(
$residue
%
$total_page
)
>
0
&&
(
$i
+
1
)
<=
(
$total_page
-
(
$residue
%
$total_page
)))
{
$k
=
0
;
++
$i
;
}
elseif
(
$k
==
$x
)
{
$k
=
0
;
++
$i
;
}
}
else
{
if
(
$k
==
$x
)
{
$k
=
0
;
++
$i
;
}
}
}
$result
=
$this
->
group
(
$resultArr
);
//循环分组后的数组,查询出各组本月业绩排行
//本月
...
...
@@ -116,25 +85,10 @@ class RankingListService
}
/**
* 门店业绩排行
* @param $siteId
* @param $resultArr
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
StoreRankingList
(
$siteId
){
$begin_time
=
date
(
'Y-m-01 00:00:00'
,
strtotime
(
'-1 month'
));
$end_time
=
date
(
"Y-m-d 23:59:59"
,
strtotime
(
-
date
(
'd'
)
.
'day'
));
$params
[
"a.site_id"
]
=
$siteId
;
$params
[
"a.status"
]
=
0
;
$params
[
'b.total_time'
]
=
array
(
'between'
,
array
(
$begin_time
,
$end_time
));
$resultArr
=
$this
->
getStoreSort
(
$params
,
$begin_time
,
$end_time
,
""
);
if
(
count
(
$resultArr
)
<=
0
)
{
return
false
;
}
private
function
group
(
$resultArr
){
//分组
$total
=
count
(
$resultArr
);
$total_page
=
floor
(
$total
/
$this
->
crewNum
);
...
...
@@ -147,7 +101,6 @@ class RankingListService
}
else
{
$x
=
ceil
(
$residue
/
$total_page
)
+
$this
->
crewNum
;
}
$result
=
[];
$i
=
0
;
$k
=
0
;
...
...
@@ -169,6 +122,31 @@ class RankingListService
}
}
}
return
$result
;
}
/**
* 门店业绩排行
* @param $siteId
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
StoreRankingList
(
$siteId
){
$begin_time
=
date
(
'Y-m-01 00:00:00'
,
strtotime
(
'-1 month'
));
$end_time
=
date
(
"Y-m-d 23:59:59"
,
strtotime
(
-
date
(
'd'
)
.
'day'
));
$params
[
"a.site_id"
]
=
$siteId
;
$params
[
"a.status"
]
=
0
;
$params
[
'b.total_time'
]
=
array
(
'between'
,
array
(
$begin_time
,
$end_time
));
$resultArr
=
$this
->
getStoreSort
(
$params
,
$begin_time
,
$end_time
,
""
);
if
(
count
(
$resultArr
)
<=
0
)
{
return
false
;
}
//分组
$result
=
$this
->
group
(
$resultArr
);
//循环分组后的数组,查询出各组本月业绩排行
//本月
...
...
@@ -202,7 +180,7 @@ class RankingListService
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
p
ublic
function
getStoreSort
(
$params
,
$begin_time
,
$end_time
,
$ids
)
p
rivate
function
getStoreSort
(
$params
,
$begin_time
,
$end_time
,
$ids
)
{
$storeModel
=
new
AStore
();
$fields
=
"a.id,a.store_name,SUM(b.performance) as performance"
;
...
...
@@ -225,7 +203,7 @@ class RankingListService
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
p
ublic
function
getSort
(
$params
,
$begin_time
,
$end_time
,
$ids
)
p
rivate
function
getSort
(
$params
,
$begin_time
,
$end_time
,
$ids
)
{
$fields
=
"a.id,c.store_name,a.name,a.phone,SUM(b.performance) as performance"
;
//查询出有业绩的经纪人
...
...
@@ -265,7 +243,6 @@ class RankingListService
foreach
(
$store_sort
as
$key
=>
$value
)
{
$store_arr
=
$this
->
agentModel
->
getStoreOrDistrict
([
"store_id"
=>
$value
[
"store_id"
],
"level"
=>
[
"in"
,
"20"
]]);
if
(
count
(
$store_arr
)
>
0
)
{
//$value["name"] = count($store_arr) > 0 ? $store_arr[0]["name"] : "---";
$store_sort
[
$key
][
"img"
]
=
$store_arr
[
0
][
"img"
];
}
}
...
...
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