package com.goafanti.common.dao;

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

import org.apache.ibatis.annotations.Param;

import com.goafanti.common.model.Admin;
import com.goafanti.common.model.OrganizationContactBook;
import com.goafanti.common.model.User;
import com.goafanti.user.bo.OrgPartnerDetailBo;
import com.goafanti.user.bo.UserBasicInfo;
import com.goafanti.user.bo.UserDownLoadBo;
import com.goafanti.user.bo.UserInterestBo;
import com.goafanti.user.bo.UserPageHomeBo;
import com.goafanti.user.bo.UserPartnerDetailBo;
import com.goafanti.common.model.UserExample;
import com.goafanti.customer.bo.BusinessListBo;
import com.goafanti.customer.bo.CustomerListOut;
import com.goafanti.customer.bo.CustomerOrganizationDetailBo;
import com.goafanti.customer.bo.CustomerPersonalDetailBo;
import com.goafanti.customer.bo.CustomerSimpleBo;
import com.goafanti.customer.bo.FollowBusinessBo;
import com.goafanti.customer.bo.LockingReleaseBo;
import com.goafanti.report.bo.CountMarketingStatisticsBo;
import com.goafanti.report.bo.marketingESBo;
import com.goafanti.report.bo.userDataListBo;

public interface UserMapper {
	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
	 * @mbg.generated  Tue Jun 26 10:23:14 CST 2018
	 */
	long countByExample(UserExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
	 * @mbg.generated  Tue Jun 26 10:23:14 CST 2018
	 */
	int deleteByExample(UserExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
	 * @mbg.generated  Tue Jun 26 10:23:14 CST 2018
	 */
	int deleteByPrimaryKey(String id);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
	 * @mbg.generated  Tue Jun 26 10:23:14 CST 2018
	 */
	int insert(User record);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
	 * @mbg.generated  Tue Jun 26 10:23:14 CST 2018
	 */
	int insertSelective(User record);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
	 * @mbg.generated  Tue Jun 26 10:23:14 CST 2018
	 */
	List<User> selectByExample(UserExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
	 * @mbg.generated  Tue Jun 26 10:23:14 CST 2018
	 */
	User selectByPrimaryKey(String id);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
	 * @mbg.generated  Tue Jun 26 10:23:14 CST 2018
	 */
	int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
	 * @mbg.generated  Tue Jun 26 10:23:14 CST 2018
	 */
	int updateByExample(@Param("record") User record, @Param("example") UserExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
	 * @mbg.generated  Tue Jun 26 10:23:14 CST 2018
	 */
	int updateByPrimaryKeySelective(User record);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table user
	 * @mbg.generated  Tue Jun 26 10:23:14 CST 2018
	 */
	int updateByPrimaryKey(User record);

	UserPageHomeBo selectUserPageHomeBoByUserId(String uid);

	UserDownLoadBo selectUserDownLoadBoByUserId(String id);

	//List<OrgListBo> selectUserByAid(String aid);

	String findUserByNameAndMobile(@Param("name") String name, @Param("mobile") String mobile);

	String findOrgByNameAndMobile(@Param("name") String name, @Param("mobile") String mobile);

	UserPartnerDetailBo findUserPartnerDetail(String uid);

	OrgPartnerDetailBo findOrgPartnerDetail(String uid);

	Long selectNumberByPrimaryKey(String userId);
	
	List<UserPartnerDetailBo> findUserPartner();
	
	User selectByMobieAndType(String mobile, Integer type);
	
	/**
	 * 根据客户模糊搜索
	 * @param name
	 * @return
	 */
	List<CustomerSimpleBo> findCustomerByName(@Param("identifyName")String identifyName);

	/**
	 * 判断客户是否存在
	 * @param name
	 * @return
	 */
	int judgeCustomerByName(@Param("identifyName")String identifyName);
	
	/**
	 * 查询单位客户详情
	 * @param uid 用户ID
	 * @return
	 */
	CustomerPersonalDetailBo findPersonalCustomerDetail(@Param("uid")String uid);
	
	
	/**
	 * 查询单位客户详情
	 * @param uid 用户ID
	 * @return
	 */
	CustomerOrganizationDetailBo findOrganizationCustomerDetail(@Param("uid")String uid);

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

	/**
	 * 查看客户联系人列表
	 * @param uid
	 * @return
	 */
	List<OrganizationContactBook> findCustomerContacts(@Param("uid")String uid,@Param("aid")String aid);

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

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

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

	/**
	 * 查询用户
	 * @param id
	 * @param identifyName 认证用户
	 * @param mobile 手机号码
	 * @param type 用户类型 0-个人 1-单位
	 * @param source 来源 0-注册 1-录入
	 * @return 
	 * @param nickname 昵称
	 */
	List<User> checkUser(@Param("id")String id,@Param("identifyName")String identifyName, @Param("mobile")String mobile,
			@Param("type")Integer type,@Param("source") Integer source,@Param("nickname") String nickname);


	List<UserInterestBo> userInterest(String uid);


	/**
	 * 查询用户基本信息
	 * @param id
	 * @return
	 */
	UserBasicInfo selectBaseInfo(@Param("id")String id);

	/**
	 * 根据用户编号
	 * @param easemobName
	 * @return
	 */
	User selectByNumber(@Param("easemobName")String easemobName);
	
	List<Admin> findAdminName(String aid);
	
	int updateEnteringAudit(@Param("id")String id,@Param("auditStatus")Integer auditStatus,@Param("auditOpinion")String auditOpinion);

	int updateRefusedCustomer(@Param("id")String id,  @Param("nickname")String nickname, @Param("mobile")String mobile, @Param("societyTag")String societyTag);

	/**
	 * 查看客户锁定的业务
	 * @param uid 客户ID
	 * @param aid 管理员ID
	 * @param businessProjectId 业务项目的ID
	 * @param type 锁定类型  0-客户  1-业务
	 * @param status 锁定状态 0-锁定 1-待释放 2-已释放
	 * @return
	 */
	List<LockingReleaseBo> selectLockedProject(@Param("uid")String uid,@Param("aid")String aid,@Param("businessProjectId")String businessProjectId, @Param("type")Integer type,@Param("status")Integer status);

	List<CustomerSimpleBo> selectPrivateCustomerByName(@Param("name")String name,@Param("aid")String aid);

	List<CustomerSimpleBo> selectSignedCustomerByName(@Param("name")String name,@Param("aid")String aid);
	
	List<User> selectUserByRoleName(@Param("roleName1")String roleName1,@Param("roleName2")String roleName2);
	
	void updateReleaseLock(String time);

	marketingESBo marketingStatistics(@Param("id")String id, @Param("dailyStart")String dailyStart, @Param("dailyEnd")String dailyEnd);

	marketingESBo marketingDepStatistics(@Param("depId")String depId, @Param("dailyStart")String dailyStart, @Param("dailyEnd")String dailyEnd);

	CountMarketingStatisticsBo countmarketingDepStatistics(@Param("depId")String depId, @Param("dailyStart")String dailyStart, @Param("dailyEnd")String dailyEnd);

	int checkCustomerInformation(String uid);

	void updateDimissionTransfer(@Param("aid")String aid, @Param("transferId")String transferId);

	List<userDataListBo> userDataStatistics(@Param("depId")String depId);

	userDataListBo userDataStatisticsCount(@Param("depId")String depId);

	int UserReceiveCount( @Param("aid")String aid);

	int getAidAndUser(@Param("uid")String uid,@Param("aid") String aid);

	 List<CustomerListOut> privateUnitCustomerList(@Param("params")Map<String, Object> params);

	int pushUserGuidance(@Param("id")String id, @Param("guidance")Integer guidance);

	/**
	 * 
	 * @param aid   归属人
	 * @param level 等级
	 * @param source 来源
	 * @param transferTime 转换时间
	 * @param shareType 私有标示
	 * @param list  用户id列表
	 */
	void updateList(@Param("aid")String aid,@Param("level")Integer level, @Param("source")Integer source,
			@Param("transferTime")Date transferTime,@Param("shareType")Integer shareType,@Param("list")List<String> list);

	int checkUserMax(String aid);

	int checkLock(@Param("uid")String uid);

	void updateShareType(@Param("uid")String uid,@Param("aid")String aid);

	void updateRelease(String orderNo);

	
	
}