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

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.NumberUtil;
import com.bonus.canteen.core.common.utils.SysUtil;
import com.bonus.canteen.core.menu.constant.MenuSalesTypeEnum;
import com.bonus.canteen.core.order.common.model.OrderDetail;
import com.bonus.canteen.core.order.common.vo.OrderDetailWithImage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.math.BigDecimal;

@ApiModel("移动端订单详情VO")
public class OrderDetailMobileVO implements OrderDetailWithImage {
   @ApiModelProperty("详情id")
   private Long detailId;
   @ApiModelProperty("订单id")
   private Long orderId;
   @ApiModelProperty("商品菜品id")
   private Long goodsDishesId;
   @ApiModelProperty("商品菜品名称")
   private String goodsDishesName;
   @ApiModelProperty("商品菜品图片路径")
   private String goodsDishesImgUrl;
   @ApiModelProperty("商品菜品分类名称")
   private String goodsDishesTypeName;
   @ApiModelProperty("菜品详情id")
   private Long menuDetailId;
   @ApiModelProperty("售卖价格 分")
   private BigDecimal salePrice;
   @ApiModelProperty("优惠价格 分")
   private BigDecimal prefPrice;
   @ApiModelProperty("计算价格 分")
   private BigDecimal price;
   @ApiModelProperty("实际支付价格 分")
   private BigDecimal realPrice;
   @ApiModelProperty("每份重量 g")
   private Integer weightUnit;
   @ApiModelProperty("数量/重量")
   private Integer quantity;
   @ApiModelProperty("商品规格名称")
   private String unitName;
   @ApiModelProperty("订单详情总金额 分")
   private BigDecimal totalAmount;
   @ApiModelProperty("订单详情计算总金额 分")
   private BigDecimal calcTotalAmount;
   @ApiModelProperty("实际付款金额 分")
   private BigDecimal realAmount;
   @ApiModelProperty("已退款金额")
   private BigDecimal refundAmount;
   @ApiModelProperty("销售方式 1 按份 2 称重")
   private Integer salesMode;
   @ApiModelProperty("明细类别")
   private Integer detailType;
   @ApiModelProperty("口味名称")
   private String tasteName;
   @ApiModelProperty("订单详情状态 1 正常 2 已退菜 3 部分退菜")
   private Integer detailState;
   @ApiModelProperty("商品已退数量")
   private Integer goodsRefundNum;
   @ApiModelProperty("纠错/退款审核状态")
   private Integer checkState;

   public String getImageUrl() {
      return SysUtil.getCutFileUrl(this.goodsDishesImgUrl);
   }

   @Override
   public String getGoodsDishesImgUrl() {
      return SysUtil.getCutFileUrl(this.goodsDishesImgUrl);
   }

   public BigDecimal getRealPrice() {
      return this.quantity != null && this.quantity != 0 ? NumberUtil.div(this.realAmount, this.quantity, 2) : this.realAmount;
   }

   public double totalGram() {
      return MenuSalesTypeEnum.WEIGHT_ON.key().equals(this.salesMode) ? (double)(this.quantity != null ? this.quantity : 0) : (double)NumberUtil.mul(this.quantity, this.weightUnit).intValue();
   }

   public static OrderDetailMobileVO of(OrderDetail orderDetail) {
      return (OrderDetailMobileVO)BeanUtil.copyProperties(orderDetail, OrderDetailMobileVO.class, new String[0]);
   }

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

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

   @Override
   public Long getGoodsDishesId() {
      return this.goodsDishesId;
   }

   public String getGoodsDishesName() {
      return this.goodsDishesName;
   }

   public String getGoodsDishesTypeName() {
      return this.goodsDishesTypeName;
   }

   public Long getMenuDetailId() {
      return this.menuDetailId;
   }

   public BigDecimal getSalePrice() {
      return this.salePrice;
   }

   public BigDecimal getPrefPrice() {
      return this.prefPrice;
   }

   public BigDecimal getPrice() {
      return this.price;
   }

   public Integer getWeightUnit() {
      return this.weightUnit;
   }

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

   public String getUnitName() {
      return this.unitName;
   }

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

   public BigDecimal getCalcTotalAmount() {
      return this.calcTotalAmount;
   }

   public BigDecimal getRealAmount() {
      return this.realAmount;
   }

   public BigDecimal getRefundAmount() {
      return this.refundAmount;
   }

   public Integer getSalesMode() {
      return this.salesMode;
   }

   @Override
   public Integer getDetailType() {
      return this.detailType;
   }

   public String getTasteName() {
      return this.tasteName;
   }

   public Integer getDetailState() {
      return this.detailState;
   }

   public Integer getGoodsRefundNum() {
      return this.goodsRefundNum;
   }

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

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

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

   public void setGoodsDishesId(final Long goodsDishesId) {
      this.goodsDishesId = goodsDishesId;
   }

   public void setGoodsDishesName(final String goodsDishesName) {
      this.goodsDishesName = goodsDishesName;
   }

   @Override
   public void setGoodsDishesImgUrl(final String goodsDishesImgUrl) {
      this.goodsDishesImgUrl = goodsDishesImgUrl;
   }

   public void setGoodsDishesTypeName(final String goodsDishesTypeName) {
      this.goodsDishesTypeName = goodsDishesTypeName;
   }

   public void setMenuDetailId(final Long menuDetailId) {
      this.menuDetailId = menuDetailId;
   }

   public void setSalePrice(final BigDecimal salePrice) {
      this.salePrice = salePrice;
   }

   public void setPrefPrice(final BigDecimal prefPrice) {
      this.prefPrice = prefPrice;
   }

   public void setPrice(final BigDecimal price) {
      this.price = price;
   }

   public void setRealPrice(final BigDecimal realPrice) {
      this.realPrice = realPrice;
   }

   public void setWeightUnit(final Integer weightUnit) {
      this.weightUnit = weightUnit;
   }

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

   public void setUnitName(final String unitName) {
      this.unitName = unitName;
   }

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

   public void setCalcTotalAmount(final BigDecimal calcTotalAmount) {
      this.calcTotalAmount = calcTotalAmount;
   }

   public void setRealAmount(final BigDecimal realAmount) {
      this.realAmount = realAmount;
   }

   public void setRefundAmount(final BigDecimal refundAmount) {
      this.refundAmount = refundAmount;
   }

   public void setSalesMode(final Integer salesMode) {
      this.salesMode = salesMode;
   }

   public void setDetailType(final Integer detailType) {
      this.detailType = detailType;
   }

   public void setTasteName(final String tasteName) {
      this.tasteName = tasteName;
   }

   public void setDetailState(final Integer detailState) {
      this.detailState = detailState;
   }

   public void setGoodsRefundNum(final Integer goodsRefundNum) {
      this.goodsRefundNum = goodsRefundNum;
   }

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