package org.xmx0632.deliciousfruit.entity;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
/**
* FruitPromotion.
*/
@Entity
@Table(name = "tbl_fruit_promotion")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class FruitPromotion extends IdEntity {
public static String PIC_STATUS_NOTREADY = "0";
public static String PIC_STATUS_READY = "1";
public static enum PromotionType {
/* 全场满就送,促销单价为0则为赠送,(decFreeValue >0 && Total >= decFreeValue) */
TOTAL_GIFT("total.gift", 0),
/* 全场满立减,(decFullValue > 0 && decMinusValue >0 && Total >= decFullValue) */
TOTAL_DEDUCT("total.deduct", 2),
/* 单品赠送 */
PRODUCT_GIFT("product.gift", 3);
private String name;
private int value;
public static String getNameByValue(int value) {
for (PromotionType type : PromotionType.values()) {
if (type.getValue() == value) {
return type.getName();
}
}
return null;
}
private PromotionType(String name, int value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
}
public static enum Avaliable {
OFFLINE("offline", 0), ONLINE("online", 1), OFFLINE_BY_MOBILE(
"offlinebymobile", 2);
private String name;
private int value;
public static String getNameByValue(int value) {
for (Avaliable type : Avaliable.values()) {
if (type.getValue() == value) {
return type.getName();
}
}
return null;
}
private Avaliable(String name, int value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
}
// private Long subid;// FruitSubPromotion
private FruitSubPromotion fruitSubPromotion;
// ERPID
private String flowid;
// 促销名称
private String promotionName;
// 促销类型: 0:满额送; 1:满额换; 2:满额立减; 3:单品买就送; 4:单品买科幻
private int promotionType;
private int avaliable;// 生效,0禁用,1生效, 2 后台强制下线
private Date startTime;// 起始时间
private Date endTime;// 终止时间
private BigDecimal totalGift = BigDecimal.ZERO;// 满额循环送起点
private BigDecimal totalExchange = BigDecimal.ZERO;// 满额换购起点
private BigDecimal totalPriceoff = BigDecimal.ZERO;// 满额立减起点
private BigDecimal priceoff = BigDecimal.ZERO;// 立减金额
private String picUrl;
private String picStatus; // 1为已上传,0 为 未上传
public FruitPromotion() {
}
public FruitPromotion(String promotionName, byte promotionType,
byte avaliable) {
this.promotionName = promotionName;
this.promotionType = promotionType;
this.avaliable = avaliable;
}
@NotNull
public String getPicStatus() {
return picStatus;
}
public void setPicStatus(String picStatus) {
this.picStatus = picStatus;
}
public String getPicUrl() {
return picUrl;
}
public void setPicUrl(String picUrl) {
this.picUrl = picUrl;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "sub_id")
public FruitSubPromotion getFruitSubPromotion() {
return fruitSubPromotion;
}
public void setFruitSubPromotion(FruitSubPromotion fruitSubPromotion) {
this.fruitSubPromotion = fruitSubPromotion;
}
public String getFlowid() {
return this.flowid;
}
public void setFlowid(String flowid) {
this.flowid = flowid;
}
@NotNull
public String getPromotionName() {
return this.promotionName;
}
public void setPromotionName(String promotionName) {
this.promotionName = promotionName;
}
@NotNull
public int getPromotionType() {
return this.promotionType;
}
public void setPromotionType(int promotionType) {
this.promotionType = promotionType;
}
@NotNull
public int getAvaliable() {
return this.avaliable;
}
public void setAvaliable(int avaliable) {
this.avaliable = avaliable;
}
public Date getStartTime() {
return this.startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return this.endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public BigDecimal getTotalGift() {
return this.totalGift;
}
public void setTotalGift(BigDecimal totalGift) {
this.totalGift = totalGift;
}
public BigDecimal getTotalExchange() {
return this.totalExchange;
}
public void setTotalExchange(BigDecimal totalExchange) {
this.totalExchange = totalExchange;
}
public BigDecimal getTotalPriceoff() {
return this.totalPriceoff;
}
public void setTotalPriceoff(BigDecimal totalPriceoff) {
this.totalPriceoff = totalPriceoff;
}
public BigDecimal getPriceoff() {
return this.priceoff;
}
public void setPriceoff(BigDecimal priceoff) {
this.priceoff = priceoff;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}