package com.yiqi.order.domain.dto;

import com.yiqi.common.enums.OrderType;
import com.yiqi.common.utils.DateUtils;
import com.yiqi.order.domain.OrderCloth;
import com.yiqi.order.domain.OrderGoods;
import com.yiqi.order.domain.OrderRechargeInstalment;
import com.yiqi.order.domain.vo.OrderPayResultVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;

/**
 * @author xiaohei
 * @date 2024/1/1
 */
@ApiModel("第三方支付结果返回")
@Data
public class PayResponseDTO {

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

    /**
     * 外部支付订单编号
     */
    private String outTradeNo;

    /*
     * 支付时间
     */
    private String payTime;

    /**
     * 是否成功  0未支付 100 支付中等待结果   101 ：支付失败   200 成功
     */
    private Integer payResult = 0;

    /**
     *
     */
    private String payMsg = "支付成功";

    /**
     * 明确的支付失败
     *
     * @param msg
     * @return
     */
    public static PayResponseDTO payError(String msg) {
        PayResponseDTO orderPayResultVO = new PayResponseDTO();
        orderPayResultVO.setPayMsg(msg);
        orderPayResultVO.setPayResult(101);
        return orderPayResultVO;
    }

    public static PayResponseDTO payWait(String orderNo) {
        PayResponseDTO orderPayResultVO = new PayResponseDTO();
        orderPayResultVO.setOrderNo(orderNo);
        orderPayResultVO.setPayMsg("支付中，请稍后");
        orderPayResultVO.setPayResult(100);
        return orderPayResultVO;
    }

    public static PayResponseDTO paySuccess(String orderNo, String outTradeNo) {
        PayResponseDTO orderPayResultVO = new PayResponseDTO();
        orderPayResultVO.setOrderNo(orderNo);
        orderPayResultVO.setOutTradeNo(outTradeNo);
        orderPayResultVO.setPayMsg("支付成功");
        orderPayResultVO.setPayResult(200);
        return orderPayResultVO;
    }


    public static Boolean ispaySuccess(PayResponseDTO payResponseDTO) {
        if (payResponseDTO == null || payResponseDTO.getPayResult() == null) {
            return false;
        }
        return payResponseDTO.getPayResult().intValue() == 200;
    }


}
