Rev 36081 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.dao.model;import com.fasterxml.jackson.annotation.JsonIgnore;import com.fasterxml.jackson.annotation.JsonIgnoreProperties;import com.spice.profitmandi.common.util.FormattingUtils;import com.spice.profitmandi.dao.enumuration.catalog.AchievementType;import com.spice.profitmandi.dao.enumuration.catalog.OfferSchemeType;import com.spice.profitmandi.service.offers.ItemCriteria;import com.spice.profitmandi.service.offers.PartnerCriteria;import com.spice.profitmandi.service.offers.PayoutSlab;import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;import java.time.LocalDateTime;import java.util.List;import java.util.Map;import java.util.Objects;@JsonIgnoreProperties(ignoreUnknown = true)public class CreateOfferRequest implements java.io.Serializable {private static final long serialVersionUID = 1L;private int id;private boolean active;private boolean baseCriteria;private boolean discount;private String name;private boolean booster;private LocalDateTime startDate;private LocalDateTime endDate;private LocalDateTime processTimestamp;private String offerNotes;private String terms;private AchievementType targetType;private AchievementType payoutType;private String activationBrands;private OfferSchemeType schemeType;private double sellinPercentage;private double brandShareTerms;private ItemCriteria itemCriteria;private String itemCriteriaString;private LocalDateTime createdOn;private List<TargetSlab> targetSlabs;private PartnerCriteria partnerCriteria;private String partnerCriteriaString;Map<Integer, QtyAmountModel> criteriaQtyAmountModel;private String reference;@JsonIgnorepublic LocalDateTime getBillingEndDate() {return this.endDate.plusDays(90);}@JsonIgnorepublic LocalDateTime getBillingStartDate() {return this.startDate.minusDays(60);}public LocalDateTime getProcessTimestamp() {return processTimestamp;}public void setProcessTimestamp(LocalDateTime processTimestamp) {this.processTimestamp = processTimestamp;}public String getReference() {return reference;}public void setReference(String reference) {this.reference = reference;}@Overridepublic boolean equals(Object o) {if (this == o) return true;if (o == null || getClass() != o.getClass()) return false;CreateOfferRequest that = (CreateOfferRequest) o;return id == that.id && active == that.active && baseCriteria == that.baseCriteria && booster == that.booster && Double.compare(that.sellinPercentage, sellinPercentage) == 0 && Double.compare(that.brandShareTerms, brandShareTerms) == 0 && eligibleSale == that.eligibleSale && Objects.equals(name, that.name) && Objects.equals(startDate, that.startDate) && Objects.equals(endDate, that.endDate) && Objects.equals(processTimestamp, that.processTimestamp) && Objects.equals(offerNotes, that.offerNotes) && Objects.equals(terms, that.terms) && targetType == that.targetType && payoutType == that.payoutType && Objects.equals(activationBrands, that.activationBrands) && schemeType == that.schemeType && Objects.equals(itemCriteria, that.itemCriteria) && Objects.equals(itemCriteriaString, that.itemCriteriaString) && Objects.equals(createdOn, that.createdOn) && Objects.equals(targetSlabs, that.targetSlabs) && Objects.equals(partnerCriteria, that.partnerCriteria) && Objects.equals(partnerCriteriaString, that.partnerCriteriaString) && Objects.equals(nextTargetSlab, that.nextTargetSlab) && Objects.equals(currentTargetSlab, that.currentTargetSlab) && Objects.equals(currentTarget, that.currentTarget) && Objects.equals(nextTarget, that.nextTarget);}@Overridepublic int hashCode() {return Objects.hash(id, active, baseCriteria, name, booster, startDate, endDate, processTimestamp, offerNotes, terms, targetType, payoutType, activationBrands, schemeType, sellinPercentage, brandShareTerms, itemCriteria, itemCriteriaString, createdOn, targetSlabs, partnerCriteria, partnerCriteriaString, eligibleSale, nextTargetSlab, currentTargetSlab, currentTarget, nextTarget);}private static final Logger LOGGER = LogManager.getLogger(CreateOfferRequest.class);public int getEligibleSale() {return eligibleSale;}public void setEligibleSale(int eligibleSale) {this.eligibleSale = eligibleSale;}public boolean isBooster() {return booster;}public void setBooster(boolean booster) {this.booster = booster;}public String getAnyItemCriteriaString() {return this.getItemCriteriaString().replaceAll("All", "");}private void addAchievementPayoutString(StringBuffer sb, ItemCriteriaPayout itemCriteriaPayout,PayoutSlab payoutSlab) {this.addAchievementString(sb, itemCriteriaPayout);sb.append(", Get ");this.addPayoutString(sb, itemCriteriaPayout, payoutSlab);}private void addAchievementString(StringBuffer sb, ItemCriteriaPayout itemCriteriaPayout) {if (this.getPayoutType().equals(AchievementType.QUANTITY)) {sb.append(itemCriteriaPayout.getShortValue()).append(" more ");if (this.baseCriteria) {sb.append("of ").append(this.getAnyItemCriteriaString());} else {sb.append("pc(s) ");}} else if (this.getPayoutType().equals(AchievementType.VALUE)) {if (this.baseCriteria) {sb.append(this.getAnyItemCriteriaString());} else {sb.append("select models worth");}sb.append(" of Rs.").append("<span class=\"currency\">").append(itemCriteriaPayout.getShortValue()).append("</span>");}}private void addPayoutString(StringBuffer sb, ItemCriteriaPayout itemCriteriaPayout, PayoutSlab payoutSlab) {/*if (itemCriteriaPayout.getAmountType().equals(AmountType.PERCENTAGE)) {sb.append(payoutSlab.getPayoutAmount()).append("% of sale of select models");} else if (itemCriteriaPayout.getAmountType().equals(AmountType.FIXED)) {sb.append("Rs.").append("<span class=\"currency\">").append(payoutSlab.getPayoutAmount()).append("</span> per pc on select models");} else {sb.append("flat Rs.").append("<span class=\"currency\">").append(payoutSlab.getPayoutAmount()).append("</span>");}*/}public String getDashboardHtml() {LOGGER.info("getDahsboard html --- {}", this.getId());String activityString = null;if (this.getSchemeType().equals(OfferSchemeType.ACTIVATION)) {activityString = "Activate";} else if (this.getSchemeType().equals(OfferSchemeType.SELLIN)) {activityString = "Purchase";} else {activityString = "Sell";}StringBuffer sb = new StringBuffer();int i = 0;for (ItemCriteriaPayout itemCriteriaPayout : this.getTargetSlabs().get(0).getItemCriteriaPayouts()) {LOGGER.info("itemCriteriaPayout {}", itemCriteriaPayout);PayoutSlab currentSlab = itemCriteriaPayout.getCurrentSlab();PayoutSlab nextSlab = itemCriteriaPayout.getNextSlab();if (i > 0) {sb.append("<span class=\"mk_show\" style=\"display:none;\"><br></span>");}if (i > 1) {sb.append("<div class=\"mk_show\" style=\"display:none;\">");} else {sb.append("<div>");}i++;if (currentSlab == null) {sb.append(activityString).append(" ");this.addAchievementPayoutString(sb, itemCriteriaPayout, nextSlab);} else {if (itemCriteriaPayout.getNextSlab() != null) {sb.append("Congratulations, you have qualified to get ");this.addPayoutString(sb, itemCriteriaPayout, currentSlab);sb.append(". ");sb.append(activityString).append(" ");this.addAchievementPayoutString(sb, itemCriteriaPayout, nextSlab);} else {sb.append("Congratulations for achieving the highest slab,");sb.append(" you have qualified to get ");this.addPayoutString(sb, itemCriteriaPayout, currentSlab);sb.append(", keep it up!!");}}sb.append("</div>");}return sb.toString();}public boolean isBaseCriteria() {return baseCriteria;}public void setBaseCriteria(boolean baseCriteria) {this.baseCriteria = baseCriteria;}private int eligibleSale;private TargetSlab nextTargetSlab;private TargetSlab currentTargetSlab;private String currentTarget;private String nextTarget;public String getCurrentTarget() {return currentTarget;}public void setCurrentTarget(String currentTarget) {this.currentTarget = currentTarget;}public String getNextTarget() {return nextTarget;}public void setNextTarget(String nextTarget) {this.nextTarget = nextTarget;}public TargetSlab getNextTargetSlab() {return nextTargetSlab;}public void setNextTargetSlab(TargetSlab nextTargetSlab) {this.nextTargetSlab = nextTargetSlab;}public TargetSlab getCurrentTargetSlab() {return currentTargetSlab;}public void setCurrentTargetSlab(TargetSlab currentTargetSlab) {this.currentTargetSlab = currentTargetSlab;}public boolean isActive() {return active;}public void setActive(boolean active) {this.active = active;}public LocalDateTime getCreatedOn() {return createdOn;}public AchievementType getPayoutType() {return payoutType;}public void setPayoutType(AchievementType payoutType) {this.payoutType = payoutType;}public String getActivationBrands() {return activationBrands;}public void setActivationBrands(String activationBrands) {this.activationBrands = activationBrands;}public void setCreatedOn(LocalDateTime createdOn) {this.createdOn = createdOn;}public String getItemCriteriaString() {return itemCriteriaString;}public String getPartnerCriteriaString() {return partnerCriteriaString;}public void setPartnerCriteriaString(String partnerCriteriaString) {this.partnerCriteriaString = partnerCriteriaString;}public PartnerCriteria getPartnerCriteria() {return partnerCriteria;}public void setPartnerCriteria(PartnerCriteria partnerCriteria) {this.partnerCriteria = partnerCriteria;}public ItemCriteria getItemCriteria() {return itemCriteria;}public void setItemCriteria(ItemCriteria itemCriteria) {this.itemCriteria = itemCriteria;}public double getBrandShareTerms() {return brandShareTerms;}public void setBrandShareTerms(double brandShareTerms) {this.brandShareTerms = brandShareTerms;}public List<TargetSlab> getTargetSlabs() {return targetSlabs;}public void setTargetSlabs(List<TargetSlab> targetSlabs) {this.targetSlabs = targetSlabs;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public LocalDateTime getStartDate() {return startDate;}public void setStartDate(LocalDateTime startDate) {this.startDate = startDate;}public LocalDateTime getEndDate() {return endDate;}public void setEndDate(LocalDateTime endDate) {this.endDate = endDate;}public AchievementType getTargetType() {return targetType;}public String getTitle() {return String.join(" ", this.getName(), ", ", "From", FormattingUtils.formatDate(this.startDate), "to", FormattingUtils.formatDate(this.endDate), String.valueOf(this.id));}public String getDescription() {return String.join(" ", this.getName() + ",", "From", FormattingUtils.formatDate(this.startDate), "to", FormattingUtils.formatDate(this.endDate));}public void setTargetType(AchievementType targetType) {this.targetType = targetType;}public OfferSchemeType getSchemeType() {return schemeType;}public void setSchemeType(OfferSchemeType schemeType) {this.schemeType = schemeType;}public double getSellinPercentage() {return sellinPercentage;}public void setSellinPercentage(double sellinPercentage) {this.sellinPercentage = sellinPercentage;}public String getOfferNotes() {return offerNotes;}public void setOfferNotes(String offerNotes) {this.offerNotes = offerNotes;}public String getTerms() {return terms;}public void setTerms(String terms) {this.terms = terms;}public void setItemCriteriaString(String itemCriteriaString) {this.itemCriteriaString = itemCriteriaString;}public boolean isWithinRange(LocalDateTime testDate) {return !(testDate.isBefore(startDate) || testDate.isAfter(endDate));}public boolean isDiscount() {return discount;}public void setDiscount(boolean discount) {this.discount = discount;}@Overridepublic String toString() {return "CreateOfferRequest{" +"id=" + id +", active=" + active +", baseCriteria=" + baseCriteria +", discount=" + discount +", name='" + name + '\'' +", booster=" + booster +", startDate=" + startDate +", endDate=" + endDate +", processTimestamp=" + processTimestamp +", offerNotes='" + offerNotes + '\'' +", terms='" + terms + '\'' +", targetType=" + targetType +", payoutType=" + payoutType +", activationBrands='" + activationBrands + '\'' +", schemeType=" + schemeType +", sellinPercentage=" + sellinPercentage +", brandShareTerms=" + brandShareTerms +", itemCriteria=" + itemCriteria +", itemCriteriaString='" + itemCriteriaString + '\'' +", createdOn=" + createdOn +", targetSlabs=" + targetSlabs +", partnerCriteria=" + partnerCriteria +", partnerCriteriaString='" + partnerCriteriaString + '\'' +", eligibleSale=" + eligibleSale +", nextTargetSlab=" + nextTargetSlab +", currentTargetSlab=" + currentTargetSlab +", currentTarget='" + currentTarget + '\'' +", nextTarget='" + nextTarget + '\'' +'}';}public boolean isSellin() {return schemeType.equals(OfferSchemeType.SELLIN);}public boolean isActivation() {return schemeType.equals(OfferSchemeType.ACTIVATION);}public boolean isSellout() {return schemeType.equals(OfferSchemeType.SELLOUT);}public void setCriteriaQtyAmountModel(Map<Integer, QtyAmountModel> criteriaQtyAmountModel) {this.criteriaQtyAmountModel = criteriaQtyAmountModel;}public Map<Integer, QtyAmountModel> getCriteriaQtyAmountModel() {return criteriaQtyAmountModel;}}