package com.cyksj.model.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;

/**
 * @author zwhui
 * @date 2024/4/24 17:08
 */
@Data
public class UpgradeOrderDon extends BaseEntity {
    /**
     * 订单编号
     */
    private String orderNo;

    /**
     * 商品id
     */
    private Long goodsId;

    private Long skuId;

    /**
     * 套餐id
     */
    private Long packageId;

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

    private Long relationId;

    /**
     * 原订单号
     */
    private Long originalOrderId;

    private String transactionId;

    /**
     * 时间
     * */
    private Long time;

    private Integer num;

    private BigDecimal price;

    /**
     * 金额
     */
    private BigDecimal money;


    /**
     * 余额支付
     */
    private BigDecimal balance;

    /**
     * 退款金额
     */
    private BigDecimal refundMoney;

    /**
     * 退款余额
     */
    private BigDecimal refundBalance;

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

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

    private Status status;

    private Type type;

    private String shopId;
    /**
     * 买家支付id
     */
    private String buyerId;


    private Boolean isWebPay;

    public enum Status {
        /**
         * 订单状态
         */
        close("已关闭"),
        noPayment("待付款"),
        hasPayment("已付款"),
        transport("已发货"),
        received("已签收"),
        complete("已完成"),
        refund("已退款"),
        ;

        private String desc;

        Status(String desc) {
            this.desc = desc;
        }

        public String getDesc() {
            return desc;
        }
    }

    @Getter
    @AllArgsConstructor
    public enum Type{
        WeChat("wechat","微信"),
        ALI_PAY("zfb","支付宝"),
        EX_CODE("exchange_code","兑换码"),
        LOTTERY("lottery","抽奖"),
        EQUIPMENT("equipment", "实物设备分销"),
        PAY_EQUIPMENT("pay_equipment", "自购设备"),
        BALANCE("balance", "余额支付"),
        PAYPAL("paypal","paypal支付"),
        STRIPE("stripe","stripe支付")
        ;
        String type;
        String desc;

        public static UpgradeOrderDon.Type getType(String type) {
            return Arrays.stream(UpgradeOrderDon.Type.values()).filter(tp -> tp.getType().equals(type)).findFirst().orElse(ALI_PAY);
        }
    }
}
