refactor(statistics): 切换数据查询服务并优化扫码统计功能

- 将 BrokerBiz 和 OrderBiz 中的数据查询从 StatisticsMapper 切换到 StatsQueryService
- 更新 StatisticsServiceImpl 使用 StatsQueryService 进行数据查询
- 添加订单数据合并功能到扫码统计图表中
- 重构扫码统计查询逻辑以支持统计数据和订单数据的合并显示
- 新增按小时和按日期统计订单数据的查询方法
- 优化 SQL 查询以分离统计数据和订单数据的查询逻辑
This commit is contained in:
2026-01-12 18:30:27 +08:00
parent 3bd658cc1f
commit f8c6604a8a
6 changed files with 165 additions and 50 deletions

View File

@@ -1,6 +1,7 @@
package com.ycwl.basic.biz;
import cn.hutool.core.date.DateUtil;
import com.ycwl.basic.clickhouse.service.StatsQueryService;
import com.ycwl.basic.mapper.BrokerMapper;
import com.ycwl.basic.mapper.BrokerRecordMapper;
import com.ycwl.basic.mapper.StatisticsMapper;
@@ -34,7 +35,7 @@ public class BrokerBiz {
@Autowired
private ScenicRepository scenicRepository;
@Autowired
private StatisticsMapper statisticsMapper;
private StatsQueryService statsQueryService;
public void processOrder(Long orderId) {
log.info("开始处理订单分佣,订单ID:{}", orderId);
@@ -52,7 +53,7 @@ public class BrokerBiz {
if (scenicConfig.getInteger("sample_store_day") != null) {
expireDay = scenicConfig.getInteger("sample_store_day");
}
List<Long> brokerIdList = statisticsMapper.getBrokerIdListForUser(order.getMemberId(), DateUtil.offsetDay(DateUtil.beginOfDay(order.getCreateAt()), -expireDay), order.getCreateAt());
List<Long> brokerIdList = statsQueryService.getBrokerIdListForUser(order.getMemberId(), DateUtil.offsetDay(DateUtil.beginOfDay(order.getCreateAt()), -expireDay), order.getCreateAt());
if (brokerIdList == null || brokerIdList.isEmpty()) {
log.info("用户与推客无关,订单ID:{}", orderId);
return;