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;

/**
 * @Description  订单补充信息
 * @Author: zhuxiaofeng
 * @Date: 2021/8/10 14:58
 */
public class RoutingOrderExtends {

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

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

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

    /**
     * 三方扩展信息
     */
    private String thirdFeatures;

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

    /**
     * 更新时间
     */
    private Date updatedAt;

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

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

    private Integer dbIndex;

    private Integer tbIndex;

    private Date syncAt;

    public Integer getDbIndex() {
        return dbIndex;
    }

    public void setDbIndex(Integer dbIndex) {
        this.dbIndex = dbIndex;
    }

    public Integer getTbIndex() {
        return tbIndex;
    }

    public void setTbIndex(Integer tbIndex) {
        this.tbIndex = tbIndex;
    }

    public Date getSyncAt() {
        return syncAt;
    }

    public void setSyncAt(Date syncAt) {
        this.syncAt = syncAt;
    }

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

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

    public String getThirdFeatures() {
        return thirdFeatures;
    }

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

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

    public void setThirdFeatures(String thirdFeatures) {
        this.thirdFeatures = thirdFeatures;
    }

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

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