package com.bonus.canteen.core.allocation.canteen.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.math.BigDecimal;
import java.time.LocalTime;

@ApiModel("配送设置DTO")
public class AllocCanteenDeliveryDTO {
   @ApiModelProperty("配送方式")
   private Integer deliveryType;
   @ApiModelProperty("取餐点名称")
   private String foodPlaceNames;
   @ApiModelProperty("配送费")
   private BigDecimal deliveryAmount;
   @ApiModelProperty("起送价")
   private BigDecimal basePrice;
   @ApiModelProperty("包装费")
   private BigDecimal packingFee;
   @ApiModelProperty("平均配送时间")
   private Integer avgDeliveryMinute;
   @ApiModelProperty("配送时间段")
   private LocalTime deliveryStartTime;
   @ApiModelProperty("配送时间段")
   private LocalTime deliveryEndTime;
   @ApiModelProperty("超时提醒时间")
   private Integer timeoutReminderMinute;
   @ApiModelProperty("超时清理时间")
   private Integer timeoutCleanMinute;

   public boolean validBasePrice(BigDecimal targetBasePrice) {
      if (this.basePrice == null) {
         return true;
      } else if (targetBasePrice == null) {
         return false;
      } else {
         return this.basePrice.compareTo(targetBasePrice) <= 0;
      }
   }

   public boolean needFee() {
      return this.deliveryAmount != null || this.packingFee != null;
   }

   public BigDecimal calcDeliveryAmountForOrder() {
      return this.deliveryAmount != null ? this.deliveryAmount : BigDecimal.ZERO;
   }

   public BigDecimal calcPackingAmountForOrder() {
      return this.packingFee != null ? this.packingFee : BigDecimal.ZERO;
   }

   public Integer getDeliveryType() {
      return this.deliveryType;
   }

   public String getFoodPlaceNames() {
      return this.foodPlaceNames;
   }

   public BigDecimal getDeliveryAmount() {
      return this.deliveryAmount;
   }

   public BigDecimal getBasePrice() {
      return this.basePrice;
   }

   public BigDecimal getPackingFee() {
      return this.packingFee;
   }

   public Integer getAvgDeliveryMinute() {
      return this.avgDeliveryMinute;
   }

   public LocalTime getDeliveryStartTime() {
      return this.deliveryStartTime;
   }

   public LocalTime getDeliveryEndTime() {
      return this.deliveryEndTime;
   }

   public Integer getTimeoutReminderMinute() {
      return this.timeoutReminderMinute;
   }

   public Integer getTimeoutCleanMinute() {
      return this.timeoutCleanMinute;
   }

   public void setDeliveryType(final Integer deliveryType) {
      this.deliveryType = deliveryType;
   }

   public void setFoodPlaceNames(final String foodPlaceNames) {
      this.foodPlaceNames = foodPlaceNames;
   }

   public void setDeliveryAmount(final BigDecimal deliveryAmount) {
      this.deliveryAmount = deliveryAmount;
   }

   public void setBasePrice(final BigDecimal basePrice) {
      this.basePrice = basePrice;
   }

   public void setPackingFee(final BigDecimal packingFee) {
      this.packingFee = packingFee;
   }

   public void setAvgDeliveryMinute(final Integer avgDeliveryMinute) {
      this.avgDeliveryMinute = avgDeliveryMinute;
   }

   public void setDeliveryStartTime(final LocalTime deliveryStartTime) {
      this.deliveryStartTime = deliveryStartTime;
   }

   public void setDeliveryEndTime(final LocalTime deliveryEndTime) {
      this.deliveryEndTime = deliveryEndTime;
   }

   public void setTimeoutReminderMinute(final Integer timeoutReminderMinute) {
      this.timeoutReminderMinute = timeoutReminderMinute;
   }

   public void setTimeoutCleanMinute(final Integer timeoutCleanMinute) {
      this.timeoutCleanMinute = timeoutCleanMinute;
   }

}
