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

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.NumberUtil;
import com.bonus.core.common.utils.SysUtil;
import com.bonus.core.device.manage.model.DeviceInfo;
import com.bonus.core.order.common.constants.OrderStateMixMobileEnum;
import com.bonus.core.order.common.model.OrderInfo;
import com.bonus.core.order.utils.LeNumUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@ApiModel("移动端订单详情VO")
public class OrderInfoMobileVO {
   @ApiModelProperty("商家订单号")
   private Long orderId;
   @ApiModelProperty("设备订单号（设备下单时）")
   private String macOrderId;
   @ApiModelProperty("托盘物理号")
   private String plateSerialNum;
   @ApiModelProperty("托盘编号")
   private String plateNum;
   @ApiModelProperty("来源类型")
   private Integer sourceType;
   @ApiModelProperty("人员id")
   private Long custId;
   @ApiModelProperty("订单日期(区别于下单时间)")
   private LocalDate orderDate;
   @ApiModelProperty("食堂id")
   private Long canteenId;
   @ApiModelProperty("食堂名称")
   private String canteenName;
   @ApiModelProperty("档口id")
   private Long stallId;
   @ApiModelProperty("档口名称")
   private String stallName;
   @ApiModelProperty("餐次类型")
   private String mealtimeType;
   @ApiModelProperty("餐次名称")
   private String mealtimeName;
   @ApiModelProperty("设备序列号（设备下单时）")
   private String machineSn;
   @ApiModelProperty("设备编号（设备下单时）")
   private String machineNum;
   @ApiModelProperty("设备名称（设备下单时）")
   private String machineName;
   @ApiModelProperty("订单总金额 单位为分")
   private BigDecimal payableAmount;
   @ApiModelProperty("打折减免 单位为分")
   private BigDecimal discountsAmount;
   @ApiModelProperty("餐券抵扣金额 单位为分")
   private BigDecimal couponAmount;
   @ApiModelProperty("配送费 单位为分")
   private BigDecimal deliveryAmount;
   @ApiModelProperty("包装费")
   private BigDecimal packingAmount;
   @ApiModelProperty("送达时间")
   private LocalDateTime deliveryTime;
   @ApiModelProperty("实际付款金额 单位为分")
   private BigDecimal realAmount;
   @ApiModelProperty("实际应付款金额 单位为分")
   private BigDecimal needPayAmount;
   @ApiModelProperty("菜品实际应付款金额合计 单位为分")
   private BigDecimal calcTotalAmount;
   @ApiModelProperty("已退款金额")
   private BigDecimal refundAmount;
   @ApiModelProperty("下单时间")
   private LocalDateTime orderTime;
   @ApiModelProperty("支付时间")
   private LocalDateTime payTime;
   @ApiModelProperty("支付方式")
   private Integer payType;
   @ApiModelProperty("支付状态")
   private Integer payState;
   @ApiModelProperty("扣款类型 1 下单扣款 2 核销扣款")
   private Integer deductionType;
   @ApiModelProperty("订单类型")
   private Integer orderType;
   private Integer dishesState;
   @ApiModelProperty("订单状态 1 已下单 2 已完成 3 已取消")
   private Integer orderState;
   private Integer orderRefundState;
   @ApiModelProperty("审核状态 1 待审核 2 审核通过 3 审核失败")
   private Integer checkState;
   @ApiModelProperty("退款手续费")
   private BigDecimal refundFeeAmount;
   @ApiModelProperty("订单备注")
   private String remark;
   @ApiModelProperty("配送方式")
   private Integer deliveryType;
   @ApiModelProperty("收货人姓名")
   private String consigneeName;
   @ApiModelProperty("收货人手机号")
   private String consigneeMobile;
   @ApiModelProperty("收货人地址")
   private String consigneeAddress;
   @ApiModelProperty("配送码/取餐码")
   private String deliveryCode;
   @ApiModelProperty("订单图片")
   private String imgUrl;
   @ApiModelProperty("热量(千卡)")
   private Double caloriesord;
   @ApiModelProperty("蛋白质(g)")
   private Double proteinord;
   @ApiModelProperty("脂肪(g)")
   private Double fatord;
   @ApiModelProperty("纤维(g)")
   private Double dietaryFiberord;
   @ApiModelProperty("碳水物(g)")
   private Double carbohydrateord;
   @ApiModelProperty("胆固醇(mg)")
   private Double cholesterolord;
   @ApiModelProperty("流水号")
   private String mealCode;
   private Integer commentState;
   private Integer orderStateMixMobile;
   @ApiModelProperty("订单明细list")
   private List<OrderDetailMobileVO> orderDetailList;

   public static OrderInfoMobileVO of(OrderInfo orderInfo) {
      return (OrderInfoMobileVO)BeanUtil.copyProperties(orderInfo, OrderInfoMobileVO.class, new String[0]);
   }

   public String getImgUrl() {
      return SysUtil.getCutFileUrl(this.imgUrl);
   }

   public BigDecimal getNeedPayAmount() {
      return NumberUtil.sub(this.payableAmount, this.discountsAmount);
   }

   public BigDecimal getCalcTotalAmount() {
      return LeNumUtil.sumField(this.orderDetailList, OrderDetailMobileVO::getCalcTotalAmount);
   }

   public Integer getOrderStateMixMobile() {
      return OrderStateMixMobileEnum.mixStateBy(this.orderState, this.payState, this.orderRefundState, this.dishesState);
   }

   public void fillDeviceInfo(DeviceInfo deviceInfo) {
      if (deviceInfo != null) {
         this.machineSn = deviceInfo.getDeviceSn();
         this.machineNum = deviceInfo.getDeviceNum();
         this.machineName = deviceInfo.getDeviceName();
      }

   }

   public void fillNutrientInfo(OrderNutrientInfoVO nutrientInfo) {
      if (nutrientInfo != null) {
         this.caloriesord = nutrientInfo.getCaloriesord();
         this.proteinord = nutrientInfo.getProteinord();
         this.fatord = nutrientInfo.getFatord();
         this.dietaryFiberord = nutrientInfo.getDietaryFiberord();
         this.carbohydrateord = nutrientInfo.getCarbohydrateord();
         this.cholesterolord = nutrientInfo.getCholesterolord();
      }

   }

   public OrderInfoMobileVO() {
      this.refundFeeAmount = BigDecimal.ZERO;
   }

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

   public String getMacOrderId() {
      return this.macOrderId;
   }

   public String getPlateSerialNum() {
      return this.plateSerialNum;
   }

   public String getPlateNum() {
      return this.plateNum;
   }

   public Integer getSourceType() {
      return this.sourceType;
   }

   public Long getCustId() {
      return this.custId;
   }

   public LocalDate getOrderDate() {
      return this.orderDate;
   }

   public Long getCanteenId() {
      return this.canteenId;
   }

   public String getCanteenName() {
      return this.canteenName;
   }

   public Long getStallId() {
      return this.stallId;
   }

   public String getStallName() {
      return this.stallName;
   }

   public String getMealtimeType() {
      return this.mealtimeType;
   }

   public String getMealtimeName() {
      return this.mealtimeName;
   }

   public String getMachineSn() {
      return this.machineSn;
   }

   public String getMachineNum() {
      return this.machineNum;
   }

   public String getMachineName() {
      return this.machineName;
   }

   public BigDecimal getPayableAmount() {
      return this.payableAmount;
   }

   public BigDecimal getDiscountsAmount() {
      return this.discountsAmount;
   }

   public BigDecimal getCouponAmount() {
      return this.couponAmount;
   }

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

   public BigDecimal getPackingAmount() {
      return this.packingAmount;
   }

   public LocalDateTime getDeliveryTime() {
      return this.deliveryTime;
   }

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

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

   public LocalDateTime getOrderTime() {
      return this.orderTime;
   }

   public LocalDateTime getPayTime() {
      return this.payTime;
   }

   public Integer getPayType() {
      return this.payType;
   }

   public Integer getPayState() {
      return this.payState;
   }

   public Integer getDeductionType() {
      return this.deductionType;
   }

   public Integer getOrderType() {
      return this.orderType;
   }

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

   public Integer getOrderState() {
      return this.orderState;
   }

   public Integer getOrderRefundState() {
      return this.orderRefundState;
   }

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

   public BigDecimal getRefundFeeAmount() {
      return this.refundFeeAmount;
   }

   public String getRemark() {
      return this.remark;
   }

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

   public String getConsigneeName() {
      return this.consigneeName;
   }

   public String getConsigneeMobile() {
      return this.consigneeMobile;
   }

   public String getConsigneeAddress() {
      return this.consigneeAddress;
   }

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

   public Double getCaloriesord() {
      return this.caloriesord;
   }

   public Double getProteinord() {
      return this.proteinord;
   }

   public Double getFatord() {
      return this.fatord;
   }

   public Double getDietaryFiberord() {
      return this.dietaryFiberord;
   }

   public Double getCarbohydrateord() {
      return this.carbohydrateord;
   }

   public Double getCholesterolord() {
      return this.cholesterolord;
   }

   public String getMealCode() {
      return this.mealCode;
   }

   public Integer getCommentState() {
      return this.commentState;
   }

   public List<OrderDetailMobileVO> getOrderDetailList() {
      return this.orderDetailList;
   }

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

   public void setMacOrderId(final String macOrderId) {
      this.macOrderId = macOrderId;
   }

   public void setPlateSerialNum(final String plateSerialNum) {
      this.plateSerialNum = plateSerialNum;
   }

   public void setPlateNum(final String plateNum) {
      this.plateNum = plateNum;
   }

   public void setSourceType(final Integer sourceType) {
      this.sourceType = sourceType;
   }

   public void setCustId(final Long custId) {
      this.custId = custId;
   }

   public void setOrderDate(final LocalDate orderDate) {
      this.orderDate = orderDate;
   }

   public void setCanteenId(final Long canteenId) {
      this.canteenId = canteenId;
   }

   public void setCanteenName(final String canteenName) {
      this.canteenName = canteenName;
   }

   public void setStallId(final Long stallId) {
      this.stallId = stallId;
   }

   public void setStallName(final String stallName) {
      this.stallName = stallName;
   }

   public void setMealtimeType(final String mealtimeType) {
      this.mealtimeType = mealtimeType;
   }

   public void setMealtimeName(final String mealtimeName) {
      this.mealtimeName = mealtimeName;
   }

   public void setMachineSn(final String machineSn) {
      this.machineSn = machineSn;
   }

   public void setMachineNum(final String machineNum) {
      this.machineNum = machineNum;
   }

   public void setMachineName(final String machineName) {
      this.machineName = machineName;
   }

   public void setPayableAmount(final BigDecimal payableAmount) {
      this.payableAmount = payableAmount;
   }

   public void setDiscountsAmount(final BigDecimal discountsAmount) {
      this.discountsAmount = discountsAmount;
   }

   public void setCouponAmount(final BigDecimal couponAmount) {
      this.couponAmount = couponAmount;
   }

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

   public void setPackingAmount(final BigDecimal packingAmount) {
      this.packingAmount = packingAmount;
   }

   public void setDeliveryTime(final LocalDateTime deliveryTime) {
      this.deliveryTime = deliveryTime;
   }

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

   public void setNeedPayAmount(final BigDecimal needPayAmount) {
      this.needPayAmount = needPayAmount;
   }

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

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

   public void setOrderTime(final LocalDateTime orderTime) {
      this.orderTime = orderTime;
   }

   public void setPayTime(final LocalDateTime payTime) {
      this.payTime = payTime;
   }

   public void setPayType(final Integer payType) {
      this.payType = payType;
   }

   public void setPayState(final Integer payState) {
      this.payState = payState;
   }

   public void setDeductionType(final Integer deductionType) {
      this.deductionType = deductionType;
   }

   public void setOrderType(final Integer orderType) {
      this.orderType = orderType;
   }

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

   public void setOrderState(final Integer orderState) {
      this.orderState = orderState;
   }

   public void setOrderRefundState(final Integer orderRefundState) {
      this.orderRefundState = orderRefundState;
   }

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

   public void setRefundFeeAmount(final BigDecimal refundFeeAmount) {
      this.refundFeeAmount = refundFeeAmount;
   }

   public void setRemark(final String remark) {
      this.remark = remark;
   }

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

   public void setConsigneeName(final String consigneeName) {
      this.consigneeName = consigneeName;
   }

   public void setConsigneeMobile(final String consigneeMobile) {
      this.consigneeMobile = consigneeMobile;
   }

   public void setConsigneeAddress(final String consigneeAddress) {
      this.consigneeAddress = consigneeAddress;
   }

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

   public void setImgUrl(final String imgUrl) {
      this.imgUrl = imgUrl;
   }

   public void setCaloriesord(final Double caloriesord) {
      this.caloriesord = caloriesord;
   }

   public void setProteinord(final Double proteinord) {
      this.proteinord = proteinord;
   }

   public void setFatord(final Double fatord) {
      this.fatord = fatord;
   }

   public void setDietaryFiberord(final Double dietaryFiberord) {
      this.dietaryFiberord = dietaryFiberord;
   }

   public void setCarbohydrateord(final Double carbohydrateord) {
      this.carbohydrateord = carbohydrateord;
   }

   public void setCholesterolord(final Double cholesterolord) {
      this.cholesterolord = cholesterolord;
   }

   public void setMealCode(final String mealCode) {
      this.mealCode = mealCode;
   }

   public void setCommentState(final Integer commentState) {
      this.commentState = commentState;
   }

   public void setOrderStateMixMobile(final Integer orderStateMixMobile) {
      this.orderStateMixMobile = orderStateMixMobile;
   }

   public void setOrderDetailList(final List<OrderDetailMobileVO> orderDetailList) {
      this.orderDetailList = orderDetailList;
   }
}
