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
52848b85
Commit
52848b85
authored
Nov 19, 2019
by
libin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
租车订单统计
parent
e6a12e7a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
27 deletions
+45
-27
OrderRentVehicleReceivedStatisticsBiz.java
...form/order/biz/OrderRentVehicleReceivedStatisticsBiz.java
+45
-27
No files found.
xx-order/xx-order-server/src/main/java/com/xxfc/platform/order/biz/OrderRentVehicleReceivedStatisticsBiz.java
View file @
52848b85
...
...
@@ -11,6 +11,7 @@ import com.xxfc.platform.order.pojo.dto.OrderDTO;
import
com.xxfc.platform.order.pojo.dto.OrderReceivedStatisticsFindDTO
;
import
com.xxfc.platform.vehicle.feign.VehicleFeign
;
import
lombok.RequiredArgsConstructor
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -34,13 +35,14 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
private
final
BaseOrderBiz
baseOrderBiz
;
private
final
OrderAccountBiz
orderAccountBiz
;
private
final
VehicleFeign
vehicleFeign
;
private
final
int
PAY_ORDER
=
101
;
private
final
String
NO_PAY_STATE_STR
=
String
.
format
(
"%s-%d"
,
"-"
,
StatisticsStatusEnum
.
NO_PAY_WAY
);
private
final
int
PAY_ORDER
=
101
;
public
List
<
OrderRentVehicleReceivedStatistics
>
selectOrderReceivedStatistics
(
OrderReceivedStatisticsFindDTO
orderReceivedStatisticsFindDTO
)
{
return
mapper
.
selectOrderRentVehicleReceivedStatistics
(
orderReceivedStatisticsFindDTO
);
}
public
void
orderRentVehicleReceivedStatistics
(
Date
startDate
,
Date
endDate
)
{
public
void
orderRentVehicleReceivedStatistics
(
Date
startDate
,
Date
endDate
)
{
List
<
OrderRentVehicleReceivedStatistics
>
orderRentVehicleReceivedStatisticsList
=
new
ArrayList
<>();
...
...
@@ -51,35 +53,41 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
.
collect
(
Collectors
.
groupingBy
(
OrderDTO:
:
getStateGroup
,
Collectors
.
counting
()));
//订单账目信息
List
<
OrderAccountBo
>
orderAccountBoList
=
orderAccountBiz
.
selectByDate
(
startDate
,
endDate
);
List
<
OrderAccountBo
>
orderAccountBoList
=
orderAccountBiz
.
selectByDate
(
startDate
,
endDate
);
//数据处理 把 未支付的单的支付方式 设置为 99
Map
<
String
,
List
<
OrderAccountBo
>>
ordersMap
=
orderAccountBoList
.
stream
().
peek
(
x
->
{
x
.
setStateGroup
(
String
.
format
(
"%d-%d-%d-%d"
,
x
.
getCompanyId
(),
x
.
getOrderOrigin
(),
x
.
getPayWay
()
==
null
?
StatisticsStatusEnum
.
NO_PAY_WAY
:
x
.
getPayWay
(),
x
.
getStatus
()));
}).
collect
(
Collectors
.
groupingBy
(
OrderAccountBo:
:
getStateGroup
,
Collectors
.
toList
()));
Set
<
Map
.
Entry
<
String
,
List
<
OrderAccountBo
>>>
ordersSet
=
ordersMap
.
entrySet
();
for
(
Map
.
Entry
<
String
,
List
<
OrderAccountBo
>>
orderEntry
:
ordersSet
)
{
String
orderKey
=
orderEntry
.
getKey
();
List
<
OrderAccountBo
>
orderAccountBos
=
orderEntry
.
getValue
();
OrderRentVehicleReceivedStatistics
orderRentVehicleReceivedStatistics
=
StatisticsStatusEnum
.
wrapStatisticsObject
(
startDate
,
orderKey
,
new
OrderRentVehicleReceivedStatistics
());
BigDecimal
totalAmount
=
BigDecimal
.
ZERO
;
BigDecimal
refundAmount
=
BigDecimal
.
ZERO
;
for
(
OrderAccountBo
orderAccountBo
:
orderAccountBos
)
{
OrderAccountDetail
accountDetailEntity
=
orderAccountBo
.
getAccountDetailEntity
();
if
(
orderAccountBo
.
getAccountType
()
==
PAY_ORDER
)
{
totalAmount
.
add
(
accountDetailEntity
.
getOrderAmount
()).
add
(
accountDetailEntity
.
getDepositAmount
());
}
else
{
refundAmount
.
add
(
accountDetailEntity
.
getOrderAmount
()).
add
(
accountDetailEntity
.
getDepositAmount
());
}
Set
<
Map
.
Entry
<
String
,
List
<
OrderAccountBo
>>>
ordersSet
=
ordersMap
.
entrySet
();
for
(
Map
.
Entry
<
String
,
List
<
OrderAccountBo
>>
orderEntry
:
ordersSet
)
{
String
orderKey
=
orderEntry
.
getKey
();
List
<
OrderAccountBo
>
orderAccountBos
=
orderEntry
.
getValue
();
OrderRentVehicleReceivedStatistics
orderRentVehicleReceivedStatistics
=
StatisticsStatusEnum
.
wrapStatisticsObject
(
startDate
,
orderKey
,
new
OrderRentVehicleReceivedStatistics
());
BigDecimal
totalAmount
=
BigDecimal
.
ZERO
;
BigDecimal
refundAmount
=
BigDecimal
.
ZERO
;
for
(
OrderAccountBo
orderAccountBo
:
orderAccountBos
)
{
OrderAccountDetail
accountDetailEntity
=
orderAccountBo
.
getAccountDetailEntity
();
if
(
orderAccountBo
.
getAccountType
()
==
PAY_ORDER
)
{
totalAmount
.
add
(
accountDetailEntity
.
getOrderAmount
()).
add
(
accountDetailEntity
.
getDepositAmount
());
}
else
{
refundAmount
.
add
(
accountDetailEntity
.
getOrderAmount
()).
add
(
accountDetailEntity
.
getDepositAmount
());
}
orderRentVehicleReceivedStatistics
.
setTotalAmount
(
totalAmount
.
subtract
(
refundAmount
));
Long
totalQuantity
=
stateGroupMap
==
null
?
0L
:
stateGroupMap
.
get
(
orderKey
)==
null
?
0L
:
stateGroupMap
.
get
(
orderKey
);
orderRentVehicleReceivedStatistics
.
setTotalQuantity
(
totalQuantity
.
intValue
());
}
orderRentVehicleReceivedStatistics
.
setTotalAmount
(
totalAmount
.
subtract
(
refundAmount
));
Long
totalQuantity
=
stateGroupMap
==
null
?
0L
:
stateGroupMap
.
get
(
orderKey
)
==
null
?
0L
:
stateGroupMap
.
get
(
orderKey
);
orderRentVehicleReceivedStatistics
.
setTotalQuantity
(
totalQuantity
.
intValue
());
}
//未支付单
List
<
OrderDTO
>
noPayOrders
=
orderDTOS
.
stream
().
filter
(
x
->
x
.
getPayWay
()
!=
null
).
collect
(
Collectors
.
toList
());
BigDecimal
totalNoPayAmount
=
CollectionUtils
.
isEmpty
(
noPayOrders
)
?
BigDecimal
.
ZERO
:
noPayOrders
.
stream
().
map
(
OrderDTO:
:
getRealAmount
).
reduce
(
BigDecimal
.
ZERO
,
(
x
,
y
)
->
x
.
add
(
y
));
int
totalNoPayOrderQuantity
=
CollectionUtils
.
isEmpty
(
noPayOrders
)
?
0
:
noPayOrders
.
size
();
List
<
Integer
>
companyIds
=
vehicleFeign
.
findCompanyIdsByAreaId
(
null
);
List
stisticsActiveState
=
ordersMap
.
isEmpty
()
?
Collections
.
EMPTY_LIST
:
Lists
.
newArrayList
(
ordersMap
.
keySet
());
List
<
OrderRentVehicleReceivedStatistics
>
otherStatisticsStateGroupList
=
createOtherStatisticsStateGroupList
(
startDate
,
stisticsActiveState
,
companyIds
);
List
<
OrderRentVehicleReceivedStatistics
>
otherStatisticsStateGroupList
=
createOtherStatisticsStateGroupList
(
startDate
,
stisticsActiveState
,
companyIds
,
totalNoPayAmount
,
totalNoPayOrderQuantity
);
orderRentVehicleReceivedStatisticsList
.
addAll
(
otherStatisticsStateGroupList
);
insertMemberReceivedStatisticsBatch
(
orderRentVehicleReceivedStatisticsList
);
}
...
...
@@ -92,18 +100,28 @@ public class OrderRentVehicleReceivedStatisticsBiz extends BaseBiz<OrderRentVehi
* @param companyIds
* @return
*/
private
List
<
OrderRentVehicleReceivedStatistics
>
createOtherStatisticsStateGroupList
(
Date
startDate
,
List
<
String
>
statisticsStateGroups
,
List
<
Integer
>
companyIds
)
{
private
List
<
OrderRentVehicleReceivedStatistics
>
createOtherStatisticsStateGroupList
(
Date
startDate
,
List
<
String
>
statisticsStateGroups
,
List
<
Integer
>
companyIds
,
BigDecimal
totalNoPayAmount
,
Integer
totalNoPayOrderQuantity
)
{
List
<
OrderRentVehicleReceivedStatistics
>
orderRentVehicleReceivedStatisticsList
=
new
ArrayList
<>();
List
<
String
>
otherStatisticsStateGroup
=
StatisticsStatusEnum
.
getOtherStatisticsStateGroup
(
companyIds
,
statisticsStateGroups
);
List
<
OrderRentVehicleReceivedStatistics
>
result
=
otherStatisticsStateGroup
.
parallelStream
().
map
(
stateGroup
->
{
List
<
OrderRentVehicleReceivedStatistics
>
result
=
otherStatisticsStateGroup
.
parallelStream
().
map
(
stateGroup
->
{
OrderRentVehicleReceivedStatistics
orderRentVehicleReceivedStatistics
=
StatisticsStatusEnum
.
wrapStatisticsObject
(
startDate
,
stateGroup
,
new
OrderRentVehicleReceivedStatistics
());
orderRentVehicleReceivedStatistics
.
setTotalAmount
(
BigDecimal
.
ZERO
);
orderRentVehicleReceivedStatistics
.
setTotalQuantity
(
0
);
return
orderRentVehicleReceivedStatistics
;
if
(
stateGroup
.
contains
(
NO_PAY_STATE_STR
))
{
orderRentVehicleReceivedStatistics
.
setTotalAmount
(
totalNoPayAmount
);
orderRentVehicleReceivedStatistics
.
setTotalQuantity
(
totalNoPayOrderQuantity
);
}
else
{
orderRentVehicleReceivedStatistics
.
setTotalAmount
(
BigDecimal
.
ZERO
);
orderRentVehicleReceivedStatistics
.
setTotalQuantity
(
0
);
}
return
orderRentVehicleReceivedStatistics
;
}).
collect
(
Collectors
.
toList
());
orderRentVehicleReceivedStatisticsList
.
addAll
(
result
==
null
?
Collections
.
EMPTY_LIST
:
result
);
orderRentVehicleReceivedStatisticsList
.
addAll
(
result
==
null
?
Collections
.
EMPTY_LIST
:
result
);
return
orderRentVehicleReceivedStatisticsList
;
}
public
void
insertMemberReceivedStatisticsBatch
(
List
<
OrderRentVehicleReceivedStatistics
>
orderRentVehicleReceivedStatistics
)
{
mapper
.
insertList
(
orderRentVehicleReceivedStatistics
);
}
...
...
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