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

import cn.hutool.core.collection.CollUtil;
import com.bonus.common.houqin.constant.LeConstants;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotNull;
import java.util.List;

public class OrderDishesUpdateDTO {
   @ApiModelProperty("订单id")
   private @NotNull Long orderId;
   @ApiModelProperty("订单二维码")
   private String qrCode;
   private @NotNull(
   message = "{order.param-illegal}"
) Integer dishesState;
   private String deliveryCode;
   private List<DetailDishesMakeCompleteDTO> detailDishesMakeList;

   public boolean ifPartMakeComplete() {
      return CollUtil.isEmpty(this.detailDishesMakeList) ? false : this.detailDishesMakeList.stream().anyMatch((s) -> {
         return LeConstants.COMMON_NO.equals(s.getCompleteMaking());
      });
   }

   public static OrderDishesUpdateDTO of(Long orderId, Integer dishesState) {
      return (new OrderDishesUpdateDTO()).setOrderId(orderId).setDishesState(dishesState);
   }

   public static OrderDishesUpdateDTO of(Long orderId, Integer dishesState, String deliveryCode) {
      return (new OrderDishesUpdateDTO()).setOrderId(orderId).setDishesState(dishesState).setDeliveryCode(deliveryCode);
   }

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

   public String getQrCode() {
      return this.qrCode;
   }

   public Integer getDishesState() {
      return this.dishesState;
   }

   public String getDeliveryCode() {
      return this.deliveryCode;
   }

   public List<DetailDishesMakeCompleteDTO> getDetailDishesMakeList() {
      return this.detailDishesMakeList;
   }

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

   public OrderDishesUpdateDTO setQrCode(final String qrCode) {
      this.qrCode = qrCode;
      return this;
   }

   public OrderDishesUpdateDTO setDishesState(final Integer dishesState) {
      this.dishesState = dishesState;
      return this;
   }

   public OrderDishesUpdateDTO setDeliveryCode(final String deliveryCode) {
      this.deliveryCode = deliveryCode;
      return this;
   }

   public OrderDishesUpdateDTO setDetailDishesMakeList(final List<DetailDishesMakeCompleteDTO> detailDishesMakeList) {
      this.detailDishesMakeList = detailDishesMakeList;
      return this;
   }


   public static class DetailDishesMakeCompleteDTO {
      private Long detailId;
      private Integer completeMaking;

      public Long getDetailId() {
         return this.detailId;
      }

      public Integer getCompleteMaking() {
         return this.completeMaking;
      }

      public DetailDishesMakeCompleteDTO setDetailId(final Long detailId) {
         this.detailId = detailId;
         return this;
      }

      public DetailDishesMakeCompleteDTO setCompleteMaking(final Integer completeMaking) {
         this.completeMaking = completeMaking;
         return this;
      }

   }
}
