Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
Overview
Overview
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
pseer
gxpt_ht
Commits
524b139a
Commit
524b139a
authored
Jul 17, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化订单查询接口
parent
ad8ed8a4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
64 deletions
+101
-64
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+101
-64
No files found.
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
524b139a
...
@@ -354,34 +354,38 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -354,34 +354,38 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
public
TableDataInfoVo
pageList
(
SOrder
sOrder
)
{
public
TableDataInfoVo
pageList
(
SOrder
sOrder
)
{
List
<
SOrder
>
sOrders
=
selectSOrderList
(
sOrder
);
List
<
SOrder
>
sOrders
=
selectSOrderList
(
sOrder
);
List
<
SOrderVo
>
sOrderVos
=
convertDosToVos
(
sOrders
);
List
<
SOrderVo
>
sOrderVos
=
convertDosToVos
(
sOrders
);
BigDecimal
totalAmount
=
new
BigDecimal
(
"0.00"
)
;
final
BigDecimal
[]
totalAmount
=
{
new
BigDecimal
(
"0.00"
)}
;
BigDecimal
amount
=
new
BigDecimal
(
"0.00"
)
;
final
BigDecimal
[]
amount
=
{
new
BigDecimal
(
"0.00"
)}
;
//优惠卷售卖总金额
//优惠卷售卖总金额
final
BigDecimal
[]
totalSalesAmount
=
{
new
BigDecimal
(
"0.00"
)};
final
BigDecimal
[]
totalSalesAmount
=
{
new
BigDecimal
(
"0.00"
)};
//申请退款总金额
//申请退款总金额
BigDecimal
totalRefundAmount
=
new
BigDecimal
(
"0.00"
)
;
final
BigDecimal
[]
totalRefundAmount
=
{
new
BigDecimal
(
"0.00"
)}
;
//实际退款总金额
//实际退款总金额
BigDecimal
totalRealRefundAmount
=
new
BigDecimal
(
"0.00"
);
final
BigDecimal
[]
totalRealRefundAmount
=
{
new
BigDecimal
(
"0.00"
)};
List
<
SConsumerCoupon
>
sConsumerCoupons
=
consumerCouponService
.
queryList
();
Map
<
Long
,
SConsumerCoupon
>
couponMap
=
consumerCouponService
.
listByIds
(
sOrders
.
stream
().
map
(
SOrder:
:
getCouponId
).
distinct
().
collect
(
Collectors
.
toList
()))
.
stream
().
collect
(
Collectors
.
toMap
(
SConsumerCoupon:
:
getId
,
s
->
s
));
if
(
CollectionUtils
.
isNotEmpty
(
sOrderVos
))
{
if
(
CollectionUtils
.
isNotEmpty
(
sOrderVos
))
{
for
(
SOrderVo
item
:
sOrderVos
)
{
sOrderVos
.
stream
().
forEach
(
item
->
{
totalAmount
=
totalAmount
.
add
(
item
.
getTotalPrice
());
totalAmount
[
0
]
=
totalAmount
[
0
].
add
(
item
.
getTotalPrice
());
amount
=
amount
.
add
(
item
.
getPayPrice
());
amount
[
0
]
=
amount
[
0
].
add
(
item
.
getPayPrice
());
sConsumerCoupons
.
stream
().
filter
(
sConsumerCoupon
->
sConsumerCoupon
.
getId
().
equals
(
item
.
getCouponId
())).
findFirst
().
ifPresent
(
sConsumerCoupon
->
{
if
(
Objects
.
nonNull
(
item
.
getCouponId
()))
{
item
.
setCouponPayPrice
(
sConsumerCoupon
.
getCouponPayPrice
());
SConsumerCoupon
userCoupon
=
couponMap
.
get
(
item
.
getCouponId
());
item
.
setPlatformType
(
sConsumerCoupon
.
getPlatformType
());
if
(
userCoupon
!=
null
)
{
if
(
sConsumerCoupon
.
getPlatformType
().
equals
(
PlatformTypeEnum
.
MEITUAN
.
getCode
()))
{
item
.
setCouponPayPrice
(
userCoupon
.
getCouponPayPrice
());
item
.
setCouponSkuId
(
String
.
valueOf
(
sConsumerCoupon
.
getDealgroupId
()));
item
.
setPlatformType
(
userCoupon
.
getPlatformType
());
}
else
if
(
sConsumerCoupon
.
getPlatformType
().
equals
(
PlatformTypeEnum
.
TIKTOK
.
getCode
()))
{
if
(
userCoupon
.
getPlatformType
().
equals
(
PlatformTypeEnum
.
MEITUAN
.
getCode
()))
{
item
.
setCouponSkuId
(
String
.
valueOf
(
sConsumerCoupon
.
getTiktokSkuId
()));
item
.
setCouponSkuId
(
String
.
valueOf
(
userCoupon
.
getDealgroupId
()));
}
else
if
(
userCoupon
.
getPlatformType
().
equals
(
PlatformTypeEnum
.
TIKTOK
.
getCode
()))
{
item
.
setCouponSkuId
(
String
.
valueOf
(
userCoupon
.
getTiktokSkuId
()));
}
totalSalesAmount
[
0
]
=
totalSalesAmount
[
0
].
add
(
ObjectUtil
.
isEmpty
(
userCoupon
.
getCouponPayPrice
())
?
new
BigDecimal
(
"0.00"
)
:
userCoupon
.
getCouponPayPrice
());
}
}
totalSalesAmount
[
0
]
=
totalSalesAmount
[
0
].
add
(
ObjectUtil
.
isEmpty
(
sConsumerCoupon
.
getCouponPayPrice
())
?
new
BigDecimal
(
"0.00"
)
:
sConsumerCoupon
.
getCouponPayPrice
());
}
});
if
(
item
.
getPayStatus
().
equals
(
YesNoEnum
.
yes
.
getIndex
())
&&
item
.
getRefundStatus
().
equals
(
RefundStatusEnum
.
REFUNDED
.
getCode
()))
{
if
(
item
.
getPayStatus
().
equals
(
YesNoEnum
.
yes
.
getIndex
())
&&
item
.
getRefundStatus
().
equals
(
RefundStatusEnum
.
REFUNDED
.
getCode
()))
{
totalRefundAmount
=
totalRefundAmount
.
add
(
ObjectUtil
.
isEmpty
(
item
.
getPayPrice
())
?
new
BigDecimal
(
"0.00"
)
:
item
.
getPayPrice
());
totalRefundAmount
[
0
]
=
totalRefundAmount
[
0
]
.
add
(
ObjectUtil
.
isEmpty
(
item
.
getPayPrice
())
?
new
BigDecimal
(
"0.00"
)
:
item
.
getPayPrice
());
totalRealRefundAmount
=
totalRealRefundAmount
.
add
(
ObjectUtil
.
isEmpty
(
item
.
getRefundPrice
())
?
new
BigDecimal
(
"0.00"
)
:
item
.
getRefundPrice
());
totalRealRefundAmount
[
0
]
=
totalRealRefundAmount
[
0
]
.
add
(
ObjectUtil
.
isEmpty
(
item
.
getRefundPrice
())
?
new
BigDecimal
(
"0.00"
)
:
item
.
getRefundPrice
());
}
}
}
}
);
}
}
sOrderVos
.
sort
(
Comparator
.
comparing
(
SOrderVo:
:
getCreateTime
).
reversed
());
sOrderVos
.
sort
(
Comparator
.
comparing
(
SOrderVo:
:
getCreateTime
).
reversed
());
PageDomain
pageDomain
=
TableSupport
.
buildPageRequest
();
PageDomain
pageDomain
=
TableSupport
.
buildPageRequest
();
...
@@ -395,11 +399,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -395,11 +399,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
tableDataInfo
.
setTotal
(
sOrderVos
.
size
());
tableDataInfo
.
setTotal
(
sOrderVos
.
size
());
tableDataInfo
.
setCode
(
200
);
tableDataInfo
.
setCode
(
200
);
tableDataInfo
.
setMsg
(
"查询成功"
);
tableDataInfo
.
setMsg
(
"查询成功"
);
tableDataInfo
.
setTotalAmount
(
totalAmount
);
tableDataInfo
.
setTotalAmount
(
totalAmount
[
0
]
);
tableDataInfo
.
setAmount
(
amount
);
tableDataInfo
.
setAmount
(
amount
[
0
]
);
tableDataInfo
.
setTotalSalesAmount
(
totalSalesAmount
[
0
]);
tableDataInfo
.
setTotalSalesAmount
(
totalSalesAmount
[
0
]);
tableDataInfo
.
setTotalRefundAmount
(
totalRefundAmount
);
tableDataInfo
.
setTotalRefundAmount
(
totalRefundAmount
[
0
]
);
tableDataInfo
.
setTotalRealRefundAmount
(
totalRealRefundAmount
);
tableDataInfo
.
setTotalRealRefundAmount
(
totalRealRefundAmount
[
0
]
);
return
tableDataInfo
;
return
tableDataInfo
;
}
}
...
@@ -1946,55 +1950,88 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -1946,55 +1950,88 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
private
List
<
SOrderVo
>
convertDosToVos
(
List
<
SOrder
>
orderList
)
{
private
List
<
SOrderVo
>
convertDosToVos
(
List
<
SOrder
>
orderList
)
{
List
<
SOrderVo
>
voList
=
new
ArrayList
<>();
List
<
SOrderVo
>
voList
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
orderList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
orderList
))
{
// 使用Map缓存查询结果,减少重复查询
try
{
Map
<
Long
,
SStore
>
storeMap
=
storeService
.
listByIds
(
orderList
.
stream
().
map
(
SOrder:
:
getStoreId
).
collect
(
Collectors
.
toSet
()))
// 使用Map缓存查询结果,减少重复查询
.
stream
().
collect
(
Collectors
.
toMap
(
SStore:
:
getId
,
s
->
s
));
// 合并查询逻辑以减少N+1查询问题
Map
<
Long
,
SRoom
>
roomMap
=
roomService
.
listByIds
(
orderList
.
stream
().
map
(
SOrder:
:
getRoomId
).
collect
(
Collectors
.
toSet
()))
Set
<
Long
>
storeIds
=
orderList
.
stream
().
map
(
SOrder:
:
getStoreId
).
collect
(
Collectors
.
toSet
());
.
stream
().
collect
(
Collectors
.
toMap
(
SRoom:
:
getId
,
s
->
s
));
Set
<
Long
>
roomIds
=
orderList
.
stream
().
map
(
SOrder:
:
getRoomId
).
distinct
().
collect
(
Collectors
.
toSet
());
Map
<
Long
,
SConsumerCoupon
>
couponMap
=
consumerCouponService
.
queryByIds
(
orderList
.
stream
().
map
(
SOrder:
:
getCouponId
).
distinct
().
collect
(
Collectors
.
toList
()))
Set
<
Long
>
couponIds
=
orderList
.
stream
().
map
(
SOrder:
:
getCouponId
).
distinct
().
collect
(
Collectors
.
toSet
());
.
stream
().
collect
(
Collectors
.
toMap
(
SConsumerCoupon:
:
getId
,
s
->
s
));
Set
<
Long
>
packIds
=
orderList
.
stream
().
map
(
SOrder:
:
getPackId
).
distinct
().
collect
(
Collectors
.
toSet
());
Map
<
Long
,
SPack
>
packMap
=
packService
.
listByIds
(
orderList
.
stream
().
map
(
SOrder:
:
getPackId
).
distinct
().
collect
(
Collectors
.
toList
()))
.
stream
().
collect
(
Collectors
.
toMap
(
SPack:
:
getId
,
s
->
s
));
Map
<
Long
,
SStore
>
storeMap
;
if
(!
storeIds
.
isEmpty
())
{
orderList
.
forEach
(
o
->
{
List
<
SStore
>
stores
=
storeService
.
listByIds
(
storeIds
);
SOrderVo
vo
=
new
SOrderVo
();
storeMap
=
stores
.
stream
().
collect
(
Collectors
.
toMap
(
SStore:
:
getId
,
s
->
s
));
BeanUtils
.
copyProperties
(
o
,
vo
);
}
else
{
SStore
store
=
storeMap
.
get
(
vo
.
getStoreId
());
storeMap
=
new
HashMap
<>();
if
(
store
!=
null
)
{
vo
.
setStoreName
(
store
.
getName
());
vo
.
setAddress
(
store
.
getAddress
());
}
}
SRoom
room
=
roomMap
.
get
(
vo
.
getRoomId
());
if
(
room
!=
null
)
{
Map
<
Long
,
SRoom
>
roomMap
;
vo
.
setRoomName
(
room
.
getName
());
if
(!
roomIds
.
isEmpty
())
{
vo
.
setRoomImages
(
room
.
getImages
());
List
<
SRoom
>
rooms
=
roomService
.
listByIds
(
roomIds
);
vo
.
setRoomType
(
room
.
getRoomType
());
roomMap
=
rooms
.
stream
().
collect
(
Collectors
.
toMap
(
SRoom:
:
getId
,
s
->
s
));
vo
.
setRoomTypeName
(
RoomType
.
getNameByCode
(
room
.
getRoomType
()));
}
else
{
roomMap
=
new
HashMap
<>();
}
}
if
(
Objects
.
nonNull
(
vo
.
getCouponId
()))
{
SConsumerCoupon
userCoupon
=
couponMap
.
get
(
vo
.
getCouponId
());
Map
<
Long
,
SConsumerCoupon
>
couponMap
;
if
(
userCoupon
!=
null
)
{
if
(!
couponIds
.
isEmpty
())
{
// 判断是否可以退款
List
<
SConsumerCoupon
>
coupons
=
consumerCouponService
.
listByIds
(
couponIds
);
vo
.
setIsRefund
(
isRefund
(
vo
,
userCoupon
));
couponMap
=
coupons
.
stream
().
collect
(
Collectors
.
toMap
(
SConsumerCoupon:
:
getId
,
s
->
s
));
vo
.
setCouponName
(
userCoupon
.
getName
());
}
else
{
// 如果优惠券为空,则调用isRefund方法时需要传入null
vo
.
setIsRefund
(
isRefund
(
vo
,
null
));
}
}
else
{
}
else
{
// 判断是否可以退款
couponMap
=
new
HashMap
<>();
vo
.
setIsRefund
(
isRefund
(
vo
,
null
));
}
}
SPack
pack
=
packMap
.
get
(
vo
.
getPackId
());
if
(
pack
!=
null
)
{
Map
<
Long
,
SPack
>
packMap
;
vo
.
setPackName
(
pack
.
getName
());
if
(!
packIds
.
isEmpty
())
{
List
<
SPack
>
packs
=
packService
.
listByIds
(
packIds
);
packMap
=
packs
.
stream
().
collect
(
Collectors
.
toMap
(
SPack:
:
getId
,
s
->
s
));
}
else
{
packMap
=
new
HashMap
<>();
}
}
voList
.
add
(
vo
);
});
orderList
.
forEach
(
o
->
{
SOrderVo
vo
=
new
SOrderVo
();
BeanUtils
.
copyProperties
(
o
,
vo
);
SStore
store
=
storeMap
.
get
(
vo
.
getStoreId
());
if
(
store
!=
null
)
{
vo
.
setStoreName
(
store
.
getName
());
vo
.
setAddress
(
store
.
getAddress
());
}
SRoom
room
=
roomMap
.
get
(
vo
.
getRoomId
());
if
(
room
!=
null
)
{
vo
.
setRoomName
(
room
.
getName
());
vo
.
setRoomImages
(
room
.
getImages
());
vo
.
setRoomType
(
room
.
getRoomType
());
vo
.
setRoomTypeName
(
RoomType
.
getNameByCode
(
room
.
getRoomType
()));
}
if
(
Objects
.
nonNull
(
vo
.
getCouponId
()))
{
SConsumerCoupon
userCoupon
=
couponMap
.
get
(
vo
.
getCouponId
());
if
(
userCoupon
!=
null
)
{
vo
.
setIsRefund
(
isRefund
(
vo
,
userCoupon
));
vo
.
setCouponName
(
userCoupon
.
getName
());
}
else
{
vo
.
setIsRefund
(
isRefund
(
vo
,
null
));
}
}
else
{
vo
.
setIsRefund
(
isRefund
(
vo
,
null
));
}
SPack
pack
=
packMap
.
get
(
vo
.
getPackId
());
if
(
pack
!=
null
)
{
vo
.
setPackName
(
pack
.
getName
());
}
voList
.
add
(
vo
);
});
}
catch
(
Exception
e
)
{
// 记录日志并处理异常,例如返回错误信息或执行其他错误处理逻辑
// log.error("订单数据转换异常", e);
throw
new
RuntimeException
(
"订单数据转换异常"
,
e
);
}
}
}
return
voList
;
return
voList
;
}
}
@Override
@Override
public
String
openDoor
(
String
orderNo
)
{
public
String
openDoor
(
String
orderNo
)
{
LambdaQueryWrapper
<
SOrder
>
orderLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
SOrder
>
orderLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
...
...
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