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

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.util.CollectionUtils;

import com.uas.platform.b2b.model.PurchaseInquiryItem;
import com.uas.platform.b2b.model.PurchaseInquiryReply;

/**
 * 卖家ERP收到的客户询价单
 * 
 * @author yingp
 * 
 */
public class QuotationDown {

	private long b2b_id_id;
	private long qu_custuu;
	private Long qu_selleruu;
	private String qu_code;
	private short qu_detno;
	private Date qu_date;
	private Date qu_recorddate;
	private Date qu_enddate;
	private String qu_remark;
	private String qu_custprodcode;
	private String qu_custproddetail;
	private String qu_custprodspec;
	private String qu_currency;
	private Float qu_taxrate;
	private Date qu_custfromdate;
	private Date qu_custtodate;
	private Date qu_fromdate;
	private Date qu_todate;
	private Double qu_minbuyqty;
	private Double qu_minqty;
	private Short qu_custlap;
	private List<RemoteFile> files;
	private List<QuotationDownDetail> details;

	public long getB2b_id_id() {
		return b2b_id_id;
	}

	public void setB2b_id_id(long b2b_id_id) {
		this.b2b_id_id = b2b_id_id;
	}

	public long getQu_custuu() {
		return qu_custuu;
	}

	public void setQu_custuu(long qu_custuu) {
		this.qu_custuu = qu_custuu;
	}

	public String getQu_code() {
		return qu_code;
	}

	public void setQu_code(String qu_code) {
		this.qu_code = qu_code;
	}

	public short getQu_detno() {
		return qu_detno;
	}

	public void setQu_detno(short qu_detno) {
		this.qu_detno = qu_detno;
	}

	public Date getQu_date() {
		return qu_date;
	}

	public void setQu_date(Date qu_date) {
		this.qu_date = qu_date;
	}

	public Date getQu_recorddate() {
		return qu_recorddate;
	}

	public void setQu_recorddate(Date qu_recorddate) {
		this.qu_recorddate = qu_recorddate;
	}

	public Date getQu_enddate() {
		return qu_enddate;
	}

	public void setQu_enddate(Date qu_enddate) {
		this.qu_enddate = qu_enddate;
	}

	public String getQu_remark() {
		return qu_remark;
	}

	public void setQu_remark(String qu_remark) {
		this.qu_remark = qu_remark;
	}

	public String getQu_custprodcode() {
		return qu_custprodcode;
	}

	public void setQu_custprodcode(String qu_custprodcode) {
		this.qu_custprodcode = qu_custprodcode;
	}

	public String getQu_custproddetail() {
		return qu_custproddetail;
	}

	public void setQu_custproddetail(String qu_custproddetail) {
		this.qu_custproddetail = qu_custproddetail;
	}

	public String getQu_custprodspec() {
		return qu_custprodspec;
	}

	public void setQu_custprodspec(String qu_custprodspec) {
		this.qu_custprodspec = qu_custprodspec;
	}

	public String getQu_currency() {
		return qu_currency;
	}

	public void setQu_currency(String qu_currency) {
		this.qu_currency = qu_currency;
	}

	public Float getQu_taxrate() {
		return qu_taxrate;
	}

	public void setQu_taxrate(Float qu_taxrate) {
		this.qu_taxrate = qu_taxrate;
	}

	public Date getQu_custfromdate() {
		return qu_custfromdate;
	}

	public void setQu_custfromdate(Date qu_custfromdate) {
		this.qu_custfromdate = qu_custfromdate;
	}

	public Date getQu_custtodate() {
		return qu_custtodate;
	}

	public void setQu_custtodate(Date qu_custtodate) {
		this.qu_custtodate = qu_custtodate;
	}

	public Date getQu_fromdate() {
		return qu_fromdate;
	}

	public void setQu_fromdate(Date qu_fromdate) {
		this.qu_fromdate = qu_fromdate;
	}

	public Date getQu_todate() {
		return qu_todate;
	}

	public void setQu_todate(Date qu_todate) {
		this.qu_todate = qu_todate;
	}

	public Double getQu_minbuyqty() {
		return qu_minbuyqty;
	}

	public void setQu_minbuyqty(Double qu_minbuyqty) {
		this.qu_minbuyqty = qu_minbuyqty;
	}

	public Double getQu_minqty() {
		return qu_minqty;
	}

	public void setQu_minqty(Double qu_minqty) {
		this.qu_minqty = qu_minqty;
	}

	public List<QuotationDownDetail> getDetails() {
		return details;
	}

	public void setDetails(List<QuotationDownDetail> details) {
		this.details = details;
	}

	public Long getQu_selleruu() {
		return qu_selleruu;
	}

	public void setQu_selleruu(Long qu_selleruu) {
		this.qu_selleruu = qu_selleruu;
	}

	public Short getQu_custlap() {
		return qu_custlap;
	}

	public void setQu_custlap(Short qu_custlap) {
		this.qu_custlap = qu_custlap;
	}

	public List<RemoteFile> getFiles() {
		return files;
	}

	public void setFiles(List<RemoteFile> files) {
		this.files = files;
	}

	public QuotationDown() {
	}

	/**
	 * 平台里面的每个客户询价明细，转为卖家ERP的一张客户询价单
	 * 
	 * @param item
	 */
	public QuotationDown(PurchaseInquiryItem item) {
		this.b2b_id_id = item.getId();
		this.qu_code = item.getInquiry().getCode();
		this.qu_currency = item.getCurrency();
		this.qu_custfromdate = item.getFromDate();
		this.qu_custprodcode = item.getProduct().getCode();
		this.qu_custproddetail = item.getProduct().getTitle();
		this.qu_custprodspec = item.getProduct().getSpec();
		this.qu_custtodate = item.getToDate();
		this.qu_custuu = item.getInquiry().getEnUU();
		this.qu_selleruu = item.getVendUserUU();
		this.qu_date = item.getInquiry().getDate();
		this.qu_detno = item.getNumber();
		this.qu_enddate = item.getInquiry().getEndDate();
		this.qu_fromdate = item.getVendFromDate();
		this.qu_minbuyqty = item.getMinOrderQty();
		this.qu_minqty = item.getMinPackQty();
		this.qu_taxrate = item.getTaxrate();
		this.qu_recorddate = item.getInquiry().getDate();
		this.qu_remark = item.getRemark();
		this.qu_todate = item.getVendToDate();
		this.qu_custlap = item.getCustLap();
		this.details = new ArrayList<QuotationDownDetail>();
		if (!CollectionUtils.isEmpty(item.getReplies())) {
			for (PurchaseInquiryReply reply : item.getReplies()) {
				this.details.add(new QuotationDownDetail(reply));
			}
		}
	}

}
