package com.bonus.core.order.common.constants;

import cn.hutool.core.collection.CollUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

//public enum OrderStateEnum implements LeExcelFieldEnum<OrderStateEnum> {
public enum OrderStateEnum {
   PLACE(1, "已下单"),
   FINISH(2, "已完成"),
   CANCEL(3, "已取消"),
   WAIT_PLACE(4, "待下单");

   private final Integer key;
   private final String desc;

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

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

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

      return "";
   }

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

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

      return list;
   }

   public static boolean isPlaceState(Integer key) {
      return PLACE.getKey().equals(key);
   }

   public static boolean isFinishState(Integer key) {
      return FINISH.getKey().equals(key);
   }

   public static boolean isCancelState(Integer key) {
      return CANCEL.getKey().equals(key);
   }

   public static boolean isWaitPlaceState(Integer key) {
      return WAIT_PLACE.getKey().equals(key);
   }

   public static boolean isValidState(Integer key) {
      return isPlaceState(key) || isFinishState(key);
   }

   public static List<Integer> validStateList() {
      return CollUtil.toList(new Integer[]{PLACE.getKey(), FINISH.getKey()});
   }

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

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

   // $FF: synthetic method
   private static OrderStateEnum[] $values() {
      return new OrderStateEnum[]{PLACE, FINISH, CANCEL, WAIT_PLACE};
   }

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