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

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

import com.uas.platform.b2b.model.PurchaseOrderReply;
import com.uas.platform.core.model.Status;

/**
 * ERP系统的采购订单明细回复记录
 * 
 * @author yingp
 * 
 */
public class PurchaseReply implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Long pr_id;
	private Double pr_qty;
	private Date pr_delivery;
	private String pr_remark;
	private String pr_pucode;
	private Short pr_pddetno;
	private Date pr_date;
	private String pr_recorder;
	/**
	 * 平台回复记录ID，传入买家的ERP。可供写入时检测，防止重复传的问题
	 */
	private Long b2b_pr_id;
	private String pr_type;

	public PurchaseReply() {
	}

	public Double getPr_qty() {
		return pr_qty;
	}

	public void setPr_qty(Double pr_qty) {
		this.pr_qty = pr_qty;
	}

	public Date getPr_delivery() {
		return pr_delivery;
	}

	public void setPr_delivery(Date pr_delivery) {
		this.pr_delivery = pr_delivery;
	}

	public String getPr_remark() {
		return pr_remark;
	}

	public void setPr_remark(String pr_remark) {
		this.pr_remark = pr_remark;
	}

	public String getPr_pucode() {
		return pr_pucode;
	}

	public void setPr_pucode(String pr_pucode) {
		this.pr_pucode = pr_pucode;
	}

	public Short getPr_pddetno() {
		return pr_pddetno;
	}

	public void setPr_pddetno(Short pr_pddetno) {
		this.pr_pddetno = pr_pddetno;
	}

	public Date getPr_date() {
		return pr_date;
	}

	public void setPr_date(Date pr_date) {
		this.pr_date = pr_date;
	}

	public String getPr_recorder() {
		return pr_recorder;
	}

	public void setPr_recorder(String pr_recorder) {
		this.pr_recorder = pr_recorder;
	}

	public Long getB2b_pr_id() {
		return b2b_pr_id;
	}

	public void setB2b_pr_id(Long b2b_pr_id) {
		this.b2b_pr_id = b2b_pr_id;
	}

	public String getPr_type() {
		return pr_type;
	}

	public void setPr_type(String pr_type) {
		this.pr_type = pr_type;
	}

	public Long getPr_id() {
		return pr_id;
	}

	public void setPr_id(Long pr_id) {
		this.pr_id = pr_id;
	}

	/**
	 * 从平台的回复记录转到买家ERP的回复记录
	 * 
	 * @param reply
	 * @return
	 */
	public PurchaseReply(PurchaseOrderReply orderReply) {
		setPr_date(orderReply.getDate());
		setPr_delivery(orderReply.getDelivery());
		setPr_qty(orderReply.getQty());
		setPr_remark(orderReply.getRemark());
		setPr_pucode(orderReply.getOrderItem().getOrder().getCode());
		setPr_pddetno(orderReply.getOrderItem().getNumber());
		setB2b_pr_id(orderReply.getId());
		//recorder录入人
		setPr_recorder(orderReply.getRecorder());
		setPr_type(orderReply.getType());
		setPr_id(orderReply.getErpId());
	}

	/**
	 * 从买家ERP的主动回复记录转到平台的回复记录
	 */
	public PurchaseOrderReply convert() {
		PurchaseOrderReply reply = new PurchaseOrderReply();
		reply.setDate(this.pr_date);
		reply.setDelivery(this.pr_delivery);
		reply.setQty(this.pr_qty);
		reply.setRecorder(this.pr_recorder);
		reply.setRemark(this.pr_remark);
		reply.setStatus((short) Status.DOWNLOADED.value());
		reply.setSendStatus((short) Status.NOT_UPLOAD.value());
		reply.setType("采购主动回复");
		reply.setErpId(this.pr_id);
		return reply;
	}

}
