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

import java.util.Date;

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

/**
 * SaleDown明细回复记录
 * 
 * @author yingp
 * 
 */
public class SaleReply {

	private Long sr_id;
	private Double sr_qty;
	private Date sr_delivery;
	private String sr_remark;
	private String sr_sacode;
	private short sr_sddetno;
	private Date sr_date;
	private String sr_recorder;
	private long cu_uu;
	private Long b2b_pd_id;
	private Long b2b_pr_id;
	private String sr_type;

	public Long getSr_id() {
		return sr_id;
	}

	public void setSr_id(Long sr_id) {
		this.sr_id = sr_id;
	}

	public Double getSr_qty() {
		return sr_qty;
	}

	public void setSr_qty(Double sr_qty) {
		this.sr_qty = sr_qty;
	}

	public Date getSr_delivery() {
		return sr_delivery;
	}

	public void setSr_delivery(Date sr_delivery) {
		this.sr_delivery = sr_delivery;
	}

	public String getSr_remark() {
		return sr_remark;
	}

	public void setSr_remark(String sr_remark) {
		this.sr_remark = sr_remark;
	}

	public String getSr_sacode() {
		return sr_sacode;
	}

	public void setSr_sacode(String sr_sacode) {
		this.sr_sacode = sr_sacode;
	}

	public short getSr_sddetno() {
		return sr_sddetno;
	}

	public void setSr_sddetno(short sr_sddetno) {
		this.sr_sddetno = sr_sddetno;
	}

	public Date getSr_date() {
		return sr_date;
	}

	public void setSr_date(Date sr_date) {
		this.sr_date = sr_date;
	}

	public String getSr_recorder() {
		return sr_recorder;
	}

	public void setSr_recorder(String sr_recorder) {
		this.sr_recorder = sr_recorder;
	}

	public long getCu_uu() {
		return cu_uu;
	}

	public void setCu_uu(long cu_uu) {
		this.cu_uu = cu_uu;
	}

	public Long getB2b_pd_id() {
		return b2b_pd_id;
	}

	public void setB2b_pd_id(Long b2b_pd_id) {
		this.b2b_pd_id = b2b_pd_id;
	}

	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 getSr_type() {
		return sr_type;
	}

	public void setSr_type(String sr_type) {
		this.sr_type = sr_type;
	}

	/**
	 * 从卖家ERP的回复记录转到平台的回复记录
	 */
	public PurchaseOrderReply convert() {
		PurchaseOrderReply reply = new PurchaseOrderReply();
		reply.setErpId(this.sr_id);
		reply.setErpDate(new Date());
		reply.setDate(this.sr_date);
		reply.setDelivery(this.sr_delivery);
		reply.setQty(this.sr_qty);
		reply.setRecorder(this.sr_recorder);
		reply.setRemark(this.sr_remark);
		reply.setStatus((short) Status.NOT_UPLOAD.value());
		reply.setSendStatus((short) Status.DOWNLOADED.value());
		reply.setType("供应商ERP回复");
		return reply;
	}

	/**
	 * 从卖家ERP的委外订单回复记录转到平台的委外加工单回复记录
	 */
	public MakeOrderReply convertToMakeReply() {
		MakeOrderReply reply = new MakeOrderReply();
		reply.setDate(this.sr_date);
		reply.setDelivery(this.sr_delivery);
		reply.setQty(this.sr_qty);
		reply.setRecorder(this.sr_recorder);
		reply.setRemark(this.sr_remark);
		reply.setBackStatus((short) Status.DOWNLOADED.value());// 写回到卖方ERP的状态
		reply.setSendStatus((short) Status.NOT_UPLOAD.value());// 传输到买方ERP的状态
		reply.setType("供应商ERP回复");
		return reply;
	}

	public SaleReply() {
	}

	/**
	 * 从平台的回复记录转到卖家ERP的回复记录
	 * 
	 * @param reply
	 */
	public SaleReply(PurchaseOrderReply reply) {
		this.sr_date = reply.getDate();
		this.sr_delivery = reply.getDelivery();
		this.sr_qty = reply.getQty();
		this.sr_recorder = reply.getRecorder();
		this.sr_remark = reply.getRemark();
		this.sr_sacode = reply.getOrderItem().getOrder().getCode();
		this.sr_sddetno = reply.getOrderItem().getNumber();
		this.b2b_pd_id = reply.getOrderItem().getId();
		this.b2b_pr_id = reply.getId();
		this.sr_type = reply.getType();
	}

	public SaleReply(MakeOrderReply reply) {
		this.sr_date = reply.getDate();
		this.sr_delivery = reply.getDelivery();
		this.sr_qty = reply.getQty();
		this.sr_recorder = reply.getRecorder();
		this.sr_remark = reply.getRemark();
		this.sr_sacode = reply.getOrder().getCode();
		this.sr_sddetno = 1;
		this.b2b_pd_id = reply.getOrderId();
		this.b2b_pr_id = reply.getId();
		this.sr_type = reply.getType();
	}
}
