package org.springblade.common.enums;

import lombok.Getter;
import org.springblade.core.log.exception.ServiceException;

/**
 * 订单类型枚举类
 */
@Getter
public enum OrderTypeEnum {
	GOODS("普通商品", 1, "mallServiceImpl"),
	CUSTOM_WINE("定制酒", 2, "customWineOrderServiceImpl"),
	FREE_WINE("免费领酒", 3, "freeWineSubmitOrderImpl"),
	SAMPLE_WINE("基酒样酒", 4, "sampleWineSubmitOrderServiceImpl"),
	LOTTERY("抽奖", 5, "lotterySubmitOrderServiceImpl"),
	TRADEMARK_AUTH("商标授权", 6, "trademarkAuthOrderServiceImpl"),
	BALANCE_RECHARGE("余额充值", 7, "balanceOrderService");
	private String name;
	private Integer value;
	private String instance;

	OrderTypeEnum(String name, Integer value, String instance) {
		this.name = name;
		this.instance = instance;
		this.value = value;
	}

	public static String getNameByValue(Integer value) {
		for (OrderTypeEnum orderTypeEnum : OrderTypeEnum.values()) {
			if (orderTypeEnum.value.equals(value)) {
				return orderTypeEnum.getName();
			}
		}
		return "未知";
	}

	public static String getInstanceByValue(Integer value) {
		for (OrderTypeEnum orderTypeEnum : OrderTypeEnum.values()) {
			if (orderTypeEnum.value.equals(value)) {
				return orderTypeEnum.getInstance();
			}
		}
		throw new ServiceException("未找到实体对象");
	}
}
