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

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.bonus.core.common.encrypt.SM4EncDecHandler;
import com.bonus.core.marketing.coupon.constants.MktCouponTypeEnum;
import com.bonus.utils.id.Id;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

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

@TableName(
   value = "mkt_coupon",
   autoResultMap = true
)
@ApiModel("餐券表")
public class MktCoupon extends Model<MktCoupon> {
   @TableId
   @ApiModelProperty("主键自增")
   private Long id;
   @ApiModelProperty("餐券id")
   private Long couponId;
   @ApiModelProperty("餐券编号")
   private Long couponNum;
   @ApiModelProperty("餐券模板备份id")
   private Long backId;
   @ApiModelProperty("餐券制作id")
   private Long makeId;
   @ApiModelProperty("餐券发放id")
   private Long grantId;
   @ApiModelProperty("定时发放id")
   private Long fixedId;
   @ApiModelProperty("定时名称")
   private String fixedName;
   @ApiModelProperty("餐券名称")
   private String couponName;
   @ApiModelProperty("餐券类型")
   private Integer couponType;
   @ApiModelProperty("组织id")
   private Long orgId;
   @ApiModelProperty("人员id")
   private Long custId;
   @ApiModelProperty("人员姓名")
   @TableField(
      value = "cust_name",
      typeHandler = SM4EncDecHandler.class
   )
   private String custName;
   @ApiModelProperty("电话")
   @TableField(
      value = "phone",
      typeHandler = SM4EncDecHandler.class
   )
   private String phone;
   @ApiModelProperty("餐券金额")
   private BigDecimal couponAmount;
   @ApiModelProperty("有效期")
   private LocalDate effectDateStart;
   @ApiModelProperty("有效期")
   private LocalDate effectDateEnd;
   @ApiModelProperty("餐券需支付金额")
   private BigDecimal couponNeedAmount;
   @ApiModelProperty("支付状态")
   private Integer payState;
   @ApiModelProperty("支付方式")
   private Integer payType;
   @ApiModelProperty("支付金额")
   private BigDecimal payAmount;
   @ApiModelProperty("支付时间")
   private LocalDateTime payTime;
   @ApiModelProperty("餐券图片链接")
   private String couponImgUrl;
   @ApiModelProperty("限定使用次数")
   private Integer limitTimes;
   @ApiModelProperty("已使用次数")
   private Integer usedTimes;
   @ApiModelProperty("餐券状态 1-未生效 2-未使用 3-已使用 4-已过期 5-已作废")
   private Integer couponState;
   @ApiModelProperty("备注")
   private String remark;
   @ApiModelProperty("核销日期")
   private LocalDate writeOffDate;
   @TableField(
      value = "crby",
      fill = FieldFill.INSERT
   )
   @ApiModelProperty("创建人")
   private String crby;
   @ApiModelProperty("创建时间")
   private LocalDateTime crtime;
   @TableField(
      value = "upby",
      fill = FieldFill.UPDATE
   )
   @ApiModelProperty("更新人")
   private String upby;
   @ApiModelProperty("更新时间")
   private LocalDateTime uptime;

   public MktCoupon(Integer couponType, Long couponId) {
      this.couponType = couponType;
      this.couponId = couponId;
      if (MktCouponTypeEnum.ELECTRON_COUPON.getKey().equals(couponType)) {
         this.couponNum = couponId;
      }

   }

   public MktCoupon(Long couponId, Long fixedId, String fixedName) {
      this.couponType = MktCouponTypeEnum.ELECTRON_COUPON.getKey();
      this.couponId = couponId;
      this.couponNum = couponId;
      this.fixedId = fixedId;
      this.fixedName = fixedName;
   }

   public void elecCouponIdHandle() {
      Long couponId = Id.next();
      this.couponId = couponId;
      this.couponNum = couponId;
   }

   public Long getId() {
      return this.id;
   }

   public Long getCouponId() {
      return this.couponId;
   }

   public Long getCouponNum() {
      return this.couponNum;
   }

   public Long getBackId() {
      return this.backId;
   }

   public Long getMakeId() {
      return this.makeId;
   }

   public Long getGrantId() {
      return this.grantId;
   }

   public Long getFixedId() {
      return this.fixedId;
   }

   public String getFixedName() {
      return this.fixedName;
   }

   public String getCouponName() {
      return this.couponName;
   }

   public Integer getCouponType() {
      return this.couponType;
   }

   public Long getOrgId() {
      return this.orgId;
   }

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

   public String getCustName() {
      return this.custName;
   }

   public String getPhone() {
      return this.phone;
   }

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

   public LocalDate getEffectDateStart() {
      return this.effectDateStart;
   }

   public LocalDate getEffectDateEnd() {
      return this.effectDateEnd;
   }

   public BigDecimal getCouponNeedAmount() {
      return this.couponNeedAmount;
   }

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

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

   public BigDecimal getPayAmount() {
      return this.payAmount;
   }

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

   public String getCouponImgUrl() {
      return this.couponImgUrl;
   }

   public Integer getLimitTimes() {
      return this.limitTimes;
   }

   public Integer getUsedTimes() {
      return this.usedTimes;
   }

   public Integer getCouponState() {
      return this.couponState;
   }

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

   public LocalDate getWriteOffDate() {
      return this.writeOffDate;
   }

   public String getCrby() {
      return this.crby;
   }

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

   public String getUpby() {
      return this.upby;
   }

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

   public void setId(final Long id) {
      this.id = id;
   }

   public void setCouponId(final Long couponId) {
      this.couponId = couponId;
   }

   public void setCouponNum(final Long couponNum) {
      this.couponNum = couponNum;
   }

   public void setBackId(final Long backId) {
      this.backId = backId;
   }

   public void setMakeId(final Long makeId) {
      this.makeId = makeId;
   }

   public void setGrantId(final Long grantId) {
      this.grantId = grantId;
   }

   public void setFixedId(final Long fixedId) {
      this.fixedId = fixedId;
   }

   public void setFixedName(final String fixedName) {
      this.fixedName = fixedName;
   }

   public void setCouponName(final String couponName) {
      this.couponName = couponName;
   }

   public void setCouponType(final Integer couponType) {
      this.couponType = couponType;
   }

   public void setOrgId(final Long orgId) {
      this.orgId = orgId;
   }

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

   public void setCustName(final String custName) {
      this.custName = custName;
   }

   public void setPhone(final String phone) {
      this.phone = phone;
   }

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

   public void setEffectDateStart(final LocalDate effectDateStart) {
      this.effectDateStart = effectDateStart;
   }

   public void setEffectDateEnd(final LocalDate effectDateEnd) {
      this.effectDateEnd = effectDateEnd;
   }

   public void setCouponNeedAmount(final BigDecimal couponNeedAmount) {
      this.couponNeedAmount = couponNeedAmount;
   }

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

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

   public void setPayAmount(final BigDecimal payAmount) {
      this.payAmount = payAmount;
   }

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

   public void setCouponImgUrl(final String couponImgUrl) {
      this.couponImgUrl = couponImgUrl;
   }

   public void setLimitTimes(final Integer limitTimes) {
      this.limitTimes = limitTimes;
   }

   public void setUsedTimes(final Integer usedTimes) {
      this.usedTimes = usedTimes;
   }

   public void setCouponState(final Integer couponState) {
      this.couponState = couponState;
   }

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

   public void setWriteOffDate(final LocalDate writeOffDate) {
      this.writeOffDate = writeOffDate;
   }

   public void setCrby(final String crby) {
      this.crby = crby;
   }

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

   public void setUpby(final String upby) {
      this.upby = upby;
   }

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


   public MktCoupon() {
   }
}
