package com.chinacreator.process.bean;


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

/**
 * <p>Description: 用户订购关系</p>
 * <p>Copyright: Copyright (c) 2013</p>
 * <p>Company: Chinacreator（长沙科创集成）</p>
 * <p>creationTime: 2013-3-22</p>
 * @author qiuhai.fan
 * @version 1.0
 */
public class VacOrder {
	
	/**
	 * 状态，0表示成功
	 */
	private int resultCode = 1;
	
	private String errorinfo;
	
	/**
	 * 订购产品列表
	 */
	private List<VacOrderItem> orderItems = new ArrayList<VacOrderItem>();

	public int getResultCode() {
		return resultCode;
	}

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

	public void setResultCode(int resultCode) {
		this.resultCode = resultCode;
	}

	public void setOrderItems(List<VacOrderItem> orderItems) {
		this.orderItems = orderItems;
	}
	
	public void addOrderItem(VacOrderItem orderItem) {
		this.orderItems.add(orderItem);
	}
	
	/**
	 * 查询指定产品ID的订购关系
	 * @param id
	 * @return
	 */
	public VacOrderItem getItem(String id) {
		if(id != null && orderItems != null) {
			for(VacOrderItem vacOrderItem : orderItems) {
				if(vacOrderItem.getId().equals(id)) {
					return vacOrderItem;
				}
			}
		}
		return null;
	}
	
	@Override
	public String toString() {
		return "VacOrder [resultCode=" + resultCode + ", orderItems="
				+ orderItems + "]";
	}

	public String getErrorinfo() {
		return errorinfo;
	}

	public void setErrorinfo(String errorinfo) {
		this.errorinfo = errorinfo;
	}
}
