package com.starry.admin.modules.shop.module.enums;

import java.util.Arrays;
import java.util.Optional;
import lombok.Getter;

/**
 * 优惠券领取渠道
 */
@Getter
public enum CouponObtainChannel {
    SELF_SERVICE("1"),
    BACKEND_GRANT("2"),
    REFUND_RETURN("3"),
    SHARE("4"),
    LOTTERY("5");

    private final String code;

    CouponObtainChannel(String code) {
        this.code = code;
    }

    public static Optional<CouponObtainChannel> fromCode(String code) {
        return Arrays.stream(values()).filter(item -> item.code.equals(code)).findFirst();
    }
}
