package cn.pluss.platform.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * 用户积分使用详情
 * </p>
 *
 * @author crystal
 * @since 2022-05-19
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("tb_pluss_user_integral_use")
@NoArgsConstructor
public class UserIntegralUse implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;


    /**
     * 名称
     */
    @TableField("name")
    private String name;


    /**
     * 用户ID
     */
    @TableField("userId")
    private Long userId;


    /**
     * 积分数
     */
    @TableField("integral")
    private BigDecimal integral;


    /**
     * 兑换状态1：待支付 2:兑换成功，3：兑换失败
     */
    @TableField("status")
    private String status;


    /**
     * 备注
     */
    @TableField("remark")
    private String remark;


    /**
     * 订单号
     */
    @TableField("orderNumber")
    private String orderNumber;


    /**
     * 兑换时间
     */
    @TableField("handleTime")
    @JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date handleTime;

    /**
     * 兑换时间 开始时间
     */
    @TableField(exist = false, condition = "handleTime &gt; #{%s}")
    private Date handleTimeStart;

    /**
     * 兑换时间 截止时间
     */
    @TableField(exist = false, condition = "handleTime &lt; #{%s}")
    private Date handleTimeEnd;

    /**
     * 创建时间
     */
    @TableField(value = "createTime", fill = FieldFill.INSERT)
    @JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    /**
     * 创建时间 开始时间
     */
    @TableField(exist = false, condition = "createTime &gt; #{%s}")
    private Date createTimeStart;

    /**
     * 创建时间 截止时间
     */
    @TableField(exist = false, condition = "createTime &lt; #{%s}")
    private Date createTimeEnd;

    public UserIntegralUse(String name, Long userId, BigDecimal integral,String orderNumber, String remark) {
        this.name = name;
        this.userId = userId;
        this.integral = integral;
        this.remark = remark;
        this.orderNumber = orderNumber;
        this.status = "2";
        Date date = new Date();
        this.handleTime = date;
        this.createTime = date;
    }
}