package com.goafanti.common.dao;

import com.goafanti.admin.bo.AdminCustomerBo;
import com.goafanti.app.bo.UserBasicInfo;
import com.goafanti.common.bo.OutUser;
import com.goafanti.common.bo.userDaysBo;
import com.goafanti.common.model.Admin;
import com.goafanti.common.model.AdminUserCount;
import com.goafanti.common.model.OrganizationContactBook;
import com.goafanti.common.model.User;
import com.goafanti.customer.bo.*;
import com.goafanti.report.bo.CountMarketingStatisticsBo;
import com.goafanti.report.bo.marketingESBo;
import com.goafanti.report.bo.userDataListBo;
import com.goafanti.user.bo.*;
import org.apache.ibatis.annotations.Param;

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

/**
 * (User)表数据库访问层
 *
 * @author makejava
 * @since 2024-11-28 15:18:27
 */
public interface UserMapper {

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    User queryById(String id);




    /**
     * 新增数据
     *
     * @param user 实例对象
     * @return 影响行数
     */
    int insert(User user);





    /**
     * 修改数据
     *
     * @param user 实例对象
     * @return 影响行数
     */
    int update(User user);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 影响行数
     */
    int deleteById(String id);


    /**
     * 新增数据
     *
     * @param user 实例对象
     * @return 影响行数
     */
    int insertSelective(User user);

    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);

    /**
     * 根据客户模糊搜索
     * @return
     */
    List<CustomerSimpleBo> findCustomerByName(@Param("identifyName")String identifyName);

    /**
     * 判断客户是否存在
     * @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,@Param("type")Integer type);

    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, @Param("date") Date date);

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

    userDataListBo userDataStatisticsCount(@Param("deps")List<String> deps);

    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,
                    @Param("data")Integer data);

    int checkUserMax(String aid);

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

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


    String checkRoleMax(String aid);

    void insertBatch(List<InputUserChannel> list);

    User selectByName(String userName);

    int updatechannelCustomerDeliver(@Param("list")List<String> list, @Param("aid")String aid);

    void updateReleaseUserChannel(@Param("list")List<userDaysBo> newCList, @Param("type")Integer type);

    String checkBeforeChannel(String uid);

    List<CustomerSimpleBo> getUserByName(String name);

    List<OutUser> getAllUser();


    List<CustomerListOut> selectPrivateOrganizationCustomerList(Map<String,Object> map);


    List<OutChannelListBo> channelUserList(Map<String, Object> params);

    List<AdminCustomerBo> selectNoChannelByaids(@Param("admins")List<AdminCustomerBo> admins,@Param("startTime") String startTime,@Param("endTime") String endTime);
    List<AdminCustomerBo> selectChannelByaids(@Param("admins")List<AdminCustomerBo> admins,@Param("startTime") String startTime,@Param("endTime") String endTime);
    List<AdminCustomerBo> selectFirstInterviewByaids(@Param("admins")List<AdminCustomerBo> admins,@Param("startTime") String startTime,@Param("endTime") String endTime);

    List<String> selectBelongByaid(String aid);

    AdminUserCount selectByaidAndDate(@Param("aid") String aid, @Param("startTime") String startTime,
                                      @Param("endTime")String endTime);

    List<AdminUserCount>selectListByaidAndDate(String  aid);

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

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

    UserArchivesDetails selectUser(String id);

    List<PublicReleaseListBo> getPublicReleaseList(String uid);

    void updateUserShareType(List<LockingReleaseBo> newList);

    List<LockingReleaseBo > selectSignReleaseUser(String id);

    int selectUserLevel(String aid);

    List<User> selectClueUserByClueType(String aid);

    void updateClueUserRelease(List<User> updateList);



}

