package com.jwipc.contract.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jwipc.contract.entity.ContractPaymentApplyDetail;
import com.jwipc.contract.model.po.AttachmentManualCheckPO;
import com.jwipc.contract.model.po.ContractPaymentRecordPO;
import com.jwipc.contract.model.po.CreateContractPayDetailPO;
import com.jwipc.contract.model.query.ContractPaymentApplyDetailQuery;
//import com.jwipc.finance.entity.PaymentCodApplyDetail;
//import com.jwipc.finance.model.query.PaymentApplyItemQuery;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 合同付款申请明细表 Mapper 接口
 * </p>
 *
 * @author 邓京术
 * @since 2025-12-10
 */
public interface ContractPaymentApplyDetailMapper extends BaseMapper<ContractPaymentApplyDetail> {

    List<CreateContractPayDetailPO> queryInvoiceByContractDetailId(Long id);
    List<CreateContractPayDetailPO> queryCodApplyInvoiceById(Long id);
    void saveManualCheckList(@Param("attachmentManualCheckPO") AttachmentManualCheckPO attachmentManualCheckPO);

    List<CreateContractPayDetailPO> findByAccountCodeAndItem1(@Param("paymentData") List<CreateContractPayDetailPO> list, @Param("id") Long id, @Param("contractNo") String contractNo);
    List<CreateContractPayDetailPO> findByAccountByStageId( @Param("id") Long id);

    /**
     * 查询货到付款明细数据
     * @param applyId
     * @return
     */
//    List<CreateContractPayDetailPO> findItemDateById(@Param("applyId") Long applyId);

    /**
     *
     * @param list
     * @param applyId
     * @return
     */
//    List<CreateContractPayDetailPO> findByApplyCodeAndItem(@Param("paymentData") List<CreatePcaDetailPO> list, @Param("cppId") Long applyId);


//    List<CreatePcaDetailPO> findByCostAccountCodeAndItem(@Param("paymentData") List<CostAccountStatementPO> list);
//    List<CreatePcaDetailPO> findByCompanyAccountCodeAndItem(@Param("paymentData") List<CompanyAccountStatementPO> list);

//    List<CreatePcaDetailPO> findByAccountCodeAndItem1(@Param("paymentData") List<CreatePcaDetailPO> list, @Param("id") Long id);

    /**
     * 查询数据
     * @param poCodeList
     * @return
     */
//    List<CreatePcaDetailPO> findPaymentDetailByPoCodeList(@Param("poCodeList") List<String> poCodeList);

    /**
     * 查询数据
     * @param poCode
     * @return
     */
    List<ContractPaymentRecordPO> findDetailByPoCode(@Param("poCode") String poCode);

    /**
     *
     * @param query
     * @return
     */
    List<CreateContractPayDetailPO> readAdvancePaymentPoData(@Param("query") ContractPaymentApplyDetailQuery query);

    /**
     * 新增时获取采购订单在SRM预付款申请情况
     *
     * @param poKeyList 采购订单号+行号
     * @return 结果
     */
//    List<PaymentAdvanceApplyDetailPO> createGetPoSituationByPoKey(@Param("poKeyList") List<String> poKeyList);

    /**
     * 新增时获取采购订单在SRM预付款申请情况
     *
     * @param poKeyList 采购订单号+行号
     * @return 结果
     */
//    List<PaymentAdvanceApplyDetailPO> findCodApplyByPoKey(@Param("poKeyList") List<String> poKeyList);
    /**
     * 编辑时获取采购订单在SRM预付款申请情况
     *
     * @param existedItemIdList 编辑仍然存在的申请明细ID集合(需要排除这些)
     * @param poKeyList 采购订单号+行号
     * @return 结果
     */
//    List<PaymentAdvanceApplyDetailPO> editGetPoSituationByApplyId(@Param("existedItemIdList") List<Long> existedItemIdList, @Param("poKeyList") List<String> poKeyList);

    /**
     * 查找货到中预付的数据
     * @param applyData
     * @return
     */
//    List<CreatePcaDetailPO> findByAlreadyData(@Param("applyData") List<CreatePcaDetailPO> applyData);


    /**
     * 根据对账付款申请单ID或单号获取明细数据 注:参数二选一即可
     *
     * @param cppId 对账付款申请单ID
     * @param cppNo 对账付款申请单号
     * @return 结果
     */
    List<ContractPaymentApplyDetail> findByCppIdOrCppNo(@Param("cppId") Long cppId, @Param("cppNo") String cppNo);

//    List<PaymentCodApplyDetail> findByPaymentDetail(@Param("appIdList") List<Long> appIdList);

    /**
     * 根据对账付款申请ID删除货到付款明细
     *
     * @param applyIdList 对账付款申请ID集合
     */
    void delDetailByApplyId(@Param("applyIdList") List<Long> applyIdList);

    List<String> getCostCenterCodeByContractNo(@Param("contractNo") String contractNo);

//    List<CreatePcaDetailPO> findAdvanceApplyDataByDataKey(@Param("dataKeys")List<String> dataKeys);
}
