package com.jwipc.contract.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jwipc.contract.entity.ContractPaymentApply;
import com.jwipc.contract.entity.ContractPaymentApplyDetail;
import com.jwipc.contract.model.po.AttachmentManualCheckPO;
import com.jwipc.contract.model.po.ContractPaymentApplyPO;
import com.jwipc.contract.model.query.ContractPaymentApplyHeadQuery;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 合同MRO付款申请主表 Mapper 接口
 * </p>
 *
 * @author
 * @since 2025-12-10
 */
public interface ContractPaymentApplyMapper extends BaseMapper<ContractPaymentApply> {

    List<ContractPaymentApplyPO> selectListByPage(@Param("query") ContractPaymentApplyHeadQuery query);

    List<ContractPaymentApplyPO> selectListByPage(Page<ContractPaymentApply> dbPage, @Param("query") ContractPaymentApplyHeadQuery query);

    /**
     * 根据对账付款申请单ID获取当前申请单状态
     *
     * @param applyIdList 到付款申请单ID集合
     * @return 结果
     */
    List<ContractPaymentApply> findDataStatusByIdList(@Param("applyIdList") List<Long> applyIdList);

    List<ContractPaymentApply> findDataStatusByContractList(@Param("contractNo") String contractNo,@Param("paymentType") String paymentType);


    List<AttachmentManualCheckPO> getByBusinessIdAndTypeList(@Param("id") Long id);
    /**
     * 根据对账单号查询对账单付款情况
     * @param accountStatementNo
     * @return
     */
    List<ContractPaymentApply> findAppDetailByAccountStatementNo(@Param("accountStatementNo") String accountStatementNo);

    List<ContractPaymentApply> findDataBySupplierAndAmount(@Param("supplierCode") String supplierCode, @Param("oaBorrowMoney") BigDecimal oaBorrowMoney, @Param("monthNum") Integer monthNum);

    List<ContractPaymentApplyDetail> findDataBySupplierAndAccountAndAmount(@Param("supplierCode") String supplierCode, @Param("contractNo") String contractNo, @Param("budOutMoney") BigDecimal budOutMoney, @Param("id") Long id);

    List<ContractPaymentApply> findUnderPaymentByContractCode(@Param("contractCode") String contractCode);
}
