Commit 825976d9 by Jony.L

首页统计bug修复

parent d4952f31
...@@ -17,6 +17,7 @@ import com.luhu.computility.module.biz.controller.admin.home.vo.HomeIndexTopBarR ...@@ -17,6 +17,7 @@ import com.luhu.computility.module.biz.controller.admin.home.vo.HomeIndexTopBarR
import com.luhu.computility.module.biz.controller.admin.home.vo.HomeIndexUsersCountRespVO; import com.luhu.computility.module.biz.controller.admin.home.vo.HomeIndexUsersCountRespVO;
import com.luhu.computility.module.compute.api.order.ComputeOrderStatisticsApi; import com.luhu.computility.module.compute.api.order.ComputeOrderStatisticsApi;
import com.luhu.computility.module.compute.api.order.dto.ComputeOrderStatisticsDTO; import com.luhu.computility.module.compute.api.order.dto.ComputeOrderStatisticsDTO;
import com.luhu.computility.module.compute.api.order.dto.ResourceOrderRespDTO;
import com.luhu.computility.module.member.controller.admin.user.vo.MemberUserPageReqVO; import com.luhu.computility.module.member.controller.admin.user.vo.MemberUserPageReqVO;
import com.luhu.computility.module.member.dal.dataobject.user.MemberUserDO; import com.luhu.computility.module.member.dal.dataobject.user.MemberUserDO;
import com.luhu.computility.module.member.service.user.MemberUserService; import com.luhu.computility.module.member.service.user.MemberUserService;
...@@ -319,19 +320,18 @@ public class HomeIndexServiceImpl implements HomeIndexService { ...@@ -319,19 +320,18 @@ public class HomeIndexServiceImpl implements HomeIndexService {
// 2. 查询目标订单(截止到endTime的有效订单) // 2. 查询目标订单(截止到endTime的有效订单)
LocalDateTime[] allTimePeriod = {LocalDate.of(1970, 1, 1).atStartOfDay(), endTime}; LocalDateTime[] allTimePeriod = {LocalDate.of(1970, 1, 1).atStartOfDay(), endTime};
// 算力订单:已完成状态 // 算力订单:已完成状态
TradeOrderPageReqVO computeQueryVO = new TradeOrderPageReqVO(); // TradeOrderPageReqVO computeQueryVO = new TradeOrderPageReqVO();
computeQueryVO.setCreateTime(allTimePeriod); // computeQueryVO.setCreateTime(allTimePeriod);
computeQueryVO.setStatus(TradeOrderStatusEnum.COMPLETED.getStatus()); // computeQueryVO.setStatus(TradeOrderStatusEnum.COMPLETED.getStatus());
List<TradeOrderDO> computeOrderList = tradeOrderQueryService.getOrderList(computeQueryVO); // List<TradeOrderDO> computeOrderList = tradeOrderQueryService.getOrderList(computeQueryVO);
// API订单:已支付状态 List<ResourceOrderRespDTO> resourceOrderList = computeOrderStatisticsApi.getPaidOrderList(allTimePeriod);
ApiOrderPageReqDTO apiOrderPageReqDTO = new ApiOrderPageReqDTO();
apiOrderPageReqDTO.setCreateTime(allTimePeriod);
List<ApiOrderRespDTO> apiOrderList = apiOrderApi.getPaidOrderList(allTimePeriod); List<ApiOrderRespDTO> apiOrderList = apiOrderApi.getPaidOrderList(allTimePeriod);
// 3. 按节点分组统计:数量 + 金额 // 3. 按节点分组统计:数量 + 金额
Map<LocalDate, Long> computeCountMap = groupOrderByNode(computeOrderList, timeNodes, dateType); Map<LocalDate, Long> computeCountMap = groupOrderByNode(resourceOrderList, timeNodes, dateType);
Map<LocalDate, Long> apiCountMap = groupOrderByNode(apiOrderList, timeNodes, dateType); Map<LocalDate, Long> apiCountMap = groupOrderByNode(apiOrderList, timeNodes, dateType);
Map<LocalDate, Integer> computeAmountMap = groupComputeAmountByNode(computeOrderList, timeNodes, dateType); Map<LocalDate, Integer> computeAmountMap = groupComputeAmountByNode(resourceOrderList, timeNodes, dateType);
Map<LocalDate, Integer> apiAmountMap = groupApiAmountByNode(apiOrderList, timeNodes, dateType); Map<LocalDate, Integer> apiAmountMap = groupApiAmountByNode(apiOrderList, timeNodes, dateType);
// 4. 构建返回结果 // 4. 构建返回结果
...@@ -395,15 +395,15 @@ public class HomeIndexServiceImpl implements HomeIndexService { ...@@ -395,15 +395,15 @@ public class HomeIndexServiceImpl implements HomeIndexService {
/** /**
* 算力订单金额分组统计(支持d/m/y) * 算力订单金额分组统计(支持d/m/y)
*/ */
private Map<LocalDate, Integer> groupComputeAmountByNode(List<TradeOrderDO> orderList, List<LocalDate> nodes, String dateType) { private Map<LocalDate, Integer> groupComputeAmountByNode(List<ResourceOrderRespDTO> orderList, List<LocalDate> nodes, String dateType) {
if (CollectionUtils.isEmpty(orderList)) { if (CollectionUtils.isEmpty(orderList)) {
return new HashMap<>(); return new HashMap<>();
} }
return nodes.stream().collect(Collectors.toMap( return nodes.stream().collect(Collectors.toMap(
node -> node, node -> node,
node -> orderList.stream() node -> (int) orderList.stream()
.filter(order -> isDateMatch(order.getCreateTime().toLocalDate(), node, dateType)) .filter(order -> isDateMatch(order.getCreateTime().toLocalDate(), node, dateType))
.mapToInt(TradeOrderDO::getPayPrice) .mapToLong(order -> order.getPaymentPrice() != null ? order.getPaymentPrice() : 0L)
.sum() .sum()
)); ));
} }
......
package com.luhu.computility.module.compute.api.order; package com.luhu.computility.module.compute.api.order;
import com.luhu.computility.module.compute.api.order.dto.ComputeOrderStatisticsDTO; import com.luhu.computility.module.compute.api.order.dto.ComputeOrderStatisticsDTO;
import com.luhu.computility.module.compute.api.order.dto.ResourceOrderRespDTO;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
/** /**
* 算力资源订单统计API接口 * 算力资源订单统计API接口
...@@ -19,4 +21,7 @@ public interface ComputeOrderStatisticsApi { ...@@ -19,4 +21,7 @@ public interface ComputeOrderStatisticsApi {
*/ */
ComputeOrderStatisticsDTO getTodayOrderStatistics(LocalDateTime[] timeRange); ComputeOrderStatisticsDTO getTodayOrderStatistics(LocalDateTime[] timeRange);
List<ResourceOrderRespDTO> getPaidOrderList(LocalDateTime[] timeRange);
} }
\ No newline at end of file
package com.luhu.computility.module.compute.api.order.dto;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @Author: jony
* @Date : 2025/11/3 09:06
* @VERSION v1.0
*/
@Data
public class ResourceOrderRespDTO {
private Long id;
/**
* 下单用户ID
*/
private Long userId;
/**
* 用户IP
*/
private String userIp;
/**
* 算力资源SKU ID
*/
private Long skuId;
/**
* 算力资源名称(下单时快照)
*/
private String spuName;
/**
* 订单编号
*/
private String orderNo;
/**
* 订单状态:0=待支付,1=已支付,2=已取消
*/
private Integer status;
/**
* 市场价格(分)
*/
private Long marketPrice;
/**
* 实付金额(分)
*/
private Long paymentPrice;
/**
* 支付订单编号
*/
private Long payOrderId;
/**
* 支付时间
*/
private LocalDateTime payTime;
/**
* 支付渠道
*/
private String payChannelCode;
/**
* 租赁开始时间
*/
private LocalDateTime rentStartTime;
/**
* 租赁结束时间
*/
private LocalDateTime rentEndTime;
/**
* 取消时间
*/
private LocalDateTime cancelTime;
/**
* 备注
*/
private String remark;
/**
* 算力资源状态:[0]未启用,[1]使用中,[2]已释放
*/
private Integer resourceStatus;
/**
* 退款状态
*/
private Integer refundStatus;
/**
* 退款金额
*/
private String refundPrice;
/**
* 开票状态:[0]未开 [1]开票中 [2]已开票
*/
private Integer invoiceStatus;
/**
* 发票链接
*/
private String invoiceUrl;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 最后更新时间
*/
private LocalDateTime updateTime;
/**
* 创建者,目前使用 SysUser 的 id 编号
*
* 使用 String 类型的原因是,未来可能会存在非数值的情况,留好拓展性。
*/
private String creator;
/**
* 更新者,目前使用 SysUser 的 id 编号
*
* 使用 String 类型的原因是,未来可能会存在非数值的情况,留好拓展性。
*/
private String updater;
/**
* 是否删除
*/
private Boolean deleted;
}
...@@ -3,15 +3,19 @@ package com.luhu.computility.module.compute.dal.mysql.resourceorder; ...@@ -3,15 +3,19 @@ package com.luhu.computility.module.compute.dal.mysql.resourceorder;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import cn.hutool.core.bean.BeanUtil;
import com.luhu.computility.framework.common.pojo.PageResult; import com.luhu.computility.framework.common.pojo.PageResult;
import com.luhu.computility.framework.mybatis.core.query.LambdaQueryWrapperX; import com.luhu.computility.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.luhu.computility.framework.mybatis.core.mapper.BaseMapperX; import com.luhu.computility.framework.mybatis.core.mapper.BaseMapperX;
import com.luhu.computility.framework.mybatis.core.query.MPJLambdaWrapperX; import com.luhu.computility.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.luhu.computility.module.compute.api.order.dto.ResourceOrderRespDTO;
import com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO; import com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO;
import com.luhu.computility.module.member.dal.dataobject.user.MemberUserDO; import com.luhu.computility.module.member.dal.dataobject.user.MemberUserDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import com.luhu.computility.module.compute.controller.admin.resourceorder.vo.*; import com.luhu.computility.module.compute.controller.admin.resourceorder.vo.*;
import static com.luhu.computility.module.compute.enums.ResourceOrderStatus.PAID;
/** /**
* 算力资源订单 Mapper * 算力资源订单 Mapper
* *
...@@ -87,4 +91,11 @@ public interface ResourceOrderMapper extends BaseMapperX<ResourceOrderDO> { ...@@ -87,4 +91,11 @@ public interface ResourceOrderMapper extends BaseMapperX<ResourceOrderDO> {
.orderByDesc(ResourceOrderDO::getId)); .orderByDesc(ResourceOrderDO::getId));
} }
default List<ResourceOrderRespDTO> getPaidOrderList(LocalDateTime[] timeRange) {
List<ResourceOrderDO> list = selectList(new LambdaQueryWrapperX<ResourceOrderDO>()
.eq(ResourceOrderDO::getStatus, PAID.getValue())
.betweenIfPresent(ResourceOrderDO::getCreateTime, timeRange));
return BeanUtil.copyToList(list, ResourceOrderRespDTO.class);
}
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.luhu.computility.module.compute.service.impl; ...@@ -2,6 +2,7 @@ package com.luhu.computility.module.compute.service.impl;
import com.luhu.computility.module.compute.api.order.ComputeOrderStatisticsApi; import com.luhu.computility.module.compute.api.order.ComputeOrderStatisticsApi;
import com.luhu.computility.module.compute.api.order.dto.ComputeOrderStatisticsDTO; import com.luhu.computility.module.compute.api.order.dto.ComputeOrderStatisticsDTO;
import com.luhu.computility.module.compute.api.order.dto.ResourceOrderRespDTO;
import com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO; import com.luhu.computility.module.compute.dal.dataobject.resourceorder.ResourceOrderDO;
import com.luhu.computility.module.compute.dal.mysql.resourceorder.ResourceOrderMapper; import com.luhu.computility.module.compute.dal.mysql.resourceorder.ResourceOrderMapper;
import com.luhu.computility.module.compute.enums.ResourceOrderStatus; import com.luhu.computility.module.compute.enums.ResourceOrderStatus;
...@@ -44,4 +45,9 @@ public class ComputeOrderStatisticsApiImpl implements ComputeOrderStatisticsApi ...@@ -44,4 +45,9 @@ public class ComputeOrderStatisticsApiImpl implements ComputeOrderStatisticsApi
} }
} }
@Override
public List<ResourceOrderRespDTO> getPaidOrderList(LocalDateTime[] timeRange) {
return resourceOrderMapper.getPaidOrderList(timeRange);
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment