package com.goafanti.customer.service;

import com.goafanti.common.bo.Result;
import com.goafanti.common.bo.userDaysBo;
import com.goafanti.common.error.BusinessException;
import com.goafanti.common.model.Admin;
import com.goafanti.common.model.OrganizationContactBook;
import com.goafanti.common.model.User;
import com.goafanti.common.model.UserMid;
import com.goafanti.core.mybatis.page.Pagination;
import com.goafanti.customer.bo.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.web.multipart.MultipartFile;

import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Set;

public interface CustomerService {
	/**
	 * 私有个人客户列表查询
	 * @param pageSize
	 * @return
	 */

	Pagination<CustomerListOut> listPrivatePersonalCustomer(CustomerListIn cli, Integer pageNo, Integer pageSize);
	/**
	 * 公共个人客户列表查询
	 * @param pageSize
	 * @return
	 */
	Pagination<CustomerListOut> listPublicPersonalCustomer(CustomerListIn cli, Integer pageNo, Integer pageSize);


	/**
	 * 所有个人客户列表查询
	 * @param pageSize
	 * @return
	 */
	Pagination<CustomerListOut> listAllPersonalCustomer(CustomerListIn cli, Integer pageNo, Integer pageSize);

	/**
	 * 管理个人客户查询(所属人同部门客户管理)
	 * @param pageSize
	 * @return
	 */
	Pagination<CustomerListOut> listAllManagePersonalCustomer(CustomerListIn cli, Integer pageNo, Integer pageSize);

	/**
	 * 私有单位客户列表查询
	 * @return
	 */
	Pagination<CustomerListOut> listPrivateOrganizationCustomer(CustomerListIn cli,Integer sort,Integer sortType,Integer power, Integer pageNo, Integer pageSize);

	/**
	 * 公共单位客户列表查询
	 * @param pageSize
	 * @return
	 */
	Pagination<CustomerListOut> listPublicOrganizationCustomer(CustomerListIn cli, Integer pageNo, Integer pageSize);


	/**
	 * 所有单位客户列表查询
	 * @param pageSize
	 * @return
	 */
	Pagination<CustomerListOut> listAllOrganizationCustomer(CustomerListIn cli, Integer pageNo, Integer pageSize);

	/**
	 * 管理单位客户列表查询
	 * @param pageSize
	 * @return
	 */
	Pagination<CustomerListOut> listAllManageOrganizationCustomer(CustomerListIn cli, Integer pageNo, Integer pageSize);

	/**
	 * 使用客户名检索客户
	 * @param name 客户名称
	 * @return
	 */
	List<CustomerSimpleBo> findCustomerByName(String name);

	/**
	 * 使用客户名检索私有客户
	 * @param name
	 * @return
	 */
	List<CustomerSimpleBo> getPrivateCustomerByName(String name);

	/**
	 * 使用客户名称检索已签单客户
	 * @param name
	 * @return
	 */
	List<CustomerSimpleBo> getSignedCustomerByName(String name);


	/**
	 * 客户全查询
	 * @param name
	 * @return
	 */
	Object getUserByName(String name);

	/**
	 * 判断是否存在某个单位客户
	 * @param name
	 * @return
	 */
	int judgeCustomerByName(String name);

	/**
	 *
	 * @return
	 */
	int addCustomer(InputAddCustomer in)  throws BusinessException;


    void checkUserName(InputAddCustomer in);

    /**
	 * 查询单位客户详情
	 * @param uid 用户ID
	 * @return
	 */
	CustomerPersonalDetailBo findPersonalCustomerDetail(String uid);


	/**
	 * 查询单位客户详情
	 * @param uid 用户ID
	 * @return
	 */
	CustomerOrganizationDetailBo findOrganizationCustomerDetail(String uid);

	/**
	 * 修改单位客户信息
	 * @param bo
	 * @return
	 */
	int updateOrganizationCustomer(CustomerOrganizationDetailBo bo);

	/**
	 * 修改个人客户信息
	 * @param bo
	 * @return
	 */
	int updatePersonalCustomer(CustomerPersonalDetailBo bo);



	/**
	 * 查看客户账户信息
	 * @param uid 客户ID
	 * @return
	 */
	User findUserAccountDetail(String uid);

	/**
	 * 更新用户基本信息
	 * @param user
	 */
	int updateUserAccount(User user);

	/**
	 * 客户联系人列表
	 * @param uid
	 * @return
	 */
	List<OrganizationContactBook> findCustomerContacts(String uid,Integer type);

	/**
	 * 添加拜访记录
	 * @param fbb
	 * @param mainStatus 0辅助跟进 1主要跟进
	 */
	int addFollow(FollowBusinessBo fbb,String ufid,Integer mainStatus,Integer type,String pid) throws BusinessException;



	/**
	 * 查询拜访记录详情
	 * @param followId
	 * @return
	 */
	FollowBusinessBo findFollowById(String followId);

	/**
	 * 查询单词拜访推进的客户意向
	 * @param followId
	 * @return
	 */
	List<BusinessListBo> findBusinessByFollowId(String followId);

	/**
	 * 修改拜访记录
	 * @param fbb
	 */
	int updateFollow(FollowBusinessBo fbb)  throws BusinessException;

	/**
	 * 查询客户的所有联系人
	 * @param uid
	 * @return
	 */
	Set<OrganizationContactBook> findAllContacts(String uid);

	/**
	 * 更新客户联系人
	 * @param ocbList
	 * @return
	 */
	int updateCustomerContacts(List<OrganizationContactBook> ocbList,String uid);

	/**
	 * 删除拜访记录
	 * @param followId
	 * @return
	 */
	int deleteFollow(String followId);

	/**
	 * 检查客户业务
	 * @param boSet
	 * @param existRows
	 */
	void checkCustomer(Set<CustomerExcelBo> boSet,Set<Integer> existRows, Set<Integer> filterRows);

	/**
	 * 保存上传数据
	 * @param boSet
	 */
	int saveUploadData(Set<CustomerExcelBo> boSet);

	/**
	 *  通过操作类型更新客户
	 * @param uid
	 * @param operatorType
	 * @return
	 */
	List<String> updateByOperatorType(String uid,String aid,String oldAid,Integer operatorType,Integer data);

	/**
	 * 客户统计
	 * @param sDate
	 * @param eDate
	 * @return
	 */
	Pagination<StatisticBo> customerStatistics(Date sDate, Date eDate, String depNo, String businessGlossoryId, Integer pageNo, Integer pageSize);

	/**
	 * 业务进度统计
	 * @param sDate
	 * @param eDate
	 * @return
	 */
	Pagination<StatisticBo> businessStatistic(Date sDate, Date eDate, String depNo, String businessGlossoryId,Integer pageNo, Integer pageSize);

	/**
	 * 拜访统计
	 * @param sDate
	 * @param eDate
	 * @return
	 */
	Pagination<StatisticBo> followStatistic(Date sDate, Date eDate, String depNo, Integer pageNo, Integer pageSize);

	/**
	 * 查询我的业务列表
	 * @param blo
	 * @return
	 */
	Pagination<BusinessListBo> listBusiness(BusinessListBo blo,Integer pageNo,Integer pageSize);

	/**
	 * 查询所有的业务列表
	 * @return
	 */
	Pagination<BusinessListBo> listAllBusiness(BusinessListBo blo, Integer pageNo, Integer pageSize);

	/**
	 * 业务管理列表
	 * @param blo
	 * @return
	 */
	Pagination<BusinessListBo> listManageBusiness(BusinessListBo blo,Integer pageNo,Integer pageSize);

	/**
	 *  意向字典
	 * @return
	 */
	List<BusinessListBo> findBusinessGlossory();

	/**
	 *
	 * @param uid 客户ID
	 * @param businessProjectId 业务项目的ID
	 * @return
	 */
	int judgeBusiness(String uid,String businessProjectId);

	/**
	 * 添加意向服务和跟进记录
	 * @param bfb
	 */
	void addBusinessAndFollow(BussinessFollowBo bfb)  throws ParseException ;

	/**
	 * 查询业务列表
	 * @param uid 客户ID
	 * @param aid 营销员ID
	 * @return
	 */
	List<BusinessListBo> findBusinessByUAid(String uid,String aid);

	/**
	 * 查询锁定的业务列表
	 * @param uid
	 * @param aid
	 * @return
	 */
	List<BusinessListBo> findLockedBusinessByUAid(String uid,String aid);

	/**
	 * 查看业务意向详情
	 * @param businessId
	 * @return
	 */
	BussinessFollowBo findBusinessDetail(String businessId);

	/**
	 * 修改业务意向
	 * @param bfb
	 * @return
	 */
	int updateBusiness(BussinessFollowBo bfb);

	/**
	 * 跟进单个业务意向
	 * @param bfb
	 * @return
	 */
	int addFollowOneBusiness(BussinessFollowBo bfb) throws ParseException;

	/**
	 * 查询某个客户的一个意向的当次拜访
	 * @param ufbId
	 * @return
	 */
	BussinessFollowBo findFollowOneBusiness(String ufbId);

	/**
	 * 修改某个客户的一个意向的当次拜访
	 * @param bfb
	 * @return
	 */
	int updateFollowOneBusiness(BussinessFollowBo bfb);

	/**
	 * 添加单个联系人
	 * @param ocb
	 * @return
	 */
	int addOneContact(OrganizationContactBook ocb);

	/**
	 * 删除业务
	 * @param businessId
	 * @return
	 */
	int deleteBusiness(String businessId);

	/**
	 * 停止业务
	 * @param businessId
	 * @return
	 */
	int updateBusinessToStop(String businessId);

	/**
	 * 删除跟进记录中间表记录
	 * @param ufbId
	 * @return
	 */
	int deleteFollowOneBusiness(String ufbId);

	/**
	 * 删除单个联系人
	 * @param ocbId
	 * @return
	 */
	int deleteOneContact(String ocbId);

	List<Admin> findAdminName();

	int updatePersonalCustomerz(CustomerPersonalDetailBo bo);

	Pagination<CustomerListOut> findEnteringAudit(CustomerListOut clo, Integer pageNo, Integer pageSize);

	Pagination<CustomerListOut> findEnteringAuditIsNo(CustomerListOut clo, Integer pageNo, Integer pageSize);

	int updateEnteringAudit(User bo);

	/**
	 * 修改为主要联系人
	 * @param ocbId
	 * @return
	 */
	int updateMainContact(String ocbId,String uid);

	/** 修改拒绝客户信息 **/
	int updateRefusedCustomer(String id,String nickname, String mobile, String societyTag);

	/**
	 * 签单的单位客户
	 * @param cli
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	Pagination<CustomerListOut>  listSignOrganizationCustomer(CustomerListIn cli, Integer pageNo, Integer pageSize);

	/**
	 * 签单的个人客户
	 * @param cli
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	Pagination<CustomerListOut> listSignPersonalCustomer(CustomerListIn cli, Integer pageNo, Integer pageSize);

	/**
	 * 查询需要释放的客户
	 * @param uid 客户Id
	 * @return
	 */
	List<LockingReleaseBo> selectWaitReleaseCustomer(String uid);

	List<LockingReleaseBo> selectWaitReleaseBusiness(String uid);

	void updateReleaseLock(Date releaseTime);

	/**
	 * 查询客户的锁定业务
	 * @param uid
	 * @return
	 */
	List<LockingReleaseBo> selectLockedProject(String uid);
	/**
	 * 再次签订项目任务
	 * @param aid
	 * @return
	 */
	int updateAgainProjectTask(String uid, String projectId, String aid);
	/**
	 * 客户资料转交
	 * @param id
	 * @param aid
	 * @return
	 */
	int updateInformationMaintainerr(String id, String aid);
	/**
	 * 个人客户资料列表
	 * @param cli
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	Pagination<CustomerListIn> listCustomerInformation(CustomerListIn cli, Integer pageNo, Integer pageSize);
	/**
	 * 部门客户资料列表
	 * @param cli
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	Pagination<CustomerListIn> listDepCustomerInformation(CustomerListIn cli, Integer pageNo, Integer pageSize);
	void updatePendingReleaseLock(List<LockingReleaseBo> newList);
	List<LockingReleaseBo> selectPendinglockUserList();
	int updateUserLevel(User u);
	public  Double countIntegrity(CustomerOrganizationDetailBo bo);
	XSSFWorkbook privateUnitCustomerOutXls(CustomerListIn cli ,Integer sort,Integer sortType,Integer pageNo, Integer pageSize);
	int customerHandOver(String userIds, String receiveId);

	List<transferListBo> transferList(String uid);
	int updatePrivateBusinessTransfer(String inputId, String uid, String pid);
	int pushReleaseUser(String id);
	/**
	 *
	 * @param id
	 * @return
	 */
	List<userDaysBo> selectReleaseUserDays(String id);

	List<userDaysBo> selectChannelUserDays(String id);

	int addGuidance(String followId, String guidance);
	/**
	 * 查看跟进记录列表
	 * @param pageNo
	 * @param pageSize
	 * @return
	 */
	Pagination<FollowListBo> listFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessGlossoryId,Integer type);
	int pushGuidance(String uid);

	boolean checkMax(String uid,String aid);
	/**
	 *
	 * @param list 释放客户
	 * @throws InterruptedException
	 */
	void pushReleaseLog(List<LockingReleaseBo> list) throws InterruptedException;
	Object listChannelCustomer(InputListChannel in);
	/**
	 *
	 * @param uids 用户集
	 * @param receiveId 接受者
	 * @param remarks	备注
	 * @param type	0总监分配 1经理分配 2回退
	 * @return
	 */
	Object pushChannelDeliver(List<String> uids, String receiveId, String remarks, Integer type);
	Object getChannelCustomerByName(String name);
	boolean checkChannel(List<String> uids);
	boolean checkBeforeChannel(String uid);
	boolean checkRecovery(List<String> uids);
	List<userDaysBo> selectChannelNotFollow(String string);
	Object listChannelCounts(InputChannelCounts in);
	int updateUserName(String uid, String userName);
	List<UserNamesListBo> listUserName(String uid);
	boolean checkUserName(String uid,String userName);
	Object getUserByNames(String name,Integer type, Integer pageNo, Integer pageSize);

	Pagination<OutUserMianProducts> mainProductsList(InputMainProductsList in) ;

	List<OutUserDateLogList> userDateLogList(String uid);

	int updateuserBusinessScope(String id, String businessScope);

	boolean checkData(String uid, String aid);

    int updateUserDate(InputUserData in );

	Pagination<OutChannelListBo> channelUserList(InputChannelListBo in);

    List<?> selectChannelUserList(InputChannelListBo in);

	/**
	 *
	 * @param uid
	 * @return 0 正常 1 被其他人领取 2领取上限
	 */
	Integer receiveEveryDay(String uid);

    int pushReceiveAsChannel(String uid);

    boolean checkOrgCode(String orgCode,String aid);

	boolean checkOrgCode(String orgCode);

    Integer queryUserMax();

    Pagination<?> selectUserLastSign(InputSelectUserLastSignBo in);

	Result selectUserLastSignExport(InputSelectUserLastSignBo in);


	/**
	 * 判断管理员角色
	 * @param aid
	 * @param roleType
	 * @return
	 */
	boolean checkAid(String aid, Integer roleType);


	void transferUser(List<String> uList, String aid, String uid);



	Result importExcel(MultipartFile file);

	Object getRestrictCustomerByName(String name);

    Object selectMyUser(SelectMyUserBo in);

	Object selectMyUserDetails(String id);
	UserArchivesDetails selectUserByUid(String id);

	Object getPublicReleaseList(String id);

	void updateUserShareType(List<LockingReleaseBo> newList);

	Object selectUserLevel();

    Object updateMid(UserMid in);

    Object checkUser(String id);

	Object updateAndReceiveCustomer(InputUpdateAndReceiveCustomer in);

}
