package com.yonge.cooleshow.biz.dal.enums.coupon;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.google.common.collect.Lists;
import com.yonge.toolset.base.enums.BaseEnum;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * 优惠券可用品类
 * @author: Eric
 * @date: 2022-03-30
 */
public enum CouponCategoryEnum implements BaseEnum<String, CouponCategoryEnum> {

    UNIVERSAL("全场通用", "UNIVERSAL"),
    VIP("小酷Ai", "VIP"),
    PIANO("云酷琴房", "PINAO_ROOM"),
    MALL("商场购物券", "MALL"),
    MUSIC("单曲点播券", "MUSIC"),
    SPARRING("陪练课购买券", "PRACTICE"),
    LIVE("直播课购买券", "LIVE"),
    VIDEO("视频课购买券", "VIDEO"),
    ;

    @EnumValue
    private String code;
    private String msg;
    private String goodsType;

    CouponCategoryEnum(String msg, String goodsType) {
        this.code = this.name();
        this.msg = msg;
        this.goodsType = goodsType;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return this.msg;
    }

    public String getGoodsType() {
        return goodsType;
    }

    /**
     * 商品对应优惠券类型
     * @param goodsType 商品类型
     * @return List<CouponCategoryEnum>
     */
    public static List<CouponCategoryEnum> getCategory(String goodsType) {

        List<CouponCategoryEnum> retlist = Lists.newArrayList(UNIVERSAL);

        if (StringUtils.isNotEmpty(goodsType)) {

            CouponCategoryEnum[] values = CouponCategoryEnum.values();

            for (CouponCategoryEnum value : values) {

                if (value.getGoodsType().equals(goodsType)) {

                    retlist.add(value);
                }
            }

        }

        return retlist;
    }

    /**
     * 商品对应优惠券类型
     * @param goodsType 商品类型
     * @return List<CouponCategoryEnum>
     */
    public static CouponCategoryEnum goodTypeTo(String goodsType) {


        if (StringUtils.isNotEmpty(goodsType)) {

            CouponCategoryEnum[] values = CouponCategoryEnum.values();

            for (CouponCategoryEnum value : values) {

                if (value.getGoodsType().equals(goodsType)) {

                    return value;
                }
            }

        }

        return null;
    }
}
