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

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.crmanalysis.vo.ContractVO;
import cn.iocoder.yudao.module.crm.controller.admin.crmanalysis.vo.TimeQueryVO;
import cn.iocoder.yudao.module.crm.controller.admin.crmcontractreceivables.vo.CrmContractReceivablesPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.crmcontractreceivables.vo.CrmContractReceivablesRespVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.crmcontractreceivables.CrmContractReceivablesDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 回款 Mapper
 *
 * @author yshop
 */
@Mapper
public interface CrmContractReceivablesMapper extends BaseMapperX<CrmContractReceivablesDO> {

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

    default PageResult<CrmContractReceivablesDO> selectPage(CrmContractReceivablesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CrmContractReceivablesDO>()
                .eqIfPresent(CrmContractReceivablesDO::getNumber, reqVO.getNumber())
                .eqIfPresent(CrmContractReceivablesDO::getCustomerId, reqVO.getCustomerId())
                .eqIfPresent(CrmContractReceivablesDO::getContractId, reqVO.getContractId())
                .betweenIfPresent(CrmContractReceivablesDO::getReturnTime, reqVO.getReturnTime())
                .eqIfPresent(CrmContractReceivablesDO::getAccountId, reqVO.getAccountId())
                .eqIfPresent(CrmContractReceivablesDO::getMoney, reqVO.getMoney())
                .eqIfPresent(CrmContractReceivablesDO::getCheckStatus, reqVO.getCheckStatus())
                .eqIfPresent(CrmContractReceivablesDO::getFlowId, reqVO.getFlowId())
                .eqIfPresent(CrmContractReceivablesDO::getStepId, reqVO.getStepId())
                .eqIfPresent(CrmContractReceivablesDO::getCheckAdminId, reqVO.getCheckAdminId())
                .eqIfPresent(CrmContractReceivablesDO::getFlowAdminId, reqVO.getFlowAdminId())
                .eqIfPresent(CrmContractReceivablesDO::getRemark, reqVO.getRemark())
                .eqIfPresent(CrmContractReceivablesDO::getOwnerUserId, reqVO.getOwnerUserId())
                .eqIfPresent(CrmContractReceivablesDO::getOrderAdminId, reqVO.getOrderAdminId())
                .eqIfPresent(CrmContractReceivablesDO::getPayStatus, reqVO.getPayStatus())
                .eqIfPresent(CrmContractReceivablesDO::getPayType, reqVO.getPayType())
                .betweenIfPresent(CrmContractReceivablesDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CrmContractReceivablesDO::getId));
    }

    List<ContractVO> selectReceivablesTop(@Param("vo") TimeQueryVO vo);
}
