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