package com.ylx.massage.enums;
import lombok.Getter;

/**
 * 售后状态枚举
 */
@Getter
public enum AfterSaleStatusEnum {

    WAIT_AUDIT(0, "待审核"),

    REFUND_COMPLETED(1, "退款完成"),

    WAITING_USER_RETURN(2, "等待用户寄回"),

    WAITING_MERCHANT_RECEIVE(3, "等待商家收货"),

    WAITING_MERCHANT_SHIP(4, "等待商家寄出"),

    COMPLETED(5, "订单完成"),

    CANCELLED(6, "售后取消");

    private final Integer code;

    private final String desc;

    AfterSaleStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据code获取枚举值
     * @param code 代码
     * @return 枚举值
     */
    public static AfterSaleStatusEnum valueOf(Integer code) {
        if (code == null) {
            return null;
        }
        for (AfterSaleStatusEnum value : AfterSaleStatusEnum.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

    public static String getDescByCode(Integer code) {
        if (code == null) {
            return "";
        }
        for (AfterSaleStatusEnum value : AfterSaleStatusEnum.values()) {
            if (value.getCode().equals(code)) {
                return value.getDesc();
            }
        }
        return "";
    }
}
