package com.uas.platform.b2b.model;

import com.alibaba.fastjson.annotation.JSONField;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.codehaus.jackson.annotate.JsonIgnore;

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

/**
 * 
 * 客户委外加工单回复记录
 * 
 * @author suntg
 *
 */
@Table(name = "make$reply")
@Entity
public class MakeOrderReply implements Serializable {

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

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

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

	/**
	 * 委外加工单Id
	 */
	@Column(name = "mr_maid")
	private Long orderId;
	
	/**
	 * 委外加工单
	 */
	@OneToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "mr_maid", insertable = false, updatable = false)
	private MakeOrder order;

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

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

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

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

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

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

	/**
	 * 类型{供应商ERP回复、供应商平台回复、采购主动回复}
	 */
	@Column(name = "mr_type")
	private String type;
	
	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;
	}
	public Long getOrderId() {
		return orderId;
	}
	public void setOrderId(Long orderId) {
		this.orderId = orderId;
	}
	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 getSendStatus() {
		return sendStatus;
	}
	public void setSendStatus(Short sendStatus) {
		this.sendStatus = sendStatus;
	}
	public Short getBackStatus() {
		return backStatus;
	}
	public void setBackStatus(Short backStatus) {
		this.backStatus = backStatus;
	}
	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;
	}
	
	@JsonIgnore
	@JSONField(serialize = false)
	public MakeOrder getOrder() {
		return order;
	}
	public void setOrder(MakeOrder order) {
		this.order = order;
	}
	/**
	 * 回复详情
	 * 
	 * @return
	 */
	public String replyDescription() {
		return "数量：" + this.qty + "，交期：" + DateFormatUtils.ISO_DATE_FORMAT.format(delivery);
	}
	
}
