package com.uas.platform.b2b.erp.model;

import com.uas.platform.b2b.model.*;

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

/**
 * 投标单主表（uas招标需要投标状态根据公布结果时间判断，用视图处理）
 * <p>
 * Created by dongbw on 17/03/07 11:16.
 */

@Table(name = "v$sale$tender")
@Entity
public class SaleTenderErp implements Serializable {

    /**
     * 序列号
     */
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "st_id")
    private Long id;


    /**
     * 招标编号
     */
    @Column(name = "st_code")
    private String code;

    /**
     * 招标项目
     */
    @Column(name = "st_title")
    private String title;

    /**
     * 单据最后修改时间
     */
    @Column(name = "st_modified")
    private Date modified;

    /**
     * 招标单录入日期
     */
    @Column(name = "st_date")
    private Date date;

    /**
     * 供应商联系人
     */
    @Column(name = "st_user")
    private String user;

    /**
     * 供应商联系人uu
     */
    @Column(name = "st_useruu")
    private Long useruu;

    /**
     * 联系人
     */
    @OneToOne
    @JoinColumn(name = "st_useruu", insertable = false, updatable = false)
    private UserBaseInfo userInfo;

    /**
     * 招标发起人uu
     */
    @Column(name = "st_recorderuu")
    private Long recorderuu;

    /**
     * 招标发起人
     */
    @OneToOne(cascade = CascadeType.REFRESH )
    @JoinColumn(name = "st_recorderuu", insertable = false, updatable = false)
    private UserBaseInfo recorder;

    /**
     * 供应商联系人电话
     */
    @Column(name = "st_usertel")
    private String userTel;

    /**
     * 供应商联系人邮箱
     */
    @Column(name = "st_useremail")
    private String userEmail;

    /**
     * 招标企业uu
     */
    @Column(name = "st_enuu")
    private Long enUU;

    /**
     * 招标企业基本信息
     */
    @OneToOne(cascade = CascadeType.REFRESH )
    @JoinColumn(name = "st_enuu", insertable = false, updatable = false)
    private Enterprise enterprise;

    /**
     * 投标截止日期
     */
    @Column(name = "st_enddate")
    private Date endDate;

    /**
     * 结果公布日期
     */
    @Column(name = "st_publishdate")
    private Date publishDate;

    /**
     * 币别
     */
    @Column(name = "st_currency")
    private String currency;

    /**
     * 是否开放报名（1为开放，0为指定供应商）
     */
    @Column(name = "st_ifopen")
    private Short ifOpen;

    /**
     * 是否发布（1为发布，0为保存）
     */
    @Column(name = "st_ispublish")
    private Short isPublish;

    /**
     * 是否含税（1含税，0不含税）
     */
    @Column(name = "st_iftax")
    private Short ifTax;

    /**
     * 收货地址
     */
    @Column(name = "st_shipaddress")
    private String shipAddress;

    /**
     * 付款方式
     */
    @Column(name = "st_payment")
    private String payment;

    /**
     * 发票类型（0表示不要发票， 1表示增值税普通发票， 2表示增值税专用发票）
     */
    @Column(name = "st_invoicetype")
    private Short invoiceType;

    /**
     * 证照要求
     */
    @Column(name = "st_certificate")
    private String certificate;

    /**
     * 投标单状态
     */
    @Column(name = "st_status")
    private String status;

    /**
     * 投标附件
     */
    @OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.REFRESH})
    @JoinTable(name = "sale$tenderattach", joinColumns = @JoinColumn(name = "st_id", referencedColumnName = "st_id"), inverseJoinColumns = @JoinColumn(name="at_id", referencedColumnName = "at_id"))
    private Set<com.uas.platform.b2b.model.Attach> bidAttaches;

    /**
     * 投标明细
     */
    @OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
    @JoinColumn(name = "sti_stid")
    @OrderBy("id")
    private Set<SaleTenderItemErp> saleTenderItems;

    /**
     * 问题单
     */
    @OneToMany(mappedBy = "saleTender", cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
    @OrderBy("id")
    private Set<SaleTenderQuestion> saleTenderQuestions;

    /**
     * 投标企业uu
     */
    @Column(name = "st_venduu")
    private Long vendUU;

    /**
     * 投标企业基本信息
     */
    @OneToOne(cascade = CascadeType.PERSIST)
    @JoinColumn(name = "st_venduu", insertable = false, updatable = false)
    private EnterpriseBaseInfo enterpriseBaseInfo;

    /**
     * 审核状态(0代表已提交，1代表已审核，uas审批流用，平台发布单据为空)
     */
    @Column(name = "st_auditstatus")
    private Short auditStatus;

    /**
     * 招标单id(消息跳转url用)
     */
    @Column(name = "st_ptid")
    private Long ptId;

    /**
     * 是否已过期，根据enddate判断，为视图虚拟列 0 未过期，1已过期
     * @param tender
     */
    @Column(name = "st_overdue", insertable = false, updatable = false)
    private Short overdue;

    /**
     * 是否已过期，根据publishdate判断，为视图虚拟列 0 未公布，1已公布
     * @param tender
     */
    @Column(name = "st_result", insertable = false, updatable = false)
    private Short result;

    /**
     * 是否已截止提问，根据questionEndDate判断，为视图虚拟列 0 未截止提问，1已截止
     * @param tender
     */
    @Column(name = "st_questionend", insertable = false, updatable = false)
    private Short questionEnd;

    /**
     * 是否全包 (1为全包，0为部分供料)
     */
    @Column(name = "st_ifall")
    private Short ifAll;

    /**
     * 总项目周期(天)
     */
    @Column(name = "st_cycle")
    private Long cycle;

    /**
     * 金额总计(全包模式用)
     */
    @Column(name = "st_totalmoney")
    private Double totalMoney;

    /**
     * 税率(% 全包模式用)
     */
    @Column(name = "st_taxrate")
    private Integer taxrate;

    /**
     * 提问截止时间
     */
    @Column(name = "st_questionenddate")
    private Date questionEndDate;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Date getModified() {
        return modified;
    }

    public void setModified(Date modified) {
        this.modified = modified;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getUserTel() {
        return userTel;
    }

    public void setUserTel(String userTel) {
        this.userTel = userTel;
    }

    public Enterprise getEnterprise() {
        return enterprise;
    }

    public void setEnterprise(Enterprise enterprise) {
        this.enterprise = enterprise;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public Date getPublishDate() {
        return publishDate;
    }

    public void setPublishDate(Date publishDate) {
        this.publishDate = publishDate;
    }

    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String currency) {
        this.currency = currency;
    }

    public Short getIfOpen() {
        return ifOpen;
    }

    public void setIfOpen(Short ifOpen) {
        this.ifOpen = ifOpen;
    }

    public Short getIsPublish() {
        return isPublish;
    }

    public void setIsPublish(Short isPublish) {
        this.isPublish = isPublish;
    }

    public Short getIfTax() {
        return ifTax;
    }

    public void setIfTax(Short ifTax) {
        this.ifTax = ifTax;
    }

    public String getShipAddress() {
        return shipAddress;
    }

    public void setShipAddress(String shipAddress) {
        this.shipAddress = shipAddress;
    }

    public String getPayment() {
        return payment;
    }

    public void setPayment(String payment) {
        this.payment = payment;
    }

    public Short getInvoiceType() {
        return invoiceType;
    }

    public void setInvoiceType(Short invoiceType) {
        this.invoiceType = invoiceType;
    }

    public String getCertificate() {
        return certificate;
    }

    public void setCertificate(String certificate) {
        this.certificate = certificate;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Set<com.uas.platform.b2b.model.Attach> getBidAttaches() {
        return bidAttaches;
    }

    public void setBidAttaches(Set<com.uas.platform.b2b.model.Attach> bidAttaches) {
        this.bidAttaches = bidAttaches;
    }

    public Set<SaleTenderItemErp> getSaleTenderItems() {
        return saleTenderItems;
    }

    public void setSaleTenderItems(Set<SaleTenderItemErp> saleTenderItems) {
        this.saleTenderItems = saleTenderItems;
    }

    public EnterpriseBaseInfo getEnterpriseBaseInfo() {
        return enterpriseBaseInfo;
    }

    public void setEnterpriseBaseInfo(EnterpriseBaseInfo enterpriseBaseInfo) {
        this.enterpriseBaseInfo = enterpriseBaseInfo;
    }

    public Long getEnUU() {
        return enUU;
    }

    public void setEnUU(Long enUU) {
        this.enUU = enUU;
    }

    public Long getVendUU() {
        return vendUU;
    }

    public void setVendUU(Long vendUU) {
        this.vendUU = vendUU;
    }

    public Short getAuditStatus() {
        return auditStatus;
    }

    public void setAuditStatus(Short auditStatus) {
        this.auditStatus = auditStatus;
    }

    public Short getIfAll() {
        return ifAll;
    }

    public Long getCycle() {
        return cycle;
    }

    public void setCycle(Long cycle) {
        this.cycle = cycle;
    }

    public void setIfAll(Short ifAll) {
        this.ifAll = ifAll;
    }

    public Double getTotalMoney() {
        return totalMoney;
    }

    public void setTotalMoney(Double totalMoney) {
        this.totalMoney = totalMoney;
    }

    public Integer getTaxrate() {
        return taxrate;
    }

    public void setTaxrate(Integer taxrate) {
        this.taxrate = taxrate;
    }

    public Long getUseruu() {
        return useruu;
    }

    public void setUseruu(Long useruu) {
        this.useruu = useruu;
    }

    public UserBaseInfo getUserInfo() {
        return userInfo;
    }

    public void setUserInfo(UserBaseInfo userInfo) {
        this.userInfo = userInfo;
    }

    public Long getRecorderuu() {
        return recorderuu;
    }

    public void setRecorderuu(Long recorderuu) {
        this.recorderuu = recorderuu;
    }

    public UserBaseInfo getRecorder() {
        return recorder;
    }

    public void setRecorder(UserBaseInfo recorder) {
        this.recorder = recorder;
    }

    public String getUserEmail() {
        return userEmail;
    }

    public void setUserEmail(String userEmail) {
        this.userEmail = userEmail;
    }

    public Long getPtId() {
        return ptId;
    }

    public void setPtId(Long ptId) {
        this.ptId = ptId;
    }

    public Short getOverdue() {
        return overdue;
    }

    public void setOverdue(Short overdue) {
        this.overdue = overdue;
    }

    public Short getResult() {
        return result;
    }

    public void setResult(Short result) {
        this.result = result;
    }

    public Date getQuestionEndDate() {
        return questionEndDate;
    }

    public void setQuestionEndDate(Date questionEndDate) {
        this.questionEndDate = questionEndDate;
    }

    public Set<SaleTenderQuestion> getSaleTenderQuestions() {
        return saleTenderQuestions;
    }

    public void setSaleTenderQuestions(Set<SaleTenderQuestion> saleTenderQuestions) {
        this.saleTenderQuestions = saleTenderQuestions;
    }

    public Short getQuestionEnd() {
        return questionEnd;
    }

    public void setQuestionEnd(Short questionEnd) {
        this.questionEnd = questionEnd;
    }
}
