统计:Review修改

This commit is contained in:
owen 2023-10-16 22:03:37 +08:00
parent 6fbb7d6d6d
commit 7aa1ecceeb
20 changed files with 143 additions and 79 deletions

View File

@ -77,8 +77,7 @@ public class MemberStatisticsController {
} }
// TODO 芋艿已经 review // TODO 芋艿已经 review
// TODO @疯狂要不 get 前缀去掉和下面的 list 接口保持一致 @GetMapping("/area-statistics-list")
@GetMapping("/get-area-statistics-list")
@Operation(summary = "按照省份,获得会员统计列表") @Operation(summary = "按照省份,获得会员统计列表")
@PreAuthorize("@ss.hasPermission('statistics:member:query')") @PreAuthorize("@ss.hasPermission('statistics:member:query')")
public CommonResult<List<MemberAreaStatisticsRespVO>> getMemberAreaStatisticsList() { public CommonResult<List<MemberAreaStatisticsRespVO>> getMemberAreaStatisticsList() {
@ -86,8 +85,7 @@ public class MemberStatisticsController {
} }
// TODO 芋艿已经 review // TODO 芋艿已经 review
// TODO @疯狂要不 get 前缀去掉和下面的 list 接口保持一致 @GetMapping("/sex-statistics-list")
@GetMapping("/get-sex-statistics-list")
@Operation(summary = "按照性别,获得会员统计列表") @Operation(summary = "按照性别,获得会员统计列表")
@PreAuthorize("@ss.hasPermission('statistics:member:query')") @PreAuthorize("@ss.hasPermission('statistics:member:query')")
public CommonResult<List<MemberSexStatisticsRespVO>> getMemberSexStatisticsList() { public CommonResult<List<MemberSexStatisticsRespVO>> getMemberSexStatisticsList() {
@ -95,12 +93,11 @@ public class MemberStatisticsController {
} }
// TODO 芋艿已经 review // TODO 芋艿已经 review
// TODO @疯狂要不 get 前缀去掉和下面的 list 接口保持一致 @GetMapping("/terminal-statistics-list")
@GetMapping("/get-terminal-statistics-list")
@Operation(summary = "按照终端,获得会员统计列表") @Operation(summary = "按照终端,获得会员统计列表")
@PreAuthorize("@ss.hasPermission('statistics:member:query')") @PreAuthorize("@ss.hasPermission('statistics:member:query')")
public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() { public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() {
return success(memberStatisticsService.getRegisterTerminalStatisticsList()); return success(memberStatisticsService.getMemberTerminalStatisticsList());
} }
@GetMapping("/user-count-comparison") @GetMapping("/user-count-comparison")

View File

@ -10,8 +10,7 @@ public class MemberCountRespVO {
@Schema(description = "用户访问量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @Schema(description = "用户访问量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer visitUserCount; private Integer visitUserCount;
// TODO @疯狂要不改成 registerUserCount注册 @Schema(description = "注册用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@Schema(description = "新增用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") private Integer registerUserCount;
private Integer createUserCount;
} }

View File

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.statistics.controller.admin.pay; package cn.iocoder.yudao.module.statistics.controller.admin.pay;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; 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 cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -24,11 +26,11 @@ public class PayStatisticsController {
@Resource @Resource
private PayWalletStatisticsService payWalletStatisticsService; private PayWalletStatisticsService payWalletStatisticsService;
// TODO @疯狂要不搞成 PaySummary只是目前只有 rechargePrice 充值金额 @GetMapping("/summary")
@GetMapping("/wallet-recharge-price")
@Operation(summary = "获取充值金额") @Operation(summary = "获取充值金额")
public CommonResult<Integer> getWalletRechargePrice() { public CommonResult<PaySummaryRespVO> getWalletRechargePrice() {
return success(payWalletStatisticsService.getRechargePriceSummary()); Integer rechargePrice = payWalletStatisticsService.getRechargePriceSummary();
return success(PayStatisticsConvert.INSTANCE.convert(rechargePrice));
} }
} }

View File

@ -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;
}

View File

@ -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.statistics.service.trade.bo.TradeSummaryRespBO;
import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; 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.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.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -104,11 +106,15 @@ public class TradeStatisticsController {
@PreAuthorize("@ss.hasPermission('statistics:trade:query')") @PreAuthorize("@ss.hasPermission('statistics:trade:query')")
public CommonResult<TradeOrderCountRespVO> getOrderCount() { public CommonResult<TradeOrderCountRespVO> 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)) Long afterSaleApplyCount = afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY);
.setAuditingWithdraw(brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING)); Long auditingWithdrawCount = brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING);
return success(vo); // 拼接返回
return success(TradeStatisticsConvert.INSTANCE.convert(undeliveredCount, pickUpCount, afterSaleApplyCount, auditingWithdrawCount));
} }
// TODO 芋艿已经 review // TODO 芋艿已经 review

View File

@ -40,5 +40,5 @@ public class TradeTrendSummaryExcelVO {
private Integer brokerageSettlementPrice; private Integer brokerageSettlementPrice;
@ExcelProperty(value = "商品退款金额", converter = MoneyConvert.class) @ExcelProperty(value = "商品退款金额", converter = MoneyConvert.class)
private Integer orderRefundPrice; private Integer afterSaleRefundPrice;
} }

View File

@ -26,7 +26,7 @@ public class TradeTrendSummaryRespVO {
private Integer orderWalletPayPrice; private Integer orderWalletPayPrice;
@Schema(description = "订单退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @Schema(description = "订单退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer orderRefundPrice; private Integer afterSaleRefundPrice;
@Schema(description = "支付佣金金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @Schema(description = "支付佣金金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer brokerageSettlementPrice; private Integer brokerageSettlementPrice;

View File

@ -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.MemberAnalyseRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; 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.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 cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@ -29,10 +30,10 @@ public interface MemberStatisticsConvert {
default List<MemberAreaStatisticsRespVO> convertList(List<Area> areaList, default List<MemberAreaStatisticsRespVO> convertList(List<Area> areaList,
Map<Integer, Integer> userCountMap, Map<Integer, Integer> userCountMap,
Map<Integer, MemberAreaStatisticsRespVO> orderMap) { Map<Integer, MemberAreaStatisticsRespBO> orderMap) {
return CollectionUtils.convertList(areaList, area -> { return CollectionUtils.convertList(areaList, area -> {
MemberAreaStatisticsRespVO orderVo = Optional.ofNullable(orderMap.get(area.getId())) MemberAreaStatisticsRespBO orderVo = Optional.ofNullable(orderMap.get(area.getId()))
.orElseGet(MemberAreaStatisticsRespVO::new); .orElseGet(MemberAreaStatisticsRespBO::new);
return new MemberAreaStatisticsRespVO() return new MemberAreaStatisticsRespVO()
.setAreaId(area.getId()).setAreaName(area.getName()) .setAreaId(area.getId()).setAreaName(area.getName())
.setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0)) .setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0))

View File

@ -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);
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.statistics.convert.trade; 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.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.TradeSummaryRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO; import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; 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.TradeOrderSummaryRespBO;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -50,21 +53,22 @@ public interface TradeStatisticsConvert {
AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice, AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice,
WalletSummaryRespBO walletSummary); WalletSummaryRespBO walletSummary);
@IterableMapping(qualifiedByName = "convert")
List<TradeTrendSummaryRespVO> convertList(List<TradeStatisticsDO> list); List<TradeTrendSummaryRespVO> convertList(List<TradeStatisticsDO> list);
// TODO @疯狂要不要搞个默认的 convertA 方法然后这个 convert 去调用 convertA特殊字段再去 set TradeTrendSummaryRespVO convertA(TradeStatisticsDO tradeStatistics);
@Named("convert")
default TradeTrendSummaryRespVO convert(TradeStatisticsDO tradeStatistics) { default TradeTrendSummaryRespVO convert(TradeStatisticsDO tradeStatistics) {
return new TradeTrendSummaryRespVO() TradeTrendSummaryRespVO vo = convertA(tradeStatistics);
return vo
.setDate(tradeStatistics.getTime().toLocalDate()) .setDate(tradeStatistics.getTime().toLocalDate())
// 营业额 = 商品支付金额 + 充值金额 // 营业额 = 商品支付金额 + 充值金额
.setTurnoverPrice(tradeStatistics.getOrderPayPrice() + tradeStatistics.getRechargePayPrice()) .setTurnoverPrice(tradeStatistics.getOrderPayPrice() + tradeStatistics.getRechargePayPrice())
.setOrderPayPrice(tradeStatistics.getOrderPayPrice())
.setRechargePrice(tradeStatistics.getRechargePayPrice())
// 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 // 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额
.setExpensePrice(tradeStatistics.getOrderWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice()) .setExpensePrice(tradeStatistics.getOrderWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice());
.setOrderWalletPayPrice(tradeStatistics.getOrderWalletPayPrice())
.setBrokerageSettlementPrice(tradeStatistics.getBrokerageSettlementPrice())
.setOrderRefundPrice(tradeStatistics.getAfterSaleRefundPrice());
} }
TradeOrderCountRespVO convert(Long undelivered, Long pickUp, Long afterSaleApply, Long auditingWithdraw);
} }

View File

@ -1,10 +1,10 @@
package cn.iocoder.yudao.module.statistics.dal.mysql.trade; package cn.iocoder.yudao.module.statistics.dal.mysql.trade;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 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.TradeOrderSummaryRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO; 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.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.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -20,7 +20,7 @@ import java.util.List;
public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
// TODO 芋艿已经 review // TODO 芋艿已经 review
List<MemberAreaStatisticsRespVO> selectSummaryListByAreaId(); List<MemberAreaStatisticsRespBO> selectSummaryListByAreaId();
// TODO 芋艿已经 review // TODO 芋艿已经 review
Integer selectCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, Integer selectCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime,
@ -65,10 +65,7 @@ public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsD
@Param("endTime") LocalDateTime endTime); @Param("endTime") LocalDateTime endTime);
// TODO @芋艿已经 review // TODO @芋艿已经 review
Long selectCountByStatus(@Param("status") Integer status); Long selectCountByStatusAndDeliveryType(@Param("status") Integer status, @Param("deliveryType") Integer deliveryType);
// TODO 芋艿已经 review
Long selectCountByStatusAndPickUpStoreIdIsNotNull(@Param("status") Integer status);
// TODO 芋艿已经 review // TODO 芋艿已经 review
TradeOrderSummaryRespVO selectPaySummaryByStatusAndPayTimeBetween(@Param("status") Integer status, TradeOrderSummaryRespVO selectPaySummaryByStatusAndPayTimeBetween(@Param("status") Integer status,

View File

@ -30,8 +30,10 @@ public class TradeStatisticsJob implements JobHandler {
@Override @Override
@TenantJob @TenantJob
public String execute(String param) { public String execute(String param) {
// TODO @疯狂要搞个默认的 1 // 默认 昨日
if (NumberUtil.isInteger(param)) { if (StrUtil.isBlank(param)) {
param = "1";
} else if (!NumberUtil.isInteger(param)) {
throw new RuntimeException("交易统计任务的参数只能为是正整数"); throw new RuntimeException("交易统计任务的参数只能为是正整数");
} }
Integer days = Convert.toInt(param, 0); Integer days = Convert.toInt(param, 0);

View File

@ -48,13 +48,12 @@ public interface MemberStatisticsService {
*/ */
List<MemberSexStatisticsRespVO> getMemberSexStatisticsList(); List<MemberSexStatisticsRespVO> getMemberSexStatisticsList();
// TODO @疯狂这个要不要使用 getMemberTerminalStatisticsList保持统一
/** /**
* 按照终端获得会员统计列表 * 按照终端获得会员统计列表
* *
* @return 会员统计列表 * @return 会员统计列表
*/ */
List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList(); List<MemberTerminalStatisticsRespVO> getMemberTerminalStatisticsList();
// TODO 芋艿已经 review // TODO 芋艿已经 review
/** /**

View File

@ -65,10 +65,10 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE),
MemberAreaStatisticsRespBO::getUserCount, Integer::sum); MemberAreaStatisticsRespBO::getUserCount, Integer::sum);
// 统计订单 // 统计订单
Map<Integer, MemberAreaStatisticsRespVO> orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(), Map<Integer, MemberAreaStatisticsRespBO> orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(),
vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), bo -> AreaUtils.getParentIdByType(bo.getAreaId(), AreaTypeEnum.PROVINCE),
vo -> vo, bo -> bo,
(a, b) -> new MemberAreaStatisticsRespVO() (a, b) -> new MemberAreaStatisticsRespBO()
.setOrderCreateUserCount(a.getOrderCreateUserCount() + b.getOrderCreateUserCount()) .setOrderCreateUserCount(a.getOrderCreateUserCount() + b.getOrderCreateUserCount())
.setOrderPayUserCount(a.getOrderPayUserCount() + b.getOrderPayUserCount()) .setOrderPayUserCount(a.getOrderPayUserCount() + b.getOrderPayUserCount())
.setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice())); .setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice()));
@ -105,7 +105,7 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
} }
@Override @Override
public List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList() { public List<MemberTerminalStatisticsRespVO> getMemberTerminalStatisticsList() {
return memberStatisticsMapper.selectSummaryListByRegisterTerminal(); return memberStatisticsMapper.selectSummaryListByRegisterTerminal();
} }
@ -129,7 +129,7 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
private MemberCountRespVO getUserCount(LocalDateTime beginTime, LocalDateTime endTime) { private MemberCountRespVO getUserCount(LocalDateTime beginTime, LocalDateTime endTime) {
return new MemberCountRespVO() return new MemberCountRespVO()
.setCreateUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) .setRegisterUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime))
.setVisitUserCount(apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime)); .setVisitUserCount(apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime));
} }

View File

@ -1,8 +1,8 @@
package cn.iocoder.yudao.module.statistics.service.trade; 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.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.*;
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.statistics.service.trade.bo.TradeOrderSummaryRespBO;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -30,7 +30,7 @@ public interface TradeOrderStatisticsService {
* *
* @return 订单统计结果 * @return 订单统计结果
*/ */
List<MemberAreaStatisticsRespVO> getSummaryListByAreaId(); List<MemberAreaStatisticsRespBO> getSummaryListByAreaId();
// TODO 芋艿已经 review // TODO 芋艿已经 review
/** /**
@ -62,13 +62,12 @@ public interface TradeOrderStatisticsService {
*/ */
Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime); Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime);
// TODO 芋艿已经 review
/** /**
* 获得交易订单数量 * 根据订单状态物流类型获得交易订单数量
* *
* @return 订单数量 * @return 订单数量
*/ */
TradeOrderCountRespVO getOrderCount(); Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType);
// TODO 芋艿已经 review // TODO 芋艿已经 review
/** /**

View File

@ -2,15 +2,15 @@ package cn.iocoder.yudao.module.statistics.service.trade;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.LocalDateTimeUtil; 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.pay.enums.order.PayOrderStatusEnum;
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; 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.TradeOrderSummaryRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; 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.dal.mysql.trade.TradeOrderStatisticsMapper;
import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum; 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.statistics.service.trade.bo.TradeOrderSummaryRespBO;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -42,7 +42,7 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ
} }
@Override @Override
public List<MemberAreaStatisticsRespVO> getSummaryListByAreaId() { public List<MemberAreaStatisticsRespBO> getSummaryListByAreaId() {
return tradeOrderStatisticsMapper.selectSummaryListByAreaId(); return tradeOrderStatisticsMapper.selectSummaryListByAreaId();
} }
@ -62,13 +62,8 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ
} }
@Override @Override
public TradeOrderCountRespVO getOrderCount() { public Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType) {
// TODO 疯狂这个可以根据 status + delivertyType 来过滤呀ps是不是搞个 service 方法交给上层去聚合这样 TradeOrderCountRespVO 可以更明确返回不用搞 bo return tradeOrderStatisticsMapper.selectCountByStatusAndDeliveryType(status, deliveryType);
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));
} }
@Override @Override

View File

@ -83,9 +83,7 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
@Override @Override
public String statisticsTrade(Integer days) { public String statisticsTrade(Integer days) {
LocalDateTime today = LocalDateTime.now(); LocalDateTime today = LocalDateTime.now();
// TODO @疯狂不用并发哈因为租户可能会丢然后一般串行就好对性能没绝对的要求哈天数也不会多
return IntStream.rangeClosed(1, days) return IntStream.rangeClosed(1, days)
.parallel()
.mapToObj(day -> statisticsTrade(today.minusDays(day))) .mapToObj(day -> statisticsTrade(today.minusDays(day)))
.sorted() .sorted()
.collect(Collectors.joining("\n")); .collect(Collectors.joining("\n"));
@ -131,7 +129,7 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
entity = TradeStatisticsConvert.INSTANCE.convert(date, orderSummary, afterSaleSummary, brokerageSettlementPrice, entity = TradeStatisticsConvert.INSTANCE.convert(date, orderSummary, afterSaleSummary, brokerageSettlementPrice,
walletSummary); walletSummary);
tradeStatisticsMapper.insert(entity); tradeStatisticsMapper.insert(entity);
// TODO @疯狂这里是不是也要把日期带上类似 108 那边 // TODO @疯狂这里是不是也要把日期带上类似 108 那边; 110 已经带上了
return stopWatch.prettyPrint(); return stopWatch.prettyPrint();
} }

View File

@ -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;
}

View File

@ -2,9 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper"> <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper">
<!-- TODO @疯狂:是返回不是的 MemberAreaStatisticsRespBO 哈 -->
<select id="selectSummaryListByAreaId" <select id="selectSummaryListByAreaId"
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO"> resultType="cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO">
SELECT receiver_area_id AS areaId, SELECT receiver_area_id AS areaId,
(SELECT COUNT(DISTINCT s.user_id) (SELECT COUNT(DISTINCT s.user_id)
FROM trade_order AS s FROM trade_order AS s
@ -86,18 +85,11 @@
GROUP BY date GROUP BY date
</select> </select>
<select id="selectCountByStatus" resultType="java.lang.Long"> <select id="selectCountByStatusAndDeliveryType" resultType="java.lang.Long">
SELECT COUNT(1) SELECT COUNT(1)
FROM trade_order FROM trade_order
WHERE status = #{status} WHERE status = #{status}
AND deleted = FALSE ANd delivery_type = #{deliveryType}
</select>
<select id="selectCountByStatusAndPickUpStoreIdIsNotNull" resultType="java.lang.Long">
SELECT COUNT(1)
FROM trade_order
WHERE status = #{status}
AND pick_up_store_id IS NOT NULL
AND deleted = FALSE AND deleted = FALSE
</select> </select>

View File

@ -22,7 +22,7 @@
SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice, SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice,
SUM(order_wallet_pay_price) AS orderWalletPayPrice, SUM(order_wallet_pay_price) AS orderWalletPayPrice,
SUM(brokerage_settlement_price) AS brokerageSettlementPrice, SUM(brokerage_settlement_price) AS brokerageSettlementPrice,
SUM(after_sale_refund_price) AS orderRefundPrice SUM(after_sale_refund_price) AS afterSaleRefundPrice
FROM trade_statistics FROM trade_statistics
WHERE time BETWEEN #{beginTime} AND #{endTime} WHERE time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE AND deleted = FALSE