package com.bonus.core.customer.constants;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import com.bonus.core.common.converter.LeExcelFieldConvertor;
import com.bonus.core.common.converter.LeExcelFieldEnum;

import java.util.*;
import java.util.stream.Collectors;

public enum OrderTypeEnum implements LeExcelFieldEnum<OrderTypeEnum> {
   CURR_MEAL(1, "当餐点餐"),
   RESERVE_MEAL(2, "预订餐"),
   BOOK_MEAL(3, "自定义报餐"),
   SHOP(4, "商城"),
   RESERVE_SHOP(5, "预订商城"),
   ROOM(6, "包间"),
   TABLE(7, "餐桌"),
   BUS(8, "班车"),
   BOOK_MEAL_3DAY(9, "3天报餐"),
   BOOK_MEAL_7DAY(10, "7天报餐"),
   ANDROID(11, "线下消费"),
   BUFFET(12, "自助餐"),
   MOBILE_SCAN(13, "到店扫码"),
   MOBILE_SCAN_SHOP(14, "到店扫码"),
   MOBILE_TAKEAWAY(15, "美团外卖"),
   MOBILE_TAKEAWAY_STORE(16, "美团到店"),
   DEDUCT(21, "补扣"),
   OUT(22, "外部订单"),
   OTHER(99, "其他");

   private final Integer key;
   private final String desc;

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

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

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

      return "";
   }

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

      for(int var4 = 0; var4 < var3; ++var4) {
         OrderTypeEnum typeEnum = var2[var4];
         Map<String, Object> typeMap = new HashMap();
         typeMap.put("key", typeEnum.getKey());
         typeMap.put("value", typeEnum.getDesc());
         typeList.add(typeMap);
      }

      return typeList;
   }

   public static List<Integer> allTypeList() {
      return (List)Arrays.stream(values()).map(OrderTypeEnum::getKey).collect(Collectors.toList());
   }

   public static boolean isCanteenCategory(Integer orderType) {
      return CollUtil.toList(new Integer[]{CURR_MEAL.getKey(), RESERVE_MEAL.getKey(), BOOK_MEAL.getKey(), BOOK_MEAL_3DAY.getKey(), BOOK_MEAL_7DAY.getKey(), MOBILE_SCAN.getKey(), ROOM.getKey(), TABLE.getKey(), ANDROID.getKey(), BUFFET.getKey(), DEDUCT.getKey(), OUT.getKey()}).contains(orderType);
   }

   public static boolean isShopCategory(Integer orderType) {
      return SHOP.getKey().equals(orderType) || RESERVE_SHOP.getKey().equals(orderType) || MOBILE_SCAN_SHOP.getKey().equals(orderType);
   }

   public static boolean isRoomCategory(Integer orderType) {
      return ROOM.getKey().equals(orderType) || TABLE.getKey().equals(orderType);
   }

   public static boolean isBookMealCategory(Integer orderType) {
      return CollUtil.toList(new Integer[]{BOOK_MEAL.getKey(), BOOK_MEAL_3DAY.getKey(), BOOK_MEAL_7DAY.getKey()}).contains(orderType);
   }

   public static boolean isAndroidCategory(Integer orderType) {
      return CollUtil.toList(new Integer[]{ANDROID.getKey(), BUFFET.getKey(), DEDUCT.getKey(), OUT.getKey()}).contains(orderType);
   }

   public static boolean isAndroidType(Integer orderType) {
      return ANDROID.getKey().equals(orderType);
   }

   public static boolean isCurrMealType(Integer orderType) {
      return CURR_MEAL.getKey().equals(orderType);
   }

   public static boolean isReserveMealType(Integer orderType) {
      return RESERVE_MEAL.getKey().equals(orderType);
   }

   public static boolean isMobileScanType(Integer orderType) {
      return MOBILE_SCAN.getKey().equals(orderType);
   }

   public static boolean isMobileScanShopType(Integer orderType) {
      return MOBILE_SCAN_SHOP.getKey().equals(orderType);
   }

   public static boolean isMobileScanCategory(Integer orderType) {
      return MOBILE_SCAN.getKey().equals(orderType) || MOBILE_SCAN_SHOP.getKey().equals(orderType);
   }

   public static boolean isShopType(Integer orderType) {
      return SHOP.getKey().equals(orderType);
   }

   public static boolean isReserveShopType(Integer orderType) {
      return RESERVE_SHOP.getKey().equals(orderType);
   }

   public static boolean isBusType(Integer orderType) {
      return BUS.getKey().equals(orderType);
   }

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

      for(int var3 = 0; var3 < var2; ++var3) {
         OrderTypeEnum orderType = var1[var3];
         if (Objects.equals(orderType.key, key)) {
            return orderType;
         }
      }

      return null;
   }

   public static boolean isRoomType(Integer orderType) {
      return ROOM.getKey().equals(orderType);
   }

   public static boolean isBuffetType(Integer orderType) {
      return BUFFET.getKey().equals(orderType);
   }

   public static boolean isTakeawayType(Integer orderType) {
      return MOBILE_TAKEAWAY.getKey().equals(orderType);
   }

   public static boolean isTakeawayCategory(Integer orderType) {
      return MOBILE_TAKEAWAY.getKey().equals(orderType) || MOBILE_TAKEAWAY_STORE.getKey().equals(orderType);
   }

   public static List<Integer> orderTypeListForWebSearchType(Integer orderType) {
      if (isShopType(orderType)) {
         return CollUtil.toList(new Integer[]{SHOP.getKey(), RESERVE_SHOP.getKey(), MOBILE_SCAN_SHOP.getKey()});
      } else if (isAndroidType(orderType)) {
         return CollUtil.toList(new Integer[]{ANDROID.getKey(), DEDUCT.getKey(), OUT.getKey(), MOBILE_SCAN.getKey()});
      } else if (isRoomType(orderType)) {
         return CollUtil.toList(new Integer[]{ROOM.getKey(), TABLE.getKey()});
      } else {
         return (List)(orderType != null ? CollUtil.toList(new Integer[]{orderType}) : ListUtil.empty());
      }
   }

   public static List<Integer> orderTypeListForMobileSearchType(Integer orderType) {
      if (isShopType(orderType)) {
         return CollUtil.toList(new Integer[]{SHOP.getKey(), RESERVE_SHOP.getKey()});
      } else if (isAndroidType(orderType)) {
         return CollUtil.toList(new Integer[]{ANDROID.getKey(), DEDUCT.getKey(), OUT.getKey()});
      } else if (isMobileScanType(orderType)) {
         return CollUtil.toList(new Integer[]{MOBILE_SCAN.getKey(), MOBILE_SCAN_SHOP.getKey()});
      } else if (isRoomType(orderType)) {
         return CollUtil.toList(new Integer[]{ROOM.getKey(), TABLE.getKey()});
      } else {
         return (List)(orderType != null ? CollUtil.toList(new Integer[]{orderType}) : ListUtil.empty());
      }
   }

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

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

   // $FF: synthetic method
   private static OrderTypeEnum[] $values() {
      return new OrderTypeEnum[]{CURR_MEAL, RESERVE_MEAL, BOOK_MEAL, SHOP, RESERVE_SHOP, ROOM, TABLE, BUS, BOOK_MEAL_3DAY, BOOK_MEAL_7DAY, ANDROID, BUFFET, MOBILE_SCAN, MOBILE_SCAN_SHOP, MOBILE_TAKEAWAY, MOBILE_TAKEAWAY_STORE, DEDUCT, OUT, OTHER};
   }

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