package com.crm.rely.backend.core.enums;

/**
 * 卡扣款退款状态类型
 *
 * @author gao
 * @date 2025/11/4 16:29
 */
public enum CardTradeStatusEnum {
    DEDUCT_PROCESSING(1, 1, "扣款处理中"),
    REFUND_PROCESSING(1, 2, "退款处理中"),
    DEDUCT_SUCCESS(2, 1, "扣款成功"),
    REFUND_SUCCESS(2, 2, "退款成功"),
    DEDUCT_FAILED(3, 1, "扣款失败"),
    REFUND_FAILED(3, 2, "退款失败");

    private final int tradeStatus;
    private final int tradeType;
    private final String description;

    CardTradeStatusEnum(int tradeStatus, int tradeType, String description) {
        this.tradeStatus = tradeStatus;
        this.tradeType = tradeType;
        this.description = description;
    }

    public int getTradeStatus() {
        return tradeStatus;
    }

    public int getTradeType() {
        return tradeType;
    }

    public String getDescription() {
        return description;
    }

    public static String matchCode(Integer tradeStatus, Integer tradeType) {
        if (tradeStatus == null || tradeType == null) {
            return "";
        }
        for (CardTradeStatusEnum enumItem : values()) {
            if (enumItem.getTradeStatus() == tradeStatus && enumItem.getTradeType() == tradeType) {
                return enumItem.getDescription();
            }
        }
        return "";
    }
}
