package com.bonus.canteen.core.order.deprecated.constants;


import com.bonus.canteen.core.common.converter.LeExcelFieldConvertor;
import com.bonus.canteen.core.common.converter.LeExcelFieldEnum;
import com.bonus.canteen.core.order.common.constants.DishesStateEnum;
import com.bonus.canteen.core.order.common.constants.OrderRefundStateEnum;
import com.bonus.canteen.core.order.common.constants.OrderStateEnum;

import java.util.ArrayList;
import java.util.List;

/** @deprecated */
@Deprecated
public enum OrderStateOldEnum implements LeExcelFieldEnum<OrderStateOldEnum> {
   ORDER_PLACED(1, "已下单"),
   RECEIVE_ORDER(2, "已接单"),
   MAKEING(3, "制作中"),
   MAKEING_COMPLETE(4, "制作完成"),
   AWAIT_DRAW(5, "待配送员抢单"),
   ALREADY_ASSIGN(6, "已指派配送员"),
   DELIVER(7, "配送中"),
   WAITTAKE(8, "待取餐"),
   CANCLE(9, "已取消"),
   REFUND(10, "已退款"),
   COMPLETE(11, "已完成"),
   ALREADY_EVALUATE(12, "已评价"),
   CHARGE_BACK(13, "退单"),
   SYSTEM_WRITE_OFF(14, "系统核销");

   private final Integer key;
   private final String desc;

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

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

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

      return "";
   }

   public static List<Integer> getOutTradeTypeList() {
      List<Integer> outTradeTypeList = new ArrayList();
      outTradeTypeList.add(CANCLE.getKey());
      return outTradeTypeList;
   }

   public static List<Integer> getOutTradeTypeOrdSumList() {
      List<Integer> outTradeTypeList = new ArrayList();
      outTradeTypeList.add(CANCLE.getKey());
      outTradeTypeList.add(REFUND.getKey());
      return outTradeTypeList;
   }

   public static List<Integer> getOutOrdStateTypeList() {
      List<Integer> outTradeTypeList = new ArrayList();
      outTradeTypeList.add(CANCLE.getKey());
      outTradeTypeList.add(REFUND.getKey());
      return outTradeTypeList;
   }

   public static List<Integer> getCompleteTypeList() {
      List<Integer> completeTypeList = new ArrayList();
      completeTypeList.add(COMPLETE.getKey());
      completeTypeList.add(ALREADY_EVALUATE.getKey());
      completeTypeList.add(SYSTEM_WRITE_OFF.getKey());
      return completeTypeList;
   }

   public static List<Integer> getNotSum() {
      List<Integer> completeTypeList = new ArrayList();
      completeTypeList.add(CANCLE.getKey());
      completeTypeList.add(REFUND.getKey());
      completeTypeList.add(CHARGE_BACK.getKey());
      return completeTypeList;
   }

   public static List<Integer> getCanDelivery() {
      List<Integer> completeTypeList = new ArrayList();
      completeTypeList.add(ORDER_PLACED.getKey());
      completeTypeList.add(RECEIVE_ORDER.getKey());
      completeTypeList.add(MAKEING.getKey());
      completeTypeList.add(MAKEING_COMPLETE.getKey());
      completeTypeList.add(AWAIT_DRAW.getKey());
      completeTypeList.add(ALREADY_ASSIGN.getKey());
      completeTypeList.add(DELIVER.getKey());
      completeTypeList.add(WAITTAKE.getKey());
      return completeTypeList;
   }

   /** @deprecated */
   @Deprecated
   public static Integer convertByNewOrderState(Integer orderState, Integer orderRefundState, Integer dishesState) {
      if (OrderRefundStateEnum.FINISH.getKey().equals(orderRefundState)) {
         return REFUND.getKey();
      } else if (OrderStateEnum.CANCEL.getKey().equals(orderState)) {
         return CANCLE.getKey();
      } else if (OrderStateEnum.FINISH.getKey().equals(orderState)) {
         return COMPLETE.getKey();
      } else if (DishesStateEnum.WAIT_TAKE.getKey().equals(dishesState)) {
         return WAITTAKE.getKey();
      } else if (DishesStateEnum.DELIVERING.getKey().equals(dishesState)) {
         return DELIVER.getKey();
      } else {
         return DishesStateEnum.MAKING.getKey().equals(dishesState) ? MAKEING.getKey() : ORDER_PLACED.getKey();
      }
   }

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

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

   public static class ExcelConvertor extends LeExcelFieldConvertor<OrderStateOldEnum> {
      public ExcelConvertor() {
         super(OrderStateOldEnum.class);
      }
   }
}
