package com.zm.order.tool.server.model;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * 订单商品评价表
 *
 * @author nianchang
 */
public class OrderItemComment {

	/**
	 * 主键
	 */
	private Long id;

	/**
	 * 业务类型
	 */
	private Integer bizType;

	/**
	 * 订单号
	 */
	private String orderNo;

	/**
	 * 用户id
	 */
	private Long userId;

	/**
	 * 商家id
	 */
	private Long sellerId;

	/**
	 * 门店id
	 */
	private Long storeId;

	/**
	 * 商品id
	 */
	private Long goodsId;

	/**
	 * skuId
	 */
	private String itemId;

	/**
	 * 订单类型
	 */
	private Integer orderType;

	/**
	 * 分数
	 */
	private Integer commentScore;

	/**
	 * 评论内容
	 */
	private String commentInfo;

	/**
	 * 是否匿名 0:否 1:是
	 */
	private Integer anonymous;

	/**
	 * 商家是否回复
	 * 0:未回复 1:已回复
	 */
	private Integer sellerReply;

	/**
	 * 商家回复信息
	 */
	private String sellerReplyInfo;

	/**
	 * 是否存在图片
	 * 0：不存在
	 * 1：存在
	 */
	private Integer existImage;

	/**
	 * 评论图片列表
	 */
	private List<String> commentImageList;

	/**
	 * 是否隐藏评论
	 * 0：不隐藏
	 * 1：隐藏
	 */
	private Integer hide;

	/**
	 * 评论时间
	 */
	private Date commentAt;

	/**
	 * 商家回复时间
	 */
	private Date replyAt;

	/**
	 * 扩展信息
	 */
	private String features;

	/**
	 * 商品快照
	 */
	private String itemInfo;

	/**
	 * 创建时间
	 */
	private Date createdAt;

	/**
	 * 修改时间
	 */
	private Date updatedAt;

	/**
	 * 删除标识
	 */
	private Integer isDeleted;

	/**
	 * 扩展信息
	 */
	private Map<String, Object> extraMap;

	/**
	 * 评论图片
	 */
	private String commentImage;

	/**
	 * 版本号
	 */
	private Integer version;

	/**
	 * 是否分享
	 */
	private Integer shares;

	/**
	 * 同步标记
	 */
	private Integer syncFlag;

	/**
	 * 履约标记
	 */
	private Integer performanceType;

	/**
	 * 精选
	 */
	private Integer selected;

	/**
	 * 买同款数
	 */
	private Integer buySameCount;

	/**
	 * 点赞数
	 */
	private Integer likesCount;

	/**
	 * 主数据源标记
	 *
	 */
	private Integer masterDataSource;

	/**
	 * 订单子类型
	 */
	private Integer orderSubType;

	/**
	 * 履约标记
	 */
	private Integer tempCount;

	public Integer getTempCount() {
		return tempCount;
	}

	public void setTempCount(Integer tempCount) {
		this.tempCount = tempCount;
	}

	public Integer getMasterDataSource() {
		return masterDataSource;
	}

	public void setMasterDataSource(Integer masterDataSource) {
		this.masterDataSource = masterDataSource;
	}

	public void paint(DataStream data) {
		this.orderType = data.getOrderType();
		this.performanceType = data.getPerformanceType();
	}

	public Integer getSelected() {
		return selected;
	}

	public void setSelected(Integer selected) {
		this.selected = selected;
	}

	public Integer getBuySameCount() {
		return buySameCount;
	}

	public void setBuySameCount(Integer buySameCount) {
		this.buySameCount = buySameCount;
	}

	public Integer getLikesCount() {
		return likesCount;
	}

	public void setLikesCount(Integer likesCount) {
		this.likesCount = likesCount;
	}

	public Integer getOrderSubType() {
		return orderSubType;
	}

	public void setOrderSubType(Integer orderSubType) {
		this.orderSubType = orderSubType;
	}

	public Integer getPerformanceType() {
		return performanceType;
	}

	public void setPerformanceType(Integer performanceType) {
		this.performanceType = performanceType;
	}

	public Integer getOrderType() {
		return orderType;
	}

	public void setOrderType(Integer orderType) {
		this.orderType = orderType;
	}

	public Long getGoodsId() {
		return goodsId;
	}

	public void setGoodsId(Long goodsId) {
		this.goodsId = goodsId;
	}

	public String getItemId() {
		return itemId;
	}

	public void setItemId(String itemId) {
		this.itemId = itemId;
	}

	public Integer getCommentScore() {
		return commentScore;
	}

	public void setCommentScore(Integer commentScore) {
		this.commentScore = commentScore;
	}

	public Date getReplyAt() {
		return replyAt;
	}

	public void setReplyAt(Date replyAt) {
		this.replyAt = replyAt;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public String getItemInfo() {
		return itemInfo;
	}

	public void setItemInfo(String itemInfo) {
		this.itemInfo = itemInfo;
	}

	public List<String> getCommentImageList() {
        if (!StringUtils.isEmpty(commentImage)) {
            return (List)JSON.parseArray(commentImage);
        }
        if (commentImageList == null) {
            return Lists.newArrayList();
        }
        return commentImageList;
    }

    public void setCommentImageList(List<String> commentImageList) {
        if (!CollectionUtils.isEmpty(commentImageList)) {
            this.commentImage = JSON.toJSONString(commentImageList);
        }
        this.commentImageList = commentImageList;
    }


	public Integer getHide() {
		return hide;
	}

	public void setHide(Integer hide) {
		this.hide = hide;
	}

	public Map<String, Object> getExtraMap() {
		if (!StringUtils.isEmpty(features)) {
			return JSON.parseObject(features);
		}
		if (extraMap == null) {
			return Maps.newHashMap();
		}
		return extraMap;
	}

	public void setExtraMap(Map<String, Object> extraMap) {
		if (!CollectionUtils.isEmpty(extraMap)) {
			this.features = JSON.toJSONString(extraMap);
		}
		this.extraMap = extraMap;
	}

    public Long getId() {
		return id;
	}

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

	public Integer getBizType() {
		return bizType;
	}

	public void setBizType(Integer bizType) {
		this.bizType = bizType;
	}

	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public Long getSellerId() {
		return sellerId;
	}

	public void setSellerId(Long sellerId) {
		this.sellerId = sellerId;
	}

	public Long getStoreId() {
		return storeId;
	}

	public void setStoreId(Long storeId) {
		this.storeId = storeId;
	}

	public Integer getAnonymous() {
		return anonymous;
	}

	public void setAnonymous(Integer anonymous) {
		this.anonymous = anonymous;
	}

	public String getCommentInfo() {
		return commentInfo;
	}

	public void setCommentInfo(String commentInfo) {
		this.commentInfo = commentInfo;
	}

	public Integer getSellerReply() {
		return sellerReply;
	}

	public void setSellerReply(Integer sellerReply) {
		this.sellerReply = sellerReply;
	}

	public String getSellerReplyInfo() {
		return sellerReplyInfo;
	}

	public void setSellerReplyInfo(String sellerReplyInfo) {
		this.sellerReplyInfo = sellerReplyInfo;
	}

	public Integer getExistImage() {
		return existImage;
	}

	public void setExistImage(Integer existImage) {
		this.existImage = existImage;
	}

	public String getCommentImage() {
		return commentImage;
	}

	public void setCommentImage(String commentImage) {
		this.commentImage = commentImage;
	}

	public Date getCommentAt() {
		return commentAt;
	}

	public void setCommentAt(Date commentAt) {
		this.commentAt = commentAt;
	}

	public String getFeatures() {
		return features;
	}

	public void setFeatures(String features) {
		this.features = features;
	}

	public Date getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}

	public Date getUpdatedAt() {
		return updatedAt;
	}

	public void setUpdatedAt(Date updatedAt) {
		this.updatedAt = updatedAt;
	}

	public Integer getIsDeleted() {
		return isDeleted;
	}

	public void setIsDeleted(Integer isDeleted) {
		this.isDeleted = isDeleted;
	}

	public Integer getShares() {
		return shares;
	}

	public void setShares(Integer shares) {
		this.shares = shares;
	}

	public Integer getSyncFlag() {
		return syncFlag;
	}

	public void setSyncFlag(Integer syncFlag) {
		this.syncFlag = syncFlag;
	}

	@Override
    public String toString() {
        return JSON.toJSONString(this);
    }

}
