统计:Review修改
This commit is contained in:
parent
6fbb7d6d6d
commit
7aa1ecceeb
|
@ -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<List<MemberAreaStatisticsRespVO>> 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<List<MemberSexStatisticsRespVO>> 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<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() {
|
||||
return success(memberStatisticsService.getRegisterTerminalStatisticsList());
|
||||
return success(memberStatisticsService.getMemberTerminalStatisticsList());
|
||||
}
|
||||
|
||||
@GetMapping("/user-count-comparison")
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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<Integer> getWalletRechargePrice() {
|
||||
return success(payWalletStatisticsService.getRechargePriceSummary());
|
||||
public CommonResult<PaySummaryRespVO> getWalletRechargePrice() {
|
||||
Integer rechargePrice = payWalletStatisticsService.getRechargePriceSummary();
|
||||
return success(PayStatisticsConvert.INSTANCE.convert(rechargePrice));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -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<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))
|
||||
.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
|
||||
|
|
|
@ -40,5 +40,5 @@ public class TradeTrendSummaryExcelVO {
|
|||
private Integer brokerageSettlementPrice;
|
||||
|
||||
@ExcelProperty(value = "商品退款金额", converter = MoneyConvert.class)
|
||||
private Integer orderRefundPrice;
|
||||
private Integer afterSaleRefundPrice;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<MemberAreaStatisticsRespVO> convertList(List<Area> areaList,
|
||||
Map<Integer, Integer> userCountMap,
|
||||
Map<Integer, MemberAreaStatisticsRespVO> orderMap) {
|
||||
Map<Integer, MemberAreaStatisticsRespBO> 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))
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -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<TradeTrendSummaryRespVO> convertList(List<TradeStatisticsDO> 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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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<TradeStatisticsDO> {
|
||||
|
||||
// TODO 芋艿:已经 review
|
||||
List<MemberAreaStatisticsRespVO> selectSummaryListByAreaId();
|
||||
List<MemberAreaStatisticsRespBO> selectSummaryListByAreaId();
|
||||
|
||||
// TODO 芋艿:已经 review
|
||||
Integer selectCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime,
|
||||
|
@ -65,10 +65,7 @@ public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsD
|
|||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
// TODO @芋艿:已经 review
|
||||
Long selectCountByStatus(@Param("status") Integer status);
|
||||
|
||||
// TODO 芋艿:已经 review
|
||||
Long selectCountByStatusAndPickUpStoreIdIsNotNull(@Param("status") Integer status);
|
||||
Long selectCountByStatusAndDeliveryType(@Param("status") Integer status, @Param("deliveryType") Integer deliveryType);
|
||||
|
||||
// TODO 芋艿:已经 review
|
||||
TradeOrderSummaryRespVO selectPaySummaryByStatusAndPayTimeBetween(@Param("status") Integer status,
|
||||
|
|
|
@ -30,8 +30,10 @@ public class TradeStatisticsJob implements JobHandler {
|
|||
@Override
|
||||
@TenantJob
|
||||
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("交易统计任务的参数只能为是正整数");
|
||||
}
|
||||
Integer days = Convert.toInt(param, 0);
|
||||
|
|
|
@ -48,13 +48,12 @@ public interface MemberStatisticsService {
|
|||
*/
|
||||
List<MemberSexStatisticsRespVO> getMemberSexStatisticsList();
|
||||
|
||||
// TODO @疯狂:这个要不要使用 getMemberTerminalStatisticsList;保持统一?
|
||||
/**
|
||||
* 按照终端,获得会员统计列表
|
||||
*
|
||||
* @return 会员统计列表
|
||||
*/
|
||||
List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList();
|
||||
List<MemberTerminalStatisticsRespVO> getMemberTerminalStatisticsList();
|
||||
|
||||
// TODO 芋艿:已经 review
|
||||
/**
|
||||
|
|
|
@ -65,10 +65,10 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
|
|||
vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE),
|
||||
MemberAreaStatisticsRespBO::getUserCount, Integer::sum);
|
||||
// 统计订单
|
||||
Map<Integer, MemberAreaStatisticsRespVO> orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(),
|
||||
vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE),
|
||||
vo -> vo,
|
||||
(a, b) -> new MemberAreaStatisticsRespVO()
|
||||
Map<Integer, MemberAreaStatisticsRespBO> 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<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList() {
|
||||
public List<MemberTerminalStatisticsRespVO> 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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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<MemberAreaStatisticsRespVO> getSummaryListByAreaId();
|
||||
List<MemberAreaStatisticsRespBO> 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
|
||||
/**
|
||||
|
|
|
@ -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<MemberAreaStatisticsRespVO> getSummaryListByAreaId() {
|
||||
public List<MemberAreaStatisticsRespBO> 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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -2,9 +2,8 @@
|
|||
<!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">
|
||||
|
||||
<!-- TODO @疯狂:是返回不是的 MemberAreaStatisticsRespBO 哈 -->
|
||||
<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 COUNT(DISTINCT s.user_id)
|
||||
FROM trade_order AS s
|
||||
|
@ -86,18 +85,11 @@
|
|||
GROUP BY date
|
||||
</select>
|
||||
|
||||
<select id="selectCountByStatus" resultType="java.lang.Long">
|
||||
<select id="selectCountByStatusAndDeliveryType" resultType="java.lang.Long">
|
||||
SELECT COUNT(1)
|
||||
FROM trade_order
|
||||
WHERE status = #{status}
|
||||
AND deleted = FALSE
|
||||
</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 delivery_type = #{deliveryType}
|
||||
AND deleted = FALSE
|
||||
</select>
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue