package com.bonus.core.marketing.v2.constants;

import cn.hutool.core.collection.CollUtil;
import com.bonus.core.marketing.util.ICommonEnum;
import com.bonus.core.marketing.v2.rule.param.RuleRangeParam;
import com.bonus.core.marketing.v2.vo.MarketRuleDetailVO;

public enum MarketRangeTypeEnum implements ICommonEnum {
   RANGE_DEVICE(1, "设备") {
      public boolean exec(RuleRangeParam param, MarketRuleDetailVO detail) {
         return CollUtil.contains(detail.getDeviceList(), "-1") || CollUtil.contains(detail.getDeviceList(), param.getDeviceSn());
      }
   },
   RANGE_MEALTIME(2, "餐次") {
      public boolean exec(RuleRangeParam param, MarketRuleDetailVO detail) {
         return CollUtil.contains(detail.getMealtimeList(), -1) || CollUtil.contains(detail.getMealtimeList(), param.getMealtimeType());
      }
   },
   RANGE_ORGANIZATION(3, "组织") {
      public boolean exec(RuleRangeParam param, MarketRuleDetailVO detail) {
         return CollUtil.contains(detail.getOrgIdList(), -1L) || CollUtil.contains(detail.getOrgIdList(), param.getOrgId());
      }
   },
   RANGE_PERSON(4, "人员类别") {
      public boolean exec(RuleRangeParam param, MarketRuleDetailVO detail) {
         return CollUtil.contains(detail.getPsnTypeList(), -1) || CollUtil.contains(detail.getPsnTypeList(), param.getPsnType());
      }
   },
   RANGE_AGE(5, "年龄段") {
      public boolean exec(RuleRangeParam param, MarketRuleDetailVO detail) {
         return CollUtil.contains(detail.getAgeTypeList(), -1) || CollUtil.contains(detail.getAgeTypeList(), param.getAgeType());
      }
   },
   RANGE_PAY_CHANNEL(6, "支付渠道") {
      public boolean exec(RuleRangeParam param, MarketRuleDetailVO detail) {
         return CollUtil.contains(detail.getPayChannelList(), -1) || CollUtil.contains(detail.getPayChannelList(), param.getPayChannel());
      }
   };

   private Integer key;
   private String value;

   public abstract boolean exec(RuleRangeParam param, MarketRuleDetailVO detail);

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

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

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

   // $FF: synthetic method
   private static MarketRangeTypeEnum[] $values() {
      return new MarketRangeTypeEnum[]{RANGE_DEVICE, RANGE_MEALTIME, RANGE_ORGANIZATION, RANGE_PERSON, RANGE_AGE, RANGE_PAY_CHANNEL};
   }
}
