package com.fzm.mall.server.admin.goods_center.entity.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fzm.mall.server.admin.constant.MALLGlobalConfig;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;

/**
 * @author wangp
 * @description 商品
 * @date 2020/8/26 17:33
 */
@Data
public class GoodsSpuVO {

    /**
     * 1.是，自动生成Token 2.是，使用外部既有Token
     */
    public static final Integer COMMODITY_PASS_AUTO = 1;

    public static final Integer COMMODITY_PASS_OUT = 2;

    private String goodsId;
    private String name;
    private String thumb;
    private Integer status;
    private BigDecimal maxPrice;
    private BigDecimal defaultPrice;
    private Long stock;
    private Long sales;
    private String enterpriseName;
    private String linkName;
    private String linkPhone;
    private String checkFailReason;
    private Integer type;
    private Long createTime;

    @ApiModelProperty(value = "1.是，自动生成Token 2.是，使用外部既有Token")
    @TableField(exist = false)
    private Integer commodityPass;

    @ApiModelProperty(value = "tokenId")
    @TableField(exist = false)
    private Long tokenId;

    @ApiModelProperty(value = "tokenIdStr")
    @TableField(exist = false)
    private String tokenIdStr;

    @ApiModelProperty(value = "1.外部nft;2.内部nft；3.内部普通")
    @TableField(exist = false)
    private Integer coinType;

    @ApiModelProperty(value = "nft销售方式（1.原商品销售 2.拷贝销售）")
    @TableField(exist = false)
    private Integer nftSalesType;

    public void initTokenId() {
        if (commodityPass.equals(COMMODITY_PASS_OUT)) {
            setTokenId(Long.valueOf(tokenIdStr));
        } else if (commodityPass.equals(COMMODITY_PASS_AUTO) && type == 6) {
            setTokenId(Long.valueOf(getTokenIdStr().replace(MALLGlobalConfig.NFT_PREFIX, "")));
        }
    }
}
