package com.jeequan.jeepay.db.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.jeequan.jeepay.core.utils.SeqKit;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

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

/**
 * <p>
 * tk缓存表
 * </p>
 *
 * @author [mybatis plus generator]
 * @since 2024-02-02
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("t_cache_tk")
@NoArgsConstructor
public class CacheTk implements Serializable {

    private static final long serialVersionUID=1L;

    @TableId(type = IdType.INPUT)
    private String tk;

    // 二维码扫码类型： 1 - 统一下单的聚合二维码,  2 - 码牌二维码 3 - 设备二维码 4:路由二维码
    private Byte type;

    /**
     * 原id 对应设备编号 二维码编号
     */
    private String sourceId;

    /**
     * 金额
     */
    private Long amount;

    /**
     * 创建时间
     */
    private Date createdAt;


    public CacheTk(Byte type, String sourceId, Long amount) {
        this.tk = SeqKit.genTk();
        this.type = type;
        this.sourceId = sourceId;
        this.amount = amount;
    }

    public CacheTk(Byte type, String sourceId) {
        this(type,sourceId,null);
    }

    public CacheTk(String tk, byte type, String sourceId,Long amount) {
        this.tk = tk;
        this.type = type;
        this.sourceId = sourceId;
        this.amount = amount;
    }
    public CacheTk(String tk, byte type, String sourceId) {
        this(tk,type,sourceId,null);
    }
}
