package com.cf.imes.module.executor.dal.mysql.funds.balancedetails;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.module.executor.controller.admin.funds.balancedetails.vo.BalanceDetailsPageReqVO;
import com.cf.imes.module.executor.controller.admin.funds.invoice.vo.InvoiceDetailsRespVO;
import com.cf.imes.module.executor.dal.dataobject.funds.balancedetails.IncomeExpenseDetailsDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface IncomeExpenseDetailsMapper extends BaseMapperX<IncomeExpenseDetailsDO> {



    default PageResult<IncomeExpenseDetailsDO> selectDetailsPage(BalanceDetailsPageReqVO pageReqVO,List<Long> organIds) {
        return selectPage(pageReqVO, new LambdaQueryWrapperX<IncomeExpenseDetailsDO>()
                .eqIfPresent(IncomeExpenseDetailsDO::getOrganId, pageReqVO.getOrganId())
                .inIfPresent(IncomeExpenseDetailsDO::getOrganId,organIds)
                .eq(IncomeExpenseDetailsDO::getDeleted, false)
                .likeIfPresent(IncomeExpenseDetailsDO::getId,pageReqVO.getId() == null ? "" : String.valueOf(pageReqVO.getId()))
                .eqIfPresent(IncomeExpenseDetailsDO::getTradeType,pageReqVO.getTradeType())
                .eqIfPresent(IncomeExpenseDetailsDO::getIncomeExpenseType,pageReqVO.getIncomeExpenseType())
                .betweenIfPresent(IncomeExpenseDetailsDO::getCreateTime,pageReqVO.getCreateTime()));

    }


    IPage<InvoiceDetailsRespVO> selectOrganInvoicable(@Param("page") IPage page, @Param(Constants.WRAPPER) Wrapper<IncomeExpenseDetailsDO> wrapper);


}
