package com.hfkj.sysenum.discount;

import lombok.Getter;

import java.util.Objects;

/**
 * 优惠券获得方式
 * @author hurui
 */
@Getter
public enum DiscountStockCodeObtainTypeEnum {
    /**
     * 加油订单
     */
    type1(1 , "加油订单"),
    /**
     * 商城订单
     */
    type2(2 , "商城订单"),
    /**
     * 赠送
     */
    type3(3 , "赠送"),
    /**
     * API
     */
    type4(4 , "API"),
    ;

    private Integer code;
    private String name;

    DiscountStockCodeObtainTypeEnum(int code , String name) {
        this.code = code;
        this.name = name;
    }

    public static String getNameByType(Integer code) {
        for (DiscountStockCodeObtainTypeEnum ele : values()) {
            if(Objects.equals(code,ele.getCode())) return ele.getName();
        }
        return null;
    }
}
