package com.ff.weijinxiao.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ff.weijinxiao.util.jsonfilter.DateSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 订单商品
 */
@Data
@Entity
@Table(name = "tb_order_good")
public class OrderGoods implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "t_id")
    private Integer id;

/*    @ManyToOne
    @JoinColumn(name = "order_id",referencedColumnName="onlyID",foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    @ApiModelProperty(value = "订单id")
    private Order order;*/

    @OneToOne
    @JoinColumn(name = "goods_batch_id",referencedColumnName="onlyID",foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    @ApiModelProperty(value = "商品批次id")
    private GoodsBatch goodsBatch;

    @OneToOne
    @JoinColumn(name = "goods_id",referencedColumnName="onlyID",foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    @ApiModelProperty(value = "商品id")
    private Goods goods;

    @Column(name = "good_cost")
    @ApiModelProperty(value = "该商品成本总额")
    private Double goodCost;

    @Column(name = "sales_volume")
    @ApiModelProperty(value = "该商品销售总额")
    private Double salesVolume;

    @Column(name = "number")
    @ApiModelProperty(value = "商品数量")
    private Double number;

    @Column(name = "profit")
    @ApiModelProperty(value = "商品售出利润(（售价-进价）*数量)")
    private Double profit;

    @Column(name = "submit_date")
    @ApiModelProperty(value = "当前提交订单时间 yyyy-MM-dd hh:mm:ss")
    private Date submitDate;

    @Column(name = "customId")
    @ApiModelProperty(value = "客户ID")
    private String customId;

    @Column(name = "sellPrice")
    @ApiModelProperty(value = "售价")
    private Double sellPrice;

    @Column(name = "supplier_name")
    @ApiModelProperty(value = "供应商id")
    private String supplierId;

    @Column(name = "uid")
    @ApiModelProperty(value = "用户登录ID")
    private String uid;

    @Column(name = "paid")
    @ApiModelProperty(value = "已支付")
    private String paid;

    @Transient
    @ApiModelProperty(value = "创建者姓名")
    private String userName;

    @Column(name = "isDelete")
    @ApiModelProperty(value = "是否是删除状态(0:否；1:是)")
    private Integer isDelete = 0;

    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间")
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")//json序列化实体类处理
    private Date createTime;

    @Column(name = "modify_time")
    @ApiModelProperty(value = "更新时间")
    @org.hibernate.annotations.UpdateTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")//json序列化实体类处理
    private Date modifyTime;

    @Column(name = "onlyID")
    @ApiModelProperty(value = "onlyID")
    private String onlyID;

    @OneToOne
    @JoinColumn(name = "book_id",referencedColumnName="id",foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    @ApiModelProperty(value = "激活账本ID")
    private AccountBook accountBook;
}
