统计 用户 领取 记录3

This commit is contained in:
2025-11-18 11:06:53 +08:00
parent 0081c145a1
commit 3e1cbf14c3

View File

@@ -144,39 +144,39 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
}
}
Map<String, Object> resultmap = BeanUtil.beanToMap(recordPage);
List<CouponRecordCountVO> recordCountVO = getMapper().countRecordBySource(mkShopCouponRecordDTO.getCouponId(), mkShopCouponRecordDTO.getUserId(),
mkShopCouponRecordDTO.getStatus(), mkShopCouponRecordDTO.getSource(), startTime, endTime);
Map<String, Long> tempMap = recordCountVO.stream()
.collect(Collectors.toMap(
CouponRecordCountVO::getSourceType,
CouponRecordCountVO::getCount,
(existing, _) -> existing
));
Map<String, Long> categoryMap = TARGET_KEY.stream()
.collect(Collectors.toMap(
key -> key,
key -> tempMap.getOrDefault(key, 0L)
));
resultmap.put("categoryMap", categoryMap);
Map<String, Long> resultCountMap = new HashMap<>();
resultCountMap.put("用户领取", 0L);
resultCountMap.put("推广发放", 0L);
resultCountMap.put("管理员赠送", 0L);
resultCountMap.put("系统发送", 0L);
if (CollUtil.isNotEmpty(recordCountVO)) {
for (CouponRecordCountVO record : recordCountVO) {
String sourceName = record.getSourceType();
Long count = record.getCount();
String category = SOURCE_TO_CATEGORY.get(sourceName);
if (category != null) {
resultCountMap.put(category, resultCountMap.get(category) + count);
}
}
}
resultmap.put("categoryMap", categoryMap);
resultmap.put("resultCountMap", resultCountMap);
// List<CouponRecordCountVO> recordCountVO = getMapper().countRecordBySource(mkShopCouponRecordDTO.getCouponId(), mkShopCouponRecordDTO.getUserId(),
// mkShopCouponRecordDTO.getStatus(), mkShopCouponRecordDTO.getSource(), startTime, endTime);
// Map<String, Long> tempMap = recordCountVO.stream()
// .collect(Collectors.toMap(
// CouponRecordCountVO::getSourceType,
// CouponRecordCountVO::getCount,
// (existing, _) -> existing
// ));
// Map<String, Long> categoryMap = TARGET_KEY.stream()
// .collect(Collectors.toMap(
// key -> key,
// key -> tempMap.getOrDefault(key, 0L)
// ));
// resultmap.put("categoryMap", categoryMap);
// Map<String, Long> resultCountMap = new HashMap<>();
// resultCountMap.put("用户领取", 0L);
// resultCountMap.put("推广发放", 0L);
// resultCountMap.put("管理员赠送", 0L);
// resultCountMap.put("系统发送", 0L);
//
// if (CollUtil.isNotEmpty(recordCountVO)) {
// for (CouponRecordCountVO record : recordCountVO) {
// String sourceName = record.getSourceType();
// Long count = record.getCount();
//
// String category = SOURCE_TO_CATEGORY.get(sourceName);
// if (category != null) {
// resultCountMap.put(category, resultCountMap.get(category) + count);
// }
// }
// }
// resultmap.put("categoryMap", categoryMap);
// resultmap.put("resultCountMap", resultCountMap);
return resultmap;
}