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

import com.gic.haoban.manage.service.entity.hm.TabHaobanHmClerkRelation;
import com.gic.haoban.manage.service.pojo.bo.hm.HmClerkRelationBO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 多人活码(TabHaobanHmClerkRelation)表数据库访问层
 *
 * @author mozhu
 * @since 2022-07-04 15:42:20
 */
public interface TabHaobanHmClerkRelationMapper {



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


    /**
     * 查询hm id和职员id
     *
     * @param hmId
     * @param clerkId
     * @return {@link HmClerkRelationBO }
     * @author mozhu
     * @date 2022-07-07 13:33:22
     */
    TabHaobanHmClerkRelation queryByHmIdAndClerkId(@Param("hmId") Long hmId, @Param("clerkId") String clerkId);

    /**
     * 更新 addnum
     *
     * @param relationId 关系id
     * @param overFlag   是否上限1是0否
     * @return int
     * @author mozhu
     * @date 2022-07-07 13:40:00
     */
    int updateAddNumById(@Param("relationId") Long relationId, @Param("overFlag") Integer overFlag);

    /**
     * 重置
     *
     * @author mozhu
     * @date 2022-07-07 13:53:36
     */
    void resetAddNumAndOverFlag();

    /**
     * 查询职员id
     *
     * @param clerkId      职员id
     * @param enterpriseId 企业标识
     * @return {@link List }<{@link TabHaobanHmClerkRelation }>
     * @author mozhu
     * @date 2022-07-08 14:49:18
     */
    List<TabHaobanHmClerkRelation> queryByClerkId(@Param("clerkId") String clerkId,@Param("enterpriseId") String enterpriseId);

    /**
     * 根据导购id获取hmid
     *
     * @param hmId hm id
     * @return {@link List }<{@link String }>
     * @author mozhu
     * @date 2022-07-08 14:56:59
     */
    List<String> getNumByHmId(@Param("hmId") Long hmId);


    /**
     * 根据hmid 获取导购信息
     *
     * @param hmId hm id
     * @return {@link List }<{@link TabHaobanHmClerkRelation }>
     * @author mozhu
     * @date 2022-07-13 17:04:38
     */
    List<TabHaobanHmClerkRelation> getHmClerkByHmId(@Param("hmId") Long hmId);
    
    List<TabHaobanHmClerkRelation> listHmClerkByHmIdList(@Param("hmIdList") List<Long> hmIdList) ;

    /**
     * 根据hmid 获取导购信息
     * @param hmId
     * @param staffId
     * @return
     */
    TabHaobanHmClerkRelation getHmClerkByHmIdAndStaffId(@Param("hmId")  Long hmId, @Param("staffId")  String staffId);

    /**
     * 更新状态通过id
     *
     * @param status
     * @param relationId
     * @return int
     * @author mozhu
     * @date 2022-07-21 16:32:43
     */
    int updateStatusById(@Param("status")  Integer status, @Param("relationId") Long relationId);

    /**
     * 查询需要删除的数据
     *
     * @param hmId     hm id
     * @param clerkIds 职员id
     * @return {@link List }<{@link TabHaobanHmClerkRelation }>
     * @author mozhu
     * @date 2022-07-26 15:42:07
     */
    List<TabHaobanHmClerkRelation> queryByHmIdNotInClerkIds(@Param("hmId") Long hmId,
                                                            @Param("clerkIds") List<String> clerkIds);


    /**
     * 更新导购名称
     *
     * @param clerkId   导购id
     * @param clerkName 导购名称
     * @param clerkCode 职员代码
     * @return int
     * @author mozhu
     * @date 2022-07-28 13:50:30
     */
    int updateClerkNameByClerkId(@Param("enterpriseId") String enterpriseId,
                                 @Param("clerkId") String clerkId,
                                 @Param("clerkName") String clerkName,
                                 @Param("clerkCode") String clerkCode);

    /**
     * 更改门店名称
     *
     * @param storeId   门店id
     * @param storeName 门店名称
     * @param storeCode 门店code
     * @return int
     * @author mozhu
     * @date 2022-07-28 13:52:35
     */
    int updateStoreNameByStoreId(@Param("enterpriseId") String enterpriseId,
                                 @Param("storeId") String storeId,
                                 @Param("storeName") String storeName,
                                 @Param("storeCode") String storeCode);
    
    /**
     * 
    * @Title: updateByClerkChangeStore
    * @Description: 导购转移门店,更新多人码门店和导购信息
    * @author xugh
    * @param tabHaobanHmClerkRelation
    * @return
    * @throws
     */
    int updateByClerkChangeStore(@Param("enterpriseId")String enterpriseId,
            @Param("clerkId")String clerkId, @Param("clerkCode")String clerkCode, @Param("clerkName")String clerkName,
            @Param("storeId")String storeId, @Param("storeCode")String storeCode, @Param("storeName")String storeName, 
            @Param("oldClerkId") String oldClerkId) ;
}

