package com.bonus.core.marketing.v2.model;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.bonus.constant.LeConstants;
import com.bonus.core.marketing.v2.rule.price.dto.RulePriceResultOrderDTO;
import com.bonus.core.marketing.v2.rule.recharge.dto.RuleRechargeResultDTO;
import com.bonus.core.marketing.vo.MarketRuleVO;
import com.bonus.utils.id.Id;
import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

@ApiModel("规则使用记录表")
public class MarketRuleRecord implements Serializable {
   private static final long serialVersionUID = 1L;
   @TableId
   @ApiModelProperty("主键")
   private Long recordId;
   @ApiModelProperty("消费规则id")
   private Long ruleId;
   @ApiModelProperty("订单id/账户交易id")
   private Long tradeId;
   @ApiModelProperty("用户id")
   private Long custId;
   @ApiModelProperty("订单类型")
   private Integer orderType;
   @ApiModelProperty("设备sn")
   private String deviceSn;
   @ApiModelProperty("餐次")
   private Integer mealtimeType;
   @ApiModelProperty("订单日期/交易日期")
   private LocalDate tradeDate;
   @ApiModelProperty("食堂id")
   private Long canteenId;
   @ApiModelProperty("档口id")
   private Long stallId;
   @ApiModelProperty("应付金额/交易金额")
   private BigDecimal amount;
   @ApiModelProperty("实付金额/实际交易金额")
   private BigDecimal realAmount;
   @ApiModelProperty("订单总优惠金额")
   private BigDecimal discountsAmount;
   @ApiModelProperty("是否生效")
   private Integer effectFlag;
   @ApiModelProperty("创建时间")
   @TableField(
      value = "crtime",
      fill = FieldFill.INSERT
   )
   private LocalDateTime crtime;
   @ApiModelProperty("更新时间")
   @TableField(
      value = "uptime",
      fill = FieldFill.UPDATE
   )
   private LocalDateTime uptime;
   @ApiModelProperty("支付渠道")
   private Integer payChannel;
   @ApiModelProperty("支付方式")
   private Integer payType;
   @ApiModelProperty("管理费")
   private BigDecimal manageCost;
   @ApiModelProperty("额外信息")
   private JsonNode extInfo;
   @ApiModelProperty("是否已赠送")
   private Integer giveFlag;

   public MarketRuleRecord(RulePriceResultOrderDTO resultOrder, MarketRuleVO ruleInfo, Long recordId) {
      BeanUtil.copyProperties(resultOrder, this, new String[0]);
      this.ruleId = ruleInfo.getRuleId();
      this.effectFlag = LeConstants.COMMON_YES;
      this.recordId = recordId;
      this.tradeId = resultOrder.getOrderId();
      this.tradeDate = resultOrder.getOrderDate();
      this.amount = resultOrder.getPayableAmount();
   }

   public MarketRuleRecord(RuleRechargeResultDTO result, MarketRuleVO ruleInfo) {
      BeanUtil.copyProperties(result, this, new String[0]);
      this.ruleId = ruleInfo.getRuleId();
      this.effectFlag = LeConstants.COMMON_YES;
      this.recordId = Id.next();
      this.tradeId = result.getTradeId();
      this.tradeDate = result.getTradeDate();
      this.realAmount = result.getActualAmount();
   }

   public Long getRecordId() {
      return this.recordId;
   }

   public Long getRuleId() {
      return this.ruleId;
   }

   public Long getTradeId() {
      return this.tradeId;
   }

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

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

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

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

   public LocalDate getTradeDate() {
      return this.tradeDate;
   }

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

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

   public BigDecimal getAmount() {
      return this.amount;
   }

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

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

   public Integer getEffectFlag() {
      return this.effectFlag;
   }

   public LocalDateTime getCrtime() {
      return this.crtime;
   }

   public LocalDateTime getUptime() {
      return this.uptime;
   }

   public Integer getPayChannel() {
      return this.payChannel;
   }

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

   public BigDecimal getManageCost() {
      return this.manageCost;
   }

   public JsonNode getExtInfo() {
      return this.extInfo;
   }

   public Integer getGiveFlag() {
      return this.giveFlag;
   }

   public void setRecordId(final Long recordId) {
      this.recordId = recordId;
   }

   public void setRuleId(final Long ruleId) {
      this.ruleId = ruleId;
   }

   public void setTradeId(final Long tradeId) {
      this.tradeId = tradeId;
   }

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

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

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

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

   public void setTradeDate(final LocalDate tradeDate) {
      this.tradeDate = tradeDate;
   }

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

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

   public void setAmount(final BigDecimal amount) {
      this.amount = amount;
   }

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

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

   public void setEffectFlag(final Integer effectFlag) {
      this.effectFlag = effectFlag;
   }

   public void setCrtime(final LocalDateTime crtime) {
      this.crtime = crtime;
   }

   public void setUptime(final LocalDateTime uptime) {
      this.uptime = uptime;
   }

   public void setPayChannel(final Integer payChannel) {
      this.payChannel = payChannel;
   }

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

   public void setManageCost(final BigDecimal manageCost) {
      this.manageCost = manageCost;
   }

   public void setExtInfo(final JsonNode extInfo) {
      this.extInfo = extInfo;
   }

   public void setGiveFlag(final Integer giveFlag) {
      this.giveFlag = giveFlag;
   }


   public MarketRuleRecord(final Long recordId, final Long ruleId, final Long tradeId, final Long custId, final Integer orderType, final String deviceSn, final Integer mealtimeType, final LocalDate tradeDate, final Long canteenId, final Long stallId, final BigDecimal amount, final BigDecimal realAmount, final BigDecimal discountsAmount, final Integer effectFlag, final LocalDateTime crtime, final LocalDateTime uptime, final Integer payChannel, final Integer payType, final BigDecimal manageCost, final JsonNode extInfo, final Integer giveFlag) {
      this.recordId = recordId;
      this.ruleId = ruleId;
      this.tradeId = tradeId;
      this.custId = custId;
      this.orderType = orderType;
      this.deviceSn = deviceSn;
      this.mealtimeType = mealtimeType;
      this.tradeDate = tradeDate;
      this.canteenId = canteenId;
      this.stallId = stallId;
      this.amount = amount;
      this.realAmount = realAmount;
      this.discountsAmount = discountsAmount;
      this.effectFlag = effectFlag;
      this.crtime = crtime;
      this.uptime = uptime;
      this.payChannel = payChannel;
      this.payType = payType;
      this.manageCost = manageCost;
      this.extInfo = extInfo;
      this.giveFlag = giveFlag;
   }

   public MarketRuleRecord() {
   }
}
