From efa6341dd2978a2d2eb73334719486b3b4804ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=9F=91=E8=9E=82?= Date: Sat, 25 Apr 2026 16:58:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(shop):=20=E4=BF=AE=E5=A4=8D=E5=BA=97?= =?UTF-8?q?=E9=93=BA=E6=A6=82=E8=A7=88=E9=A1=B5=E9=80=80=E6=AC=BE=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E7=BB=9F=E8=AE=A1=EF=BC=8CgetRefundStatusId=E6=94=B9?= =?UTF-8?q?=E4=B8=BAgetRefundStatusIds=E6=94=AF=E6=8C=81=E5=A4=9A=E9=80=80?= =?UTF-8?q?=E6=AC=BE=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shop/service/impl/ShopServiceImpl.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopServiceImpl.java index 6aebb9cc..cbfd864a 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopServiceImpl.java @@ -249,14 +249,14 @@ public class ShopServiceImpl extends ServiceImpl implements /** * 获取退款状态ID(根据 is_refund 字段查找) */ - private Long getRefundStatusId() { + private List getRefundStatusIds() { Long companyId = currentUserContext.getCurrentCompanyId(); LambdaQueryWrapper 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 statusList = orderStatusService.list(wrapper); + return statusList.stream().map(OrderStatusPO::getId).collect(Collectors.toList()); } /** @@ -325,7 +325,7 @@ public class ShopServiceImpl extends ServiceImpl implements List promotionFees = promotionFeeMapper.selectList(promotionWrapper); // 获取退款状态ID - Long refundStatusId = getRefundStatusId(); + List refundStatusIds = getRefundStatusIds(); // 按日期分组订单数据 Map> ordersByDate = orders.stream() @@ -368,7 +368,7 @@ public class ShopServiceImpl extends ServiceImpl 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 implements */ private ShopOverviewVO.DailyStatistics calculateRefundAmountStatistics( Map> ordersByDate, List dateList, - List allOrders, Long refundStatusId) { + List allOrders, List 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 implements dailyData.setDate(date); List 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); }