package com.sckw.payment.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sckw.core.utils.IdWorker;
import com.sckw.core.web.context.LoginUserHolder;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.time.LocalDateTime;

/**
 * 结算-交易订单-状态信息
 * @author xucaiqin
 * @date 2023-07-10 16:42:19
 */
@Getter
@Setter
@ToString
@TableName(value = "kwp_settlement_trade_track")
public class KwpSettlementTradeTrack {
    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.INPUT)
    private Long id;

    /**
     * 交易订单结算id
     */
    @TableField(value = "t_settlement_id")
    private Long tSettlementId;

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

    /**
     * 用户状态（0正常、1已锁）
     */
    @TableField(value = "`status`")
    private Integer status;

    @TableField(value = "create_by")
    private Long createBy;

    @TableField(value = "create_time")
    private LocalDateTime createTime;

    @TableField(value = "update_by")
    private Long updateBy;

    /**
     * 更新时间
     */
    @TableField(value = "update_time")
    private LocalDateTime updateTime;

    /**
     * 是否删除（0未删除，1删除）
     */
    @TableField(value = "del_flag")
    private Integer delFlag;

    public static KwpSettlementTradeTrack build(Long tSettlementId, Integer status) {
        KwpSettlementTradeTrack kwpSettlementTradeTrack = new KwpSettlementTradeTrack();
        kwpSettlementTradeTrack.setId(new IdWorker(1).nextId());
        kwpSettlementTradeTrack.setTSettlementId(tSettlementId);
        kwpSettlementTradeTrack.setRemark("");
        kwpSettlementTradeTrack.setStatus(status);
        kwpSettlementTradeTrack.setCreateBy(LoginUserHolder.getUserId());
        kwpSettlementTradeTrack.setCreateTime(LocalDateTime.now());
        kwpSettlementTradeTrack.setUpdateBy(LoginUserHolder.getUserId());
        kwpSettlementTradeTrack.setUpdateTime(LocalDateTime.now());
        kwpSettlementTradeTrack.setDelFlag(0);
        return kwpSettlementTradeTrack;
    }
}
