package cn.reghao.tnb.content.app.chat.model.po;

import cn.reghao.jutil.jdk.web.db.BaseObject;
import cn.reghao.tnb.common.auth.UserContext;
import cn.reghao.tnb.content.app.chat.model.dto.HongbaoDto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.time.LocalDateTime;

/**
 * @author reghao
 * @date 2024-12-03 14:41:06
 */
@NoArgsConstructor
@AllArgsConstructor
@Setter
@Getter
public class Hongbao extends BaseObject<Integer> {
    private long hongbaoId;
    private Integer receiverType;
    private Long receiverId;
    private Double amount;
    private Integer num;
    private Integer remain;
    private String remark;
    private long createBy;
    private LocalDateTime createAt;

    public Hongbao(long hongbaoId, HongbaoDto hongbaoDto) {
        this.hongbaoId = hongbaoId;
        this.receiverType = hongbaoDto.getReceiverType();
        this.receiverId = hongbaoDto.getReceiverId();
        this.amount = hongbaoDto.getAmount();
        this.num = hongbaoDto.getNum();
        this.remain = hongbaoDto.getNum();
        this.remark = hongbaoDto.getRemark();
        this.createBy = UserContext.getUserId();
        this.createAt = LocalDateTime.now();
    }
}
