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

import java.math.BigDecimal;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.List;

import com.fzm.mall.server.front.asset.model.vo.TranOrderVO;
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-09-07
 */
@Data
@TableName("tran")
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="Tran对象", description="")
public class Tran implements Serializable {

    /**
     * 转让-状态：1->可用，2->已撤销
     */
    public static final Integer TRANSFER_STATUS_EFFECTIVE = 1;

    public static final Integer TRANSFER_STATUS_CANCLED = 2;

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "转让仓库主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

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

    @ApiModelProperty(value = "转让单号")
    private String tranId;

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

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

    @ApiModelProperty(value = "商品skuId")
    private String skuId;

    @ApiModelProperty(value = "商品数量")
    private Integer number;

    @ApiModelProperty(value = "类型  1 单价 2 打包")
    private Integer type;

    @ApiModelProperty(value = "价格")
    private BigDecimal price;

    @ApiModelProperty(value = "状态 1：正常 2：撤回 3：完成")
    private Integer status;

    @ApiModelProperty(value = "库存")
    private Integer stock;

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

    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    private Long createTime;

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

    @ApiModelProperty(value = "转赠记录集合")
    @TableField(exist = false)
    private List<TranOrderVO> recordList;

    public void init() {
        setTranId(UUIdUtil.getUUID());
        setStatus(TRANSFER_STATUS_EFFECTIVE);
        setStock(number);
    }
}
