package com.uas.platform.b2b.model;

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

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

@Entity
@Table(name = "sale$orders")
public class SaleOrder implements Serializable {

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

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sale$orders_gen")
	@SequenceGenerator(name = "sale$orders_gen", sequenceName = "sale$orders_seq", allocationSize = 1)
	@Column(name = "sa_id")
	private Long id;

	/**
	 * 订单所属企业UU
	 */
	@Column(name = "sa_enuu")
	private Long enUU;

	/**
	 * 订单所属业务员UU
	 */
	@Column(name = "sa_useruu")
	private Long userUU;

	/**
	 * 销售订单号
	 */
	@Column(name = "sa_code")
	private String code;

	/**
	 * 销售类型
	 */
	@Column(name = "sa_type")
	private String type;

	/**
	 * 单据归属日期
	 */
	@Column(name = "sa_date")
	private Date date;

	/**
	 * 录单人员UU
	 */
	@Column(name = "sa_recorderuu")
	private Long recorderUU;

	/**
	 * 客户企业UU
	 */
	@Column(name = "sa_custuu")
	private Long custUU;

	/**
	 * 客户联系人UU
	 */
	@Column(name = "sa_custuseruu")
	private Long custUserUU;

	/**
	 * 交货地址
	 */
	@Column(name = "sa_shipaddress")
	private String shipAddress;

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

	/**
	 * 收款币种
	 */
	@Column(name = "sa_currency")
	private String currency;

	/**
	 * 收款方式
	 */
	@Column(name = "sa_payments")
	private String payments;

	/**
	 * 订单状态
	 */
	@Column(name = "sa_status")
	private String status;

	/**
	 * 订单明细
	 */
	@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, mappedBy = "order", fetch = FetchType.EAGER)
	@OrderBy("sd_number")
	@NotFound(action = NotFoundAction.IGNORE)
	private List<SaleOrderItem> orderItems;

	public Long getId() {
		return id;
	}

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

	public Long getEnUU() {
		return enUU;
	}

	public void setEnUU(Long enUU) {
		this.enUU = enUU;
	}

	public Long getUserUU() {
		return userUU;
	}

	public void setUserUU(Long userUU) {
		this.userUU = userUU;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getType() {
		return type;
	}

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

	public Date getDate() {
		return date;
	}

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

	public Long getRecorderUU() {
		return recorderUU;
	}

	public void setRecorderUU(Long recorderUU) {
		this.recorderUU = recorderUU;
	}

	public Long getCustUU() {
		return custUU;
	}

	public void setCustUU(Long custUU) {
		this.custUU = custUU;
	}

	public Long getCustUserUU() {
		return custUserUU;
	}

	public void setCustUserUU(Long custUserUU) {
		this.custUserUU = custUserUU;
	}

	public String getShipAddress() {
		return shipAddress;
	}

	public void setShipAddress(String shipAddress) {
		this.shipAddress = shipAddress;
	}

	public String getRemark() {
		return remark;
	}

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

	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}

	public String getPayments() {
		return payments;
	}

	public void setPayments(String payments) {
		this.payments = payments;
	}

	public String getStatus() {
		return status;
	}

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

	public List<SaleOrderItem> getOrderItems() {
		return orderItems;
	}

	public void setOrderItems(List<SaleOrderItem> orderItems) {
		this.orderItems = orderItems;
	}

}
