package com.sonic.lion.domain.enums;

import com.sonic.lion.enums.BizType;

/**
 * @author: code
 * @date: 2025/07/09
 * @Description: 交易事件
 * @version: 1.0.0
 */
public enum TradeEvent {

    /**
     * 付款
     */
    PAYMENT(1, "PAYMENT"),

    /**
     * 提现
     */
    WITHDRAW(2, "WITHDRAW"),

    /**
     * 退款
     */
    REFUND(3, "REFUND"),

    /**
     * 绑定账户
     */
    BIND_ACCOUNT(4, "BIND_ACCOUNT"),
    ;

    private final int value;

    private final String desc;

    TradeEvent(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public int getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static TradeEvent get(int value) {
        for (TradeEvent tradeType : values()) {
            if (tradeType.getValue() == value) {
                return tradeType;
            }
        }
        return null;
    }

    public static TradeEvent get(BizType bizType) {
        if (bizType == BizType.CHARGE) {
            return PAYMENT;
        } else if (bizType == BizType.REFUND) {
            return REFUND;
        } else if (bizType == BizType.WITHDRAW) {
            return WITHDRAW;
        } else {
            return null;
        }
    }
}
