package com.goafanti.order.service;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;

import javax.mail.MessagingException;
import javax.servlet.http.HttpServletResponse;


import com.goafanti.common.error.BusinessException;
import com.goafanti.common.model.TOrderDun;
import com.goafanti.common.model.TOrderNew;
import com.goafanti.common.model.TOrderNewWithBLOBs;
import com.goafanti.common.model.TOrderOutsource;
import com.goafanti.common.model.TOrderRefundWithBLOBs;
import com.goafanti.common.model.TOrderTask;
import com.goafanti.core.mybatis.page.Pagination;
import com.goafanti.order.bo.InputArrearsDunListBo;
import com.goafanti.order.bo.OrderDunTaskBo;
import com.goafanti.order.bo.OrderRefundDetailBo;
import com.goafanti.order.bo.OutArrearsDunListBo;
import com.goafanti.order.bo.OutNewOrderDunBo;
import com.goafanti.order.bo.TDunLogListBo;
import com.goafanti.order.bo.TOrderLogBo;
import com.goafanti.order.bo.TOrderNewBo;
import com.goafanti.order.bo.TOrderRefundBo;
import com.goafanti.order.bo.TOrderTaskBo;
import com.goafanti.order.bo.outOrderDunListBo;

public interface OrderNewService {
	
	/**
	 * 创建订单
	 * @param uid
	 * @param orderType
	 * @return
	 */
	int createServiceOrder(String uid, Integer orderType);
	/**
	 * 创建项目
	 * @param t
	 */
	int addOrderTask(TOrderTask t);
	/**
	 * 修改项目信息
	 * @param t
	 * @return
	 */
	int updateOrderTask(TOrderTask t);
	/**
	 * 删除项目
	 * @param id
	 * @return
	 */
	int delectOrderTask(Integer id);
	/**
	 * 项目详情
	 * @param orderNo
	 * @return
	 */
	 List<TOrderTaskBo> selectOrderTask(String orderNo);
	 /**
	  * 订单提交或保存
	  * @param t
	  * @param isSubmit
	  * @return
	  */
	int updateServiceOrder(TOrderNewWithBLOBs t, Integer isSubmit);
	/**
	 * 订单详情
	 * @param orderNo
	 * @return
	 */
	TOrderNewBo getOrderNewDetail(String orderNo);
	/**
	 * 收款截点编辑
	 * @param orderDun
	 * @return
	 */
	int createOrderDun(String orderDun,String orderNo);
	/**
	 * 订单列表
	 * @param name
	 * @param orderNo
	 * @param starTime
	 * @param endTime
	 * @param orderStatus
	 * @param pageNo
	 * @param pageSize
	 * @param amountStatus 
	 * @return
	 */
	Pagination<TOrderNewBo> orderNewList(String name, String orderNo, String starTime, String endTime,Integer specially ,Integer approval,Integer distribution,String depId,String contractNo,Integer outsource,Integer liquidationStatus, Integer amountStatus,Integer pageNo, Integer pageSize);
	/**
	 * 订单审核
	 * @param orderNo
	 * @param orderStatus
	 * @param object 
	 * @return
	 */
	int updateOrderNew(String orderNo, Integer orderStatus,String reason,Integer outsource, TOrderOutsource object);
	
	/**
	 * 催款订单列表
	 * @param name
	 * @param orderNo
	 * @param starTime
	 * @param endTime
	 * @param orderStatus
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	Pagination<outOrderDunListBo> dunOrderNewList(String name, String orderNo, String starTime, String endTime, Integer specially,String adminName,String depId,
			Integer newStatus,Integer pageNo, Integer pageSize);
	/**
	 * 新增催款记录
	 * @return
	 */
	int createDunLog(String dunId,String dumTime,String remarks);
	/**
	 * 查询催款记录
	 * @param dunId
	 * @return
	 */
	List<TDunLogListBo> selectDunLogList(String dunId);
	/**
	 * 新增退单
	 * @param t
	 * @return
	 */
	int addOrderRefund(TOrderRefundWithBLOBs t);
	/**
	 * 特批审核
	 * @param orderNo
	 * @param confirm
	 * @return
	 */
	int updateApprovalOrder(String orderNo,Integer confirm,String reason);
	/**
	 * 查看收款截点
	 * @param orderNo
	 * @return
	 */
	List<TOrderDun> selectOrderDun(String orderNo);
	/**
	 * 退单列表
	 * @param name
	 * @param orderNo
	 * @param starTime
	 * @param endTime
	 * @param specially
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	Pagination<TOrderRefundBo> orderRefundList(String name, String orderNo, String starTime, String endTime, Integer specially,
			Integer pageNo, Integer pageSize);
	
	boolean checkOrderMain(TOrderTask t);
	
	boolean chekeOrderStatus(String orderNo);
	
	boolean chekeApprovalOrderStatus(String orderNo);
	
	int deleteOrderNew(String orderNo);
	
	boolean checkOderSettlementAmount(String orderNo);
	
	boolean checkORderTask(String orderNo);
	
	void exportOrderDunData(String name,String orderNo,String starTime,String endTime,Integer specially,String adminName,
			String depId,Integer newStatus,Integer pageNo,Integer pageSize,HttpServletResponse response) throws  Exception;
	
	int updateOrderOver(String orderNo);
	
	OrderRefundDetailBo orderRefundDetail(String id);
	
	int updateOrderRefund(TOrderRefundWithBLOBs t);
	
	int updatetechnicianBackOrder(String orderNo, String reason);
	
	List<OrderDunTaskBo> selectAllOrderDun();
	
	void updateOrderDun(TOrderDun tDun);
	
	void addNoticAndSendEmail(String orderNo, OrderDunTaskBo t, Integer code)throws UnsupportedEncodingException, MessagingException;
	
	void addNewDunNoticAndSendEmail(String orderNo, OutNewOrderDunBo o);
	
	void addTimingTaskNewDunNoticAndSendEmail(TOrderNew t2, OutNewOrderDunBo o);
	
	boolean checkORderDun(String orderNo);
	
	int updateFinance(String orderNo, String newFinance);
	List<TOrderLogBo> selectOrderLog(String orderNo);

	void pushGeneralSendNoticeAndEmail(List<String> alist, Integer type,String OrderNo,String adminId,Integer approval);
	void exportOrderTaskData(String orderNo, HttpServletResponse response)throws IOException,BusinessException ;
	
	int pushOutsourceProjectAudit(TOrderOutsource o);
	Pagination<OutArrearsDunListBo> arrearsDunList(InputArrearsDunListBo in);
	void exportArrearsDunListData(InputArrearsDunListBo in, HttpServletResponse response) throws IOException;
	void pushOrderDun(String orderNo);
	int checkOutAudit(Integer id);
	
}
