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

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.crm.dal.dataobject.salesperformancesettlement.SalesPerformanceSettlementDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.crm.controller.admin.salesperformancesettlement.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 销售业绩结算记录 Mapper
 *
 * @author 艾楷
 */
@Mapper
public interface SalesPerformanceSettlementMapper extends BaseMapperX<SalesPerformanceSettlementDO> {

    default PageResult<SalesPerformanceSettlementDO> selectPage(SalesPerformanceSettlementPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SalesPerformanceSettlementDO>()
                .eqIfPresent(SalesPerformanceSettlementDO::getUserId, reqVO.getUserId())
                .eqIfPresent(SalesPerformanceSettlementDO::getSalesPerformanceId, reqVO.getSalesPerformanceId())
                .eqIfPresent(SalesPerformanceSettlementDO::getYear, reqVO.getYear())
                .eqIfPresent(SalesPerformanceSettlementDO::getMonth, reqVO.getMonth())
                .eqIfPresent(SalesPerformanceSettlementDO::getActualPayment, reqVO.getActualPayment())
                .eqIfPresent(SalesPerformanceSettlementDO::getActualSale, reqVO.getActualSale())
                .eqIfPresent(SalesPerformanceSettlementDO::getScore, reqVO.getScore())
                .eqIfPresent(SalesPerformanceSettlementDO::getTotalScore, reqVO.getTotalScore())
                .eqIfPresent(SalesPerformanceSettlementDO::getConfirmFlag, reqVO.getConfirmFlag())
                .betweenIfPresent(SalesPerformanceSettlementDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(SalesPerformanceSettlementDO::getId));
    }

    /**
     *
     * @param vo
     * @param page
     * @return
     */
    IPage<SalesPerformanceSettlementDO> getSalesPerformanceSettlementPage(@Param("vo") SalesPerformanceSettlementPageReqVO vo, @Param("page") Page page);

    /**
     *
     * @param id
     * @return
     */
    SalesPerformanceSettlementDO getSalesPerformanceSettlement(@Param("id") Long id);
}
