CustomerMapper.java 9.54 KB
package cn.com.glsx.entmicro.mapper;

import cn.com.glsx.entmicro.entity.Customer;
import cn.com.glsx.entmicro.model.CustomerMagicRopResponse;
import cn.com.glsx.entmicro.model.request.CustListSearchRequest;
import cn.com.glsx.entmicro.model.request.CustomerMergeRequest;
import cn.com.glsx.entmicro.model.request.CustomerStandardRequest;
import cn.com.glsx.entmicro.model.response.*;
import cn.com.glsx.entmicro.model.response.customer.CustomerFollowRpcResponse;
import com.github.pagehelper.Page;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

@Mapper
public interface CustomerMapper extends CommonBaseMapper<Customer> {
    List<StaffFollowResponse> getStaffFollowById(Integer id);

    List<StaffFollowResponse> getStaffFollowByOneId(@Param("oneId")String oneId,@Param("merchantId") Integer merchantId);

    @MapKey("id")
    Map<Integer, BelongCustomerBaseResponse> getCustomerBaseByOneId(@Param("oneId")String oneId,@Param("merchantId") Integer merchantId);

    @MapKey("groupId")
    Map<Integer, CustomerBaseCountResponse> countCustomerBase(@Param("ids") Set<Integer> ids);

    /**
     * userId 查客户
     *
     * @param userid
     * @return
     */
    Customer getCustomerByUserId(String userid);

    int updateOneIdByCust(@Param("oneId") String oneId, @Param("custId") Integer custId);

    int changeOneId(@Param("newOneId") String newOneId,@Param("ids") List<Integer> id);

    void deleteaById(Integer id);

    List<CustomerStandardRequest> findAllCustomerByMerchantId(@Param("merchantId")int merchantId,@Param("userIds") List<String> userIds);

    /**
     * 批量userId查客户
     * @param userid
     * @return
     */
    @MapKey("userid")
    Map<String, Customer> getCustomersByUserId(@Param("ids") List<String> userid);

    CustomerInfo getCustomerById(@Param("custId") Integer custId,@Param("staffId")Integer staffId);

    /**
     * oneId批量查跟进员工
     *
     * @param oneIds
     * @return
     */
    @MapKey("oneId")
    Map<String, CustomerFollowStaffResponse> getCustomerStaffByOneId(@Param("oneIds") List<String> oneIds,@Param("merchantId") Integer merchantId);

    /**
     * oneId批量查跟进员工
     *
     * @param oneIds
     * @return
     */
    @MapKey("oneId")
    Map<String, CustomerFollowStaffResponse> getAllCustomerStaffByOneId(@Param("oneIds") List<String> oneIds,@Param("merchantId") Integer merchantId);

    /**
     * oneId批量查跟进员工(List)
     *
     * @param oneIdList
     * @return
     */
    List<CustomerFollowStaffResponse> getListCustomerStaffByOneId(@Param("merchantIdList") List<Integer> merchantIdList,
                                                                  @Param("oneIdList") List<String> oneIdList,@Param("staffIdList") List<Integer> staffIdList);

    int getCustomerByOneId(@Param("oneId")String oneId, @Param("merchantId") Integer merchantId);

    /**
     * 通过企业员工查询所有客户信息
     *
     * @param userIdList
     * @return
     */
    List<CustomerInfo> getCustomerInfoByUserId(@Param("userIdList") List<String> userIdList, @Param("sex") Byte sex,
                                               @Param("start") Date start, @Param("end") Date end);

    List<CustomerInfoResponse> findCustomerByStaffId(@Param("staffId") Integer integer, @Param("keyword") String keyword, @Param("isMiniPro") Boolean isMiniPro);

    List<CustomerInfoResponse> findCustomerBychantIds(@Param("custSearchRequest") CustListSearchRequest custSearchRequest);

    List<CustomerInfoResponse> findCustomerByStaffIds(@Param("custSearchRequest") CustListSearchRequest custSearchRequest);


    List<Customer> findCustomerByPhones(@Param("phones") List<String> phones, @Param("merchantId") Integer merchantId);

    List<CustomerInfoResponse> findNoAddEntmocroCustByMerchant(@Param("merchantId") Integer merchantId);

    List<CustomerInfoResponse> findNoPhoneCustByMerchant(@Param("merchantId") Integer merchantId);

    int findNoAddEntmocroCustByMerchantCount(@Param("merchantId") Integer merchantId);

    int findNoPhoneCustByMerchantCount(@Param("merchantId") Integer merchantId);

    List<CustomerInfoResponse> findWaitRenewal(@Param("merchantId") Integer merchantId);

    List<CustomerInfoResponse> findWaitRegularMaintain(@Param("merchantId") Integer merchantId);

    Integer findWaitRenewalCount(@Param("merchantId") Integer merchantId);

    int findWaitRegularMaintainCount(@Param("merchantId") Integer merchantId);

    List<CustomerInfoResponse> findMagicCust(@Param("merchantId") Integer merchantId);

    /**
     * 查询魔方客户数
     * @param merchantId
     * @param status
     * @return
     */
    int findMagicCustCount(@Param("merchantId") Integer merchantId,
                           @Param("status") Integer status);

    Customer findPhoneAndMerchantId(@Param("customerPhone") String customerPhone, @Param("merchantid")List<Integer> merchantid);

    int batchUpdateOneId(@Param("customers")List<CustomerMagicRopResponse> customers);

    int batchUpdate(@Param("customers")List<Customer> customers);

    int batchInsert(@Param("customers")List<Customer> customers);

    /**
     * 查询客户是否是企微客户
     *
     * @param phone 手机号码
     * @return
     */
    List<Customer> isEntmicroCustomer(@Param("phone") String phone, @Param("merchantId") Integer merchantId);

    Page<String> selectAllOneId();

    /**
     * 批量oneId查客户,过滤没加员工好友的信息
     *
     * @param oneIdList
     * @param merchantId
     * @return
     */
    List<CustomerNickNameRpcResponse> findByBatchOneId(@Param("oneIdList")List<String> oneIdList,
                                                       @Param("merchantId")Integer merchantId);

    List<CustomerInfoResponse> findCustomerBymergeIds(@Param("mergeIds") List<Integer> mergeIds, @Param("phone") String phone, @Param("merchantId") Integer merchantId, @Param("customerName") String customerName);

    /**
     * 批量补充手机号
     */
    int updatePhoneByUserId(@Param("customer")List<Customer> customer);

    void insertinto(@Param("sql") String toString);
    /**
     * 根据手机号和来源渠道查询客户列表
     *
     * @param phoneList
     * @param merchantId
     * @param addWay
     * @return
     */
    List<Customer> selectCustomerNameByPhone(@Param("phoneList") List<String> phoneList,@Param("merchantId") Integer merchantId,@Param("addWay") String addWay);

    Customer getNotEntmicroCustomerByOneId(@Param("customerMergeRequest")CustomerMergeRequest customerMergeRequest);

    List<CustGroupResponse> filterCustomerChatIdsByStaffIds(@Param("merchantId") Integer merchantId,@Param("staffIds")List<Integer> staffIds);

    List<CustomerInfoResponse> findCusetomerListByMergeIds(@Param("mergeIds")List<Integer> mergeIds,
                                                           @Param("merchantId") Integer merchantId,
                                                           @Param("staffId") Integer staffId);

    //根据客户表id列表查询客户合并表id列表
    List<Integer> getMergeIdList(@Param("customerIds") List<Integer> customerIds, @Param("merchantId")Integer merchantId);

    List<Integer> findCustomerByOneId(@Param("oldOneId") String oldOneId, @Param("merchantId")Integer merchantId);

    List<String> queryOneIdByPhoneNumber(@Param("phone")String phone, @Param("merchantId")Integer merchantId);

    /**
     * 查询门店下的企微客户
     * @param merhcantId
     * @return
     */
    List<Customer> selectCustomerByMerchant(Integer merhcantId);

    void updateCustomerMergeSubscribe(@Param("appId") String appId, @Param("merchantId") Integer merchantId);

    List<String> selectUseridByUnionIdIsNull(@Param("merchantId")Integer merchantId);

    /**
     * userId批量查跟进员工
     *
     * @param userIdList
     * @return
     */
    @MapKey("customerUserId")
    Map<String, CustomerFollowStaffResponse> getCustomerStaffByUserId(@Param("userIdList") List<String> userIdList);

    List<StaffFollowResponse> selectFollowStaffByCustomerPhone(@Param("merchantId")Integer merchantId, @Param("customerPhone")String customerPhone,
                                                               @Param("staffIdList")List<Integer> staffIdList,@Param("userIdList") List<String> userIdList);

    /**
     * 客户主键查跟进人关联
     * @param id
     * @return
     */
    List<Integer> getStaffByCustomerId(@Param("id")Integer id);

    /**
     * unionId查客户
     * @param unionIdList
     * @return
     */
    List<String> selectUseridByUnionId(@Param("unionIdList") List<String> unionIdList);

    /**
     * 批量oneId获取跟进人关联
     * @param oneIdList
     * @param merchantId
     * @return
     */
    List<CustomerFollowRpcResponse> getCustomerFollowByOneIdList(@Param("oneIdList")List<String> oneIdList,
                                                                 @Param("merchantId")Integer merchantId);


    List<CustomerInfoResponse> findAddEntmicroCustomerByPhones(@Param("merchantId") Integer merchantId,@Param("phoneList") List<String> phoneList);

    CustomerInfoResponse findCustomerByUserIdOrOneId(@Param("id") String id, @Param("merchantId") Integer merchantId);

    List<CustomerInfoResponse> findCustomerByOneidList(@Param("oneIdList")List<String> oneIdList,
                                                       @Param("merchantId")Integer merchantId);

    List<String> findUserIdByCustomerId(@Param("customerIds")List<Integer> customerIds);
}