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.common.page.PageDTO;
import com.bonus.canteen.core.order.common.constants.OrderTypeEnum;
import com.bonus.canteen.core.order.common.dto.OrderRefundSearchParam;
import com.bonus.canteen.core.order.common.query.OrderQueryParam;
import com.bonus.canteen.core.order.utils.LeNumUtil;
import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.annotations.ApiModelProperty;

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

public class OrderRefundWebDTO extends PageDTO implements OrderQueryParam {
   @ApiModelProperty("开始日期")
   private LocalDate startDate;
   @ApiModelProperty("结束日期")
   private LocalDate endDate;
   @ApiModelProperty("人员姓名/编号/手机号")
   private String custSearchInfo;
   @ApiModelProperty("订单id")
   private Long orderId;
   private String macOrderId;
   @ApiModelProperty("审核状态")
   private Integer checkState;
   @ApiModelProperty("申请类型")
   private Integer applyType;
   /** @deprecated */
   private Integer orderType;
   @ApiModelProperty("导出字段")
   private List<String> exportCols;
   private List<Integer> orderTypeList;
   @ApiModelProperty("扩展字段")
   private JsonNode extParam;

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

   public OrderRefundSearchParam convertToOrderRefundSearchParam() {
      OrderRefundSearchParam param = new OrderRefundSearchParam();
      param.setStartDate(this.startDate);
      param.setEndDate(this.endDate);
      param.setCustSearchInfo(this.custSearchInfo);
      param.setOrderId(this.orderId);
      param.setMacOrderId(this.macOrderId);
      param.setCheckState(this.checkState);
      param.setApplyType(this.applyType);
      param.setOrderTypeList(this.getOrderTypeList());
      return param;
   }

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

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

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

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

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

   public Integer getCheckState() {
      return this.checkState;
   }

   public Integer getApplyType() {
      return this.applyType;
   }

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

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

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

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

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

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

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

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

   public void setCheckState(final Integer checkState) {
      this.checkState = checkState;
   }

   public void setApplyType(final Integer applyType) {
      this.applyType = applyType;
   }

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

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

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

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

}
