package com.izouma.zhirongip.domain.supply;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.izouma.zhirongip.annotations.EnumFormat;
import com.izouma.zhirongip.annotations.Searchable;
import com.izouma.zhirongip.converter.StringArrayConverter;
import com.izouma.zhirongip.domain.BaseEntity;
import com.izouma.zhirongip.enums.*;
import com.izouma.zhirongip.utils.excel.EnumExcelConverter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;

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

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@ApiModel(value = "商标")
@Where(clause = "del = 0")
public class Logo extends BaseEntity {

    @ExcelIgnore
    private Long userId;

    @Searchable
    @ApiModelProperty(value = "商标名称")
    private String name;

    @ApiModelProperty(value = "申请号")
    private String code;

    @ApiModelProperty(value = "申请日期")
    private LocalDate applyTime;

    @EnumFormat(value = LogoType.class,
            fromExcel = {"普通商标", "集体商标", "证明商标"},
            toJavaEnum = {"GENERAL", "COLLECTIVE", "PROOF"})
    @ExcelProperty(value = "商标类型", converter = EnumExcelConverter.class)
    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "商标类型")
    private LogoType logoType;

    /*
    setting
     */
    @ExcelIgnore
    @ApiModelProperty(value = "所属分类")
    private Long category;

    @ApiModelProperty(value = "核定使用商品/服务项目")
    @Convert(converter = StringArrayConverter.class)
    private List<String> servicesItem;

    @ApiModelProperty(value = "商标注册人")
    private String owner;

    @ExcelIgnore
    @Convert(converter = StringArrayConverter.class)
    @Column(columnDefinition = "TEXT")
    @ApiModelProperty(value = "商标图样")
    private List<String> img;


    @ApiModelProperty(value = "交易方式")
    private String tradingMethod;

    @ApiModelProperty(value = "交易方式")
    private Long tradingMethodId;

    /*
    （万元）
     */
    @ApiModelProperty(value = "期望价（万元）")
    private BigDecimal expectedPrice;

    @ApiModelProperty(value = "面议")
    private Boolean negotiateDirectly;

    @ApiModelProperty(value = "底价（万元）")
    private BigDecimal basePrice;

    @EnumFormat(value = CommissionType.class,
            fromExcel = {"佣金", "百分比"},
            toJavaEnum = {"COMMISSION", "PERCENTAGE"})
    @ExcelProperty(value = "佣金类型", converter = EnumExcelConverter.class)
    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "佣金类型")
    private CommissionType commissionType;

    @ApiModelProperty(value = "佣金（万元）")
    private BigDecimal commission;

    @ApiModelProperty(value = "联系人")
    private String contact;

    @ApiModelProperty(value = "电话")
    private String phone;

    @ApiModelProperty(value = "邮箱")
    private String email;

    @ApiModelProperty(value = "所在地区")
    private String address;

    @ApiModelProperty(value = "浏览量")
    private long view;

    @Enumerated(EnumType.STRING)
    private ApplyStatus status;

    @Transient
    private String categoryName;
}