package com.bonus.canteen.core.account.v3.constants;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import com.bonus.canteen.core.notice.notice.v2.constant.NoticeTemplateKeyEnum;
import com.google.common.collect.Maps;

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

public enum AccTradeTypeEnum {
   RECHARGE(10, "充值"),
   RECHARGE_GIFT(11, "赠送"),
   REVOKE_RECHARGE_GIFT(12, "撤销赠送"),
   REVOKE_RECHARGE(40, "撤销充值"),
   SUBSIDY(20, "补贴"),
   REVOKE_SUBSIDY(50, "撤销补贴"),
   CLEAR(100, "清空"),
   LUCK_MONEY(140, "红包发放"),
   WITHDRAW(30, "提现"),
   TRANSFER_OUT(60, "转出"),
   TRANSFER_IN(70, "转入"),
   FREEZE(80, "冻结"),
   UN_FREEZE(90, "解冻"),
   CONSUME(110, "消费"),
   CONSUME_REPAIR(120, "消费补扣"),
   CONSUME_REFUND(130, "消费退款");

   private final Integer key;
   private final String desc;

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

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

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

      return "";
   }

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

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

      return null;
   }

   public static Map<String, String> noticeTemplateKey4TradeTypeDescMap() {
      Map<String, String> templateKeyMap = Maps.newHashMap();
      templateKeyMap.put(NoticeTemplateKeyEnum.ACC_RECHARGE.getKey(), RECHARGE.getDesc());
      templateKeyMap.put(NoticeTemplateKeyEnum.ACC_SUB.getKey(), SUBSIDY.getDesc());
      templateKeyMap.put(NoticeTemplateKeyEnum.ACC_WITHDRAW.getKey(), WITHDRAW.getDesc());
      templateKeyMap.put(NoticeTemplateKeyEnum.ACC_FROZEN.getKey(), FREEZE.getDesc());
      templateKeyMap.put(NoticeTemplateKeyEnum.ACC_UNFROZEN.getKey(), UN_FREEZE.getDesc());
      templateKeyMap.put(NoticeTemplateKeyEnum.ACC_SUB_CLEAR.getKey(), CLEAR.getDesc());
      templateKeyMap.put(NoticeTemplateKeyEnum.ACC_PAY.getKey(), CONSUME.getDesc());
      templateKeyMap.put(NoticeTemplateKeyEnum.ACC_REPAIR_DEDUCT.getKey(), CONSUME_REPAIR.getDesc());
      templateKeyMap.put(NoticeTemplateKeyEnum.ACC_REFUND.getKey(), CONSUME_REFUND.getDesc());
      templateKeyMap.put(NoticeTemplateKeyEnum.ACC_RED_SEND.getKey(), LUCK_MONEY.getDesc());
      templateKeyMap.put(NoticeTemplateKeyEnum.ACC_TRANSFER.getKey(), TRANSFER_IN.getDesc());
      return templateKeyMap;
   }

   public static List<Integer> getRechargeTradeTypeList() {
      List<Integer> rechargeList = new ArrayList();
      rechargeList.add(RECHARGE.getKey());
      rechargeList.add(RECHARGE_GIFT.getKey());
      rechargeList.add(SUBSIDY.getKey());
      rechargeList.add(WITHDRAW.getKey());
      rechargeList.add(REVOKE_RECHARGE.getKey());
      rechargeList.add(REVOKE_SUBSIDY.getKey());
      rechargeList.add(CLEAR.getKey());
      return rechargeList;
   }

   public static boolean getConvertFlag(Integer flowType) {
      AccTradeTypeEnum tradeEnum = getEnum(flowType);
      if (Objects.isNull(tradeEnum)) {
         return false;
      } else {
         boolean var10000;
         switch (tradeEnum.ordinal()) {
            case 2:
            case 3:
            case 5:
            case 6:
            case 8:
            case 9:
            case 11:
            case 13:
            case 14:
               var10000 = true;
               break;
            case 4:
            case 7:
            case 10:
            case 12:
            default:
               var10000 = false;
         }

         return var10000;
      }
   }

   public static List<Integer> getRechargeListForApp() {
      List<Integer> rechargeList = new ArrayList();
      rechargeList.add(RECHARGE.getKey());
      rechargeList.add(SUBSIDY.getKey());
      rechargeList.add(LUCK_MONEY.getKey());
      return rechargeList;
   }

   public static List<Integer> incomeTypeList() {
      return ListUtil.toList(new Integer[]{RECHARGE.getKey(), SUBSIDY.getKey(), LUCK_MONEY.getKey(), CONSUME_REFUND.getKey()});
   }

   public static List<Integer> expenditureTypeList() {
      return ListUtil.toList(new Integer[]{REVOKE_RECHARGE_GIFT.getKey(), REVOKE_RECHARGE.getKey(), REVOKE_SUBSIDY.getKey(), CONSUME.getKey(), CONSUME_REPAIR.getKey(), WITHDRAW.getKey(), CLEAR.getKey()});
   }

   public static List<Integer> appSubTradeTypeList() {
      return (List)CollUtil.addAll(subIncomeTypeList(), subExpenditureTypeList());
   }

   public static List<Integer> subIncomeTypeList() {
      return ListUtil.toList(new Integer[]{RECHARGE_GIFT.getKey(), SUBSIDY.getKey(), TRANSFER_IN.getKey(), CONSUME_REFUND.getKey()});
   }

   public static List<Integer> subExpenditureTypeList() {
      return ListUtil.toList(new Integer[]{REVOKE_RECHARGE_GIFT.getKey(), REVOKE_SUBSIDY.getKey(), CLEAR.getKey(), WITHDRAW.getKey(), CONSUME.getKey(), CONSUME_REPAIR.getKey()});
   }

   public static List<Integer> appWorkTradeTypeList() {
      return (List)CollUtil.addAll(expenditureTypeList(), incomeTypeList());
   }

   public static AccTradeTypeEnum conversionRevoke(Integer key) {
      AccTradeTypeEnum tradeEnum = getEnum(key);
      if (Objects.isNull(tradeEnum)) {
         return null;
      } else {
         AccTradeTypeEnum result = null;
         switch (tradeEnum.ordinal()) {
            case 0:
               result = REVOKE_RECHARGE;
               break;
            case 1:
               result = REVOKE_RECHARGE_GIFT;
            case 2:
            case 3:
            default:
               break;
            case 4:
               result = REVOKE_SUBSIDY;
         }

         return result;
      }
   }

   public static List<Integer> getAccRechargeRepealList() {
      return ListUtil.toList(new Integer[]{REVOKE_RECHARGE.getKey(), REVOKE_RECHARGE_GIFT.getKey()});
   }

   public static List<Integer> listExpiredSubsidyExpend() {
      return ListUtil.toList(new Integer[]{CLEAR.getKey(), WITHDRAW.getKey(), CONSUME.getKey(), CONSUME_REPAIR.getKey()});
   }

   public static List<Integer> listExpiredSubsidyIncome() {
      return ListUtil.toList(new Integer[]{CONSUME_REFUND.getKey()});
   }

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

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

   // $FF: synthetic method
   private static AccTradeTypeEnum[] $values() {
      return new AccTradeTypeEnum[]{RECHARGE, RECHARGE_GIFT, REVOKE_RECHARGE_GIFT, REVOKE_RECHARGE, SUBSIDY, REVOKE_SUBSIDY, CLEAR, LUCK_MONEY, WITHDRAW, TRANSFER_OUT, TRANSFER_IN, FREEZE, UN_FREEZE, CONSUME, CONSUME_REPAIR, CONSUME_REFUND};
   }
}
