package com.bonus.canteen.core.marketing.v2.rule.recharge.constants;

import com.bonus.canteen.core.marketing.util.EnumUtil;
import com.bonus.canteen.core.marketing.util.ICommonEnum;

import java.util.Objects;

public enum RuleRechargeEnum implements ICommonEnum {
   RULE_FULL_GIFT(1, "优惠-满赠"),
   RULE_TIMES_GIFT(2, "优惠-按次数赠送"),
   RULE_MAX_AMOUNT(51, "限额-上限金额"),
   RULE_SUM_AMOUNT(52, "限额-累计上限金额"),
   RULE_MANAGE_COST(101, "其他费用-管理费");

   private final Integer key;
   private final String value;

   public static boolean isDiscountRule(Integer key) {
      boolean flag = false;
      RuleRechargeEnum ruleType = (RuleRechargeEnum) EnumUtil.getEnumByKey(RuleRechargeEnum.class, key);
      if (Objects.isNull(ruleType)) {
         return false;
      } else {
         switch (ruleType.ordinal()) {
            case 0:
            case 1:
               flag = true;
            default:
               return flag;
         }
      }
   }

   public static boolean isLimitAmountRule(Integer key) {
      boolean flag = false;
      RuleRechargeEnum ruleType = (RuleRechargeEnum)EnumUtil.getEnumByKey(RuleRechargeEnum.class, key);
      if (Objects.isNull(ruleType)) {
         return false;
      } else {
         switch (ruleType.ordinal()) {
            case 2:
            case 3:
               flag = true;
            default:
               return flag;
         }
      }
   }

   public static boolean isOtherFeeRule(Integer key) {
      boolean flag = false;
      RuleRechargeEnum ruleType = (RuleRechargeEnum)EnumUtil.getEnumByKey(RuleRechargeEnum.class, key);
      if (Objects.nonNull(ruleType) && ruleType == RULE_MANAGE_COST) {
         flag = true;
      }

      return flag;
   }

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

   @Override
   public String getValue() {
      return this.value;
   }

   private RuleRechargeEnum(final Integer key, final String value) {
      this.key = key;
      this.value = value;
   }

   // $FF: synthetic method
   private static RuleRechargeEnum[] $values() {
      return new RuleRechargeEnum[]{RULE_FULL_GIFT, RULE_TIMES_GIFT, RULE_MAX_AMOUNT, RULE_SUM_AMOUNT, RULE_MANAGE_COST};
   }
}
