Subversion Repositories SmartDukaan

Rev

Rev 37027 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.dao.entity.user;

import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
import com.spice.profitmandi.dao.enumuration.dtr.VisitStatus;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.List;

@Entity
@Table(name = "user.lead")
public class Lead {
        @Id
        @Column(name = "id", unique = true, updatable = false)
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private int id;

        @Column(name = "first_name")
        private String firstName;

        @Column(name = "source")
        private String source;

        @Column(name = "color")
        private String color;

        @Transient
        private List<LeadActivity> leadActivities;

        @Transient
        private VisitStatus visitStatus;

        @Column(name = "outlet_name")
        private String outLetName;

        @Column(name = "potential")
        private double potential;

        public double getPotential() {
                return potential;
        }

        public void setPotential(double potential) {
                this.potential = potential;
        }

        public String getOutLetName() {
                return outLetName;
        }

        public void setOutLetName(String outLetName) {
                this.outLetName = outLetName;
        }

        public List<LeadActivity> getLeadActivities() {
                return leadActivities;
        }

        public void setLeadActivities(List<LeadActivity> leadActivities) {
                this.leadActivities = leadActivities;
        }

        @Column(name = "notinterested_reason")
        public String notinterestedReason;

        public String getNotinterestedReason() {
                return notinterestedReason;
        }

        public void setNotinterestedReason(String notinterestedReason) {
                this.notinterestedReason = notinterestedReason;
        }

        public String getColor() {
                return color;
        }

        public void setColor(String color) {
                this.color = color;
        }

        public String getSource() {
                return source;
        }

        public void setSource(String source) {
                this.source = source;
        }

        public String getFirstName() {
                return firstName;
        }

        public void setFirstName(String firstName) {
                this.firstName = firstName;
        }

        public String getLastName() {
                return lastName;
        }

        public void setLastName(String lastName) {
                this.lastName = lastName;
        }

        public String getFullName() {
                return String.join(", ", firstName, lastName);
        }

        @Column(name = "last_name")
        private String lastName;

        @Column(length = 10, name = "mobile")
        private String leadMobile;

        @Column(name = "created_by")
        private String createdBy;

        @Column(name = "auth_id")
        private int authId;

        public int getAuthId() {
                return authId;
        }

        @Transient
        private LeadActivity leadActivity;

        @Transient
        private LocalDateTime scheduledTimestamp;

        public LeadActivity getLeadActivity() {
                return leadActivity;
        }

        public VisitStatus getVisitStatus() {
                return visitStatus;
        }

        public void setVisitStatus(VisitStatus visitStatus) {
                this.visitStatus = visitStatus;
        }

        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + id;
                return result;
        }

        @Override
        public boolean equals(Object obj) {
                if (this == obj)
                        return true;
                if (obj == null)
                        return false;
                if (getClass() != obj.getClass())
                        return false;
                Lead other = (Lead) obj;
                if (id != other.id)
                        return false;
                return true;
        }

        public LocalDateTime getScheduledTimestamp() {
                return scheduledTimestamp;
        }

        public void setScheduledTimestamp(LocalDateTime scheduledTimestamp) {
                this.scheduledTimestamp = scheduledTimestamp;
        }

        public void setLeadActivity(LeadActivity leadActivity) {
                this.leadActivity = leadActivity;
        }

        public void setAuthId(int authId) {
                this.authId = authId;
        }

        @Column(name = "address")
        private String address;

        @Column(name = "city")
        private String city;

        @Column(name = "state")
        private String state;

        @Column(name = "recording_url")
        private String recordingUrl;

        public String getRecordingUrl() {
                return recordingUrl;
        }

        public void setRecordingUrl(String recordingUrl) {
                this.recordingUrl = recordingUrl;
        }

        @Column(name = "status")
        @Enumerated(EnumType.STRING)
        private LeadStatus status;

        @Column(name = "assign_to")
        private int assignTo;

        @Column(name = "closure_timestamp")
        private LocalDateTime closureTimestamp;

        public LocalDateTime getClosureTimestamp() {
                return closureTimestamp;
        }

        public void setClosureTimestamp(LocalDateTime closureTimestamp) {
                this.closureTimestamp = closureTimestamp;
        }

        @Column(name = "created_timestamp")
        private LocalDateTime createdTimestamp;

        @Column(name = "updated_timestamp")
        private LocalDateTime updatedTimestamp;

        // ---- LMS operating-core columns (additive; see migration_lms_operating_core.sql) ----
        // Legacy `status` above is kept in sync with `stage` (LeadStage.toLegacyStatus) on every mutation.

        /** Immutable formatted LMS id, e.g. LMS-UPW-26-000123. Generated on create; null for legacy rows. */
        @Column(name = "lms_code")
        private String lmsCode;

        /** Richer lifecycle stage (SOP §8). Null for legacy rows → derive via LeadStage.fromLegacy on read. */
        @Column(name = "stage")
        @Enumerated(EnumType.STRING)
        private com.spice.profitmandi.dao.enumuration.dtr.LeadStage stage;

        /** Last call disposition (SOP §12.2). */
        @Column(name = "disposition")
        @Enumerated(EnumType.STRING)
        private com.spice.profitmandi.dao.enumuration.dtr.LeadDisposition disposition;

        /** Sub-reason for NOT_INTERESTED (Price / Terms / Already partnered / Category mismatch / Other). */
        @Column(name = "disposition_sub_reason")
        private String dispositionSubReason;

        /** Creation path: 'A' = BGC outbound, 'B' = field encounter (geo mandatory). */
        @Column(name = "creation_path")
        private String creationPath;

        /** Resolved region (FK to cs.region) driving auto-assignment. */
        @Column(name = "region_id")
        private Integer regionId;

        /** Region short code (UPW/UPE/RJ/PB/HR/UK/DL) — denormalised for display + LMS id. */
        @Column(name = "region_code")
        private String regionCode;

        /** Auto-resolved owning BM/RSM auth id (distinct from assignTo, which is the working owner/ASM). */
        @Column(name = "owner_bm_id")
        private Integer ownerBmId;

        /** ASSIGNED / HOLD / FALLBACK (SOP §10.2). HOLD = no active BM/RSM for the region. */
        @Column(name = "assignment_status")
        private String assignmentStatus;

        /** First-contact SLA deadline = created + 5h (SOP §11). */
        @Column(name = "first_contact_due")
        private LocalDateTime firstContactDue;

        /** When first contact (call/visit with disposition) actually happened. Stamped once. */
        @Column(name = "first_contacted_at")
        private LocalDateTime firstContactedAt;

        /** Count of NOT_REACHABLE attempts; lead auto-flags DROPPED after N (SOP §8). */
        @Column(name = "unreachable_count")
        private Integer unreachableCount;

        public String getLmsCode() {
                return lmsCode;
        }

        public void setLmsCode(String lmsCode) {
                this.lmsCode = lmsCode;
        }

        public com.spice.profitmandi.dao.enumuration.dtr.LeadStage getStage() {
                return stage;
        }

        public void setStage(com.spice.profitmandi.dao.enumuration.dtr.LeadStage stage) {
                this.stage = stage;
        }

        public com.spice.profitmandi.dao.enumuration.dtr.LeadDisposition getDisposition() {
                return disposition;
        }

        public void setDisposition(com.spice.profitmandi.dao.enumuration.dtr.LeadDisposition disposition) {
                this.disposition = disposition;
        }

        public String getDispositionSubReason() {
                return dispositionSubReason;
        }

        public void setDispositionSubReason(String dispositionSubReason) {
                this.dispositionSubReason = dispositionSubReason;
        }

        public String getCreationPath() {
                return creationPath;
        }

        public void setCreationPath(String creationPath) {
                this.creationPath = creationPath;
        }

        public Integer getRegionId() {
                return regionId;
        }

        public void setRegionId(Integer regionId) {
                this.regionId = regionId;
        }

        public String getRegionCode() {
                return regionCode;
        }

        public void setRegionCode(String regionCode) {
                this.regionCode = regionCode;
        }

        public Integer getOwnerBmId() {
                return ownerBmId;
        }

        public void setOwnerBmId(Integer ownerBmId) {
                this.ownerBmId = ownerBmId;
        }

        public String getAssignmentStatus() {
                return assignmentStatus;
        }

        public void setAssignmentStatus(String assignmentStatus) {
                this.assignmentStatus = assignmentStatus;
        }

        public LocalDateTime getFirstContactDue() {
                return firstContactDue;
        }

        public void setFirstContactDue(LocalDateTime firstContactDue) {
                this.firstContactDue = firstContactDue;
        }

        public LocalDateTime getFirstContactedAt() {
                return firstContactedAt;
        }

        public void setFirstContactedAt(LocalDateTime firstContactedAt) {
                this.firstContactedAt = firstContactedAt;
        }

        public Integer getUnreachableCount() {
                return unreachableCount;
        }

        public void setUnreachableCount(Integer unreachableCount) {
                this.unreachableCount = unreachableCount;
        }

        /** Effective stage for display: stored stage, or derived from legacy status for pre-LMS rows. */
        @Transient
        public com.spice.profitmandi.dao.enumuration.dtr.LeadStage getEffectiveStage() {
                return stage != null
                                ? stage
                                : com.spice.profitmandi.dao.enumuration.dtr.LeadStage.fromLegacy(status, color);
        }

        public int getAssignTo() {
                return assignTo;
        }

        public void setAssignTo(int assignTo) {
                this.assignTo = assignTo;
        }

        public int getId() {
                return id;
        }

        public void setId(int id) {
                this.id = id;
        }

        public String getLeadMobile() {
                return leadMobile;
        }

        public void setLeadMobile(String leadMobile) {
                this.leadMobile = leadMobile;
        }

        public String getCreatedBy() {
                return createdBy;
        }

        public void setCreatedBy(String createdBy) {
                this.createdBy = createdBy;
        }

        public String getAddress() {
                return address;
        }

        public void setAddress(String address) {
                this.address = address;
        }

        public String getCity() {
                return city;
        }

        public void setCity(String city) {
                this.city = city;
        }

        public String getState() {
                return state;
        }

        public void setState(String state) {
                this.state = state;
        }

        public LeadStatus getStatus() {
                return status;
        }

        public void setStatus(LeadStatus status) {
                this.status = status;
        }

        public LocalDateTime getCreatedTimestamp() {
                return createdTimestamp;
        }

        public void setCreatedTimestamp(LocalDateTime createdTimestamp) {
                this.createdTimestamp = createdTimestamp;
        }

        public LocalDateTime getUpdatedTimestamp() {
                return updatedTimestamp;
        }

        public void setUpdatedTimestamp(LocalDateTime updatedTimestamp) {
                this.updatedTimestamp = updatedTimestamp;
        }

        @Override
        public String toString() {
                return "Lead [id=" + id + ", firstName=" + firstName + ", source=" + source + ", color=" + color
                                + ", leadActivities=" + leadActivities + ", visitStatus=" + visitStatus + ", outLetName=" + outLetName
                                + ", notinterestedReason=" + notinterestedReason + ", lastName=" + lastName + ", leadMobile="
                                + leadMobile + ", createdBy=" + createdBy + ", authId=" + authId + ", leadActivity=" + leadActivity
                                + ", scheduledTimestamp=" + scheduledTimestamp + ", address=" + address + ", city=" + city + ", state="
                                + state + ", status=" + status + ", assignTo=" + assignTo + ", closureTimestamp=" + closureTimestamp
                                + ", createdTimestamp=" + createdTimestamp + ", updatedTimestamp=" + updatedTimestamp + "]";
        }

}