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

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Maps;
import com.zm.order.tool.server.model.Operation;
import com.zm.order.tool.server.model.OrderItem;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * @Description 订单操作DTO
 * @Author: ph
 * @Date: 2019/11/6 11:32
 */
public class OrderOperateDTO {

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

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

    /**
     * 操作人
     */
    private Long operator;

    /**
     * 操作类型
     */
    private String operation;

    /**
     * 角色
     */
    private Integer role;

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

    /**
     * 是否实时更新 1：是
     */
    private Integer realTime;

    /**
     * 修改商品信息列表
     */
    private List<OrderItem> orderItemList;

    /**
     * 更新履约信息
     */
    private Map<String,Object> performanceMap;

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

    /**
     * 支付明细
     */
    private List<OrderPayDetailsDTO> payDetailsList;

    public List<OrderPayDetailsDTO> getPayDetailsList() {
        return payDetailsList;
    }

    public void setPayDetailsList(List<OrderPayDetailsDTO> payDetailsList) {
        this.payDetailsList = payDetailsList;
    }

    public Map<String, Object> getPerformanceMap() {
        return performanceMap;
    }

    public void setPerformanceMap(Map<String, Object> performanceMap) {
        this.performanceMap = performanceMap;
    }

    /**
     * 返回操作对象
     *
     * @return
     */
    public Operation operation() {
        Operation operation = new Operation();
        operation.setOperator(this.operator);
        operation.setOperation(this.operation);
        operation.setRole(role);
        return operation;
    }

    public List<OrderItem> getOrderItemList() {
        return orderItemList;
    }

    public void setOrderItemList(List<OrderItem> orderItemList) {
        this.orderItemList = orderItemList;
    }

    public Boolean isRealTime(){
        return Objects.equals(1,this.realTime);
    }

    public Integer getRealTime() {
        return realTime;
    }

    public void setRealTime(Integer realTime) {
        this.realTime = realTime;
    }

    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 Long getOperator() {
        return operator;
    }

    public void setOperator(Long operator) {
        this.operator = operator;
    }

    public String getOperation() {
        return operation;
    }

    public void setOperation(String operation) {
        this.operation = operation;
    }

    public Integer getRole() {
        return role;
    }

    public void setRole(Integer role) {
        this.role = role;
    }

    public Map<String, Object> getOperateInfo() {
        return operateInfo == null ? Maps.newHashMap() : operateInfo;
    }

    public void setOperateInfo(Map<String, Object> operateInfo) {
        this.operateInfo = operateInfo;
    }

    public Map<String, Object> getThirdExtraMap() {
        return thirdExtraMap;
    }

    public void setThirdExtraMap(Map<String, Object> thirdExtraMap) {
        this.thirdExtraMap = thirdExtraMap;
    }

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