package com.uas.platform.b2b.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OrderBy;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.codehaus.jackson.annotate.JsonIgnore;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * 
 * 采购订单回复记录
 * 
 * @author yingp
 *
 */
@Table(name = "purc$reply")
@Entity
public class PurchaseOrderReply implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

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

	/**
	 * 回复时日期
	 */
	@Column(name = "pr_date")
	@OrderBy
	private Date date;

	/**
	 * 采购订单明细
	 */
	@ManyToOne(cascade = { CascadeType.REFRESH, CascadeType.MERGE })
	@JoinColumn(name = "pr_pdid")
	private PurchaseOrderItem orderItem;

	/**
	 * 数量
	 */
	@Column(name = "pr_qty")
	private Double qty;

	/**
	 * 备注
	 */
	@Column(name = "pr_remark")
	private String remark;

	/**
	 * 交货日期
	 */
	@Column(name = "pr_delivery")
	private Date delivery;

	/**
	 * (针对买家的)传输状态{待上传、已下载}
	 */
	@Column(name = "pr_status")
	private Short status;

	/**
	 * (针对卖家的)传输状态{待上传、已下载}
	 */
	@Column(name = "pr_sendstatus")
	private Short sendStatus;

	/**
	 * 回复人
	 */
	@Column(name = "pr_recorder")
	private String recorder;

	/**
	 * 类型{供应商ERP回复、供应商平台回复、采购主动回复}
	 */
	@Column(name = "pr_type")
	private String type;

	/**
	 * erpid
	 * 
	 * @return
	 */
	@Column(name = "pr_erpid")
	private Long erpId;

	/**
	 * 保存数据的时间
	 * 
	 * @return
	 */
	@Column(name = "pr_erpdate")
	private Date erpDate;

	public Long getId() {
		return id;
	}

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

	public Date getDate() {
		return date;
	}

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

	@JsonIgnore
	@JSONField(serialize = false)
	public PurchaseOrderItem getOrderItem() {
		return orderItem;
	}

	public void setOrderItem(PurchaseOrderItem orderItem) {
		this.orderItem = orderItem;
	}

	public Double getQty() {
		return qty;
	}

	public void setQty(Double qty) {
		this.qty = qty;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Date getDelivery() {
		return delivery;
	}

	public void setDelivery(Date delivery) {
		this.delivery = delivery;
	}

	public Short getStatus() {
		return status;
	}

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

	public Short getSendStatus() {
		return sendStatus;
	}

	public void setSendStatus(Short sendStatus) {
		this.sendStatus = sendStatus;
	}

	public String getRecorder() {
		return recorder;
	}

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

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Long getErpId() {
		return erpId;
	}

	public void setErpId(Long erpId) {
		this.erpId = erpId;
	}

	public Date getErpDate() {
		return erpDate;
	}

	public void setErpDate(Date erpDate) {
		this.erpDate = erpDate;
	}



	/**
	 * 回复详情
	 * 
	 * @return
	 */
	public String replyDescription() {
		return "数量：" + this.qty + "，交期：" + DateFormatUtils.ISO_DATE_FORMAT.format(delivery);
	}

}
