|
@@ -1,5 +1,6 @@
|
|
|
package com.qunzhixinxi.hnqz.daemon.quartz.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.entity.SingleMemberSettleSameAmountInSeveralMonths;
|
|
|
import com.qunzhixinxi.hnqz.daemon.quartz.entity.WmScorePackageSettleNote;
|
|
@@ -11,6 +12,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -48,6 +50,9 @@ public class WmScorePackageSettleNoteServiceImpl extends ServiceImpl<WmScorePack
|
|
|
|
|
|
/**
|
|
|
* 同一用户,连续多月结算金额相同
|
|
|
+ * <p>
|
|
|
+ * 在A企业下,张三5月份结算了1000(加入是两个积分包500和500),六月份也结算了1000(400和600),这是连续两个月结算金额相同,应该把500、500、400、600四个积分包列出来
|
|
|
+ * 同一个用户,同一个月结算相同金额不算
|
|
|
*
|
|
|
* @param startTime 开始时间
|
|
|
* @param endTime 结束时间
|
|
@@ -58,16 +63,20 @@ public class WmScorePackageSettleNoteServiceImpl extends ServiceImpl<WmScorePack
|
|
|
|
|
|
List<SingleMemberSettleSameAmountInSeveralMonths> list = wmScorePackageSettleNoteMapper.singleMemberSettleSameAmountInSeveralMonths(startTime, endTime);
|
|
|
|
|
|
- // 按照用户分组,然后按照结算金额分组,如果结算金额对应的结算记录大于1,则表明有相同的金额
|
|
|
- Map<String, Map<BigDecimal, List<SingleMemberSettleSameAmountInSeveralMonths>>> collect = list.stream().collect(Collectors.groupingBy(SingleMemberSettleSameAmountInSeveralMonths::getUsername, Collectors.groupingBy(SingleMemberSettleSameAmountInSeveralMonths::getSettleAmount)));
|
|
|
+ // 按照用户分组,然后按照结算金额分组,再按创建月分组,如果创建月对应的结算记录大于1,则表明有相同的金额
|
|
|
+ Map<String, Map<BigDecimal, Map<String, List<SingleMemberSettleSameAmountInSeveralMonths>>>> collect =
|
|
|
+ list.stream().collect(Collectors.groupingBy(SingleMemberSettleSameAmountInSeveralMonths::getUsername,
|
|
|
+ Collectors.groupingBy(SingleMemberSettleSameAmountInSeveralMonths::getSettleAmount,
|
|
|
+ Collectors.groupingBy(e -> DateTimeFormatter.ofPattern(DatePattern.NORM_MONTH_PATTERN).format(e.getCreateTime())))));
|
|
|
|
|
|
|
|
|
List<SingleMemberSettleSameAmountInSeveralMonths> duplicated = new ArrayList<>(list.size());
|
|
|
|
|
|
- for (Map.Entry<String, Map<BigDecimal, List<SingleMemberSettleSameAmountInSeveralMonths>>> entry : collect.entrySet()) {
|
|
|
- for (Map.Entry<BigDecimal, List<SingleMemberSettleSameAmountInSeveralMonths>> ent : entry.getValue().entrySet()) {
|
|
|
- if (ent.getValue().size() > 1) {
|
|
|
- duplicated.addAll(ent.getValue());
|
|
|
+ for (Map.Entry<String, Map<BigDecimal, Map<String, List<SingleMemberSettleSameAmountInSeveralMonths>>>> entry : collect.entrySet()) {
|
|
|
+ for (Map.Entry<BigDecimal, Map<String, List<SingleMemberSettleSameAmountInSeveralMonths>>> ent : entry.getValue().entrySet()) {
|
|
|
+ Map<String, List<SingleMemberSettleSameAmountInSeveralMonths>> entValue = ent.getValue();
|
|
|
+ if (entValue.size() > 1) {
|
|
|
+ entValue.forEach((key, value) -> duplicated.addAll(value));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -110,6 +119,8 @@ public class WmScorePackageSettleNoteServiceImpl extends ServiceImpl<WmScorePack
|
|
|
|
|
|
/**
|
|
|
* 同一企业,当前月给多个用户支付相同金额
|
|
|
+ * <p>
|
|
|
+ * 统计逻辑通 singleMemberSettleSameAmountInSeveralMonths
|
|
|
*
|
|
|
* @param startTime 开始时间
|
|
|
* @param endTime 结束时间
|
|
@@ -120,15 +131,19 @@ public class WmScorePackageSettleNoteServiceImpl extends ServiceImpl<WmScorePack
|
|
|
public List<SingleMemberSettleSameAmountInSeveralMonths> singleEnterpriseSettleSameAmountForSeveralMembersInCurrentMonth(LocalDateTime startTime, LocalDateTime endTime, int memberCount) {
|
|
|
List<SingleMemberSettleSameAmountInSeveralMonths> list = wmScorePackageSettleNoteMapper.singleMemberSettleSameAmountInSeveralMonths(startTime, endTime);
|
|
|
|
|
|
- // 按照企业分组,然后按照结算金额分组,如果结算金额对应的结算记录大于1,则表明有相同的金额
|
|
|
- Map<String, Map<BigDecimal, List<SingleMemberSettleSameAmountInSeveralMonths>>> collect = list.stream().collect(Collectors.groupingBy(SingleMemberSettleSameAmountInSeveralMonths::getDeptId, Collectors.groupingBy(SingleMemberSettleSameAmountInSeveralMonths::getSettleAmount)));
|
|
|
+ // 按照企业分组,然后按照结算金额分组,然后按照月份分组如果结算金额对应的结算记录大于1,则表明有相同的金额
|
|
|
+ Map<String, Map<BigDecimal, Map<String, List<SingleMemberSettleSameAmountInSeveralMonths>>>> collect =
|
|
|
+ list.stream().collect(Collectors.groupingBy(SingleMemberSettleSameAmountInSeveralMonths::getDeptId,
|
|
|
+ Collectors.groupingBy(SingleMemberSettleSameAmountInSeveralMonths::getSettleAmount,
|
|
|
+ Collectors.groupingBy(e -> DateTimeFormatter.ofPattern(DatePattern.NORM_MONTH_PATTERN).format(e.getCreateTime())))));
|
|
|
|
|
|
List<SingleMemberSettleSameAmountInSeveralMonths> riskResult = new ArrayList<>(list.size());
|
|
|
|
|
|
- for (Map.Entry<String, Map<BigDecimal, List<SingleMemberSettleSameAmountInSeveralMonths>>> entry : collect.entrySet()) {
|
|
|
- for (Map.Entry<BigDecimal, List<SingleMemberSettleSameAmountInSeveralMonths>> ent : entry.getValue().entrySet()) {
|
|
|
- if (ent.getValue().size() > memberCount) {
|
|
|
- riskResult.addAll(ent.getValue());
|
|
|
+ for (Map.Entry<String, Map<BigDecimal, Map<String, List<SingleMemberSettleSameAmountInSeveralMonths>>>> entry : collect.entrySet()) {
|
|
|
+ for (Map.Entry<BigDecimal, Map<String, List<SingleMemberSettleSameAmountInSeveralMonths>>> ent : entry.getValue().entrySet()) {
|
|
|
+ Map<String, List<SingleMemberSettleSameAmountInSeveralMonths>> entValue = ent.getValue();
|
|
|
+ if (entValue.size() > memberCount) {
|
|
|
+ entValue.forEach((k, v) -> riskResult.addAll(v));
|
|
|
}
|
|
|
}
|
|
|
|