package com.bonus.core.order.mq.constants;

import cn.hutool.core.collection.CollUtil;
import com.bonus.core.order.common.constants.OrderTypeEnum;

import java.util.List;

public interface OrderMQConstants {
   Integer ORDER_CANCEL_DELAY_SECONDS = 1800;
   Integer ORDER_CANCEL_DELAY_SECONDS_FOR_SCAN = 60;
   List<Integer> PAY_QUERY_DELAY_SECOND_LIST = CollUtil.toList(new Integer[]{2, 2, 4, 6, 10, 16});
   Integer PAY_QUERY_MAX_SECOND = 44;

   static int nextPayQueryDelay(int queryTriggerTime) {
      return queryTriggerTime - 1 >= PAY_QUERY_DELAY_SECOND_LIST.size() ? -1 : (Integer)PAY_QUERY_DELAY_SECOND_LIST.get(queryTriggerTime - 1);
   }

   static Integer delaySecondByOrderType(Integer orderType) {
      return OrderTypeEnum.isMobileScanType(orderType) ? ORDER_CANCEL_DELAY_SECONDS_FOR_SCAN : ORDER_CANCEL_DELAY_SECONDS;
   }
}
