| Line 158... |
Line 158... |
| 158 |
int assignTo = resolveAiLeadAssignee();
|
158 |
int assignTo = resolveAiLeadAssignee();
|
| 159 |
lead.setAssignTo(assignTo);
|
159 |
lead.setAssignTo(assignTo);
|
| 160 |
lead.setAuthId(lead.getAssignTo());
|
160 |
lead.setAuthId(lead.getAssignTo());
|
| 161 |
lead.setCreatedTimestamp(LocalDateTime.now());
|
161 |
lead.setCreatedTimestamp(LocalDateTime.now());
|
| 162 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
162 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
163 |
// Stamp before the insert: region, owner, stage and an SLA clock. Without it the lead is
|
| - |
|
164 |
// invisible to every SLA report.
|
| - |
|
165 |
lmsAssignmentService.stamp(lead, "A");
|
| 163 |
leadCreationService.createUnattended(lead);
|
166 |
leadCreationService.createUnattended(lead);
|
| - |
|
167 |
// Only stamp the code on a lead that was actually written. createUnattended SKIPS the
|
| - |
|
168 |
// persist when the number collides with an open lead, and a blind persist here would
|
| - |
|
169 |
// resurrect the duplicate it just refused.
|
| - |
|
170 |
if (lead.getId() > 0) {
|
| - |
|
171 |
lead.setLmsCode(lmsAssignmentService.generateLmsCode(lead));
|
| - |
|
172 |
leadRepository.persist(lead);
|
| - |
|
173 |
}
|
| 164 |
|
174 |
|
| 165 |
LOGGER.info("AI lead intake: created lead id={} for mobile {}, assigned to authId={}", lead.getId(), mobile, assignTo);
|
175 |
LOGGER.info("AI lead intake: created lead id={} for mobile {}, assigned to authId={}", lead.getId(), mobile, assignTo);
|
| 166 |
return aiLeadResponse(HttpStatus.OK, "200", "OK", "SUCCESS", lead.getId());
|
176 |
return aiLeadResponse(HttpStatus.OK, "200", "OK", "SUCCESS", lead.getId());
|
| 167 |
}
|
177 |
}
|
| 168 |
|
178 |
|
| Line 213... |
Line 223... |
| 213 |
|
223 |
|
| 214 |
@Autowired
|
224 |
@Autowired
|
| 215 |
private LeadRepository leadRepository;
|
225 |
private LeadRepository leadRepository;
|
| 216 |
|
226 |
|
| 217 |
@Autowired
|
227 |
@Autowired
|
| - |
|
228 |
private com.spice.profitmandi.service.LmsAssignmentService lmsAssignmentService;
|
| - |
|
229 |
|
| - |
|
230 |
@Autowired
|
| 218 |
private com.spice.profitmandi.dao.service.lead.LeadCreationService leadCreationService;
|
231 |
private com.spice.profitmandi.dao.service.lead.LeadCreationService leadCreationService;
|
| 219 |
|
232 |
|
| 220 |
@Autowired
|
233 |
@Autowired
|
| 221 |
private LeadActivityRepository leadActivityRepository;
|
234 |
private LeadActivityRepository leadActivityRepository;
|
| 222 |
|
235 |
|
| Line 1075... |
Line 1088... |
| 1075 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
1088 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
| 1076 |
String authUserName = authUser.getFirstName() + " " + authUser.getLastName();
|
1089 |
String authUserName = authUser.getFirstName() + " " + authUser.getLastName();
|
| 1077 |
lead.setCreatedBy(authUserName);
|
1090 |
lead.setCreatedBy(authUserName);
|
| 1078 |
lead.setAuthId(authUser.getId());
|
1091 |
lead.setAuthId(authUser.getId());
|
| 1079 |
LOGGER.info("lead --- {}", lead);
|
1092 |
LOGGER.info("lead --- {}", lead);
|
| - |
|
1093 |
// Stamp before the insert: region, owner, stage and an SLA clock.
|
| - |
|
1094 |
lmsAssignmentService.stamp(lead, "A");
|
| 1080 |
// Goes through the service so a stale open lead on this number is retired first.
|
1095 |
// Goes through the service so a stale open lead on this number is retired first.
|
| - |
|
1096 |
// Unlike createUnattended, create() throws on a block, so reaching the next line means
|
| - |
|
1097 |
// the lead was written.
|
| 1081 |
leadCreationService.create(lead, authUser.getId(), false);
|
1098 |
leadCreationService.create(lead, authUser.getId(), false);
|
| - |
|
1099 |
lead.setLmsCode(lmsAssignmentService.generateLmsCode(lead));
|
| - |
|
1100 |
leadRepository.persist(lead);
|
| 1082 |
LeadActivity leadActivity = new LeadActivity();
|
1101 |
LeadActivity leadActivity = new LeadActivity();
|
| 1083 |
leadActivity.setLeadId(lead.getId());
|
1102 |
leadActivity.setLeadId(lead.getId());
|
| 1084 |
leadActivity.setRemark(createRefferalRequest.getRemark());
|
1103 |
leadActivity.setRemark(createRefferalRequest.getRemark());
|
| 1085 |
leadActivity.setAuthId(authUser.getId());
|
1104 |
leadActivity.setAuthId(authUser.getId());
|
| 1086 |
|
1105 |
|
| Line 1298... |
Line 1317... |
| 1298 |
} else {
|
1317 |
} else {
|
| 1299 |
lead.setColor("Yellow");
|
1318 |
lead.setColor("Yellow");
|
| 1300 |
}
|
1319 |
}
|
| 1301 |
lead.setNotinterestedReason(createLeadActivityRequest.getReason());
|
1320 |
lead.setNotinterestedReason(createLeadActivityRequest.getReason());
|
| 1302 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
1321 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
| 1303 |
// Persist the mutated Lead row. Without this the audit activity is written but
|
- |
|
| 1304 |
// the main lead table keeps the old status/assignTo — the list view shows the
|
- |
|
| 1305 |
// stale row while the activity dialog shows the new state.
|
1322 |
leadRepository.persist(lead);
|
| 1306 |
leadRepository.persist(lead);
|
1323 |
leadRepository.persist(lead);
|
| 1307 |
|
1324 |
|
| 1308 |
int authId = 0;
|
1325 |
int authId = 0;
|
| 1309 |
authId = lead.getAssignTo();
|
1326 |
authId = lead.getAssignTo();
|
| 1310 |
Map<Integer, LeadActivity> leadActivityMap = new HashMap<>();
|
1327 |
Map<Integer, LeadActivity> leadActivityMap = new HashMap<>();
|
| Line 1515... |
Line 1532... |
| 1515 |
lead.setColor("yellow");
|
1532 |
lead.setColor("yellow");
|
| 1516 |
// change
|
1533 |
// change
|
| 1517 |
lead.setCreatedBy(createdBy.getFullName());
|
1534 |
lead.setCreatedBy(createdBy.getFullName());
|
| 1518 |
lead.setAuthId(createdBy.getId());
|
1535 |
lead.setAuthId(createdBy.getId());
|
| 1519 |
|
1536 |
|
| - |
|
1537 |
lmsAssignmentService.stamp(lead, "A");
|
| 1520 |
// CSV: skip only the colliding row, import the rest.
|
1538 |
// CSV: skip only the colliding row, import the rest. The continue also skips the
|
| - |
|
1539 |
// lms_code stamp below, which is right — nothing was written to stamp.
|
| 1521 |
if (leadCreationService.createUnattended(lead).isBlocked()) { continue; }
|
1540 |
if (leadCreationService.createUnattended(lead).isBlocked()) { continue; }
|
| - |
|
1541 |
lead.setLmsCode(lmsAssignmentService.generateLmsCode(lead));
|
| - |
|
1542 |
leadRepository.persist(lead);
|
| 1522 |
|
1543 |
|
| 1523 |
LeadActivity leadActivity = new LeadActivity();
|
1544 |
LeadActivity leadActivity = new LeadActivity();
|
| 1524 |
leadActivity.setLeadId(lead.getId());
|
1545 |
leadActivity.setLeadId(lead.getId());
|
| 1525 |
leadActivity.setRemark("New Lead");
|
1546 |
leadActivity.setRemark("New Lead");
|
| 1526 |
leadActivity.setSchelduleTimestamp(null);
|
1547 |
leadActivity.setSchelduleTimestamp(null);
|