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

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

import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;
import java.util.Objects;


/**
 * 
 * 商品加料模型
 * @author NianChang
 */
public class OrderItemBatching {

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

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

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

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

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

	/**
	 * 加料ID
	 */
	private String batchingId;

	/**
	 * 加料名称
	 */
	private String batchingName;

	/**
	 * 加料编码
	 */
	private String code;

	/**
	 * 购买数量
	 */
	private Integer num;

	/**
	 * 价格
	 */
	private BigDecimal price;

	/**
	 * 订单商品主键id
	 */
	private Long orderItemId;

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

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

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

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

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

	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 Long getUserId() {
		return userId;
	}

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

	public String getOrderNo() {
		return orderNo;
	}

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

	public String getBatchingId() {
		return batchingId;
	}

	public void setBatchingId(String batchingId) {
		this.batchingId = batchingId;
	}

	public String getBatchingName() {
		return batchingName;
	}

	public void setBatchingName(String batchingName) {
		this.batchingName = batchingName;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Integer getNum() {
		return num;
	}

	public void setNum(Integer num) {
		this.num = num;
	}

	public BigDecimal getPrice() {
		return price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	public Long getOrderItemId() {
		return orderItemId;
	}

	public void setOrderItemId(Long orderItemId) {
		this.orderItemId = orderItemId;
	}

	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 String getFeatures() {
		return features;
	}

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

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

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

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

}
