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

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Maps;

import com.zm.order.tool.server.enums.DocTypeEnum;
import org.springframework.util.StringUtils;

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

/**
 * @author mybatis-generator
 * @date 2019/11/04
 */
public class Refund {

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

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

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

    public String getFeaturesCipher() {
        return featuresCipher;
    }

    public void setFeaturesCipher(String featuresCipher) {
        this.featuresCipher = featuresCipher;
    }

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

    /**
     * 订单类型
     */
    private Integer orderType;

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

    /**
     * 订单退款方式
     */
    private Integer refundWay;

    /**
     * 退款级别
     */
    private Integer refundLevel;

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

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

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

    /**
     * 来源
     */
    private Integer source;

    /**
     * 来源单号
     */
    private String sourceNo;

    /**
     * 退款类型
     */
    private Integer refundType;


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

    /**
     * 退的三方的钱
     */
    private Integer amount;

    /**
     * 退余额的钱
     */
    private Integer walletAmount;

    /**
     * 退款金额详细信息
     */
    private String refundAmountDetails;

    /**
     * 申请人
     */
    private Long applicant;

    /**
     * 退款原因
     */
    private String applyReason;

    /**
     * 图片
     */
    private String images;

    /**
     * 申请时间
     */
    private Date applyAt;

    /**
     * 下单时间
     */
    private Date orderAt;

    /**
     * 退款状态
     */
    private Integer status;

    /**
     * 是否独立收款
     */
    private Integer isAlone;

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

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

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

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

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

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

    /**
     * 订单子类型
     */
    private Integer orderSubType;

    /**
     * 买家手机号
     */
    private String mobile;

    /**
     * 来源系统
     */
    private Integer fromSystem;

    /**
     * 处理时间
     */
    private Date dealAt;

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

    /**
     * 复查状态
     */
    private Integer reviewStatus;

    /**
     * 礼品卡退款金额
     */
    private Integer giftCardAmount;

    /**
     * 履约类型
     */
    private Integer performanceType;

    /**
     * 退款明细
     */
    private String refundDetailInfo;

    private String mobileCipher;

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

    /**
     * 账单时间
     */
    private Date billAt;

    public Date getBillAt() {
        return billAt;
    }

    public void setBillAt(Date billAt) {
        this.billAt = billAt;
    }

    public Integer getMasterDataSource() {
        return masterDataSource;
    }

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

    public String getMobileCipher() {
        return mobileCipher;
    }

    public void setMobileCipher(String mobileCipher) {
        this.mobileCipher = mobileCipher;
    }

    public String getMobile() {
        return mobile;
    }

    public Integer getReviewStatus() {
        return reviewStatus;
    }

    public void setReviewStatus(Integer reviewStatus) {
        this.reviewStatus = reviewStatus;
    }

    public Integer getGiftCardAmount() {
        return giftCardAmount;
    }

    public void setGiftCardAmount(Integer giftCardAmount) {
        this.giftCardAmount = giftCardAmount;
    }

    public Integer getPerformanceType() {
        return performanceType;
    }

    public void setPerformanceType(Integer performanceType) {
        this.performanceType = performanceType;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public Integer getOrderSubType() {
        return orderSubType;
    }

    public void setOrderSubType(Integer orderSubType) {
        this.orderSubType = orderSubType;
    }

    public Integer getRefundWay() {
        return refundWay;
    }

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

    public Integer getFromSystem() {
        return fromSystem;
    }

    public void setFromSystem(Integer fromSystem) {
        this.fromSystem = fromSystem;
    }

    public Integer getPayType() {
        return payType;
    }

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

    public String getRefundDetailInfo() {
        return refundDetailInfo;
    }

    public void setRefundDetailInfo(String refundDetailInfo) {
        this.refundDetailInfo = refundDetailInfo;
    }

    public Date getDealAt() {
        return dealAt;
    }

    public void setDealAt(Date dealAt) {
        this.dealAt = dealAt;
    }

    /**
     * 封装状态对象
     *
     * @return
     */
    public Status status() {
        Status status = new Status();
        status.setBizType(this.bizType);
        status.setStatus(this.status);
        status.setDocType(DocTypeEnum.REFUND.getType());
        return status;
    }

    public Integer getAmount() {
        return amount;
    }

    public void setAmount(Integer amount) {
        this.amount = amount;
    }

    public Integer getWalletAmount() {
        return walletAmount;
    }

    public void setWalletAmount(Integer walletAmount) {
        this.walletAmount = walletAmount;
    }

    public Long getId() {
        return id;
    }

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

    public Integer getBizType() {
        return bizType;
    }

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

    public String getOrderNo() {
        return orderNo;
    }

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

    public Integer getOrderType() {
        return orderType;
    }

    public void setOrderType(Integer orderType) {
        this.orderType = orderType;
    }

    public String getRefundNo() {
        return refundNo;
    }

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

    public Integer getRefundLevel() {
        return refundLevel;
    }

    public void setRefundLevel(Integer refundLevel) {
        this.refundLevel = refundLevel;
    }

    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 Integer getSource() {
        return source;
    }

    public void setSource(Integer source) {
        this.source = source;
    }

    public String getSourceNo() {
        return sourceNo;
    }

    public void setSourceNo(String sourceNo) {
        this.sourceNo = sourceNo;
    }

    public Integer getRefundType() {
        return refundType;
    }

    public void setRefundType(Integer refundType) {
        this.refundType = refundType;
    }

    public Integer getRefundAmount() {
        return refundAmount;
    }

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

    public String getRefundAmountDetails() {
        return refundAmountDetails;
    }

    public void setRefundAmountDetails(String refundAmountDetails) {
        this.refundAmountDetails = refundAmountDetails;
    }

    public Long getApplicant() {
        return applicant;
    }

    public void setApplicant(Long applicant) {
        this.applicant = applicant;
    }

    public String getApplyReason() {
        return applyReason;
    }

    public void setApplyReason(String applyReason) {
        this.applyReason = applyReason;
    }

    public String getImages() {
        return images;
    }

    public void setImages(String images) {
        this.images = images;
    }

    public Date getApplyAt() {
        return applyAt;
    }

    public void setApplyAt(Date applyAt) {
        this.applyAt = applyAt;
    }

    public Date getOrderAt() {
        return orderAt;
    }

    public void setOrderAt(Date orderAt) {
        this.orderAt = orderAt;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    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;
        }
        return Maps.newHashMap();
    }

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

    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 getVersion() {
        return version;
    }

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

    public Integer getIsAlone() {
        return isAlone;
    }

    public void setIsAlone(Integer isAlone) {
        this.isAlone = isAlone;
    }

    public void paint(DataStream data) {
        this.orderType = data.getOrderType();
        this.orderSubType = data.getOrderSubType();
        this.status = data.getRefundStatus();
        this.source = data.getSource();
        this.payType = data.getPayType();
        this.performanceType = data.getPerformanceType();
    }

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