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

import com.bonus.canteen.core.order.common.model.OrderRefundDetail;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

@ApiModel("订单详情退单DTO")
public class OrderDetailRefundDTO {
   @ApiModelProperty("订单详情id")
   private @NotNull Long detailId;
   @ApiModelProperty("退单数量")
   private @NotNull @Min(0L) Integer quantity;
   @ApiModelProperty("恢复库存数量")
   private Integer restoreQuantity;

   public OrderRefundDetail convertToOrderRefundDetail() {
      OrderRefundDetail refundDetail = OrderRefundDetail.newDefaultInstance();
      refundDetail.setDetailId(this.detailId);
      refundDetail.setQuantity(this.quantity);
      refundDetail.setRestoreQuantity(this.restoreQuantity);
      return refundDetail;
   }

   public static OrderDetailRefundDTO of(Long detailId, Integer quantity) {
      OrderDetailRefundDTO dto = new OrderDetailRefundDTO();
      dto.setDetailId(detailId);
      dto.setQuantity(quantity);
      return dto;
   }

   public static String[] logFields() {
      return new String[]{"detailId", "quantity", "restoreQuantity"};
   }

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

   public Integer getQuantity() {
      return this.quantity;
   }

   public Integer getRestoreQuantity() {
      return this.restoreQuantity;
   }

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

   public void setQuantity(final Integer quantity) {
      this.quantity = quantity;
   }

   public void setRestoreQuantity(final Integer restoreQuantity) {
      this.restoreQuantity = restoreQuantity;
   }

}
