package com.uas.platform.b2b.service;

import java.util.List;

import org.springframework.data.domain.Page;

import com.uas.platform.b2b.model.PurchaseOrder;
import com.uas.platform.b2b.model.PurchaseOrderAll;
import com.uas.platform.b2b.model.PurchaseOrderAllItem;
import com.uas.platform.b2b.model.PurchaseOrderDone;
import com.uas.platform.b2b.model.PurchaseOrderEnd;
import com.uas.platform.b2b.model.PurchaseOrderItem;
import com.uas.platform.b2b.model.PurchaseOrderReply;
import com.uas.platform.b2b.model.PurchaseOrderTodo;
import com.uas.platform.core.model.PageInfo;

public interface PurchaseOrderService {

	/**
	 * 批量保存、修改采购订单明细
	 * 
	 * @param items
	 * @return
	 */
	public void saveItems(List<PurchaseOrderItem> items);

	/**
	 * 批量保存、修改采购订单
	 * 
	 * @param orders
	 * @return
	 */
	public void save(List<PurchaseOrderAllItem> orders);

	/**
	 * 分页查找订单
	 * 
	 * @param pageInfo
	 * @return
	 */
	public Page<PurchaseOrder> findAllByPageInfo(PageInfo pageInfo);

	/**
	 * 分页查找订单，包括明细
	 * 
	 * @param pageInfo
	 * @return
	 */
	public Page<PurchaseOrderAll> findAllDetailByPageInfo(PageInfo pageInfo);

	/**
	 * 分页查找待回复订单，包括明细
	 * 
	 * @param pageInfo
	 * @return
	 */
	public Page<PurchaseOrderTodo> findTodoByPageInfo(PageInfo pageInfo);
	
	/**
	 * 分页查找已回复订单，包括明细
	 * 
	 * @param pageInfo
	 * @return
	 */
	public Page<PurchaseOrderDone> findDoneByPageInfo(PageInfo pageInfo);
	
	/**
	 * 分页查找已结案订单明细
	 * 
	 * @param pageInfo
	 * @return
	 */
	public Page<PurchaseOrderEnd> findEndByPageInfo(PageInfo pageInfo);

	/**
	 * 用订单号查找订单
	 * 
	 * @param code
	 * @return
	 */
	public PurchaseOrderAll findByCode(String code);

	/**
	 * 用订单ID查找订单
	 * 
	 * @param id
	 * @return
	 */
	public PurchaseOrderAll findById(Long id);

	/**
	 * 回复单个明细
	 * 
	 * @param reply
	 */
	public void reply(PurchaseOrderReply reply);

	/**
	 * 批量回复
	 * 
	 * @param replies
	 */
	public void reply(List<PurchaseOrderReply> replies);

	/**
	 * 批量回复
	 * 
	 * @param orderItemIdString
	 *            回复的明细ID的字符串数组
	 */
	public void reply(String[] orderItemIdString);

	/**
	 * 查找订单明细的回复记录
	 * 
	 * @param orderItemId
	 *            订单明细ID
	 * @return
	 */
	public List<PurchaseOrderReply> findReplyByOrderItem(long orderItemId);

	/**
	 * 查找所有待上传到供应商ERP的订单
	 * 
	 * @return
	 */
	public List<PurchaseOrderAll> findNotUploadOrder();

	/**
	 * 查找所有待上传到买家的回复记录
	 * 
	 * @return
	 */
	public List<PurchaseOrderReply> findNotUploadReply();

	/**
	 * 查找所有待上传到卖家的回复记录
	 * 
	 * @return
	 */
	public List<PurchaseOrderReply> findNotSendReply();

	/**
	 * 回复记录成功传到买家ERP之后
	 * 
	 * @param idArray
	 */
	public void onReplyUploadSuccess(String[] idArray);

	/**
	 * 回复记录成功传到卖家ERP之后
	 * 
	 * @param idArray
	 */
	public void onReplyDownSuccess(String[] idArray);

	/**
	 * 平台的订单传到供应商ERP之后，修改平台里面的订单的上传状态
	 * 
	 * @param idArray
	 */
	public void onSaleDownSuccess(String[] idArray);

	/**
	 * 查找所有待上传到卖家的结案、反结案客户采购单
	 * 
	 * @return
	 */
	public List<PurchaseOrderItem> findNotSendEnd();

	/**
	 * 结案、反结案客户采购单成功传到卖家ERP之后
	 * 
	 * @param idArray
	 */
	public void onEndDownSuccess(String[] idArray);

	/**
	 * 获取待回复的客户采购单条数
	 * 
	 * @return
	 */
	public int getOnhandCount();
}