Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
youjj
cloud-platform
Commits
164b5c08
Commit
164b5c08
authored
Nov 27, 2019
by
libin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'staff-statistics' into dev
parents
146b16c0
f5e83a5b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
22 deletions
+34
-22
StaffStatisticsBiz.java
...github/wxiaoqi/security/admin/biz/StaffStatisticsBiz.java
+34
-22
No files found.
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/biz/StaffStatisticsBiz.java
View file @
164b5c08
...
@@ -10,6 +10,7 @@ import com.github.wxiaoqi.security.admin.dto.StaffStatisticsFindDTO;
...
@@ -10,6 +10,7 @@ import com.github.wxiaoqi.security.admin.dto.StaffStatisticsFindDTO;
import
com.github.wxiaoqi.security.admin.vo.WalletPostionVo
;
import
com.github.wxiaoqi.security.admin.vo.WalletPostionVo
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.github.wxiaoqi.security.common.vo.PageDataVO
;
import
com.github.wxiaoqi.security.common.vo.PageDataVO
;
import
com.google.common.collect.Lists
;
import
com.xxfc.platform.order.contant.enumerate.StatisticsStatusEnum
;
import
com.xxfc.platform.order.contant.enumerate.StatisticsStatusEnum
;
import
com.xxfc.platform.order.feign.OrderFeign
;
import
com.xxfc.platform.order.feign.OrderFeign
;
import
com.xxfc.platform.order.pojo.dto.OrderDTO
;
import
com.xxfc.platform.order.pojo.dto.OrderDTO
;
...
@@ -250,7 +251,7 @@ public class StaffStatisticsBiz {
...
@@ -250,7 +251,7 @@ public class StaffStatisticsBiz {
//2.根据员工id范围和其他条件分页查询
//2.根据员工id范围和其他条件分页查询
List
<
Integer
>
userIds
=
allStaffs
.
stream
().
map
(
UserStaffBo:
:
getUserId
).
collect
(
Collectors
.
toList
());
List
<
Integer
>
userIds
=
allStaffs
.
stream
().
map
(
UserStaffBo:
:
getUserId
).
collect
(
Collectors
.
toList
());
List
<
AppUserSellingWaterDTO
>
appUserSellingWaterDTOS
=
appUserSellingWaterBiz
.
findStatffSellerWaterByUserIdsAndTime
(
userIds
,
staffStatisticsFindDTO
.
getStartDate
(),
staffStatisticsFindDTO
.
getEndDate
());
List
<
AppUserSellingWaterDTO
>
appUserSellingWaterDTOS
=
appUserSellingWaterBiz
.
findStatffSellerWaterByUserIdsAndTime
(
userIds
,
staffStatisticsFindDTO
.
getStartDate
(),
staffStatisticsFindDTO
.
getEndDate
());
Map
<
Integer
,
Map
<
String
,
Map
<
Integer
,
Map
<
Integer
,
List
<
AppUserSellingWaterDTO
>
>>>>
sellingWaterMap
=
new
HashMap
<>();
Map
<
Integer
,
Map
<
String
,
Map
<
Integer
,
List
<
AppUserSellingWaterDTO
>>>>
sellingWaterMap
=
new
HashMap
<>();
if
(
CollectionUtils
.
isNotEmpty
(
appUserSellingWaterDTOS
))
{
if
(
CollectionUtils
.
isNotEmpty
(
appUserSellingWaterDTOS
))
{
//3.根据订单id查询订单相关信息
//3.根据订单id查询订单相关信息
...
@@ -265,7 +266,7 @@ public class StaffStatisticsBiz {
...
@@ -265,7 +266,7 @@ public class StaffStatisticsBiz {
sellingWaterMap
=
appUserSellingWaterDTOS
.
stream
().
collect
(
Collectors
.
groupingBy
(
AppUserSellingWaterDTO:
:
getUserId
,
sellingWaterMap
=
appUserSellingWaterDTOS
.
stream
().
collect
(
Collectors
.
groupingBy
(
AppUserSellingWaterDTO:
:
getUserId
,
Collectors
.
groupingBy
(
AppUserSellingWaterDTO:
:
getStateGroup
,
Collectors
.
groupingBy
(
AppUserSellingWaterDTO:
:
getOrderType
,
Collectors
.
groupingBy
(
AppUserSellingWaterDTO:
:
getStatus
,
Collectors
.
toList
()
)))));
Collectors
.
groupingBy
(
AppUserSellingWaterDTO:
:
getStateGroup
,
Collectors
.
groupingBy
(
AppUserSellingWaterDTO:
:
getOrderType
,
Collectors
.
toList
(
)))));
}
}
Map
<
Integer
,
String
>
companyMap
=
vehicleFeign
.
findCompanyMap
();
Map
<
Integer
,
String
>
companyMap
=
vehicleFeign
.
findCompanyMap
();
...
@@ -275,13 +276,13 @@ public class StaffStatisticsBiz {
...
@@ -275,13 +276,13 @@ public class StaffStatisticsBiz {
String
stateGroup
=
String
.
format
(
"%d-%d-%d"
,
userStaffBo
.
getUserId
(),
userStaffBo
.
getPostionId
(),
userStaffBo
.
getCompanyId
()
==
null
?
NO_COMPANY_STATE
:
userStaffBo
.
getCompanyId
());
String
stateGroup
=
String
.
format
(
"%d-%d-%d"
,
userStaffBo
.
getUserId
(),
userStaffBo
.
getPostionId
(),
userStaffBo
.
getCompanyId
()
==
null
?
NO_COMPANY_STATE
:
userStaffBo
.
getCompanyId
());
StaffStatisticsBo
staffStatisticsBo
=
creatDefaultStaffStatistics
(
userStaffBo
);
StaffStatisticsBo
staffStatisticsBo
=
creatDefaultStaffStatistics
(
userStaffBo
);
if
(!
sellingWaterMap
.
isEmpty
())
{
if
(!
sellingWaterMap
.
isEmpty
())
{
Map
<
String
,
Map
<
Integer
,
Map
<
Integer
,
List
<
AppUserSellingWaterDTO
>
>>>
userSellingWaterMap
=
sellingWaterMap
.
get
(
userStaffBo
.
getUserId
());
Map
<
String
,
Map
<
Integer
,
List
<
AppUserSellingWaterDTO
>>>
userSellingWaterMap
=
sellingWaterMap
.
get
(
userStaffBo
.
getUserId
());
if
(
userSellingWaterMap
!=
null
&&
!
userSellingWaterMap
.
isEmpty
())
{
if
(
userSellingWaterMap
!=
null
&&
!
userSellingWaterMap
.
isEmpty
())
{
AtomicReference
<
BigDecimal
>
royaltyAmountAtomicReference
=
new
AtomicReference
<>(
BigDecimal
.
ZERO
);
AtomicReference
<
BigDecimal
>
royaltyAmountAtomicReference
=
new
AtomicReference
<>(
BigDecimal
.
ZERO
);
List
<
String
>
postionNames
=
new
ArrayList
<>
(
staffStatisticsBo
.
getPostionNames
());
List
<
String
>
postionNames
=
Lists
.
newArrayList
(
staffStatisticsBo
.
getPostionNames
());
List
<
Integer
>
postionIds
=
new
ArrayList
<>
(
staffStatisticsBo
.
getPostionIds
());
List
<
Integer
>
postionIds
=
Lists
.
newArrayList
(
staffStatisticsBo
.
getPostionIds
());
List
<
String
>
companyNames
=
new
ArrayList
<>
(
staffStatisticsBo
.
getCompanyNames
());
List
<
String
>
companyNames
=
Lists
.
newArrayList
(
staffStatisticsBo
.
getCompanyNames
());
List
<
Integer
>
compnayIds
=
new
ArrayList
<>
(
staffStatisticsBo
.
getCompnayIds
());
List
<
Integer
>
compnayIds
=
Lists
.
newArrayList
(
staffStatisticsBo
.
getCompnayIds
());
userSellingWaterMap
.
forEach
((
K
,
V
)
->
{
userSellingWaterMap
.
forEach
((
K
,
V
)
->
{
if
(!
K
.
equals
(
stateGroup
))
{
if
(!
K
.
equals
(
stateGroup
))
{
String
[]
sates
=
K
.
split
(
"-"
);
String
[]
sates
=
K
.
split
(
"-"
);
...
@@ -319,7 +320,7 @@ public class StaffStatisticsBiz {
...
@@ -319,7 +320,7 @@ public class StaffStatisticsBiz {
return
staffStatisticsBos
;
return
staffStatisticsBos
;
}
}
private
StaffStatisticsBo
wrapStaffStatistics
(
Map
<
Integer
,
Map
<
Integer
,
List
<
AppUserSellingWaterDTO
>
>>
waterDTOSMap
,
AtomicReference
<
BigDecimal
>
royaltyAmountAtomicReference
,
StaffStatisticsBo
staffStatisticsBo
)
{
private
StaffStatisticsBo
wrapStaffStatistics
(
Map
<
Integer
,
List
<
AppUserSellingWaterDTO
>>
waterDTOSMap
,
AtomicReference
<
BigDecimal
>
royaltyAmountAtomicReference
,
StaffStatisticsBo
staffStatisticsBo
)
{
waterDTOSMap
.
forEach
((
K
,
V
)
->
{
waterDTOSMap
.
forEach
((
K
,
V
)
->
{
Map
<
String
,
Object
>
orderRentResultMap
=
wrapStaffStatisticsMap
(
V
);
Map
<
String
,
Object
>
orderRentResultMap
=
wrapStaffStatisticsMap
(
V
);
BigDecimal
royaltyAmount
=
royaltyAmountAtomicReference
.
get
();
BigDecimal
royaltyAmount
=
royaltyAmountAtomicReference
.
get
();
...
@@ -345,34 +346,45 @@ public class StaffStatisticsBiz {
...
@@ -345,34 +346,45 @@ public class StaffStatisticsBiz {
return
staffStatisticsBo
;
return
staffStatisticsBo
;
}
}
private
Map
<
String
,
Object
>
wrapStaffStatisticsMap
(
Map
<
Integer
,
List
<
AppUserSellingWaterDTO
>
>
sellingWaters
)
{
private
Map
<
String
,
Object
>
wrapStaffStatisticsMap
(
List
<
AppUserSellingWaterDTO
>
sellingWaters
)
{
Map
<
String
,
Object
>
staffStatisticsResultMap
=
new
HashMap
<>(
2
);
Map
<
String
,
Object
>
staffStatisticsResultMap
=
new
HashMap
<>(
2
);
AtomicInteger
orderCounter
=
new
AtomicInteger
(
0
);
AtomicInteger
orderCounter
=
new
AtomicInteger
(
0
);
if
(
sellingWaters
==
null
||
sellingWaters
.
isEmpty
(
))
{
if
(
CollectionUtils
.
isEmpty
(
sellingWaters
))
{
staffStatisticsResultMap
.
put
(
TOTAL_AMOUNT_VAL
,
BigDecimal
.
ZERO
);
staffStatisticsResultMap
.
put
(
TOTAL_AMOUNT_VAL
,
BigDecimal
.
ZERO
);
staffStatisticsResultMap
.
put
(
TOTAL_NUM_VAL
,
orderCounter
.
get
());
staffStatisticsResultMap
.
put
(
TOTAL_NUM_VAL
,
orderCounter
.
get
());
}
}
BigDecimal
totalAmount
=
BigDecimal
.
ZERO
;
BigDecimal
totalAmount
=
BigDecimal
.
ZERO
;
BigDecimal
royaltyAmount
=
BigDecimal
.
ZERO
;
BigDecimal
royaltyAmount
=
BigDecimal
.
ZERO
;
Set
<
Map
.
Entry
<
Integer
,
List
<
AppUserSellingWaterDTO
>>>
sellingWaterSet
=
sellingWaters
.
entrySet
();
Map
<
Integer
,
List
<
AppUserSellingWaterDTO
>>
orderSellingMap
=
sellingWaters
.
stream
().
collect
(
Collectors
.
groupingBy
(
AppUserSellingWaterDTO:
:
getOrderId
,
Collectors
.
toList
()));
for
(
Map
.
Entry
<
Integer
,
List
<
AppUserSellingWaterDTO
>>
sellingWaterEntry
:
sellingWaterSet
)
{
Set
<
Map
.
Entry
<
Integer
,
List
<
AppUserSellingWaterDTO
>>>
orderSellingSet
=
orderSellingMap
.
entrySet
();
List
<
AppUserSellingWaterDTO
>
waterDTOS
=
sellingWaterEntry
.
getValue
();
for
(
Map
.
Entry
<
Integer
,
List
<
AppUserSellingWaterDTO
>>
orderSellingEntry
:
orderSellingSet
)
{
for
(
AppUserSellingWaterDTO
waterDTO
:
waterDTOS
)
{
BigDecimal
inAmount
=
BigDecimal
.
ZERO
;
if
(
sellingWaterEntry
.
getKey
()
==
0
)
{
BigDecimal
outAmount
=
BigDecimal
.
ZERO
;
royaltyAmount
=
royaltyAmount
.
add
(
waterDTO
.
getCommission
());
boolean
isCommissionZero
=
false
;
totalAmount
=
totalAmount
.
add
(
waterDTO
.
getPrice
());
List
<
AppUserSellingWaterDTO
>
appUserSellingWaterDTOS
=
orderSellingEntry
.
getValue
();
orderCounter
.
incrementAndGet
();
for
(
AppUserSellingWaterDTO
waterDTO
:
appUserSellingWaterDTOS
)
{
if
(
waterDTO
.
getStatus
()
==
0
)
{
royaltyAmount
=
royaltyAmount
.
add
(
waterDTO
.
getCommission
());
totalAmount
=
totalAmount
.
add
(
waterDTO
.
getPrice
());
inAmount
=
inAmount
.
add
(
waterDTO
.
getCommission
());
isCommissionZero
=
waterDTO
.
getCommission
().
intValue
()==
0
;
}
if
(
waterDTO
.
getStatus
()
==
1
)
{
royaltyAmount
=
royaltyAmount
.
subtract
(
waterDTO
.
getCommission
());
totalAmount
=
totalAmount
.
subtract
(
waterDTO
.
getPrice
());
outAmount
=
outAmount
.
add
(
waterDTO
.
getCommission
());
isCommissionZero
=!
isCommissionZero
;
}
}
}
if
(
sellingWaterEntry
.
getKey
()
==
1
)
{
if
(
appUserSellingWaterDTOS
.
size
()==
1
||
inAmount
.
subtract
(
outAmount
).
intValue
()>
0
||
isCommissionZero
){
royaltyAmount
=
royaltyAmount
.
subtract
(
waterDTO
.
getCommission
());
orderCounter
.
incrementAndGet
();
totalAmount
=
totalAmount
.
subtract
(
waterDTO
.
getPrice
());
}
}
}
}
staffStatisticsResultMap
.
put
(
TOTAL_AMOUNT_VAL
,
totalAmount
);
staffStatisticsResultMap
.
put
(
TOTAL_AMOUNT_VAL
,
totalAmount
);
staffStatisticsResultMap
.
put
(
TOTAL_NUM_VAL
,
orderCounter
.
get
());
staffStatisticsResultMap
.
put
(
TOTAL_NUM_VAL
,
orderCounter
.
get
());
staffStatisticsResultMap
.
put
(
TOTAL_COMMISSION_VAL
,
royaltyAmount
);
staffStatisticsResultMap
.
put
(
TOTAL_COMMISSION_VAL
,
royaltyAmount
);
}
return
staffStatisticsResultMap
;
return
staffStatisticsResultMap
;
}
}
...
...
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