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_goods_batch")
public class GoodsBatch implements Serializable {

    private static final long serialVersionUID = 1L;

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

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

    @OneToOne
    @JoinColumn(name = "supplier_id",referencedColumnName="onlyID",foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    @ApiModelProperty(value = "供应商")
    private Supplier supplier;

    @Column(name = "purchase_price")
    @ApiModelProperty(value = "商品进价,小数点后保留2位")
    private Double purchasePrice;

    @Column(name = "sell_price")
    @ApiModelProperty(value = "商品售价,小数点后保留2位")
    private Double sellPrice;

    @Column(name = "purchase_number")
    @ApiModelProperty(value = "进货数量，可以为负")
    private Double purchaseNumber;

    @Column(name = "stock_number")
    @ApiModelProperty(value = "库存数量")
    private Double stockNumber;

    @Column(name = "submit_date")
    @ApiModelProperty(value = "进货日期，格式（yyyy-MM-dd）")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd")//json序列化实体类处理
    private Date submitDate;

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

    @Column(name = "isBackup")
    @ApiModelProperty(value = "是否备份过(0:否；1:是)")
    private Integer isBackup = 0;

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

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

    @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;

    @Column(name = "goodsCode")
    @ApiModelProperty(value = "商品货号")
    private String goodsCode;

    @Column(name = "goodsBarcode")
    @ApiModelProperty(value = "商品条码")
    private String goodsBarcode;

    @Column(name = "purchase_totle_price")
    @ApiModelProperty(value = "进货总价")
    private String purchaseTotlePrice;

    @Column(name = "payWay")
    @ApiModelProperty(value = "付款方式 1=现金 2=刷卡 3=支付宝 4=微信")
    private Integer payWay;

    @Column(name = "realPayMoney")
    @ApiModelProperty(value = "实付款")
    private Float realPayMoney;

    @Column(name = "payables")
    @ApiModelProperty(value = "欠款 应付账款（欠供应商的钱） =商品进货总价-实付款-优惠金额=商品销售价格*商品进货数量+其他花费-实付款-优惠金额")
    private Float payables;

    @Column(name = "prices1")
    @ApiModelProperty(value = "零售价格")
    private Float prices1;

    @Column(name = "prices2")
    @ApiModelProperty(value = "员工内部价")
    private Float prices2;

    @Column(name = "prices3")
    @ApiModelProperty(value = "一级代理价格")
    private Float prices3;

    @Column(name = "prices4")
    @ApiModelProperty(value = "二级代理价格")
    private Float prices4;

    @Column(name = "prices5")
    @ApiModelProperty(value = "三级代理价格")
    private Float prices5;

    @Column(name = "productionDate")
    @ApiModelProperty(value = "生产日期")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd")//json序列化实体类处理
    private Date productionDate;

    @Column(name = "begoodTime")
    @ApiModelProperty(value = "有效期")
    private String begoodTime;

    @Column(name = "factory")
    @ApiModelProperty(value = "生产厂商")
    private String factory;

    @Column(name = "explains")
    @ApiModelProperty(value = "商品描述")
    private String explains;

    @Column(name = "image")
    @ApiModelProperty(value = "商品图片 300长度")
    private String image;

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

}
