package cn.iocoder.yudao.module.crm.dal.mysql.crmcustomer;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.crm.controller.admin.crmcustomer.vo.CrmCustomerPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.crmcustomer.vo.CrmCustomerRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.crmcustomer.vo.CustomerStatisticRespVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.crmcustomer.CrmCustomerDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 客户 Mapper
 *
 * @author yshop
 */
@Mapper
public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {

//    default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO reqVO, List<Long> ids) {
//
//
//        return selectPage(reqVO, new LambdaQueryWrapperX<CrmCustomerDO>()
//                //.eq(CustomerTypesEnum.OPEN.getValue().equals(reqVO.getType()),)
//                .inIfPresent(CrmCustomerDO::getOwnerUserId, ids)
//                .likeIfPresent(CrmCustomerDO::getName, reqVO.getName())
//                .eqIfPresent(CrmCustomerDO::getMobile, reqVO.getMobile())
//                .eqIfPresent(CrmCustomerDO::getTelephone, reqVO.getTelephone())
//                .eqIfPresent(CrmCustomerDO::getDealStatus, reqVO.getDealStatus())
//                .eqIfPresent(CrmCustomerDO::getLevel, reqVO.getLevel())
//                .eqIfPresent(CrmCustomerDO::getIndustry, reqVO.getIndustry())
//                .eqIfPresent(CrmCustomerDO::getSource, reqVO.getSource())
//                .eqIfPresent(CrmCustomerDO::getWeixin, reqVO.getWeixin())
//                .eqIfPresent(CrmCustomerDO::getQq, reqVO.getQq())
//                .eqIfPresent(CrmCustomerDO::getFollowStatus, reqVO.getFollowStatus())
//                .orderByDesc(CrmCustomerDO::getId));
//    }

    IPage<CrmCustomerDO> selectPage(@Param("page") IPage page, @Param("dto") CrmCustomerPageReqVO pageReqVO, @Param("ids") List<Long> ids);

    IPage<CrmCustomerRespVO> selectPageList2(@Param("page") IPage page, @Param("dto") CrmCustomerPageReqVO pageReqVO, @Param("ids") List<Long> ids);

    List<CustomerStatisticRespVO> selectStatistic(@Param("userIds") List<Long> userIds, @Param("createTime") LocalDateTime[] createTime);

    IPage<CrmCustomerDO> selectPageList(@Param("page") IPage page, @Param("dto") CrmCustomerPageReqVO pageReqVO, @Param("ids") List<Long> ids);

    /**
     * 获取重复客户的所有负责人名称
     *
     * @param name
     * @return
     */
    List<String> getRepeatOwnerUserName(@Param("name") String name);
}
