package com.bonus.canteen.core.order.weight.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.bonus.canteen.core.menu.constant.MenuSalesTypeEnum;
import io.swagger.annotations.ApiModelProperty;

import java.math.BigDecimal;
import java.time.LocalDateTime;

public class MacWeighConsumVO {
   @ApiModelProperty("订单明细 id")
   private Long orderDetailId;
   @ApiModelProperty("订单明细 id")
   private Long detailId;
   private String submitKey;
   @ApiModelProperty("商品菜品id")
   private Long dishesId;
   @ApiModelProperty("菜品编号")
   private Integer menuNo;
   @ApiModelProperty("菜品名称")
   private String dishesName;
   @ApiModelProperty("菜品图片")
   private String menuImgUrl;
   @ApiModelProperty("菜品单价")
   private BigDecimal menuPrice;
   @ApiModelProperty("每份重量")
   private Integer weight;
   @ApiModelProperty("菜品重量")
   private Integer menuWeigh;
   @ApiModelProperty("销售方式")
   private Integer salseMode;
   @ApiModelProperty("销售数量")
   private Integer quantity;
   @ApiModelProperty("终端编号")
   private String macNo;
   @ApiModelProperty("菜品总价")
   private Integer totalAmount;
   @ApiModelProperty("终端时间")
   @JSONField(
      format = "yyyy-MM-dd HH:mm:ss"
   )
   private LocalDateTime macTime;

   @ApiModelProperty("菜品名称")
   public String getMenuName() {
      return this.dishesName;
   }

   public static MacWeighConsumVO of(OrderWeightDetailVO orderWeightDetailVO) {
      MacWeighConsumVO macWeighConsumVO = new MacWeighConsumVO();
      macWeighConsumVO.setOrderDetailId(orderWeightDetailVO.getDetailId());
      macWeighConsumVO.setDetailId(orderWeightDetailVO.getDetailId());
      macWeighConsumVO.setDishesId(orderWeightDetailVO.getGoodsDishesId());
      macWeighConsumVO.setMenuNo(orderWeightDetailVO.getCustomDishesId());
      macWeighConsumVO.setDishesName(orderWeightDetailVO.getGoodsDishesName());
      macWeighConsumVO.setMenuImgUrl(orderWeightDetailVO.getGoodsDishesImgUrl());
      macWeighConsumVO.setMenuPrice(orderWeightDetailVO.getPrefPrice());
      macWeighConsumVO.setWeight(orderWeightDetailVO.getWeightUnit());
      macWeighConsumVO.setMenuWeigh(orderWeightDetailVO.getQuantity());
      macWeighConsumVO.setSalseMode(orderWeightDetailVO.getSalesMode());
      macWeighConsumVO.setMacNo(orderWeightDetailVO.getMachineNum());
      macWeighConsumVO.setMacTime(orderWeightDetailVO.getSubmitTime());
      macWeighConsumVO.setMenuWeigh(orderWeightDetailVO.getTotalWeight());
      macWeighConsumVO.setSubmitKey(orderWeightDetailVO.getSubmitKey());
      macWeighConsumVO.setTotalAmount(orderWeightDetailVO.getCalcTotalAmount() != null ? orderWeightDetailVO.getCalcTotalAmount().intValue() : 0);
      if (MenuSalesTypeEnum.PORTION_ON.key().equals(orderWeightDetailVO.getSalesMode())) {
         macWeighConsumVO.setQuantity(orderWeightDetailVO.getQuantity());
      } else {
         macWeighConsumVO.setMenuWeigh(orderWeightDetailVO.getQuantity());
      }

      return macWeighConsumVO;
   }

   public Long getOrderDetailId() {
      return this.orderDetailId;
   }

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

   public String getSubmitKey() {
      return this.submitKey;
   }

   public Long getDishesId() {
      return this.dishesId;
   }

   public Integer getMenuNo() {
      return this.menuNo;
   }

   public String getDishesName() {
      return this.dishesName;
   }

   public String getMenuImgUrl() {
      return this.menuImgUrl;
   }

   public BigDecimal getMenuPrice() {
      return this.menuPrice;
   }

   public Integer getWeight() {
      return this.weight;
   }

   public Integer getMenuWeigh() {
      return this.menuWeigh;
   }

   public Integer getSalseMode() {
      return this.salseMode;
   }

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

   public String getMacNo() {
      return this.macNo;
   }

   public Integer getTotalAmount() {
      return this.totalAmount;
   }

   public LocalDateTime getMacTime() {
      return this.macTime;
   }

   public void setOrderDetailId(final Long orderDetailId) {
      this.orderDetailId = orderDetailId;
   }

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

   public void setSubmitKey(final String submitKey) {
      this.submitKey = submitKey;
   }

   public void setDishesId(final Long dishesId) {
      this.dishesId = dishesId;
   }

   public void setMenuNo(final Integer menuNo) {
      this.menuNo = menuNo;
   }

   public void setDishesName(final String dishesName) {
      this.dishesName = dishesName;
   }

   public void setMenuImgUrl(final String menuImgUrl) {
      this.menuImgUrl = menuImgUrl;
   }

   public void setMenuPrice(final BigDecimal menuPrice) {
      this.menuPrice = menuPrice;
   }

   public void setWeight(final Integer weight) {
      this.weight = weight;
   }

   public void setMenuWeigh(final Integer menuWeigh) {
      this.menuWeigh = menuWeigh;
   }

   public void setSalseMode(final Integer salseMode) {
      this.salseMode = salseMode;
   }

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

   public void setMacNo(final String macNo) {
      this.macNo = macNo;
   }

   public void setTotalAmount(final Integer totalAmount) {
      this.totalAmount = totalAmount;
   }

   public void setMacTime(final LocalDateTime macTime) {
      this.macTime = macTime;
   }

}
