mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:59:19 +08:00
fix(shop): 修复店铺概览页退款金额统计,getRefundStatusId改为getRefundStatusIds支持多退款状态
This commit is contained in:
+11
-11
@@ -249,14 +249,14 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
|
||||
/**
|
||||
* 获取退款状态ID(根据 is_refund 字段查找)
|
||||
*/
|
||||
private Long getRefundStatusId() {
|
||||
private List<Long> getRefundStatusIds() {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
LambdaQueryWrapper<OrderStatusPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(OrderStatusPO::getCompanyId, companyId)
|
||||
.eq(OrderStatusPO::getIsRefund, 1)
|
||||
.last("LIMIT 1");
|
||||
OrderStatusPO status = orderStatusService.getOne(wrapper);
|
||||
return status != null ? status.getId() : null;
|
||||
.select(OrderStatusPO::getId);
|
||||
List<OrderStatusPO> statusList = orderStatusService.list(wrapper);
|
||||
return statusList.stream().map(OrderStatusPO::getId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -325,7 +325,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
|
||||
List<PromotionFeePO> promotionFees = promotionFeeMapper.selectList(promotionWrapper);
|
||||
|
||||
// 获取退款状态ID
|
||||
Long refundStatusId = getRefundStatusId();
|
||||
List<Long> refundStatusIds = getRefundStatusIds();
|
||||
|
||||
// 按日期分组订单数据
|
||||
Map<LocalDate, List<OrderPO>> ordersByDate = orders.stream()
|
||||
@@ -368,7 +368,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
|
||||
|
||||
// 计算退款金额统计
|
||||
ShopOverviewVO.DailyStatistics refundAmountStats = calculateRefundAmountStatistics(
|
||||
ordersByDate, dateList, orders, refundStatusId);
|
||||
ordersByDate, dateList, orders, refundStatusIds);
|
||||
overviewVO.setRefundAmount(refundAmountStats);
|
||||
|
||||
// 计算推广费统计
|
||||
@@ -543,14 +543,14 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
|
||||
*/
|
||||
private ShopOverviewVO.DailyStatistics calculateRefundAmountStatistics(
|
||||
Map<LocalDate, List<OrderPO>> ordersByDate, List<LocalDate> dateList,
|
||||
List<OrderPO> allOrders, Long refundStatusId) {
|
||||
List<OrderPO> allOrders, List<Long> refundStatusIds) {
|
||||
ShopOverviewVO.DailyStatistics stats = new ShopOverviewVO.DailyStatistics();
|
||||
|
||||
// 计算总退款金额
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
if (refundStatusId != null) {
|
||||
if (!refundStatusIds.isEmpty()) {
|
||||
total = allOrders.stream()
|
||||
.filter(order -> refundStatusId.equals(order.getStatusId()))
|
||||
.filter(order -> refundStatusIds.contains(order.getStatusId()))
|
||||
.map(order -> order.getReceivedAmount() != null ? order.getReceivedAmount() : BigDecimal.ZERO)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
@@ -563,9 +563,9 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
|
||||
dailyData.setDate(date);
|
||||
List<OrderPO> dayOrders = ordersByDate.getOrDefault(date, List.of());
|
||||
BigDecimal dayRefund = BigDecimal.ZERO;
|
||||
if (refundStatusId != null) {
|
||||
if (!refundStatusIds.isEmpty()) {
|
||||
dayRefund = dayOrders.stream()
|
||||
.filter(order -> refundStatusId.equals(order.getStatusId()))
|
||||
.filter(order -> refundStatusIds.contains(order.getStatusId()))
|
||||
.map(order -> order.getReceivedAmount() != null ? order.getReceivedAmount() : BigDecimal.ZERO)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user