package cn.superdesk.uniorder.dubbo.facade.accounting.customer;

import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dao.entity.accounting.unified.customer.AccountingUnifiedCustomer;
import cn.superdesk.uniorder.dao.entity.accounting.unified.customer.AccountingUnifiedCustomerOrder;
import cn.superdesk.uniorder.dao.entity.base.UnifiedOrder;
import cn.superdesk.uniorder.dao.entity.base.UnifiedOrderGoods;
import cn.superdesk.uniorder.dao.entity.sys.SysOrder;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dto.param.accounting.unified.customer.UnifiedCustomerCreateDimGoodsParam;
import cn.superdesk.uniorder.dto.param.accounting.unified.customer.UnifiedCustomerCreateDimOrderParam;
import cn.superdesk.uniorder.dto.vo.accounting.unified.customer.*;
import cn.superdesk.uniorder.dto.vo.accounting.unified.customer.statement.CustomerStatementOfAccountDetailItemVo;
import cn.superdesk.uniorder.dto.vo.accounting.unified.customer.statement.CustomerStatementOfAccountDetailVo;
import cn.superdesk.uniorder.dto.vo.sys.SysOrderQuery;

import java.util.List;
import java.util.Map;


/**
 * @Description: 客户结算 对账单
 * @Author: linjinyu 部分重构
 * @CreateDate: 2020/12/18 下午3:15
 * @UpdateUser: linjinyu
 * @UpdateDate: 2020/12/18 下午3:15
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public interface DubboAccountingUnifiedCustomerService {

	/****************************************** 自动 生成对账单 start ******************************************/


	AccountingUnifiedCustomer addAuto(String company, Long realnameId, Integer dateType, String startTime, String endTime, LoginSysUser loginSysUser) throws Exception;

	/****************************************** 自动 生成对账单 start ******************************************/


	AccountingUnifiedCustomer findById(Long id);

	AccountingUnifiedCustomer findByAccountingOrderSn(String dzSn);


	ReportOrderQA findReportFromOrder(Map<String, Object> params);

	List<String> findRealNamesByOrder(String company, Integer dateType, String startTime, String endTime);

	R<List<DzMainAutoPage>> findAllViewPage(Map<String, Object> params, int pageNo, int pageSize);

	R<List<ViewSysOrder>> findOrderViewPage(Map<String, Object> params, int pageNo, int pageSize);

	List<ViewSysOrderJoinGoods> findOrderViewGoodsTb(Map<String, Object> params);

	List<ViewSysOrderGoods> findOrderViewGoods(SysOrderQuery params);

	List<SysOrder> findAllFromOrder(Map<String, Object> queryMap);

	/**
	 * 创建结算单(对账单)(老)
	 *
	 * @param userId
	 * @param orders
	 * @param startTime
	 * @param endTime
	 * @param dateType
	 * @param sendEmail
	 * @return
	 * @throws Exception
	 */
	AccountingUnifiedCustomer addDzMain(Long userId, List<SysOrder> orders, String startTime, String endTime, Integer dateType, Integer sendEmail) throws Exception;

	//add dz 20190909


	/****************************************** 对账单 创建 start ******************************************/
	/**
	 * 创建结算单(对账单)(新) ---- 与 createScoreAccountingCustomer 对映
	 *
	 * @param userId
	 * @param orders
	 * @param model
	 * @return
	 * @throws Exception
	 */
	AccountingUnifiedCustomer opCreateAccountingDimOrder(Long userId, List<UnifiedOrder> orders, UnifiedCustomerCreateDimOrderParam model) throws Exception;

	/**
	 * 效率优化 mark by linjinyu at 20211203
	 *
	 * @param unifiedCustomerCreateDimGoodsParam
	 * @param loginSysUser
	 * @return
	 */
	AccountingUnifiedCustomer opCreateAccountingDimGoods(UnifiedCustomerCreateDimGoodsParam unifiedCustomerCreateDimGoodsParam, LoginSysUser loginSysUser);

	/****************************************** 对账单 创建   end ******************************************/

	/****************************************** 对账单 编辑 start ******************************************/
	void opEditAccountingDimOrder(AccountingUnifiedCustomer statementOfAccount, UnifiedOrder order, String add, LoginSysUser loginSysUser);

	void opEditAccountingDimGoods(AccountingUnifiedCustomer accountingUnifiedCustomer, UnifiedOrder unifiedOrder, UnifiedOrderGoods unifiedOrderGoods, String add, LoginSysUser loginSysUser);
	/****************************************** 对账单 编辑   end ******************************************/


	/****************************************** 对账单 详情 start ******************************************/
	CustomerStatementOfAccountDetailVo getCustomerStatementOfAccountDetailDimOrder2Goods(Long accountingOrderId);

	CustomerStatementOfAccountDetailVo getCustomerStatementOfAccountDetailDimGoods2Goods(Long accountingOrderId);
	/****************************************** 对账单 详情   end ******************************************/

	/**
	 * 客户结算>对账单
	 *
	 * @param queryMap
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	R<List<CustomerStatementOfAccountDetailVo>> getDzMainViewByPage(Map<String, Object> queryMap, int pageNo, int pageSize);

	ReportOrderQA getDzReportOrder(Map<String, Object> params);


	/******************************** 对账 操作 start ********************************/
	/**
	 * 动作 重新对账 取消对账
	 * <p>
	 * setAccountingStatus ? -> -1
	 *
	 * @param id
	 */
	void optAccountingCustomerActionCancel(Long id);

	/**
	 * 动作 拒绝对账
	 * <p>
	 * setAccountingStatus ? -> 2
	 *
	 * @param id
	 * @param userId
	 */
	void optAccountingCustomerActionRefuse(Long id, LoginSysUser loginSysUser);

	/**
	 * 动作 确认对账
	 * <p>
	 * setAccountingStatus ? -> 1
	 *
	 * @param id
	 * @param userId
	 */
	void optAccountingCustomerActionConfirm(Long id, LoginSysUser loginSysUser);

	void optAccountingCustomerActionSubmit(Long id, LoginSysUser loginSysUser);

	/**
	 * ***************************** 对账 操作   end ******************************
	 **/


	List<CustomerStatementOfAccountDetailVo> getDzMainView(Map<String, Object> params);

	//	ResponseResult<List<ViewSysOrderGoods>> getOrderViewByPage(SysOrderQuery query, int pageNum,int pageSize);

	R<List<ExpSysOrder>> getOrderViewByPage(SysOrderQuery query, int pageNum, int pageSize);

	R<List<ExpSysOrder>> getOrderViewByPageProject(SysOrderQuery query, int pageNum, int pageSize);

	/**
	 * 导出 excel ? 上头的好像已经没调用了?弃了？
	 *
	 * @param params
	 * @return
	 */
	@Deprecated
	List<CustomerStatementOfAccountDetailItemVo> getDzMainViewExcel(Map<String, Object> params);

	ReportOrderQA getOrderReportData(SysOrderQuery query);

	ReportOrderQA getOrderReportDataDeath(SysOrderQuery query);

	void updateFieldSendEmailTime(Long parseLong);

	@Deprecated
	List<ExpSysOrder> findOrderViewExcel(Map<String, Object> params);

	List<ExpSysOrder> getOrderViewExcel(SysOrderQuery query);


	/**
	 * 客户结算-对账单-导出报表
	 *
	 * @param params
	 * @return
	 */
	List<ViewDzOrderExcel> getDzOrderExcel(Map<String, Object> params);

	AccountingUnifiedCustomerOrder findOrderById(Long dzOrderId);

	void updateObj(AccountingUnifiedCustomer statementOfAccount4Update, LoginSysUser loginSysUser);

	void updateFieldRemark(AccountingUnifiedCustomer statementOfAccount4Update, LoginSysUser loginSysUser);


	List<UnifiedOrder> getUnifiedOrderByDzId(Map<String, Object> params);

	List<AccountingUnifiedCustomerOrder> getDzOrderAll(Map<String, Object> dzOrderMap);


	/****************************************** 补丁程序 start ******************************************/
	void patchXDimOrder2DimGoods(String accountingOrderSn);

	void patchXAccountingAmountAndQuantityOrderAndQuantityGoods(String accountingOrderSn);
	/****************************************** 补丁程序   end ******************************************/


}
