package com.izouma.nineth.domain;

import com.izouma.nineth.annotations.Searchable;
import com.izouma.nineth.annotations.SearchableOne;
import com.izouma.nineth.converter.FileObjectListConverter;
import com.izouma.nineth.enums.*;
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;

@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AuctionOrder extends BaseEntityNoID {
    @Id
    private Long id;

    @ApiModelProperty("用户ID")
    @SearchableOne
    private Long userId;

    private String nickname;

    @ApiModelProperty("拍卖ID")
    private Long auctionId;

    @ApiModelProperty("名称")
    @SearchableOne
    private String name;

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

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

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

    @Enumerated(EnumType.STRING)
    @ApiModelProperty("拍卖类型")
    private AuctionSource source;

    @Enumerated(EnumType.STRING)
    @ApiModelProperty("支付类型")
    private AuctionPaymentType paymentType;

    @ApiModelProperty("价格")
    @Column(precision = 10, scale = 2)
    private BigDecimal price;

//    @ApiModelProperty("gas费")
//    @Column(precision = 10, scale = 2)
//    private BigDecimal gasPrice;

    @ApiModelProperty("总价")
    @Column(precision = 10, scale = 2)
    private BigDecimal totalPrice;

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

    @ApiModelProperty("支付方式")
    @Enumerated(EnumType.STRING)
    private PayMethod payMethod;

    @ApiModelProperty("交易ID")
    @Searchable
    @Column(length = 90)
    private String transactionId;

    @ApiModelProperty("支付时间")
    private LocalDateTime payTime;

    @ApiModelProperty("取消时间")
    private LocalDateTime cancelTime;

    @ApiModelProperty("退款时间")
    private LocalDateTime refundTime;

    @ApiModelProperty("收货人")
    private String contactName;

    @ApiModelProperty("收货电话")
    private String contactPhone;

    @ApiModelProperty("收货地址")
    private String address;

    @ApiModelProperty("拍卖记录id")
    private Long auctionRecordId;

    @ApiModelProperty("拍卖记录id")
    private String courierId;
}
