From e34b6d59b2938e29c384c4b887c3bdea12d598a6 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Tue, 08 Jul 2025 14:18:46 +0800
Subject: [PATCH] refactor(mall): 重构管理员数据统计逻辑
---
src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallMemberServiceImpl.java | 59 +++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 43 insertions(+), 16 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallMemberServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallMemberServiceImpl.java
index fee552f..b353d10 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallMemberServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallMemberServiceImpl.java
@@ -81,6 +81,8 @@
private final MallGoodsCouponMapper mallGoodsCouponMapper;
private final HappySaleLevelMapper happySaleLevelMapper;
private final HappyMemberLevelMapper happyMemberLevelMapper;
+ private final MallOrderInfoMapper mallOrderInfoMapper;
+ private final HappyActivityOrderMapper happyActivityOrderMapper;
@Override
@@ -1015,25 +1017,50 @@
Math.toIntExact(mallMembers.stream().filter(mallMember -> DateUtil.compare(mallMember.getCreatedTime(), DateUtil.beginOfMonth(new Date())) >= 0).count()));
}
- List<Integer> typeList = Arrays.asList(ScoreFlowTypeEnum.WECHAT_PAY.getValue(), ScoreFlowTypeEnum.PAY_BALANCE.getValue());
- List<MallMoneyFlow> mallMoneyFlows = mallMoneyFlowMapper.selectList(
- Wrappers.lambdaQuery(MallMoneyFlow.class)
- .in(MallMoneyFlow::getType, typeList)
- );
- if(CollUtil.isNotEmpty(mallMoneyFlows)){
- adminDataInfoVo.setTotalAmount(mallMoneyFlows.stream().map(MallMoneyFlow::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add).negate());
- adminDataInfoVo.setTotalDayAmount(
- mallMoneyFlows.stream().filter(mallMoneyFlow -> DateUtil.compare(mallMoneyFlow.getCreatedTime(), DateUtil.beginOfDay(new Date())) >= 0)
- .map(MallMoneyFlow::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add).negate());
- adminDataInfoVo.setTotalWeekAmount(
- mallMoneyFlows.stream().filter(mallMoneyFlow -> DateUtil.compare(mallMoneyFlow.getCreatedTime(), DateUtil.beginOfWeek(new Date())) >= 0)
- .map(MallMoneyFlow::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add).negate());
- adminDataInfoVo.setTotalMonthAmount(
- mallMoneyFlows.stream().filter(mallMoneyFlow -> DateUtil.compare(mallMoneyFlow.getCreatedTime(), DateUtil.beginOfMonth(new Date())) >= 0)
- .map(MallMoneyFlow::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add).negate());
+ BigDecimal totalAmount = BigDecimal.ZERO;//总数
+ BigDecimal totalDayAmount = BigDecimal.ZERO;//新增
+ BigDecimal totalWeekAmount = BigDecimal.ZERO;//本周新增
+ BigDecimal totalMonthAmount = BigDecimal.ZERO;//本月新增
+
+ List<MallOrderInfo> mallOrderInfos = mallOrderInfoMapper.selectList(
+ Wrappers.lambdaQuery(MallOrderInfo.class)
+ .eq(MallOrderInfo::getPayResult, "1")
+ );
+ if(CollUtil.isNotEmpty(mallOrderInfos)){
+ totalAmount = totalAmount.add(mallOrderInfos.stream().map(MallOrderInfo::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
+ totalDayAmount = totalDayAmount.add(
+ mallOrderInfos.stream().filter(entity -> DateUtil.compare(entity.getPayTime(), DateUtil.beginOfDay(new Date())) >= 0)
+ .map(MallOrderInfo::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
+ totalWeekAmount = totalWeekAmount.add(
+ mallOrderInfos.stream().filter(entity -> DateUtil.compare(entity.getPayTime(), DateUtil.beginOfWeek(new Date())) >= 0)
+ .map(MallOrderInfo::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
+ totalMonthAmount = totalMonthAmount.add(
+ mallOrderInfos.stream().filter(entity -> DateUtil.compare(entity.getPayTime(), DateUtil.beginOfMonth(new Date())) >= 0)
+ .map(MallOrderInfo::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
}
+ List<HappyActivityOrder> happyActivityOrders = happyActivityOrderMapper.selectList(
+ Wrappers.lambdaQuery(HappyActivityOrder.class)
+ .eq(HappyActivityOrder::getPayState, StateUpDownEnum.PAY_STATE_PAY_SUCCESS.getCode())
+ );
+ if(CollUtil.isNotEmpty(happyActivityOrders)){
+ totalAmount = totalAmount.add(happyActivityOrders.stream().map(HappyActivityOrder::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
+ totalDayAmount = totalDayAmount.add(
+ happyActivityOrders.stream().filter(entity -> DateUtil.compare(entity.getPayTime(), DateUtil.beginOfDay(new Date())) >= 0)
+ .map(HappyActivityOrder::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
+ totalWeekAmount = totalWeekAmount.add(
+ happyActivityOrders.stream().filter(entity -> DateUtil.compare(entity.getPayTime(), DateUtil.beginOfWeek(new Date())) >= 0)
+ .map(HappyActivityOrder::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
+ totalMonthAmount = totalMonthAmount.add(
+ happyActivityOrders.stream().filter(entity -> DateUtil.compare(entity.getPayTime(), DateUtil.beginOfMonth(new Date())) >= 0)
+ .map(HappyActivityOrder::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
+ }
+ adminDataInfoVo.setTotalAmount(totalAmount);
+ adminDataInfoVo.setTotalDayAmount(totalDayAmount);
+ adminDataInfoVo.setTotalWeekAmount(totalWeekAmount);
+ adminDataInfoVo.setTotalMonthAmount(totalMonthAmount);
+
return new FebsResponse().success().data(adminDataInfoVo);
}
}
--
Gitblit v1.9.1