diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java index 59d2dd2b4..f67cd7250 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java @@ -77,8 +77,7 @@ public class MemberStatisticsController { } // TODO 芋艿:已经 review - // TODO @疯狂:要不 get 前缀去掉,和下面的 list 接口保持一致 - @GetMapping("/get-area-statistics-list") + @GetMapping("/area-statistics-list") @Operation(summary = "按照省份,获得会员统计列表") @PreAuthorize("@ss.hasPermission('statistics:member:query')") public CommonResult> getMemberAreaStatisticsList() { @@ -86,8 +85,7 @@ public class MemberStatisticsController { } // TODO 芋艿:已经 review - // TODO @疯狂:要不 get 前缀去掉,和下面的 list 接口保持一致 - @GetMapping("/get-sex-statistics-list") + @GetMapping("/sex-statistics-list") @Operation(summary = "按照性别,获得会员统计列表") @PreAuthorize("@ss.hasPermission('statistics:member:query')") public CommonResult> getMemberSexStatisticsList() { @@ -95,12 +93,11 @@ public class MemberStatisticsController { } // TODO 芋艿:已经 review - // TODO @疯狂:要不 get 前缀去掉,和下面的 list 接口保持一致 - @GetMapping("/get-terminal-statistics-list") + @GetMapping("/terminal-statistics-list") @Operation(summary = "按照终端,获得会员统计列表") @PreAuthorize("@ss.hasPermission('statistics:member:query')") public CommonResult> getMemberTerminalStatisticsList() { - return success(memberStatisticsService.getRegisterTerminalStatisticsList()); + return success(memberStatisticsService.getMemberTerminalStatisticsList()); } @GetMapping("/user-count-comparison") diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java index d44f2ac5e..ce81658cf 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java @@ -10,8 +10,7 @@ public class MemberCountRespVO { @Schema(description = "用户访问量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") private Integer visitUserCount; - // TODO @疯狂:要不改成 registerUserCount,注册 - @Schema(description = "新增用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer createUserCount; + @Schema(description = "注册用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Integer registerUserCount; } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java index 0af4dc697..362ec7d57 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java @@ -1,6 +1,8 @@ package cn.iocoder.yudao.module.statistics.controller.admin.pay; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.statistics.controller.admin.pay.vo.PaySummaryRespVO; +import cn.iocoder.yudao.module.statistics.convert.pay.PayStatisticsConvert; import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -24,11 +26,11 @@ public class PayStatisticsController { @Resource private PayWalletStatisticsService payWalletStatisticsService; - // TODO @疯狂:要不搞成 PaySummary?只是目前只有 rechargePrice 充值金额? - @GetMapping("/wallet-recharge-price") + @GetMapping("/summary") @Operation(summary = "获取充值金额") - public CommonResult getWalletRechargePrice() { - return success(payWalletStatisticsService.getRechargePriceSummary()); + public CommonResult getWalletRechargePrice() { + Integer rechargePrice = payWalletStatisticsService.getRechargePriceSummary(); + return success(PayStatisticsConvert.INSTANCE.convert(rechargePrice)); } } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java new file mode 100644 index 000000000..01edc24cf --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java @@ -0,0 +1,13 @@ +package cn.iocoder.yudao.module.statistics.controller.admin.pay.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理后台 - 支付统计 Response VO") +@Data +public class PaySummaryRespVO { + + @Schema(description = "充值金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Integer rechargePrice; + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java index 457988986..6c14230af 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java @@ -14,6 +14,8 @@ import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; +import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; @@ -104,11 +106,15 @@ public class TradeStatisticsController { @PreAuthorize("@ss.hasPermission('statistics:trade:query')") public CommonResult getOrderCount() { // 订单统计 - TradeOrderCountRespVO vo = tradeOrderStatisticsService.getOrderCount(); + Long undeliveredCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType( + TradeOrderStatusEnum.UNDELIVERED.getStatus(), DeliveryTypeEnum.EXPRESS.getType()); + Long pickUpCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType( + TradeOrderStatusEnum.DELIVERED.getStatus(), DeliveryTypeEnum.PICK_UP.getType()); // 售后统计 - vo.setAfterSaleApply(afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY)) - .setAuditingWithdraw(brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING)); - return success(vo); + Long afterSaleApplyCount = afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY); + Long auditingWithdrawCount = brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING); + // 拼接返回 + return success(TradeStatisticsConvert.INSTANCE.convert(undeliveredCount, pickUpCount, afterSaleApplyCount, auditingWithdrawCount)); } // TODO 芋艿:已经 review diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java index 654d75893..928818dd0 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java @@ -40,5 +40,5 @@ public class TradeTrendSummaryExcelVO { private Integer brokerageSettlementPrice; @ExcelProperty(value = "商品退款金额", converter = MoneyConvert.class) - private Integer orderRefundPrice; + private Integer afterSaleRefundPrice; } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java index 2525a9993..9c323327f 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java @@ -26,7 +26,7 @@ public class TradeTrendSummaryRespVO { private Integer orderWalletPayPrice; @Schema(description = "订单退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderRefundPrice; + private Integer afterSaleRefundPrice; @Schema(description = "支付佣金金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") private Integer brokerageSettlementPrice; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java index 14a1bcad8..2d527b0a3 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java @@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnaly import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO; +import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -29,10 +30,10 @@ public interface MemberStatisticsConvert { default List convertList(List areaList, Map userCountMap, - Map orderMap) { + Map orderMap) { return CollectionUtils.convertList(areaList, area -> { - MemberAreaStatisticsRespVO orderVo = Optional.ofNullable(orderMap.get(area.getId())) - .orElseGet(MemberAreaStatisticsRespVO::new); + MemberAreaStatisticsRespBO orderVo = Optional.ofNullable(orderMap.get(area.getId())) + .orElseGet(MemberAreaStatisticsRespBO::new); return new MemberAreaStatisticsRespVO() .setAreaId(area.getId()).setAreaName(area.getName()) .setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0)) diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java new file mode 100644 index 000000000..08f38005f --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.statistics.convert.pay; + +import cn.iocoder.yudao.module.statistics.controller.admin.pay.vo.PaySummaryRespVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +/** + * 支付统计 Convert + * + * @author owen + */ +@Mapper +public interface PayStatisticsConvert { + + PayStatisticsConvert INSTANCE = Mappers.getMapper(PayStatisticsConvert.class); + + PaySummaryRespVO convert(Integer rechargePrice); + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java index bc519847f..6a6c06817 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.statistics.convert.trade; import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderCountRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO; import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; @@ -9,7 +10,9 @@ import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespB import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; +import org.mapstruct.IterableMapping; import org.mapstruct.Mapper; +import org.mapstruct.Named; import org.mapstruct.factory.Mappers; import java.time.LocalDateTime; @@ -50,21 +53,22 @@ public interface TradeStatisticsConvert { AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice, WalletSummaryRespBO walletSummary); + @IterableMapping(qualifiedByName = "convert") List convertList(List list); - // TODO @疯狂:要不要搞个默认的 convertA 方法,然后这个 convert 去调用 convertA,特殊字段再去 set? + TradeTrendSummaryRespVO convertA(TradeStatisticsDO tradeStatistics); + + @Named("convert") default TradeTrendSummaryRespVO convert(TradeStatisticsDO tradeStatistics) { - return new TradeTrendSummaryRespVO() + TradeTrendSummaryRespVO vo = convertA(tradeStatistics); + return vo .setDate(tradeStatistics.getTime().toLocalDate()) // 营业额 = 商品支付金额 + 充值金额 .setTurnoverPrice(tradeStatistics.getOrderPayPrice() + tradeStatistics.getRechargePayPrice()) - .setOrderPayPrice(tradeStatistics.getOrderPayPrice()) - .setRechargePrice(tradeStatistics.getRechargePayPrice()) // 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 - .setExpensePrice(tradeStatistics.getOrderWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice()) - .setOrderWalletPayPrice(tradeStatistics.getOrderWalletPayPrice()) - .setBrokerageSettlementPrice(tradeStatistics.getBrokerageSettlementPrice()) - .setOrderRefundPrice(tradeStatistics.getAfterSaleRefundPrice()); + .setExpensePrice(tradeStatistics.getOrderWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice()); } + TradeOrderCountRespVO convert(Long undelivered, Long pickUp, Long afterSaleApply, Long auditingWithdraw); + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java index 5f8645f5d..43b4c4dfd 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java @@ -1,10 +1,10 @@ package cn.iocoder.yudao.module.statistics.dal.mysql.trade; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO; import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; +import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -20,7 +20,7 @@ import java.util.List; public interface TradeOrderStatisticsMapper extends BaseMapperX { // TODO 芋艿:已经 review - List selectSummaryListByAreaId(); + List selectSummaryListByAreaId(); // TODO 芋艿:已经 review Integer selectCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, @@ -65,10 +65,7 @@ public interface TradeOrderStatisticsMapper extends BaseMapperX getMemberSexStatisticsList(); - // TODO @疯狂:这个要不要使用 getMemberTerminalStatisticsList;保持统一? /** * 按照终端,获得会员统计列表 * * @return 会员统计列表 */ - List getRegisterTerminalStatisticsList(); + List getMemberTerminalStatisticsList(); // TODO 芋艿:已经 review /** diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java index 0b8f9cb53..7b159059f 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java @@ -65,10 +65,10 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService { vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), MemberAreaStatisticsRespBO::getUserCount, Integer::sum); // 统计订单 - Map orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(), - vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), - vo -> vo, - (a, b) -> new MemberAreaStatisticsRespVO() + Map orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(), + bo -> AreaUtils.getParentIdByType(bo.getAreaId(), AreaTypeEnum.PROVINCE), + bo -> bo, + (a, b) -> new MemberAreaStatisticsRespBO() .setOrderCreateUserCount(a.getOrderCreateUserCount() + b.getOrderCreateUserCount()) .setOrderPayUserCount(a.getOrderPayUserCount() + b.getOrderPayUserCount()) .setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice())); @@ -105,7 +105,7 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService { } @Override - public List getRegisterTerminalStatisticsList() { + public List getMemberTerminalStatisticsList() { return memberStatisticsMapper.selectSummaryListByRegisterTerminal(); } @@ -129,7 +129,7 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService { private MemberCountRespVO getUserCount(LocalDateTime beginTime, LocalDateTime endTime) { return new MemberCountRespVO() - .setCreateUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) + .setRegisterUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) .setVisitUserCount(apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime)); } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java index b8bd25e75..982957e24 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java @@ -1,8 +1,8 @@ package cn.iocoder.yudao.module.statistics.service.trade; import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; +import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; import java.time.LocalDateTime; @@ -30,7 +30,7 @@ public interface TradeOrderStatisticsService { * * @return 订单统计结果 */ - List getSummaryListByAreaId(); + List getSummaryListByAreaId(); // TODO 芋艿:已经 review /** @@ -62,13 +62,12 @@ public interface TradeOrderStatisticsService { */ Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime); - // TODO 芋艿:已经 review /** - * 获得交易订单数量 + * 根据订单状态、物流类型,获得交易订单数量 * * @return 订单数量 */ - TradeOrderCountRespVO getOrderCount(); + Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType); // TODO 芋艿:已经 review /** diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java index 63655ceec..36131ec96 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java @@ -2,15 +2,15 @@ package cn.iocoder.yudao.module.statistics.service.trade; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO; +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendReqVO; +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO; import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper; import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum; +import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -42,7 +42,7 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ } @Override - public List getSummaryListByAreaId() { + public List getSummaryListByAreaId() { return tradeOrderStatisticsMapper.selectSummaryListByAreaId(); } @@ -62,13 +62,8 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ } @Override - public TradeOrderCountRespVO getOrderCount() { - // TODO 疯狂:这个可以根据 status + delivertyType 来过滤呀;ps:是不是搞个 service 方法,交给上层去聚合,这样 TradeOrderCountRespVO 可以更明确返回,不用搞 bo; - Long undeliveredCount = tradeOrderStatisticsMapper.selectCountByStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()); - Long pickUpCount = tradeOrderStatisticsMapper.selectCountByStatusAndPickUpStoreIdIsNotNull(TradeOrderStatusEnum.DELIVERED.getStatus()); - return new TradeOrderCountRespVO() - .setPickUp(ObjUtil.defaultIfNull(pickUpCount, 0L)) - .setUndelivered(ObjUtil.defaultIfNull(undeliveredCount, 0L)); + public Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType) { + return tradeOrderStatisticsMapper.selectCountByStatusAndDeliveryType(status, deliveryType); } @Override diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java index b3f625d98..930389152 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java @@ -83,9 +83,7 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { @Override public String statisticsTrade(Integer days) { LocalDateTime today = LocalDateTime.now(); - // TODO @疯狂:不用并发哈,因为租户可能会丢;然后,一般串行就好,对性能没绝对的要求哈,天数也不会多; return IntStream.rangeClosed(1, days) - .parallel() .mapToObj(day -> statisticsTrade(today.minusDays(day))) .sorted() .collect(Collectors.joining("\n")); @@ -131,7 +129,7 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { entity = TradeStatisticsConvert.INSTANCE.convert(date, orderSummary, afterSaleSummary, brokerageSettlementPrice, walletSummary); tradeStatisticsMapper.insert(entity); - // TODO @疯狂:这里是不是也要把日期带上?类似 108 那边 + // TODO @疯狂:这里是不是也要把日期带上?类似 108 那边; 110 已经带上了 return stopWatch.prettyPrint(); } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java new file mode 100644 index 000000000..3d3572f90 --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.statistics.service.trade.bo; + +import lombok.Data; + +/** + * 会员地区统计 Response BO + * + * @author owen + */ +@Data +public class MemberAreaStatisticsRespBO { + + /** + * 省份编号 + */ + private Integer areaId; + /** + * 省份名称 + */ + private String areaName; + + /** + * 会员数量 + */ + private Integer userCount; + + /** + * 下单的会员数量 + */ + private Integer orderCreateUserCount; + /** + * 支付订单的会员数量 + */ + private Integer orderPayUserCount; + + /** + * 订单支付金额,单位:分 + */ + private Integer orderPayPrice; + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml index e054b32b0..c79c639a4 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml @@ -2,9 +2,8 @@ - - SELECT COUNT(1) FROM trade_order WHERE status = #{status} - AND deleted = FALSE - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml index 74cc11ac9..380044e40 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml @@ -22,7 +22,7 @@ SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice, SUM(order_wallet_pay_price) AS orderWalletPayPrice, SUM(brokerage_settlement_price) AS brokerageSettlementPrice, - SUM(after_sale_refund_price) AS orderRefundPrice + SUM(after_sale_refund_price) AS afterSaleRefundPrice FROM trade_statistics WHERE time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE