package com.fzm.mall.server.front.asset.model;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;

import com.fzm.mall.server.front.util.UUIdUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 用户资产-转赠
 * </p>
 *
 * @author fzm
 * @since 2021-08-17
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("user_asset_transfer_record")
@ApiModel(value="UserAssetTransferRecord对象", description="用户资产-转赠")
public class UserAssetTransferRecord implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 状态 1->成功，2->失败, 3->转账中
     */
    public static final Integer RECORD_STATUS_SUCCESS = 1;

    public static final Integer RECORD_STATUS_FAIL = 2;

    public static final Integer RECORD_STATUS_IN_PROGRESS = 3;

    @ApiModelProperty(value = "用户资产表自增id")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "用户uid")
    private String uid;

    @ApiModelProperty(value = "商品编号")
    private String goodsId;

    @ApiModelProperty(value = "规格编号")
    private String skuId;

    @ApiModelProperty(value = "资产名称 如:btc、金币")
    private String coin;

    @ApiModelProperty(value = "转赠记录编号")
    private String transferRecordId;

    @ApiModelProperty(value = "转赠地址")
    private String toAddress;

    @ApiModelProperty(value = "接收用户id")
    private String toUid;

    @ApiModelProperty(value = "转赠数量")
    private Integer num;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "状态 1->成功，2->失败，3->转账中")
    private Integer status;

    @ApiModelProperty(value = "信息入库时间")
    @TableField(fill = FieldFill.INSERT)
    private Long createTime;

    @ApiModelProperty(value = "信息更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updateTime;

    public void init(String toUid, boolean inChain) {
        setToUid(toUid);
        if (inChain){
            setStatus(RECORD_STATUS_IN_PROGRESS);
        }else{
            setStatus(RECORD_STATUS_SUCCESS);
        }
        setTransferRecordId(UUIdUtil.getUUID());
    }
}
