| 25899 |
tejbeer |
1 |
package com.spice.profitmandi.dao.repository.dtr;
|
|
|
2 |
|
| 32471 |
tejbeer |
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
4 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 25899 |
tejbeer |
5 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
|
|
6 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
|
| 32471 |
tejbeer |
7 |
import com.spice.profitmandi.dao.model.LeadDetailModel;
|
| 33246 |
ranu |
8 |
import org.springframework.stereotype.Repository;
|
| 25899 |
tejbeer |
9 |
|
| 33246 |
ranu |
10 |
import java.time.LocalDateTime;
|
|
|
11 |
import java.util.List;
|
|
|
12 |
|
| 25899 |
tejbeer |
13 |
@Repository
|
|
|
14 |
public interface LeadRepository {
|
| 31249 |
tejbeer |
15 |
|
| 32471 |
tejbeer |
16 |
public void persist(Lead lead);
|
| 25899 |
tejbeer |
17 |
|
| 32471 |
tejbeer |
18 |
public List<Lead> selectByAssignAuthIdAndStatus(int authId, LeadStatus status, int offset, int limit);
|
| 25899 |
tejbeer |
19 |
|
| 32471 |
tejbeer |
20 |
public Lead selectById(int id);
|
| 25915 |
amit.gupta |
21 |
|
| 35507 |
ranu |
22 |
List<Lead> selectAllByColorStatusAndBetweenDate(List<LeadStatus> status, List<String> color, LocalDateTime createdTimestamp, LocalDateTime endDateTimeStamp);
|
|
|
23 |
|
| 32471 |
tejbeer |
24 |
public List<Lead> selectAllByIds(List<Integer> ids);
|
| 31249 |
tejbeer |
25 |
|
| 32471 |
tejbeer |
26 |
public List<Lead> selectByAssignAuthIdAndStatus(int authId, LeadStatus status);
|
| 26298 |
tejbeer |
27 |
|
| 32471 |
tejbeer |
28 |
public List<Lead> selectByAssignAuthIdsAndStatus(List<Integer> authId, LeadStatus status);
|
| 26298 |
tejbeer |
29 |
|
| 32471 |
tejbeer |
30 |
public List<Lead> selectAll(int offset, int limit);
|
| 25979 |
tejbeer |
31 |
|
| 33246 |
ranu |
32 |
public List<Lead> selectAllBylistStatus(List<LeadStatus> status) throws ProfitMandiBusinessException;
|
| 27610 |
tejbeer |
33 |
|
| 32471 |
tejbeer |
34 |
public List<Lead> selectAllByStatus(LeadStatus status);
|
| 25979 |
tejbeer |
35 |
|
| 32471 |
tejbeer |
36 |
public List<Lead> selectAllByStatusAndUpdatedTimestamp(List<LeadStatus> status, LocalDateTime updatedTimestamp);
|
| 27615 |
tejbeer |
37 |
|
| 32471 |
tejbeer |
38 |
public List<Lead> selectAllByStatus(List<LeadStatus> status, int offset, int limit);
|
| 25988 |
tejbeer |
39 |
|
| 32471 |
tejbeer |
40 |
List<Lead> selectLeadsScheduledBetweenDate(List<Integer> fofoIds, LocalDateTime startDate, LocalDateTime endDate);
|
| 25988 |
tejbeer |
41 |
|
| 32471 |
tejbeer |
42 |
public long selectCountByStatus(List<LeadStatus> status);
|
| 25988 |
tejbeer |
43 |
|
| 32471 |
tejbeer |
44 |
public long getLeadCount(LeadStatus status, String searchTerm);
|
| 25988 |
tejbeer |
45 |
|
| 32471 |
tejbeer |
46 |
public List<Lead> selectBySearchTerm(List<LeadStatus> status, String searchTerm, int offset, int limit);
|
| 27642 |
tejbeer |
47 |
|
| 36984 |
aman |
48 |
// Global lead search: matches name / mobile / outlet / city across ALL leads (any status, any date).
|
|
|
49 |
public List<Lead> selectByGlobalSearch(String searchTerm, int limit);
|
|
|
50 |
|
| 32471 |
tejbeer |
51 |
public List<Lead> selectAllByColorStatusAndUpdatedTimestamp(List<LeadStatus> status, List<String> color, LocalDateTime updatedTimestamp);
|
| 29277 |
manish |
52 |
|
| 34894 |
aman |
53 |
public List<Lead> selectAllByColorStatusAndCreatedTimestamp(List<LeadStatus> status, List<String> color, LocalDateTime createdTimestamp);
|
|
|
54 |
|
| 32471 |
tejbeer |
55 |
List<Lead> selectAllByStatusAndUpdatedTimestampAndAuthId(List<LeadStatus> status, LocalDateTime updatedTimestamp, List<Integer> authIds);
|
| 29277 |
manish |
56 |
|
| 32471 |
tejbeer |
57 |
List<Lead> selectAllByColorStatusAndUpdatedTimestampAndAuthIds(List<LeadStatus> status, List<Integer> authIds, List<String> color, LocalDateTime updatedTimestamp);
|
|
|
58 |
|
| 35769 |
amit |
59 |
List<Lead> selectAllByColorStatusAndBetweenCreatedDate(List<LeadStatus> status, List<String> color, LocalDateTime startDate, LocalDateTime endDate);
|
|
|
60 |
|
|
|
61 |
List<Lead> selectAllByColorStatusAndBetweenCreatedDateAndAuthIds(List<LeadStatus> status, List<Integer> authIds, List<String> color, LocalDateTime startDate, LocalDateTime endDate);
|
|
|
62 |
|
| 32471 |
tejbeer |
63 |
public void persistLeadDetail(LeadDetailModel leadDetailModel, AuthUser authUser) throws ProfitMandiBusinessException;
|
|
|
64 |
|
| 35079 |
vikas |
65 |
Lead selectByMobileNumber(String mobileNumber);
|
| 36957 |
aman |
66 |
|
|
|
67 |
Lead selectByMobileNumberAndSource(String mobileNumber, String source);
|
| 37120 |
vikas |
68 |
|
|
|
69 |
// ---- LMS dashboard aggregation (SOP §18) -------------------------------------------------
|
|
|
70 |
// All aggregates bucket EVERY lead: rows with a real `stage` use it; legacy rows (stage NULL)
|
|
|
71 |
// derive a stage from `status` in SQL, mirroring LeadStage.fromLegacy. Read-only, no schema change.
|
|
|
72 |
|
|
|
73 |
/** (derivedStage, count) for the optional region + created-date window. */
|
|
|
74 |
java.util.List<Object[]> countByDerivedStage(Integer regionId, LocalDateTime from, LocalDateTime to);
|
|
|
75 |
|
|
|
76 |
/** (derivedStage, SUM(potential)) for the optional region + window — for the onboarded-value KPI. */
|
|
|
77 |
java.util.List<Object[]> sumPotentialByDerivedStage(Integer regionId, LocalDateTime from, LocalDateTime to);
|
|
|
78 |
|
|
|
79 |
/** (regionCode, derivedStage, count) across all regions in the window — feeds the state funnel. */
|
|
|
80 |
java.util.List<Object[]> countByRegionAndDerivedStage(LocalDateTime from, LocalDateTime to);
|
|
|
81 |
|
|
|
82 |
/** (regionCode, totalWithDue, onTime) — first-contact SLA compliance per region. */
|
|
|
83 |
java.util.List<Object[]> slaComplianceByRegion(LocalDateTime from, LocalDateTime to);
|
|
|
84 |
|
|
|
85 |
/** (ownerBmId, isoYearWeek, totalWithDue, onTime) — SLA compliance per BM per week, for the heat-map. */
|
|
|
86 |
java.util.List<Object[]> slaComplianceByBmAndWeek(LocalDateTime from, LocalDateTime to);
|
|
|
87 |
|
|
|
88 |
/** (derivedStage, count) of OPEN leads not touched since {@code olderThan} — the ageing widget. */
|
|
|
89 |
java.util.List<Object[]> ageingByDerivedStage(LocalDateTime olderThan);
|
|
|
90 |
|
|
|
91 |
/** Single row of conditional-sum attention counts (see impl) for the optional region. */
|
|
|
92 |
Object[] attentionCounts(Integer regionId, LocalDateTime now, LocalDateTime nowPlus1h);
|
|
|
93 |
|
|
|
94 |
/** Lead ids for a drill-down bucket (STAGE / ATTENTION / REGION), newest first, capped at {@code limit}. */
|
|
|
95 |
java.util.List<Integer> selectLeadIdsForBucket(String bucketType, String bucketKey, Integer regionId,
|
|
|
96 |
LocalDateTime now, LocalDateTime nowPlus1h,
|
|
|
97 |
LocalDateTime from, LocalDateTime to, int limit);
|
| 25899 |
tejbeer |
98 |
}
|