1
This commit is contained in:
@@ -478,11 +478,11 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
// ==================== 追加:按下单人分组统计 ====================
|
||||
outputs.add("\n━━━━━━━ 按下单人统计 ━━━━━━━");
|
||||
|
||||
// 按下单人分组(过滤掉拍错退款)
|
||||
// 按下单人「前缀」分组:取第一个 "-" 之前为同组(如 凡-林、凡-淑玲 → 凡;陈文慧-林、陈文慧-666 → 陈文慧);无 "-" 则按完整下单人
|
||||
Map<String, List<JDOrder>> byBuyer = filtered.stream()
|
||||
.filter(o -> o.getStatus() == null || !"拍错退款".equals(o.getStatus()))
|
||||
.filter(o -> o.getBuyer() != null && !o.getBuyer().isEmpty())
|
||||
.collect(Collectors.groupingBy(JDOrder::getBuyer));
|
||||
.collect(Collectors.groupingBy(o -> buyerGroupKey(o.getBuyer())));
|
||||
|
||||
List<Map.Entry<String, List<JDOrder>>> buyerEntries = new ArrayList<>(byBuyer.entrySet());
|
||||
buyerEntries.sort(Comparator.comparing(en -> en.getKey() == null ? "" : en.getKey()));
|
||||
@@ -2225,6 +2225,25 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 慢单「按下单人统计」分组键:第一个 "-" 前的前缀视为同一对象;无 "-" 时用整段下单人。
|
||||
*/
|
||||
private static String buyerGroupKey(String buyer) {
|
||||
if (buyer == null) {
|
||||
return "";
|
||||
}
|
||||
String t = buyer.trim();
|
||||
if (t.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
int idx = t.indexOf('-');
|
||||
if (idx > 0) {
|
||||
String prefix = t.substring(0, idx).trim();
|
||||
return prefix.isEmpty() ? t : prefix;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
private boolean contains(Object field, String kwLower) {
|
||||
if (field == null) return false;
|
||||
return String.valueOf(field).toLowerCase(Locale.ROOT).contains(kwLower);
|
||||
|
||||
Reference in New Issue
Block a user