package com.bonus.canteen.core.common.enums;

import com.bonus.canteen.core.common.converter.LeExcelFieldConvertor;
import com.bonus.canteen.core.common.converter.LeExcelFieldEnum;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum DeliveryTypeEnum implements LeExcelFieldEnum<DeliveryTypeEnum> {
   SELF_TAKE(1, "自取堂食"),
   MERCHANT(2, "商家配送"),
   DINING_CABINET(3, "取餐柜配送"),
   FRESH_CABINET(4, "生鲜柜配送"),
   TAKE_OUT(5, "自取外带"),
   FOOD_PLACE(6, "取餐点自取"),
   TAKEAWAY(7, "外卖配送"),
   TAKEAWAY_STORE(8, "外卖到店"),
   NONE(0, "无配送");

   private final Integer key;
   private final String desc;

   private DeliveryTypeEnum(Integer key, String desc) {
      this.key = key;
      this.desc = desc;
   }

   public static String getDesc(Integer key) {
      DeliveryTypeEnum[] var1 = values();
      int var2 = var1.length;

      for(int var3 = 0; var3 < var2; ++var3) {
         DeliveryTypeEnum temp = var1[var3];
         if (temp.getKey().equals(key)) {
            return temp.getDesc();
         }
      }

      return "";
   }

   public static DeliveryTypeEnum getTypeEnum(Integer key) {
      DeliveryTypeEnum[] var1 = values();
      int var2 = var1.length;

      for(int var3 = 0; var3 < var2; ++var3) {
         DeliveryTypeEnum typeEnum = var1[var3];
         if (typeEnum.getKey().equals(key)) {
            return typeEnum;
         }
      }

      return NONE;
   }

   public static List<Map<String, Object>> getAllEnumsList() {
      DeliveryTypeEnum[] enums = values();
      List<Map<String, Object>> list = new ArrayList();
      DeliveryTypeEnum[] var2 = enums;
      int var3 = enums.length;

      for(int var4 = 0; var4 < var3; ++var4) {
         DeliveryTypeEnum typeEnum = var2[var4];
         if (!NONE.getKey().equals(typeEnum.getKey())) {
            Map<String, Object> map = new HashMap();
            map.put("key", typeEnum.getKey());
            map.put("value", typeEnum.getDesc());
            list.add(map);
         }
      }

      return list;
   }

   public static boolean isNeedDeliveryType(Integer key) {
      return MERCHANT.getKey().equals(key) || DINING_CABINET.getKey().equals(key) || FRESH_CABINET.getKey().equals(key);
   }

   public static boolean isValidType(Integer key) {
      return getTypeEnum(key) != NONE;
   }


   @Override
   public Integer getKey() {
      return this.key;
   }


   @Override
   public String getDesc() {
      return this.desc;
   }

   public static class ExcelConvertor extends LeExcelFieldConvertor<DeliveryTypeEnum> {
      public ExcelConvertor() {
         super(DeliveryTypeEnum.class);
      }
   }

}
