package com.jwipc.finance.mapper;

import com.jwipc.finance.entity.PaymentCodApplyDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jwipc.finance.model.po.*;
import com.jwipc.finance.model.query.PaymentApplyItemQuery;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 对账付款申请明细表 Mapper 接口
 * </p>
 *
 * @author WT
 * @since 2024-03-08
 */
public interface PaymentCodApplyDetailMapper extends BaseMapper<PaymentCodApplyDetail> {
    /**
     * 查询货到付款明细数据
     * @param applyId
     * @return
     */
    List<CreatePcaDetailPO> findItemDateById(@Param("applyId") Long applyId);

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


    List<CreatePcaDetailPO> findByAccountCodeAndItem(@Param("paymentData") List<AccountStatementPO> list);
    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<PaymentRecordPO> findDetailByPoCode(@Param("poCode") String poCode);

    /**
     *
     * @param query
     * @return
     */
    List<CreatePaaDetailPO> readAdvancePaymentPoData(@Param("query") PaymentApplyItemQuery 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<PaymentCodApplyDetail> 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<CreatePcaDetailPO> findAdvanceApplyDataByDataKey(@Param("dataKeys")List<String> dataKeys);

    String findAccountNoByAccountNo(@Param("no") Long no);
}
