package com.bonus.canteen.core.marketing.v2.rule.recharge.handler.fullgift.extension;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSONObject;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.canteen.core.marketing.v2.rule.recharge.constants.RuleRechargeEnum;
import com.bonus.canteen.core.marketing.v2.rule.recharge.handler.RuleRechargeHandler;
import com.bonus.canteen.core.marketing.v2.rule.recharge.handler.fullgift.dto.RechargeGiftFullDTO;

public interface RechargeFullGiftHandlerExtension extends RuleRechargeHandler {
   @Override
   default Integer getRuleType() {
      return RuleRechargeEnum.RULE_FULL_GIFT.getKey();
   }

   @Override
   default void checkRuleInfo(String ruleInfo) {
      RechargeGiftFullDTO rule = (RechargeGiftFullDTO)JSONObject.parseObject(ruleInfo, RechargeGiftFullDTO.class);
      if (CollUtil.isEmpty(rule.getItems())) {
         throw new ServiceException("规则配置有误");
      }
   }
}
