feat: event lead rows carry attendance and source, with an attended filter

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-01 21:31:03 +08:00
1 parent cba2929a00
commit 3af5cccd59
16 files changed
+160 -55

No files matched your search

@@ -73,10 +73,11 @@ public class AdminEventLeadController {
@RequestParam(required = false) String status,
@RequestParam(required = false) Long interestId,
@RequestParam(required = false) String leadType,
@RequestParam(required = false) Boolean attended,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "20") int size,
@RequestParam(required = false) Long companyId) {
return ResponseEntity.ok(adminEventLeadService.list(eventUuid, salespersonId, temperature, status, interestId, leadType, page, size, companyId));
return ResponseEntity.ok(adminEventLeadService.list(eventUuid, salespersonId, temperature, status, interestId, leadType, attended, page, size, companyId));
}
@AppAuth
@@ -31,8 +31,9 @@ public class AdminEventLeadExportController {
@RequestParam(required = false) String status,
@RequestParam(required = false) Long interestId,
@RequestParam(required = false) String leadType,
@RequestParam(required = false) Boolean attended,
@RequestParam(required = false) Long companyId) {
byte[] file = adminEventLeadService.export(eventUuid, salespersonId, temperature, status, interestId, leadType, companyId);
byte[] file = adminEventLeadService.export(eventUuid, salespersonId, temperature, status, interestId, leadType, attended, companyId);
// The service has already parsed the uuid as a number, so its digits are the canonical uuid; nothing else reaches the header.
return xlsx("event-leads-" + eventUuid.replaceAll("\\D", ""), file);
}
@@ -183,9 +183,9 @@ public class AdminEventLeadService {
// --- listing and edit ---
public Map<String, Object> list(String eventUuid, Long salespersonId, String temperature, String status, Long interestId,
String leadType, int page, int size, Long companyId) {
String leadType, Boolean attended, int page, int size, Long companyId) {
CompanyEvent event = loadEvent(eventUuid, companyId);
Map<String, Object> p = search(event, salespersonId, temperature, status, interestId, leadType, page, size);
Map<String, Object> p = search(event, salespersonId, temperature, status, interestId, leadType, attended, page, size);
List<Map<String, Object>> rows = p == null || p.get("content") == null ? List.of() : (List<Map<String, Object>>) p.get("content");
Map<Long, Map<String, Object>> interests = rows.isEmpty() ? Map.of() : interests(event.getCompanyId());
Map<Long, Map<String, Object>> users = new HashMap<>();
@@ -199,14 +199,14 @@ public class AdminEventLeadService {
}
/** The whole filtered listing as xlsx, paged 100 at a time. ponytail: buffers up to 20000 rows in memory; stream to the response if that grows. */
public byte[] export(String eventUuid, Long salespersonId, String temperature, String status, Long interestId, String leadType, Long companyId) {
public byte[] export(String eventUuid, Long salespersonId, String temperature, String status, Long interestId, String leadType, Boolean attended, Long companyId) {
User caller = caller();
CompanyEvent event = loadEvent(eventUuid, companyId);
Map<Long, Map<String, Object>> users = new HashMap<>();
Map<Long, Map<String, Object>>[] interests = new Map[1];
return LeadExport.build(caller.getUsername(), "event-leads:" + event.getUuid(), "Event leads",
List.of("Name", "Mobile", "Email", "Lead type", "Salesperson", "Temperature", "Status", "Interests", "Next follow-up"),
page -> search(event, salespersonId, temperature, status, interestId, leadType, page, LeadExport.PAGE),
List.of("Name", "Mobile", "Email", "Lead type", "Salesperson", "Temperature", "Status", "Interests", "Next follow-up", "Attended", "Source"),
page -> search(event, salespersonId, temperature, status, interestId, leadType, attended, page, LeadExport.PAGE),
r -> {
if (interests[0] == null) interests[0] = interests(event.getCompanyId());
Map<String, Object> m = view(r, interests[0], users);
@@ -215,10 +215,20 @@ public class AdminEventLeadService {
return Arrays.asList(m.get("name"), m.get("mobile"), m.get("email"), label(m.get("leadType")),
sp == null ? null : sp.get("name"), label(m.get("temperature")), label(m.get("status")),
String.join(", ", ((List<Map<String, Object>>) m.get("interests")).stream().map(i -> String.valueOf(i.get("name"))).toList()),
follow == null ? null : LocalDate.parse(follow));
follow == null ? null : LocalDate.parse(follow),
(boolean) m.get("attended") ? "Yes" : "No", sourceLabel(m.get("source")));
});
}
private static String sourceLabel(Object source) {
return switch (String.valueOf(source)) {
case "STAFF" -> "Staff";
case "QR" -> "QR";
case "INVITE" -> "Invite";
default -> source == null ? null : source.toString();
};
}
/** HOT becomes Hot. */
private static String label(Object code) {
String s = code == null ? null : code.toString();
@@ -226,7 +236,7 @@ public class AdminEventLeadService {
}
private Map<String, Object> search(CompanyEvent event, Long salespersonId, String temperature, String status, Long interestId,
String leadType, int page, int size) {
String leadType, Boolean attended, int page, int size) {
Map<String, Object> body = new LinkedHashMap<>();
body.put("companyId", event.getCompanyId());
body.put("eventUuid", event.getUuid());
@@ -235,6 +245,7 @@ public class AdminEventLeadService {
body.put("status", oneOf("status", status, STATUSES));
body.put("interestId", interestId);
body.put("leadType", oneOf("leadType", leadType, LEAD_TYPES));
body.put("attended", attended);
body.put("page", Math.max(page, 0));
body.put("size", size);
return restTemplateUtil.postForEntity(url(RestApiCounterServiceConstants.API_REST_COUNTER_EVENT_LEAD_FIND_BY_EVENT), MAP, body).getBody();
@@ -351,6 +362,8 @@ public class AdminEventLeadService {
m.put("nextFollowUpDate", d.get("nextFollowUpDate"));
m.put("notes", d.get("notes"));
m.put("capturedAt", d.get("capturedAt"));
m.put("attended", d.get("attendedAt") != null);
m.put("source", d.get("source"));
return m;
}