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.util.Date;
import java.util.Map;
import java.util.Objects;


/**
 * 订单退款明细
 *
 * @author nianchang
 */
public class RefundDetail {

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

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

	/**
	 * 退款单号
	 */
	private String refundNo;

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

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

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

	/**
	 * 支付类型
	 */
	private Integer payType;

	/**
	 * 退款金额
	 */
	private Integer refundAmount;

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

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

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

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

	/**
	 * 业务类型
	 */
	private String features;

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

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

	public Integer getMasterDataSource() {
		return masterDataSource;
	}

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

    public Long getId() {
		return id;
	}

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

	public String getOrderNo() {
		return orderNo;
	}

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

	public String getRefundNo() {
		return refundNo;
	}

	public void setRefundNo(String refundNo) {
		this.refundNo = refundNo;
	}

	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 getPayType() {
		return payType;
	}

	public void setPayType(Integer payType) {
		this.payType = payType;
	}

	public Integer getRefundAmount() {
		return refundAmount;
	}

	public void setRefundAmount(Integer refundAmount) {
		this.refundAmount = refundAmount;
	}

	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 getBizType() {
		return bizType;
	}

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

	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;
	}
	public void paint(DataStream data) {
		this.payType = data.getPayType();
	}

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

}
