package com.tzy.framework.pay.dto;

import lombok.Data;
import lombok.ToString;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 订单信息
 */
@Data
@ToString
public class PaymentInfoResponseDto implements Serializable {

    private static final long serializableUid = 1l;
    //订单编码
    private String orderNo;
    //平台类型
    private String payWay;
    //平台 appid
    private String appid;
    //平台支付编码
    private String paymentNo;
    /** 应付款 */
    private BigDecimal paymentPrice;
    /** 实付款-用户支付款 */
    private BigDecimal actualPayment;
    //下单时间
    private Date paymentTime;
    //支付成功时间
    private Date paymentSuccessTime;

    private Integer code = 0;

    private String msg = "SUCCESS";

    private boolean success = false;

    private String tradeState;

    private String tradeStateDesc;

    private Map<String ,Object> data = new HashMap<>();

    public static PaymentInfoResponseDto ok(){
        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
        paymentInfoResponseDto.setSuccess(true);
        return paymentInfoResponseDto;
    }

    public static PaymentInfoResponseDto ok(String msg){
        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
        paymentInfoResponseDto.setSuccess(true);
        paymentInfoResponseDto.setMsg(msg);
        return paymentInfoResponseDto;
    }

    public static PaymentInfoResponseDto ok(Integer code, String msg){
        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
        paymentInfoResponseDto.setSuccess(true);
        paymentInfoResponseDto.setCode(code);
        paymentInfoResponseDto.setMsg(msg);
        return paymentInfoResponseDto;
    }

    public static PaymentInfoResponseDto error(Integer code, String msg){
        PaymentInfoResponseDto paymentInfoResponseDto = new PaymentInfoResponseDto();
        paymentInfoResponseDto.setCode(code);
        paymentInfoResponseDto.setMsg(msg);
        paymentInfoResponseDto.setSuccess(false);
        return paymentInfoResponseDto;
    }

    public PaymentInfoResponseDto put(String key, Object value){
        if(null == this.data) this.data = new HashMap<>();
        this.data.put(key,value);
        return this;
    }

    public String getString(String key){
        if(null == this.data) return null;
        return (String) this.data.get(key);
    }

    public Object get(String key){
        if(null == this.data) return null;
        return this.data.get(key);
    }
}
