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 mybatis-generator
 * @date 2019/11/04
 */
public class RefundItem {

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

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

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

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

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

    /**
     * 退款商品类型
     */
    private Integer itemType;

    /**
     * 订单行id
     */
    private Long orderItemId;

    /**
     * goodsId
     */
    private Long goodsId;

    /**
     * 商品id
     */
    private String itemId;

    /**
     * 商品名称
     */
    private String itemName;

    /**
     * 商品名称
     */
    private String itemSign;

    /**
     * 商品图片
     */
    private String itemImage;

    /**
     * 商品规格
     */
    private String itemSpec;

    /**
     * 商品单位
     */
    private String itemUnit;

    /**
     * 商品单价
     */
    private Integer itemPrice;

    /**
     * 数量
     */
    private BigDecimal num;

    /**
     * 优惠金额
     */
    private Integer discountAmount;

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

    /**
     * 退款数量
     */
    private BigDecimal refundNum;

    /**
     * 商品退款方式
     */
    private Integer refundWay;

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

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

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

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

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

    /**
     * 来源id
     */
    private String sourceId;

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

    public Long getSellerId() {
        return sellerId;
    }

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

    public String getSourceId() {
        return sourceId;
    }

    public void setSourceId(String sourceId) {
        this.sourceId = sourceId;
    }

    public Integer getItemType() {
        return itemType;
    }

    public void setItemType(Integer itemType) {
        this.itemType = itemType;
    }

    public Integer getRefundWay() {
        return refundWay;
    }

    public void setRefundWay(Integer refundWay) {
        this.refundWay = refundWay;
    }
    public Integer getBizType() {
        return bizType;
    }

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

    public Long getId() {
        return id;
    }

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

    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 getRefundNo() {
        return refundNo;
    }

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

    public Long getOrderItemId() {
        return orderItemId;
    }

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

    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 String getItemName() {
        return itemName;
    }

    public void setItemName(String itemName) {
        this.itemName = itemName;
    }

    public String getItemImage() {
        return itemImage;
    }

    public void setItemImage(String itemImage) {
        this.itemImage = itemImage;
    }

    public String getItemSpec() {
        return itemSpec;
    }

    public void setItemSpec(String itemSpec) {
        this.itemSpec = itemSpec;
    }

    public String getItemUnit() {
        return itemUnit;
    }

    public void setItemUnit(String itemUnit) {
        this.itemUnit = itemUnit;
    }

    public Integer getItemPrice() {
        return itemPrice;
    }

    public void setItemPrice(Integer itemPrice) {
        this.itemPrice = itemPrice;
    }

    public BigDecimal getNum() {
        return num;
    }

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

    public Integer getDiscountAmount() {
        return discountAmount;
    }

    public void setDiscountAmount(Integer discountAmount) {
        this.discountAmount = discountAmount;
    }

    public Integer getRefundAmount() {
        return refundAmount;
    }

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

    public BigDecimal getRefundNum() {
        return refundNum;
    }

    public void setRefundNum(BigDecimal refundNum) {
        this.refundNum = refundNum;
    }

    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 String getItemSign() {
        return itemSign;
    }

    public void setItemSign(String itemSign) {
        this.itemSign = itemSign;
    }

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

    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);
    }
}