package com.bonus.canteen.core.pay.common.constants;

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

public enum PayStateEnum implements LeExcelFieldEnum<PayStateEnum> {
   UN_PAY(1, "未支付"),
   PAY_INPROCESS(2, "支付中"),
   PAY_SUCC(3, "支付成功"),
   PAY_FAIL(4, "支付失败"),
   PAY_CLOSE(5, "支付关闭"),
   PART_PAY(6, "部分支付");

   private final Integer key;
   private final String desc;

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

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

      return "";
   }

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

   public static boolean isFinishedState(Integer key) {
      return ListUtil.toList(new Integer[]{PAY_SUCC.getKey(), PART_PAY.getKey(), PAY_FAIL.getKey(), PAY_CLOSE.getKey()}).contains(key);
   }

   public static boolean isPaidState(Integer key) {
      return ListUtil.toList(new Integer[]{PAY_SUCC.getKey(), PART_PAY.getKey()}).contains(key);
   }

   public static boolean isPaySuccessState(Integer key) {
      return ListUtil.toList(new Integer[]{PAY_SUCC.getKey()}).contains(key);
   }

   public static boolean isPartPayState(Integer key) {
      return ListUtil.toList(new Integer[]{PART_PAY.getKey()}).contains(key);
   }

   public static boolean isFailedState(Integer key) {
      return ListUtil.toList(new Integer[]{PAY_FAIL.getKey(), PAY_CLOSE.getKey()}).contains(key);
   }

   public static boolean isCloseState(Integer key) {
      return ListUtil.toList(new Integer[]{PAY_CLOSE.getKey()}).contains(key);
   }

   public static boolean isPayingState(Integer key) {
      return PAY_INPROCESS.getKey().equals(key);
   }

   public static boolean isUnPayState(Integer key) {
      return UN_PAY.getKey().equals(key);
   }

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

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

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