package com.gic.haoban.manage.service.dao.mapper;

import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation;
import com.gic.haoban.manage.service.entity.ext.MemberStaffRelExtDO;
import org.apache.ibatis.annotations.Param;

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

public interface TabHaobanStaffClerkRelationMapper {

    int insert(TabHaobanStaffClerkRelation record);

    TabHaobanStaffClerkRelation selectByPrimaryKey(String staffClerkRelationId);

    List<StaffClerkRelationDTO> listBindCode(@Param("wxEnterpriseId") String wxEnterpriseId,
                                                   @Param("enterpriseId") String enterpriseId,
                                                   @Param("clerkCodeList") Set<String> clerkCodeList);

    List<StaffClerkRelationDTO> listBindCodeByStaffId(@Param("enterpriseIdList") List<String> enterpriseIdList, @Param("staffId") String staffId);

    StaffClerkRelationDTO getOneByClerkId(@Param("clerkId") String clerkId,@Param("wxEnterpriseId") String wxEnterpriseId);
    
    StaffClerkRelationDTO getByCodeAndEnterpriseId(@Param("clerkCode") String clerkCode, @Param("enterpriseId") String enterpriseId);
    StaffClerkRelationDTO getStaffClerkRelationDTO(@Param("clerkCode") String clerkCode, @Param("enterpriseId") String enterpriseId);

    List<StaffClerkRelationDTO> listByClerkIds(@Param("clerkIds") List<String> clerkIds,   @Param("wxEnterpriseId") String wxEnterpriseId);
    
    StaffClerkRelationDTO getOneByStoreIdAndStaffId(@Param("storeId") String storeId, @Param("staffId") String staffId);

    StaffClerkRelationDTO getByStaffAndClerk(@Param("staffId") String staffId,@Param("clerkId") String clerkId) ;


    int changeStatusByClerkId(@Param("clerkId") String clerkId, @Param("status") Integer status);

    //无效接口删除
//    void delByStoreIdAndCode(@Param("storeId") String storeId, @Param("clerkCode") String clerkCode);

    /**
     * 解绑
     */
    int cleanStaffDepart(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("staffIds") List<String> staffIds);

    int delByPrimaryKey(@Param("staffClerkRelationId") String staffClerkRelationId);

    void delByClerkId(@Param("clerkId") String clerkId);

    List<StaffClerkRelationDTO> listByEnterpriseIdAndStaffid(@Param("enterpriseId") String enterpriseId, @Param("staffId") String staffId);

    List<StaffClerkRelationDTO> lisByStaffId(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("staffId") String staffId, @Param("storeIdList") List<String> storeIdList);

    //无效接口删除
//    StaffClerkRelationDTO getByCodeAndStoreId(@Param("clerkCode") String clerkCode, @Param("storeId") String storeId);

    List<String> listByWxEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId);

    List<StaffClerkRelationDTO> pageByWxEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId);
    
    
    /**
     * 查询有关联的员工id列表
     */
    List<String> listRelationsStaffId(@Param("staffIdList") Set<String> staffIdList);
    
    /**
     * 已使用的门店id列表
     */
    List<StaffClerkRelationDTO> listBindStoreIdByEnterpriseId(String enterpriseId);

    /**
     * 删除绑定根据门店
     */
    void delByStoreIds(@Param("storeIds") Set<String> storeIds);

    /**
     * 批量查询会员与导购关系并且返回关联信息
     */
    List<MemberStaffRelExtDO> listMemberStaffRelNew(
            @Param("memberIdList") List<String> memberIdList,
            @Param("clerkIdList") List<String> clerkIdList,
            @Param("enterpriseId") String enterpriseId, @Param("wxEnterpriseId") String wxEnterpriseId);

    /**
     * 根据导购查询wxuserid
     */
    List<String> listWxUserIdByClerkIds(@Param("clerkIds") List<String> clerkIds,
                                        @Param("wxEnterpriseId") String wxEnterpriseId , @Param("type") int type);

    /**
     * id wx用户id列表
     */
    List<StaffClerkRelationDTO> listIdsByWxUserIds(@Param("wxUserIds") List<String> wxUserIds,
                                                   @Param("wxEnterpriseId") String wxEnterpriseId,
                                                   @Param("enterpriseId") String enterpriseId , @Param("type")int type);

    /**
     * 更新联系我状态
     */
    int updateOpenConcatFlagById(@Param("openConcatFlag") Integer openConcatFlag, @Param("staffClerkRelationId") String staffClerkRelationId);

    /**
     * 通过openuserid 不在范围内 查询id
     */
    List<StaffClerkRelationDTO> listIdsByNotInWxOpenUserIds(@Param("wxOpenUserIds") List<String> wxOpenUserIds,
                                                            @Param("wxEnterpriseId") String wxEnterpriseId,
                                                            @Param("enterpriseId") String enterpriseId);


    /**
     * 通过userid 不在范围内 查询id
     */
    List<StaffClerkRelationDTO> listIdsByNotInWxUserIds(@Param("wxUserIds") List<String> wxUserIds,
                                                        @Param("wxEnterpriseId") String wxEnterpriseId,
                                                        @Param("enterpriseId") String enterpriseId);

    void deleteByEnterpriseId(@Param("enterpriseId") String enterpriseId);

    int getBindByStaffIdAndEnterpriseId(@Param("enterpriseId") String enterpriseId, @Param("staffId") String staffId);

    List<StaffClerkRelationDTO> listManageBindByStaffId(@Param("staffId") String staffId);

    List<StaffClerkRelationDTO> listByStoreIds(@Param("wxEnterpriseId") String wxEnterpriseId,@Param("storeIds") List<String> storeIds);

    List<String> listAllClerkIdsByEnterpriseId(@Param("enterpriseId") String enterpriseId);

    /**
     * 根据staffId查询gic品牌id
     * @param wxEnterpriseId 企业微信id
     * @param staffIdList 成员id数组
     * @return
     */
    List<StaffClerkRelationDTO> listByWxEnterpriseIdAndStaffId(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("staffIdList") Set<String> staffIdList);

    List<StaffClerkRelationDTO> listByStaffIdsForClerk(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("staffIdList") Set<String> staffIdList);

    List<String> listAllStaffIdByEnterpriseId(@Param("enterpriseId") String enterpriseId,@Param("wxEnterpriseId") String wxEnterpriseId);

    /**
     * 查询成员离职是关联的导购
     * @param staffId
     * @param delTime
     * @return
     */
    List<String> taskoverClerkIdList(@Param("staffId")String staffId, @Param("delTime") Date delTime) ;

    List<TabHaobanStaffClerkRelation> taskoverClerkIdListAll(@Param("staffId")String staffId) ;
}