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


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.invoice.vo.InvoiceAmountRespVO;
import com.cf.imes.module.executor.controller.admin.funds.invoice.vo.InvoicePurchaseRecord;
import com.cf.imes.module.executor.controller.admin.funds.purchase.vo.PurchaseRecordPageReqVO;
import com.cf.imes.module.executor.dal.dataobject.funds.purchase.PurchaseRecordDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface PurchaseRecordMapper extends BaseMapperX<PurchaseRecordDO> {


    InvoiceAmountRespVO selectOrganInvoice(@Param("organId") Long organId);



    default PageResult<PurchaseRecordDO> selectPage(PurchaseRecordPageReqVO pageReqVO) {
        return selectPage(pageReqVO, new LambdaQueryWrapperX<PurchaseRecordDO>()
                .eq(PurchaseRecordDO::getDeleted,false)
                .eqIfPresent(PurchaseRecordDO::getOrganId,pageReqVO.getOrganId())
                .likeIfPresent(PurchaseRecordDO::getProductName,pageReqVO.getProductName())
                .eqIfPresent(PurchaseRecordDO::getPurchaseMonths,pageReqVO.getPurchaseMonths())
                .betweenIfPresent(PurchaseRecordDO::getCreateTime,pageReqVO.getCreateTime())
                .likeIfPresent(PurchaseRecordDO::getCreator,pageReqVO.getCreator()));

    }

    List<InvoicePurchaseRecord> selectPurchaseRecord(@Param("purchaseIdList") List<Long> purchaseIdList, @Param("organId") Long organId);

}
