add customerCount for list event record

This commit is contained in:
Timi
2026-09-16 12:54:39 +08:00
parent 6ac84c11b2
commit a2b6253d1d
6 changed files with 30 additions and 0 deletions
@@ -69,6 +69,7 @@ public class GaoEventRecordController {
result.setTotal(pageResult.getTotal()); result.setTotal(pageResult.getTotal());
result.setList(pageResult.getList()); result.setList(pageResult.getList());
result.setNumberValueTotal(resolveNumberValueTotal(page)); result.setNumberValueTotal(resolveNumberValueTotal(page));
result.setCustomerCount(service.countCustomerByRange(page));
{ {
List<String> customerIdList = result.getList().stream().map(GaoEventRecord::getCustomerId).toList(); List<String> customerIdList = result.getList().stream().map(GaoEventRecord::getCustomerId).toList();
Map<String, GaoEvent> eventMap = eventService.mapByIdList(result.getList().stream().map(GaoEventRecord::getEventId).toList()); Map<String, GaoEvent> eventMap = eventService.mapByIdList(result.getList().stream().map(GaoEventRecord::getEventId).toList());
@@ -87,6 +87,12 @@ public interface GaoEventRecordMapper extends BaseMapper<GaoEventRecord, String>
/// @return 登记事件记录列表 /// @return 登记事件记录列表
List<GaoEventRecord> selectByRange(GaoEventRecordPage page); List<GaoEventRecord> selectByRange(GaoEventRecordPage page);
/// 按登记记录列表条件统计去重客户数量
///
/// @param page 登记记录范围查询请求
/// @return 去重后的客户数量
long countCustomerByRange(GaoEventRecordPage page);
/// 按登记记录列表条件汇总数值 /// 按登记记录列表条件汇总数值
/// ///
/// @param page 登记记录范围查询请求 /// @param page 登记记录范围查询请求
@@ -117,6 +117,12 @@ public interface GaoEventRecordService extends BaseService<GaoEventRecord, Strin
/// @return 登记事件记录列表 /// @return 登记事件记录列表
PageResult<GaoEventRecord> pageByRange(GaoEventRecordPage req); PageResult<GaoEventRecord> pageByRange(GaoEventRecordPage req);
/// 按登记记录列表条件统计去重客户数量
///
/// @param req 登记记录范围查询请求
/// @return 去重后的客户数量
long countCustomerByRange(GaoEventRecordPage req);
/// 按时间范围统计门店登记数 /// 按时间范围统计门店登记数
/// ///
/// @param req 门店报表查询请求 /// @param req 门店报表查询请求
@@ -467,6 +467,12 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService<GaoEve
return result; return result;
} }
@Override
public long countCustomerByRange(GaoEventRecordPage page) {
TimiException.required(page.getStoreId(), "not found page.storeId");
return mapper.countCustomerByRange(page);
}
@Override @Override
public List<GaoEventRecordDailyStatView> stateDailyByRange(GaoStoreChartReq req) { public List<GaoEventRecordDailyStatView> stateDailyByRange(GaoStoreChartReq req) {
return mapper.stateDailyByRange(req); return mapper.stateDailyByRange(req);
@@ -19,4 +19,8 @@ public class GaoEventRecordPageResult extends PageResult<GaoEventRecord> {
/// 指定单个数值事件的登记数值合计,未指定单个 NUMBER 事件时为空 /// 指定单个数值事件的登记数值合计,未指定单个 NUMBER 事件时为空
@JsonView(ResponseView.Public.class) @JsonView(ResponseView.Public.class)
private Long numberValueTotal; private Long numberValueTotal;
/// 查询条件下去重后的客户数量
@JsonView(ResponseView.Public.class)
private Long customerCount;
} }
@@ -167,6 +167,13 @@
ORDER BY r.`registered_at` DESC, r.`created_at` DESC ORDER BY r.`registered_at` DESC, r.`created_at` DESC
LIMIT #{offset}, #{limit} LIMIT #{offset}, #{limit}
</select> </select>
<select id="countCustomerByRange" resultType="long">
SELECT
COUNT(DISTINCT r.`customer_id`)
<include refid="rangeFrom"/>
WHERE
<include refid="rangeWhere"/>
</select>
<select id="sumNumberValueByRange" resultType="java.lang.Long"> <select id="sumNumberValueByRange" resultType="java.lang.Long">
SELECT SELECT
COALESCE(SUM(r.`number_value`), 0) COALESCE(SUM(r.`number_value`), 0)