You've already forked FrameTour-BE
添加订单统计方法
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.ycwl.basic.service.pc;
|
||||
|
||||
import com.ycwl.basic.model.mobile.statistic.req.CommonQueryReq;
|
||||
import com.ycwl.basic.model.pc.statistics.resp.OrderStatisticsResp;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -17,4 +18,11 @@ public interface StatisticsService {
|
||||
* @return 统计数据(超过7天返回日期级别,否则返回小时级别)
|
||||
*/
|
||||
List<HashMap<String, String>> getScanCodeMemberChartAuto(CommonQueryReq query);
|
||||
|
||||
/**
|
||||
* 获取订单统计数据(包含订单数量和金额、推送订单数量、现场订单数量)
|
||||
* @param query 查询参数(包含景区ID、开始时间、结束时间;如果scenicId为空则统计全部景区,否则统计指定景区)
|
||||
* @return 统计数据(totalOrderCount: 总订单数量, totalOrderAmount: 总订单金额, pushOrderCount: 推送订单数量, sceneOrderCount: 现场订单数量)
|
||||
*/
|
||||
OrderStatisticsResp getOrderStatistics(CommonQueryReq query);
|
||||
}
|
@@ -2,6 +2,7 @@ package com.ycwl.basic.service.pc.impl;
|
||||
|
||||
import com.ycwl.basic.mapper.StatisticsMapper;
|
||||
import com.ycwl.basic.model.mobile.statistic.req.CommonQueryReq;
|
||||
import com.ycwl.basic.model.pc.statistics.resp.OrderStatisticsResp;
|
||||
import com.ycwl.basic.service.pc.StatisticsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -74,4 +75,30 @@ public class StatisticsServiceImpl implements StatisticsService {
|
||||
return getScanCodeMemberChartByHour(query);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderStatisticsResp getOrderStatistics(CommonQueryReq query) {
|
||||
// 时间参数兜底与规范化
|
||||
if (query.getStartTime() == null && query.getEndTime() == null) {
|
||||
// 默认查询今天:00:00:00 - 23:59:59
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime startOfDay = now.withHour(0).withMinute(0).withSecond(0).withNano(0);
|
||||
LocalDateTime endOfDay = now.withHour(23).withMinute(59).withSecond(59).withNano(0);
|
||||
query.setStartTime(Date.from(startOfDay.atZone(ZoneId.systemDefault()).toInstant()));
|
||||
query.setEndTime(Date.from(endOfDay.atZone(ZoneId.systemDefault()).toInstant()));
|
||||
} else {
|
||||
if (query.getEndTime() != null) {
|
||||
// 保证 endTime 为当天最后一秒
|
||||
LocalDateTime endDateTime = query.getEndTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
LocalDateTime endOfDay = endDateTime.withHour(23).withMinute(59).withSecond(59).withNano(0);
|
||||
query.setEndTime(Date.from(endOfDay.atZone(ZoneId.systemDefault()).toInstant()));
|
||||
} else if (query.getStartTime() != null) {
|
||||
// 仅传 startTime 时,将 endTime 置为 startTime 当天的 23:59:59
|
||||
LocalDateTime startDateTime = query.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
LocalDateTime endOfStartDay = startDateTime.withHour(23).withMinute(59).withSecond(59).withNano(0);
|
||||
query.setEndTime(Date.from(endOfStartDay.atZone(ZoneId.systemDefault()).toInstant()));
|
||||
}
|
||||
}
|
||||
return statisticsMapper.getOrderStatistics(query);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user