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

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

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


/**
 * 订单评论统计表
 *
 * @author nianchang
 */
public class OrderCommentCount {

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

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

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

	/**
	 * 评论统计
	 */
	private Integer commentCount;

	/**
	 * 好评统计
	 */
	private Integer goodCount;

	/**
	 * 差评统计
	 */
	private Integer badCount;

	/**
	 * 商家回复统计
	 */
	private Integer replyCount;

	/**
	 * 精选统计
	 */
	private Integer qualityCount;

	/**
	 * 有图统计
	 */
	private Integer imageCount;

	/**
	 * 匿名统计
	 */
	private Integer anonymousCount;

	/**
	 * 推荐菜统计
	 */
	private Integer recommendCount;

	/**
	 * 评分信息
	 */
	private String scoreInfo;

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

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

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

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

	/**
	 * 中评统计
	 */
	private Integer middleCount;

	/**
	 * 评分信息
	 */
	private Map<String, Object> scoreInfoMap;

	public String getScoreInfo() {
		return scoreInfo;
	}

	public void setScoreInfo(String scoreInfo) {
		this.scoreInfo = scoreInfo;
	}

	public void init() {
        this.commentCount = 0;
        this.badCount = 0;
        this.goodCount = 0;
        this.middleCount = 0;
        this.recommendCount = 0;
        this.anonymousCount = 0;
        this.imageCount = 0;
        this.qualityCount = 0;
        this.replyCount = 0;
    }

	public Integer getMiddleCount() {
		return middleCount;
	}

	public void setMiddleCount(Integer middleCount) {
		this.middleCount = middleCount;
	}

	public Integer getVersion() {
		return version;
	}

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

	public Long getId() {
		return id;
	}

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

	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 getCommentCount() {
		return commentCount;
	}

	public void setCommentCount(Integer commentCount) {
		this.commentCount = commentCount;
	}

	public Integer getGoodCount() {
		return goodCount;
	}

	public void setGoodCount(Integer goodCount) {
		this.goodCount = goodCount;
	}

	public Integer getBadCount() {
		return badCount;
	}

	public void setBadCount(Integer badCount) {
		this.badCount = badCount;
	}

	public Integer getReplyCount() {
		return replyCount;
	}

	public void setReplyCount(Integer replyCount) {
		this.replyCount = replyCount;
	}

	public Integer getQualityCount() {
		return qualityCount;
	}

	public void setQualityCount(Integer qualityCount) {
		this.qualityCount = qualityCount;
	}

	public Integer getImageCount() {
		return imageCount;
	}

	public void setImageCount(Integer imageCount) {
		this.imageCount = imageCount;
	}

	public Integer getAnonymousCount() {
		return anonymousCount;
	}

	public void setAnonymousCount(Integer anonymousCount) {
		this.anonymousCount = anonymousCount;
	}

	public Integer getRecommendCount() {
		return recommendCount;
	}

	public void setRecommendCount(Integer recommendCount) {
		this.recommendCount = recommendCount;
	}

	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 Map<String, Object> getScoreInfoMap() {
        if (!StringUtils.isEmpty(scoreInfo)) {
            return JSON.parseObject(scoreInfo, Map.class);
        }
        if (scoreInfoMap == null) {
            return Maps.newHashMap();
        }
        return scoreInfoMap;
    }

    public void setScoreInfoMap(Map<String, Object> scoreInfoMap) {
        if (!CollectionUtils.isEmpty(scoreInfoMap)) {
            this.scoreInfo = JSON.toJSONString(scoreInfoMap);
        }
        this.scoreInfoMap = scoreInfoMap;
    }

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

}
