Coupon.java 3.15 KB
package com.topdraw.business.module.coupon.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.time.LocalDateTime;

/**
 * @author XiangHan
 * @date 2021-10-22
 */
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="m_coupon")
public class Coupon implements Serializable {

    /** id */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /** 标识 */
    @Column(name = "code", nullable = false)
    private String code;

    /** 名称 */
    @Column(name = "title", nullable = false)
    private String title;

    /** 图片 */
    @Column(name = "images")
    private String images;

    /** 发行量,-1代表不限量 */
    @Column(name = "stock")
    private Integer stock;

    /** 剩余量,-1代表不限量 */
    @Column(name = "remain_stock")
    private Integer remainStock;

    /** 优惠形式:1:现金;2:折扣 */
    @Column(name = "use_type")
    private Integer useType;

    /** 面额 */
    @Column(name = "denomination")
    private BigDecimal denomination;

    /** 折扣 */
    @Column(name = "discount")
    private BigDecimal discount;

    /** 适用用户范围:1:新用户;2:全体用户 */
    @Column(name = "user_range")
    private Integer userRange;

    /** 限领次数 -1:无限次; >0:具体次数 */
    @Column(name = "collect_limit")
    private Integer collectLimit;

    /** 适用门槛:1:无门槛;2:满减形式 */
    @Column(name = "threshold_type")
    private Integer thresholdType;

    /** 满减门槛 */
    @Column(name = "amount_threshold")
    private BigDecimal amountThreshold;

    /** 产品范围:1:全部商品;2:指定商品 */
    @Column(name = "item_range")
    private Integer itemRange;

    /** 生效形式:1:固定日期;2:相对日期 */
    @Column(name = "effect_type")
    private Integer effectType;

    /** 生效时间 */
    @Column(name = "start_time")
    private Timestamp startTime;

    /** 过期时间 */
    @Column(name = "expire_time")
    private LocalDateTime expireTime;

    /** 自领取当日,几天内有效 */
    @Column(name = "valid_days")
    private Integer validDays;

    /** 使用说明 */
    @Column(name = "description")
    private String description;

    /** 状态0:未开始,1:启用;2:停用 */
    @Column(name = "status")
    private Integer status;

    /** 创建时间 */
    @CreatedDate
    @Column(name = "create_time")
    private Timestamp createTime;

    /** 更新时间 */
    @LastModifiedDate
    @Column(name = "update_time")
    private Timestamp updateTime;

    public void copy(Coupon source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}