package com.palmnest.service.repair;

import com.palmnest.application.bean.Page;
import com.palmnest.application.dto.WebPageResultDto;
import com.palmnest.application.dto.input.RepairTypeDetialDto;
import com.palmnest.model.Element;
import com.palmnest.model.OrgElement;
import com.palmnest.model.User;
import com.palmnest.model.repair.RepairBill;
import com.palmnest.service.GenericManager;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public interface RepairBillManager extends GenericManager<RepairBill, Long> {

	public Page findPageByStatus(Integer status, String repairTypeIds, Long serviceUser, int pageSize, int pageNo, Integer orgId);

	/**
	 * 查询对应区域人员名下进行中的单
	 *
	 * @param userId
	 * @param areaId
	 * @return
	 */
	List<RepairBill> findBy(Long userId, Long areaId);

	public Page findPageBy(Map<String, Object> params, int pageSize, int pageNo);

	/**
	 * 查找超过2分钟还没人抢单的单
	 *
	 * @return
	 */
	List<RepairBill> findSingleOvertime();

	/**
	 * 查找所有挂单预计开始时间超过当前时间的单
	 *
	 * @return
	 */
	List<RepairBill> findPendOvertime();

	/**
	 * 查找所有挂单预计开始时间超过当前时间5分钟的单
	 *
	 * @return
	 */
	List<RepairBill> findManagePendOvertime();

	RepairBill findByCode(String code, BigDecimal repairCost);

	public Integer findCountBy(Integer status, String repairTypeIds, Long serviceUser, Integer orgId);

	public RepairBill findByCode(String code);

	public Integer updateGrabBill(RepairBill bill, Integer version);

	WebPageResultDto findAllTree(int pageNo, int pageSize, Map<String,String> param, String code);

	RepairTypeDetialDto getDetail(String itemId, String orgId);

	void saveRepair(RepairTypeDetialDto param, User user);

    void delete(String itemId, User user);

	List<RepairBill> getTotalByDateAndRepairType(Long id, Integer type, String date,String endDate,String orgIds);

    Page findPageByRepairUser(Map<String, Object> params, int pageSize, int pageNo);

	Page findBordPage(Map<String, Object> conditions, int pageSize, int pageNo);


	List<RepairBill> getByOrg(String orgIds);
	
	OrgElement findByCodeAndOrgId(String code, Integer orgId);
	
	OrgElement findByCodeAndOrgIdAndId(String code, Integer orgId,Long id);
	
	Element findByCodeAndId(String code, Integer orgId,Long id);
	
	/**
	 * 获取微信端创建的所有工单数、收费数、费用
	 * @param orgId
	 * @param virtId
	 * @param type
	 * @param date
	 * @param endDate
	 * @return
	 */
	Page getAllWxOrder(Map<String, Object> conditions,int type,int pageNo,int pageSize);
	
	/**
	 * 获取订单明细
	 * @param orgId
	 * @param virtId
	 * @param isFree  ==1获取所有工单数的明细 ==0获取收费工单数的明细
	 * @param type
	 * @param date
	 * @param endDate
	 * @return
	 */
	Page getWxAmountOrder(Map<String, Object> conditions,int isFree,int type,int pageNo,int pageSize);
	
	/**
	 * 获取微信端创建的所有工单数、收费数、费用
	 * @param orgId
	 * @param virtId
	 * @param type
	 * @param date
	 * @param endDate
	 * @return
	 */
	List<Map<String,Object>> getExportAllWxOrder(Map<String, Object> conditions,int type);

	public List<Map<String,Object>> getSendUserData(Integer userId);

	public Integer updateSendUserData(String sendBillIds);
	
	/**
	 * 获取订单明细
	 * @param orgId
	 * @param virtId
	 * @param isFree  ==1获取所有工单数的明细 ==0获取收费工单数的明细
	 * @param type
	 * @param date
	 * @param endDate
	 * @return
	 */
	List<Map<String,Object>> getExportWxAmountOrder(Map<String, Object> conditions, int isFree, int type);

	Page getPeoplecOrderList(Map<String, Object> conditions,int type,int pageNo,int pageSize);

	//获取自动好评工程维修数据
	List<Integer> getAutomaticHighPraiseRepairData();

	Page getBillCommentList(Map<String, Object> conditions,int type,int pageNo,int pageSize);
}
