package com.palmnest.dao.estateserve;

import com.palmnest.application.bean.Page;
import com.palmnest.application.dto.AppUserBindInfoDto;
import com.palmnest.dao.GenericDao;
import com.palmnest.model.User;
import com.palmnest.model.estateserve.AppUser;

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

/**
 * 用户管理DAO
 *
 * @author ldb
 */
public interface AppUserDao extends GenericDao<AppUser, Integer> {

	/**
	 * 查询会员用户信息
	 *
	 * @param developId 微信公众号原始ID
	 * @param openId    微信用户OpenId
	 * @return
	 */
	public AppUser getAppUserByOpenId(String developId, String openId);

	/**
	 * 根据手机号码查询用户
	 *
	 * @param userMobile
	 * @return
	 */
	public AppUser getAppUsersByPhone(String userMobile);

	/**
	 * 获取管理员管理的用户集合
	 *
	 * @param userId 管理员ID
	 * @return
	 */
	public Page queryAppUserList(int userId, int virtualId, int pageNo, int pageSize);

	/**
	 * 根据企业ID和状态查询待审核和审核通过的人数
	 *
	 * @param virtualArchId
	 * @param status
	 * @return
	 */
	public Integer getAppUserNonCheckedCount(String virtualArchId, String status);

	/**
	 * 根据企业+角色
	 * 获取用户信息集合信息
	 *
	 * @param roleType
	 * @return
	 */
	public List<AppUser> getAppUserByRoleType(String roleType, int virtualId);

	public List<AppUser> getAppUserByVirId(int virtualId);

	/**
	 * 获取该项目下所有角色类型用户
	 *
	 * @param orgId
	 * @return
	 */
	List<AppUser> getUserByOrgIdAndRoleType(String orgId, String roleTypes);

	/**
	 * 订餐-账号列表
	 *
	 * @param paramets
	 * @param pageSize
	 * @param pageNo
	 * @return
	 */
	Page findList(Map<String, Object> paramets, int pageSize, int pageNo);

	/**
	 * 新增数据时调用,获取用户id(服务之窗用户)
	 *
	 * @return
	 */
	public Integer getUserId();

	/**
	 * 获取员工编号(自增序列)
	 *
	 * @return
	 */
	public Integer getUserNumer();

	/**
	 * 根据手机号码和项目id查询用户
	 *
	 * @param userMobile
	 * @return
	 */
	public AppUser getAppUsersByPhoneAndOrg(String userMobile, Integer orgId);

	/**
	 * 根据微信用户和项目id查询用户
	 *
	 * @param wxUserId
	 * @return
	 */
	public AppUser getAppUserByWxUserAndOrg(Integer wxUserId, Integer orgId);

	/**
	 * 根据手机号码和项目id查询用户
	 *
	 * @param userMobile
	 * @return
	 */
	public AppUser getAppUsersByPhoneAndOrg(String userMobile, String orgId, String isEnabled);

	public void updateAppUser(Integer userId, Integer wxUserId, Integer orgId);

	/**
	 * 获取以下项目下且wxUserId不为空的wxUser
	 *
	 * @param orgIds
	 * @return
	 */
	List<AppUser> getWxUserByOrgIds(String orgIds);

	/**
	 * 获取该项目下所有有效的用户
	 *
	 * @param orgId
	 * @return
	 */
	List<AppUser> getAppUserByOrgId(Integer orgId);

	/**
	 * 根据用户id修改这些用户的积分
	 *
	 * @param map
	 * @return
	 */
	int updateAppUserByUserIds(Map<String, String> map);

	AppUser getAppUserByLingLingId(String lingLingId);

	public AppUser getUserByVicIdAndMobile(Integer virtualArchId, String mobile);

	List<Map<String, Object>> getWhiteUserByMobileAndOrg2(String mobile, Integer publicId);

	List<Map<String, Object>> getWeiXiaoAppUsersByIds(String userIds, Integer orgId);

	List<Map<String, Object>> getUserMobileAndDepName(Integer orgId);

	List<AppUser> getAppUserByIds(String userIds);

	List<AppUser> getWhiteUserByMobile(String mobile);

	List<AppUser> countOrgWhiteUser(String[] orgIds);

	String getUserMealcard(String userMobile);

	User getByAccount(String account);

	AppUser getWhiteUserByMobileAndVirt(Integer virId, String employeePhone);
	
	AppUser getWhiteUserByMobileAndOrgId(Integer orgId, String employeePhone);

	/**
	 * 获取能够参会的参会人信息
	 *
	 * @param virtId
	 * @param name
	 * @return
	 */
	List<Map<String, Object>> getVirtDeptUser(Integer virtId, String name);

	List<Map<String, Object>> getGroupUser(Integer groupId, Integer orgId,String name);
	
	List<Map<String, Object>> getNotGroupUser(Integer groupId, Integer orgId,String name);
	/**
	 * 根据项目、openid获取绑定的openid
	 */
	AppUserBindInfoDto getByOrgIdAndOpenId(Integer orgId,String openId);
	
	/**
	 * 从新框架中获取用户
	 * @param userId
	 * @return
	 */
	AppUser findUserByNewFramework(Integer userId,String database);
	
	/**
	 * 获取项目下所有的用户
	 * @param orgIds
	 * @return
	 */
	List<Map<String, Object>> getAllUserByOrgIds(String orgIds,String userIds,String openIds);
	
	AppUser findLoginUserByOpenId(Integer orgId,String openId);
	
}
