Subversion Repositories SmartDukaan

Rev

Rev 36957 | Rev 37029 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36957 Rev 37027
Line 772... Line 772...
772
        }
772
        }
773
 
773
 
774
        Lead lead = new Lead();
774
        Lead lead = new Lead();
775
        lead.setLeadMobile(mobile);
775
        lead.setLeadMobile(mobile);
776
        lead.setFirstName(firstName.trim());
776
        lead.setFirstName(firstName.trim());
-
 
777
        // last_name / city / address / state are NOT NULL (no default) in user.lead; a minimal
-
 
778
        // name+number lead from the AI omits them, so coalesce nulls to "" to avoid an insert crash.
777
        lead.setLastName(aiLeadRequest.getLastName());
779
        lead.setLastName(aiLeadRequest.getLastName() == null ? "" : aiLeadRequest.getLastName().trim());
-
 
780
        String city = aiLeadRequest.getCity() == null ? "" : aiLeadRequest.getCity().trim();
778
        lead.setCity(aiLeadRequest.getCity());
781
        lead.setCity(city);
779
        lead.setOutLetName(aiLeadRequest.getOutletName());
782
        lead.setOutLetName(aiLeadRequest.getOutletName());
780
        // AI flow does not collect a separate address; mirror web capture and fall back to city
783
        // AI flow does not collect a separate address; mirror web capture and fall back to city
781
        lead.setAddress(aiLeadRequest.getCity());
784
        lead.setAddress(city);
-
 
785
        // AI flow does not collect state, but the column is NOT NULL - default to empty
-
 
786
        lead.setState("");
782
 
787
 
783
        // Source is stamped server-side; the caller cannot override it
788
        // Source is stamped server-side; the caller cannot override it
784
        lead.setSource(AI_LEAD_SOURCE);
789
        lead.setSource(AI_LEAD_SOURCE);
785
        lead.setCreatedBy(AI_LEAD_SOURCE);
790
        lead.setCreatedBy(AI_LEAD_SOURCE);
786
        lead.setStatus(LeadStatus.followUp);
791
        lead.setStatus(LeadStatus.followUp);
787
        lead.setColor("yellow");
792
        lead.setColor("yellow");
788
 
793
 
-
 
794
        // Optional call-recording URL - voice leads only. Store null when absent so chat leads stay empty.
-
 
795
        String recordingUrl = aiLeadRequest.getRecordingUrl();
-
 
796
        if (recordingUrl != null && !recordingUrl.trim().isEmpty()) {
-
 
797
            lead.setRecordingUrl(recordingUrl.trim());
-
 
798
        }
-
 
799
 
789
        // Auto-assign using the same routing the public web capture uses today
800
        // Auto-assign using the same routing the public web capture uses today
790
        lead.setAssignTo(53);
801
        lead.setAssignTo(53);
791
        lead.setAuthId(lead.getAssignTo());
802
        lead.setAuthId(lead.getAssignTo());
792
 
803
 
793
        lead.setCreatedTimestamp(LocalDateTime.now());
804
        lead.setCreatedTimestamp(LocalDateTime.now());