package com.izouma.nineth.domain;

import com.izouma.nineth.annotations.Searchable;
import com.izouma.nineth.converter.FileObjectConverter;
import com.izouma.nineth.converter.FileObjectListConverter;
import com.izouma.nineth.enums.AuctionSource;
import com.izouma.nineth.enums.AuctionStatus;
import com.izouma.nineth.enums.AuctionType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@ApiModel("拍卖藏品")
public class AuctionActivity extends BaseEntity {

    @ApiModelProperty("起拍人ID")
    private Long sellerId;

    @ApiModelProperty("起拍人昵称")
    private String seller;

    @ApiModelProperty("起拍人头像")
    private String sellerAvatar;

    @ApiModelProperty("拍卖名称")
    @Searchable
    private String name;

    @Enumerated(EnumType.STRING)
    @ApiModelProperty("拍卖类型")
    private AuctionType auctionType;

    @ApiModelProperty("铸造者")
    private String minter;

    @ApiModelProperty("藏品ID")
    private Long assetId;

    @ApiModelProperty("图片")
    @Column(columnDefinition = "TEXT")
    @Convert(converter = FileObjectListConverter.class)
    private List<FileObject> pic;

    @Column(columnDefinition = "TEXT")
    @Convert(converter = FileObjectConverter.class)
    private FileObject model3d;

    @ApiModelProperty("详情")
    @Column(columnDefinition = "TEXT")
    private String detail;

    @ApiModelProperty("分类")
    private String category;

    @ApiModelProperty("起拍价")
    private BigDecimal startingPrice;

    @ApiModelProperty("保证金")
    private BigDecimal deposit;

    @ApiModelProperty("一口价")
    private BigDecimal fixedPrice;

    @ApiModelProperty("开始时间")
    private LocalDateTime startTime;

    @ApiModelProperty("加价幅度")
    private BigDecimal increment;

    @ApiModelProperty("截止时间")
    private LocalDateTime endTime;

    //每次出价实时更新
    @ApiModelProperty("成交价")
    private BigDecimal purchasePrice;

    @ApiModelProperty("买家id")
    private Long purchaserId;

    @ApiModelProperty("当前竞价id")
    private Long recordId;

    @ApiModelProperty("买家")
    private String purchaser;

    @ApiModelProperty("状态")
    @Enumerated(EnumType.STRING)
    private AuctionStatus status;

    @ApiModelProperty("来源")
    private AuctionSource source;

    @ApiModelProperty("版税比例")
    private double royalties;

    @ApiModelProperty("手续费比例")
    private double serviceCharge;

    @Column(columnDefinition = "int(11) default 0")
    @ApiModelProperty("围观次数")
    private int likes;

    @Column(columnDefinition = "int(11) default 0")
    @ApiModelProperty("出价次数")
    private int bids;

    private boolean hasFixedPrice;

    private boolean liked;

    @ApiModelProperty("上架")
    @Column(columnDefinition = "tinyint unsigned default 0")
    private boolean onShelf = false;
}
