package com.qmth.sop.business.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qmth.sop.business.bean.dto.DataPermissionDto;
import com.qmth.sop.business.bean.result.CrmAnalyseResult;
import com.qmth.sop.business.bean.result.TBCrmResult;
import com.qmth.sop.business.entity.TBCrm;
import org.apache.ibatis.annotations.Param;

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

/**
 * <p>
 * </p>
 *
 * @author dhshu
 */
public interface CrmAnalyseMapper extends BaseMapper<TBCrm> {

    @SuppressWarnings("MybatisXMapperMethodInspection")
    Map<String, Object> countCustomType(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("dpr") DataPermissionDto dpr);

    IPage<TBCrmResult> crmDetail(Page<Object> iPage, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("month") String month, @Param("crmYear") String crmYear, @Param("type") String type, @Param("supplierId") Long supplierId, @Param("province") String province, @Param("serviceId") Long serviceId, @Param("dpr") DataPermissionDto dpr);

    default IPage<TBCrmResult> crmDetail(Page<Object> iPage, Long startTime, Long endTime, String type, DataPermissionDto dpr) {
        return crmDetail(iPage, startTime, endTime, null, null, type, null, null, null, dpr);
    }

    @SuppressWarnings("MybatisXMapperMethodInspection")
    List<Map<String, Object>> monthly(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("type") String type, @Param("dpr") DataPermissionDto dpr);

    default IPage<TBCrmResult> crmDetail(Page<Object> iPage, String year, String month, String type, Long startTime, Long endTime, DataPermissionDto dpr) {
        return crmDetail(iPage, startTime, endTime, month, year, type, null, null, null, dpr);
    }

    List<CrmAnalyseResult> supplier(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("dpr") DataPermissionDto dpr);

    default IPage<TBCrmResult> crmDetailSupplier(Page<Object> iPage, Long startTime, Long endTime, Long supplierId, DataPermissionDto dpr) {
        return crmDetail(iPage, startTime, endTime, null, null, null, supplierId, null, null, dpr);
    }

    List<CrmAnalyseResult> region(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("type") String type, @Param("dpr") DataPermissionDto dpr);

    default IPage<TBCrmResult> crmDetail(Page<Object> iPage, Long startTime, Long endTime, String province, String type, DataPermissionDto dpr) {
        return crmDetail(iPage, startTime, endTime, null, null, type, null, province, null, dpr);
    }

    default IPage<TBCrmResult> crmDetail(Page<Object> iPage, Long serviceId, Long startTime, Long endTime, DataPermissionDto dpr) {
        return crmDetail(iPage, startTime, endTime, null, null, null, null, null, serviceId, dpr);
    }

    List<Map<String, Object>> project(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("dpr") DataPermissionDto dpr);

    @SuppressWarnings("MybatisXMapperMethodInspection")
    Map<String, Object> projectCount(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("dpr") DataPermissionDto dpr);

    Integer findAllocation(@Param("startTime") Long startTime,@Param("endTime")  Long endTime,@Param("dpr")  DataPermissionDto dpr);
}
