package com.bonus.canteen.core.marketing.v2.rule.pay.dto;

import com.bonus.canteen.core.account.v3.api.dto.AccOrdBaseDTO;
import com.bonus.canteen.core.marketing.v2.rule.price.dto.RulePriceResultOrderDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.time.LocalDate;
import java.util.Objects;

@ApiModel("扣款规则入参")
public class RulePayComputeDTO {
   @ApiModelProperty("人员id")
   private Long custId;
   @ApiModelProperty("订单类型")
   private Integer orderType;
   @ApiModelProperty("食堂id")
   private Long canteenId;
   @ApiModelProperty("设备sn码")
   private String deviceSn;
   @ApiModelProperty("消费日期")
   private LocalDate consumeDate;

   public RulePayComputeDTO(RulePriceResultOrderDTO order) {
      this.custId = order.getCustId();
      this.orderType = order.getOrderType();
      this.canteenId = order.getCanteenId();
      this.deviceSn = order.getDeviceSn();
      this.consumeDate = order.getOrderDate();
   }

   public RulePayComputeDTO(AccOrdBaseDTO accOrdOnlineDTO) {
      this.custId = accOrdOnlineDTO.getCustId();
      this.orderType = accOrdOnlineDTO.getOrderType();
      this.canteenId = accOrdOnlineDTO.getCanteenId();
      this.deviceSn = accOrdOnlineDTO.getMchSn();
      this.consumeDate = Objects.nonNull(accOrdOnlineDTO.getOrdTime()) ? accOrdOnlineDTO.getOrdTime().toLocalDate() : LocalDate.now();
   }

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

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

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

   public String getDeviceSn() {
      return this.deviceSn;
   }

   public LocalDate getConsumeDate() {
      return this.consumeDate;
   }

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

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

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

   public RulePayComputeDTO setDeviceSn(final String deviceSn) {
      this.deviceSn = deviceSn;
      return this;
   }

   public RulePayComputeDTO setConsumeDate(final LocalDate consumeDate) {
      this.consumeDate = consumeDate;
      return this;
   }

   public RulePayComputeDTO(final Long custId, final Integer orderType, final Long canteenId, final String deviceSn, final LocalDate consumeDate) {
      this.custId = custId;
      this.orderType = orderType;
      this.canteenId = canteenId;
      this.deviceSn = deviceSn;
      this.consumeDate = consumeDate;
   }

   public RulePayComputeDTO() {
   }
}
