package com.jwipc.finance.service;

import com.jwipc.finance.entity.PaymentAdvanceApplyDetail;
import com.jwipc.finance.entity.PaymentCodApplyDetail;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jwipc.finance.model.po.*;
import com.jwipc.finance.model.query.PaymentApplyItemQuery;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 对账付款申请明细表 服务类
 * </p>
 *
 * @author WT
 * @since 2024-03-08
 */
public interface IPaymentCodApplyDetailService extends IService<PaymentCodApplyDetail> {
    /**
     * 查询数据
     * @param applyId
     * @return
     */
    List<CreatePcaDetailPO> findItemDateById(Long applyId);

    /**
     * 根据开票申请查找货到付款数据
     * @param list 开票申请信息
     * @param applyId 货到付款id
     * @return
     */
    List<CreatePcaDetailPO> findByApplyCodeAndItem(List<CreatePcaDetailPO> list, Long applyId);
    List<CreatePcaDetailPO> findByAccountCodeAndItem(List<AccountStatementPO> list);
    List<CreatePcaDetailPO> findByCostAccountCodeAndItem(List<CostAccountStatementPO> list);
    List<CreatePcaDetailPO> findByCompanyAccountCodeAndItem(List<CompanyAccountStatementPO> list);
    List<CreatePcaDetailPO> findByAccountCodeAndItem1(List<CreatePcaDetailPO> list, Long id);

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

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

    /**
     * 查找订单预付信息
     * @param query
     * @return
     */
    List<CreatePaaDetailPO> readAdvancePaymentPoData(PaymentApplyItemQuery query);
    /**
     * 获取采购订单在SRM预付款申请情况
     *
     * @param params 查询参数
     * @param existedItemIdList 编辑仍然存在的申请明细ID集合(需要排除这些)
     * @param applyId 预付款申请单ID(用于判断当前查询是是否在编辑阶段)
     */
    void findPoAdvanceApplySituation(List<CreatePaaDetailPO> params, List<Long> existedItemIdList, Long applyId);

    /**
     *查询已经到票的金额
     * @param poKeyList
     * @return
     */
    List<PaymentAdvanceApplyDetailPO> findCodApplyByPoKey(@Param("poKeyList") List<String> poKeyList);

    /**
     * 查下货到中已经预付的数据
     * @param applyData
     * @return
     */
    List<CreatePcaDetailPO> findByAlreadyData(List<CreatePcaDetailPO> applyData);

    /**
     * 更新明细行号问题
     *
     * @param applyId 申请ID
     */
    void updateDetailItemNo(Long applyId);

    /**
     * 查找明细数据
     * @param appIdList 主表id
     * @return
     */
    List<PaymentCodApplyDetail> findByPaymentDetail(List<Long> appIdList);

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

    List<CreatePcaDetailPO> findAdvanceApplyDataByDataKey(List<String> dataKeys);

    String findAccountNoByAccountNo(long no);
}
