package com.bonus.canteen.core.order.web.dto;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import com.bonus.canteen.core.account.v3.constants.AccExceptionRecordStatusEnum;
import com.bonus.canteen.core.common.page.PageDTO;
import com.bonus.canteen.core.order.common.constants.OrderStateMixEnum;
import com.bonus.canteen.core.order.common.constants.OrderTypeEnum;
import com.bonus.canteen.core.order.common.dto.OrderSearchParam;
import com.bonus.canteen.core.order.common.query.OrderQueryParam;
import com.bonus.canteen.core.order.utils.LeNumUtil;
import com.bonus.canteen.core.pay.common.constants.PayStateEnum;
import com.bonus.common.houqin.constant.LeConstants;
import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.time.LocalDate;
import java.util.List;

@ApiModel("订单明细WebDTO")
public class OrderDetailWebDTO extends PageDTO implements OrderQueryParam {
   /** @deprecated */
   @Deprecated
   private Integer orderType;
   /** @deprecated */
   @Deprecated
   private Integer appSaleMode;
   private String macOrderId;
   private Long orderId;
   private String tradeNo;
   private LocalDate startDate;
   private LocalDate endDate;
   private String mealCode;
   private String custSearchInfo;
   private String goodsSearchInfo;
   private String deviceSearchInfo;
   private List<Integer> orderStateMixList;
   private Long canteenId;
   private Long stallId;
   private List<Integer> mealtimeTypeList;
   private List<Integer> payStateList;
   private List<Integer> orderRefundStateList;
   private List<Integer> payTypeList;
   private List<Integer> deliveryTypeList;
   private List<Integer> sourceTypeList;
   private List<String> exportCols;
   private List<Long> areaIdList;
   private List<Long> canteenIdList;
   private List<Long> stallIdList;
   private Integer ifCoupon;
   private Integer ifOnline;
   private Integer nuClearMode;
   private Integer psnType;
   private List<Integer> orderTypeList;
   private List<Long> orgIdList;
   private List<Long> roomIdList;
   private List<Long> operatorIdList;
   private List<Long> cashierIdList;
   private Integer ifWaitingPay;
   private Integer ifAccExceptionRecordProcessed;
   private String serialNum;
   @ApiModelProperty("扩展字段")
   private JsonNode extParam;

   public List<Integer> getOrderTypeList() {
      if (CollUtil.isNotEmpty(this.orderTypeList)) {
         return this.orderTypeList;
      } else if (LeNumUtil.isValidId(this.appSaleMode)) {
         return ListUtil.toList(new Integer[]{this.appSaleMode});
      } else {
         return LeNumUtil.isValidId(this.orderType) ? OrderTypeEnum.orderTypeListForWebSearchType(this.orderType) : ListUtil.empty();
      }
   }

   public List<Integer> getOrderStateList() {
      return OrderStateMixEnum.convertToOrderStateList(this.orderStateMixList);
   }

   public List<Integer> getPayStateList() {
      return (List)(LeConstants.COMMON_YES.equals(this.ifWaitingPay) ? ListUtil.toList(new Integer[]{PayStateEnum.PAY_INPROCESS.getKey(), PayStateEnum.PART_PAY.getKey()}) : OrderStateMixEnum.convertToPayStateList(this.orderStateMixList));
   }

   public List<Integer> getOrderRefundStateList() {
      return OrderStateMixEnum.convertToOrderRefundStateList(this.orderStateMixList);
   }

   public List<Long> getCanteenIdList() {
      if (CollUtil.isNotEmpty(this.canteenIdList)) {
         return this.canteenIdList;
      } else {
         return (List)(LeNumUtil.isValidId(this.canteenId) ? ListUtil.toList(new Long[]{this.canteenId}) : ListUtil.empty());
      }
   }

   public List<Long> getStallIdList() {
      if (CollUtil.isNotEmpty(this.stallIdList)) {
         return this.stallIdList;
      } else {
         return (List)(LeNumUtil.isValidId(this.stallId) ? ListUtil.toList(new Long[]{this.stallId}) : ListUtil.empty());
      }
   }

   public List<Integer> getPsnTypeList() {
      return (List)(LeNumUtil.isValidId(this.psnType) ? ListUtil.toList(new Integer[]{this.psnType}) : ListUtil.empty());
   }

   public OrderSearchParam convertToOrderSearchParam() {
      OrderSearchParam orderSearchParamDTO = new OrderSearchParam();
      orderSearchParamDTO.setOrderTypeList(this.getOrderTypeList());
      orderSearchParamDTO.setOrderStateList(this.getOrderStateList());
      orderSearchParamDTO.setPayStateList(this.getPayStateList());
      orderSearchParamDTO.setOrderRefundStateList(this.getOrderRefundStateList());
      orderSearchParamDTO.setPsnTypeList(this.getPsnTypeList());
      orderSearchParamDTO.setMealtimeTypeList(this.mealtimeTypeList);
      orderSearchParamDTO.setPayTypeList(this.payTypeList);
      orderSearchParamDTO.setDeliveryTypeList(this.deliveryTypeList);
      orderSearchParamDTO.setSourceTypeList(this.sourceTypeList);
      orderSearchParamDTO.setOrderIdList((List)(LeNumUtil.isValidId(this.orderId) ? ListUtil.toList(new Long[]{this.orderId}) : ListUtil.empty()));
      orderSearchParamDTO.setMacOrderId(this.macOrderId);
      orderSearchParamDTO.setOrgIdList(this.orgIdList);
      orderSearchParamDTO.setAreaIdList(this.areaIdList);
      orderSearchParamDTO.setCanteenIdList(this.getCanteenIdList());
      orderSearchParamDTO.setStallIdList(this.getStallIdList());
      orderSearchParamDTO.setRoomIdList(this.roomIdList);
      orderSearchParamDTO.setOperatorIdList(this.operatorIdList);
      orderSearchParamDTO.setCashierIdList(this.cashierIdList);
      orderSearchParamDTO.setStartDate(this.startDate);
      orderSearchParamDTO.setEndDate(this.endDate);
      orderSearchParamDTO.setIfCoupon(this.ifCoupon);
      orderSearchParamDTO.setIfOnline(this.ifOnline);
      orderSearchParamDTO.setNuClearMode(this.nuClearMode);
      orderSearchParamDTO.setTradeNo(this.tradeNo);
      orderSearchParamDTO.setMealCode(this.mealCode);
      orderSearchParamDTO.setCustSearchInfo(this.custSearchInfo);
      orderSearchParamDTO.setGoodsSearchInfo(this.goodsSearchInfo);
      orderSearchParamDTO.setDeviceSearchInfo(this.deviceSearchInfo);
      orderSearchParamDTO.setSerialNum(this.serialNum);
      if (LeConstants.COMMON_YES.equals(this.ifAccExceptionRecordProcessed)) {
         orderSearchParamDTO.setAccExceptionRecordStateList(CollUtil.toList(new Integer[]{AccExceptionRecordStatusEnum.SECOND_SUCC.getKey()}));
      } else if (LeConstants.COMMON_NO.equals(this.ifAccExceptionRecordProcessed)) {
         orderSearchParamDTO.setAccExceptionRecordStateList(CollUtil.toList(new Integer[]{AccExceptionRecordStatusEnum.FAIL.getKey()}));
      }

      return orderSearchParamDTO;
   }

   /** @deprecated */
   @Deprecated
   public Integer getOrderType() {
      return this.orderType;
   }

   /** @deprecated */
   @Deprecated
   public Integer getAppSaleMode() {
      return this.appSaleMode;
   }

   public String getMacOrderId() {
      return this.macOrderId;
   }

   public Long getOrderId() {
      return this.orderId;
   }

   public String getTradeNo() {
      return this.tradeNo;
   }

   public LocalDate getStartDate() {
      return this.startDate;
   }

   public LocalDate getEndDate() {
      return this.endDate;
   }

   public String getMealCode() {
      return this.mealCode;
   }

   public String getCustSearchInfo() {
      return this.custSearchInfo;
   }

   public String getGoodsSearchInfo() {
      return this.goodsSearchInfo;
   }

   public String getDeviceSearchInfo() {
      return this.deviceSearchInfo;
   }

   public List<Integer> getOrderStateMixList() {
      return this.orderStateMixList;
   }

   public Long getCanteenId() {
      return this.canteenId;
   }

   public Long getStallId() {
      return this.stallId;
   }

   public List<Integer> getMealtimeTypeList() {
      return this.mealtimeTypeList;
   }

   public List<Integer> getPayTypeList() {
      return this.payTypeList;
   }

   public List<Integer> getDeliveryTypeList() {
      return this.deliveryTypeList;
   }

   public List<Integer> getSourceTypeList() {
      return this.sourceTypeList;
   }

   public List<String> getExportCols() {
      return this.exportCols;
   }

   public List<Long> getAreaIdList() {
      return this.areaIdList;
   }

   public Integer getIfCoupon() {
      return this.ifCoupon;
   }

   public Integer getIfOnline() {
      return this.ifOnline;
   }

   public Integer getNuClearMode() {
      return this.nuClearMode;
   }

   public Integer getPsnType() {
      return this.psnType;
   }

   public List<Long> getOrgIdList() {
      return this.orgIdList;
   }

   public List<Long> getRoomIdList() {
      return this.roomIdList;
   }

   public List<Long> getOperatorIdList() {
      return this.operatorIdList;
   }

   public List<Long> getCashierIdList() {
      return this.cashierIdList;
   }

   public Integer getIfWaitingPay() {
      return this.ifWaitingPay;
   }

   public Integer getIfAccExceptionRecordProcessed() {
      return this.ifAccExceptionRecordProcessed;
   }

   public String getSerialNum() {
      return this.serialNum;
   }

   public JsonNode getExtParam() {
      return this.extParam;
   }

   /** @deprecated */
   @Deprecated
   public void setOrderType(final Integer orderType) {
      this.orderType = orderType;
   }

   /** @deprecated */
   @Deprecated
   public void setAppSaleMode(final Integer appSaleMode) {
      this.appSaleMode = appSaleMode;
   }

   public void setMacOrderId(final String macOrderId) {
      this.macOrderId = macOrderId;
   }

   public void setOrderId(final Long orderId) {
      this.orderId = orderId;
   }

   public void setTradeNo(final String tradeNo) {
      this.tradeNo = tradeNo;
   }

   public void setStartDate(final LocalDate startDate) {
      this.startDate = startDate;
   }

   public void setEndDate(final LocalDate endDate) {
      this.endDate = endDate;
   }

   public void setMealCode(final String mealCode) {
      this.mealCode = mealCode;
   }

   public void setCustSearchInfo(final String custSearchInfo) {
      this.custSearchInfo = custSearchInfo;
   }

   public void setGoodsSearchInfo(final String goodsSearchInfo) {
      this.goodsSearchInfo = goodsSearchInfo;
   }

   public void setDeviceSearchInfo(final String deviceSearchInfo) {
      this.deviceSearchInfo = deviceSearchInfo;
   }

   public void setOrderStateMixList(final List<Integer> orderStateMixList) {
      this.orderStateMixList = orderStateMixList;
   }

   public void setCanteenId(final Long canteenId) {
      this.canteenId = canteenId;
   }

   public void setStallId(final Long stallId) {
      this.stallId = stallId;
   }

   public void setMealtimeTypeList(final List<Integer> mealtimeTypeList) {
      this.mealtimeTypeList = mealtimeTypeList;
   }

   public void setPayStateList(final List<Integer> payStateList) {
      this.payStateList = payStateList;
   }

   public void setOrderRefundStateList(final List<Integer> orderRefundStateList) {
      this.orderRefundStateList = orderRefundStateList;
   }

   public void setPayTypeList(final List<Integer> payTypeList) {
      this.payTypeList = payTypeList;
   }

   public void setDeliveryTypeList(final List<Integer> deliveryTypeList) {
      this.deliveryTypeList = deliveryTypeList;
   }

   public void setSourceTypeList(final List<Integer> sourceTypeList) {
      this.sourceTypeList = sourceTypeList;
   }

   public void setExportCols(final List<String> exportCols) {
      this.exportCols = exportCols;
   }

   public void setAreaIdList(final List<Long> areaIdList) {
      this.areaIdList = areaIdList;
   }

   public void setCanteenIdList(final List<Long> canteenIdList) {
      this.canteenIdList = canteenIdList;
   }

   public void setStallIdList(final List<Long> stallIdList) {
      this.stallIdList = stallIdList;
   }

   public void setIfCoupon(final Integer ifCoupon) {
      this.ifCoupon = ifCoupon;
   }

   public void setIfOnline(final Integer ifOnline) {
      this.ifOnline = ifOnline;
   }

   public void setNuClearMode(final Integer nuClearMode) {
      this.nuClearMode = nuClearMode;
   }

   public void setPsnType(final Integer psnType) {
      this.psnType = psnType;
   }

   public void setOrderTypeList(final List<Integer> orderTypeList) {
      this.orderTypeList = orderTypeList;
   }

   public void setOrgIdList(final List<Long> orgIdList) {
      this.orgIdList = orgIdList;
   }

   public void setRoomIdList(final List<Long> roomIdList) {
      this.roomIdList = roomIdList;
   }

   public void setOperatorIdList(final List<Long> operatorIdList) {
      this.operatorIdList = operatorIdList;
   }

   public void setCashierIdList(final List<Long> cashierIdList) {
      this.cashierIdList = cashierIdList;
   }

   public void setIfWaitingPay(final Integer ifWaitingPay) {
      this.ifWaitingPay = ifWaitingPay;
   }

   public void setIfAccExceptionRecordProcessed(final Integer ifAccExceptionRecordProcessed) {
      this.ifAccExceptionRecordProcessed = ifAccExceptionRecordProcessed;
   }

   public void setSerialNum(final String serialNum) {
      this.serialNum = serialNum;
   }

   public void setExtParam(final JsonNode extParam) {
      this.extParam = extParam;
   }
}
