/*
*
*
*/
package com.easyshopping.entity;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.PrePersist;
import javax.persistence.PreRemove;
import javax.persistence.PreUpdate;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.Valid;
import javax.validation.constraints.Digits;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang.StringUtils;
import org.dom4j.io.SAXReader;
import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.FieldBridge;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.NumericField;
import org.hibernate.search.annotations.Similarity;
import org.hibernate.search.annotations.Store;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.core.io.ClassPathResource;
import org.wltea.analyzer.lucene.IKAnalyzer;
import org.wltea.analyzer.lucene.IKSimilarity;
import com.easyshopping.BigDecimalNumericFieldBridge;
import com.easyshopping.CommonAttributes;
import com.easyshopping.util.FreemarkerUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
import freemarker.template.TemplateException;
/**
* Entity - 商品
*
*
* @version 1.0
*/
@Indexed
@Similarity(impl = IKSimilarity.class)
@Entity
@Table(name = "xx_product")
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "xx_product_sequence")
public class Product extends BaseEntity {
private static final long serialVersionUID = 2167830430439593293L;
/** 点击数缓存名称 */
public static final String HITS_CACHE_NAME = "productHits";
/** 点击数缓存更新间隔时间 */
public static final int HITS_CACHE_INTERVAL = 600000;
/** 商品属性值属性个数 */
public static final int ATTRIBUTE_VALUE_PROPERTY_COUNT = 20;
/** 商品属性值属性名称前缀 */
public static final String ATTRIBUTE_VALUE_PROPERTY_NAME_PREFIX = "attributeValue";
/** 全称规格前缀 */
public static final String FULL_NAME_SPECIFICATION_PREFIX = "[";
/** 全称规格后缀 */
public static final String FULL_NAME_SPECIFICATION_SUFFIX = "]";
/** 全称规格分隔符 */
public static final String FULL_NAME_SPECIFICATION_SEPARATOR = " ";
/** 静态路径 */
private static String staticPath;
/**
* 排序类型
*/
public enum OrderType {
/** 置顶降序 */
topDesc,
/** 价格升序 */
priceAsc,
/** 价格降序 */
priceDesc,
/** 销量降序 */
salesDesc,
/** 评分降序 */
scoreDesc,
/** 日期降序 */
dateDesc
}
/** 编号 */
private String sn;
/** 名称 */
private String name;
/** 全称 */
private String fullName;
/** 销售价 */
private BigDecimal price;
/** 成本价 */
private BigDecimal cost;
/** 市场价 */
private BigDecimal marketPrice;
/** 展示图片 */
private String image;
/** 单位 */
private String unit;
/** 重量 */
private Integer weight;
/** 库存 */
private Integer stock;
/** 已分配库存 */
private Integer allocatedStock;
/** 库存备注 */
private String stockMemo;
/** 赠送积分 */
private Long point;
/** 是否上架 */
private Boolean isMarketable;
/** 是否列出 */
private Boolean isList;
/** 是否置顶 */
private Boolean isTop;
/** 是否为赠品 */
private Boolean isGift;
/** 介绍 */
private String introduction;
/** 备注 */
private String memo;
/** 搜索关键词 */
private String keyword;
/** 页面标题 */
private String seoTitle;
/** 页面关键词 */
private String seoKeywords;
/** 页面描述 */
private String seoDescription;
/** 评分 */
private Float score;
/** 总评分 */
private Long totalScore;
/** 评分数 */
private Long scoreCount;
/** 点击数 */
private Long hits;
/** 周点击数 */
private Long weekHits;
/** 月点击数 */
private Long monthHits;
/** 销量 */
private Long sales;
/** 周销量 */
private Long weekSales;
/** 月销量 */
private Long monthSales;
/** 周点击数更新日期 */
private Date weekHitsDate;
/** 月点击数更新日期 */
private Date monthHitsDate;
/** 周销量更新日期 */
private Date weekSalesDate;
/** 月销量更新日期 */
private Date monthSalesDate;
/** 商品属性值0 */
private String attributeValue0;
/** 商品属性值1 */
private String attributeValue1;
/** 商品属性值2 */
private String attributeValue2;
/** 商品属性值3 */
private String attributeValue3;
/** 商品属性值4 */
private String attributeValue4;
/** 商品属性值5 */
private String attributeValue5;
/** 商品属性值6 */
private String attributeValue6;
/** 商品属性值7 */
private String attributeValue7;
/** 商品属性值8 */
private String attributeValue8;
/** 商品属性值9 */
private String attributeValue9;
/** 商品属性值10 */
private String attributeValue10;
/** 商品属性值11 */
private String attributeValue11;
/** 商品属性值12 */
private String attributeValue12;
/** 商品属性值13 */
private String attributeValue13;
/** 商品属性值14 */
private String attributeValue14;
/** 商品属性值15 */
private String attributeValue15;
/** 商品属性值16 */
private String attributeValue16;
/** 商品属性值17 */
private String attributeValue17;
/** 商品属性值18 */
private String attributeValue18;
/** 商品属性值19 */
private String attributeValue19;
/** 商品分类 */
private ProductCategory productCategory;
/** 货品 */
private Goods goods;
/** 品牌 */
private Brand brand;
/** 商品图片 */
private List<ProductImage> productImages = new ArrayList<ProductImage>();
/** 评论 */
private Set<Review> reviews = new HashSet<Review>();
/** 咨询 */
private Set<Consultation> consultations = new HashSet<Consultation>();
/** 标签 */
private Set<Tag> tags = new HashSet<Tag>();
/** 收藏会员 */
private Set<Member> favoriteMembers = new HashSet<Member>();
/** 规格 */
private Set<Specification> specifications = new HashSet<Specification>();
/** 规格值 */
private Set<SpecificationValue> specificationValues = new HashSet<SpecificationValue>();
/** 促销 */
private Set<Promotion> promotions = new HashSet<Promotion>();
/** 购物车项 */
private Set<CartItem> cartItems = new HashSet<CartItem>();
/** 订单项 */
private Set<OrderItem> orderItems = new HashSet<OrderItem>();
/** 赠品项 */
private Set<GiftItem> giftItems = new HashSet<GiftItem>();
/** 到货通知 */
private Set<ProductNotify