package com.cf.imes.module.system.dal.mysql.funds.invoice;


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.system.controller.admin.funds.invoice.vo.InvoiceAmountRespVO;
import com.cf.imes.module.system.controller.admin.funds.invoice.vo.InvoiceDetailsPageReqVO;
import com.cf.imes.module.system.dal.dataobject.funds.invoice.InvoiceRecordsDO;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface InvoiceRecordsMapper extends BaseMapperX<InvoiceRecordsDO> {


    default PageResult<InvoiceRecordsDO> selectInvoiceRecordsPage(InvoiceDetailsPageReqVO pageReqVO) {
        return selectPage(pageReqVO, new LambdaQueryWrapperX<InvoiceRecordsDO>()
                .eq(InvoiceRecordsDO::getDeleted,false)
                .eqIfPresent(InvoiceRecordsDO::getOrganId,pageReqVO.getOrganId())
                .likeIfPresent(InvoiceRecordsDO::getInvoiceNo,pageReqVO.getInvoiceNo())
                .eqIfPresent(InvoiceRecordsDO::getStatus,pageReqVO.getStatus())
                .likeIfPresent(InvoiceRecordsDO::getCreator,pageReqVO.getCreator())
                .likeIfPresent(InvoiceRecordsDO::getInvoicePerson,pageReqVO.getInvoicePerson())
                .betweenIfPresent(InvoiceRecordsDO::getInvoiceAmount,pageReqVO.getInvoiceAmount())
                .betweenIfPresent(InvoiceRecordsDO::getCreateTime,pageReqVO.getCreateTime())
                .betweenIfPresent(InvoiceRecordsDO::getInvoiceTime,pageReqVO.getInvoiceTime()));
    }

    /**
     * 查询管理端开票金额统计：待开票、已开票
     *
     * @return
     */
    InvoiceAmountRespVO getManageInvoiceAmountStatistics();
}
