Blame | Last modification | View Log | RSS feed
package com.spice.profitmandi.dao.entity.user;import com.spice.profitmandi.dao.enumuration.dtr.MetaLeadOutcome;import javax.persistence.Column;import javax.persistence.Entity;import javax.persistence.EnumType;import javax.persistence.Enumerated;import javax.persistence.GeneratedValue;import javax.persistence.GenerationType;import javax.persistence.Id;import javax.persistence.Lob;import javax.persistence.Table;import javax.persistence.UniqueConstraint;import java.time.LocalDateTime;/*** One row of a Meta lead-ads export, and what the import did with it.** <p>Serves three jobs at once:** <ul>* <li><b>Idempotency.</b> {@code meta_lead_id} is Meta's own id — unique and stable — so* re-uploading the same file, or an overlapping export, creates nothing twice. The existing* lead CSV import ({@code /csvFileAndSetLead}) has no dedupe at all and silently doubles every* lead on a second upload; this is the fix for that class of mistake.</li>* <li><b>Accounting.</b> Every row gets a row here whatever happened to it, so a 60-row file* always adds up to 60 and "where did that lead go?" has an answer.</li>* <li><b>Attribution.</b> Campaign, form and placement are kept so lead quality can later be* compared across campaigns — the reason for running the ads in the first place.</li>* </ul>** <p>{@code raw_row} holds the original row verbatim as JSON. Mapping is lossy by nature (a business* -value band becomes a number, a name gets split), and the source file will not be around in six* months; keeping the original means a mapping bug can be replayed rather than merely regretted.*/@Entity@Table(name = "user.meta_lead",uniqueConstraints = {@UniqueConstraint(columnNames = "meta_lead_id")})public class MetaLead {@Id@Column(name = "id", unique = true, updatable = false)@GeneratedValue(strategy = GenerationType.IDENTITY)private int id;/** Meta's own lead id. The idempotency key — unique, and stable across exports. */@Column(name = "meta_lead_id")private String metaLeadId;@Column(name = "import_batch_id")private Integer importBatchId;/** The lead this became. Null for every outcome except CREATED. */@Column(name = "lead_id")private Integer leadId;@Column(name = "outcome")@Enumerated(EnumType.STRING)private MetaLeadOutcome outcome;/** Why it was skipped or rejected. Null on CREATED. */@Column(name = "reason")private String reason;@Column(name = "campaign_name")private String campaignName;@Column(name = "form_name")private String formName;/** {@code fb} or {@code ig} — which placement produced the lead. */@Column(name = "platform")private String platform;/** When Meta captured the lead, as opposed to when we imported it. */@Column(name = "meta_created_time")private LocalDateTime metaCreatedTime;/** The original row as JSON, so a mapping bug can be replayed rather than guessed at. */@Lob@Column(name = "raw_row")private String rawRow;@Column(name = "created_timestamp")private LocalDateTime createdTimestamp;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getMetaLeadId() {return metaLeadId;}public void setMetaLeadId(String metaLeadId) {this.metaLeadId = metaLeadId;}public Integer getImportBatchId() {return importBatchId;}public void setImportBatchId(Integer importBatchId) {this.importBatchId = importBatchId;}public Integer getLeadId() {return leadId;}public void setLeadId(Integer leadId) {this.leadId = leadId;}public MetaLeadOutcome getOutcome() {return outcome;}public void setOutcome(MetaLeadOutcome outcome) {this.outcome = outcome;}public String getReason() {return reason;}public void setReason(String reason) {this.reason = reason;}public String getCampaignName() {return campaignName;}public void setCampaignName(String campaignName) {this.campaignName = campaignName;}public String getFormName() {return formName;}public void setFormName(String formName) {this.formName = formName;}public String getPlatform() {return platform;}public void setPlatform(String platform) {this.platform = platform;}public LocalDateTime getMetaCreatedTime() {return metaCreatedTime;}public void setMetaCreatedTime(LocalDateTime metaCreatedTime) {this.metaCreatedTime = metaCreatedTime;}public String getRawRow() {return rawRow;}public void setRawRow(String rawRow) {this.rawRow = rawRow;}public LocalDateTime getCreatedTimestamp() {return createdTimestamp;}public void setCreatedTimestamp(LocalDateTime createdTimestamp) {this.createdTimestamp = createdTimestamp;}@Overridepublic String toString() {return "MetaLead [metaLeadId=" + metaLeadId + ", outcome=" + outcome + ", leadId=" + leadId + "]";}}