package com.jwipc.finance.mapper;

import com.jwipc.finance.entity.PaymentAdvanceApplyDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jwipc.finance.model.po.CreatePaaDetailPO;
import com.jwipc.finance.model.po.InvoicedApplyPaPO;
import com.jwipc.finance.model.po.PaymentAdvanceApplyDetailPO;
import com.jwipc.finance.model.po.PaymentRecordPO;
import com.jwipc.finance.model.query.PaymentApplyItemQuery;
import org.apache.ibatis.annotations.Param;

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

/**
 * <p>
 * 预付款申请明细表 Mapper 接口
 * </p>
 *
 * @author WT
 * @since 2024-03-08
 */
public interface PaymentAdvanceApplyDetailMapper extends BaseMapper<PaymentAdvanceApplyDetail> {
    /**
     * 查询明细数据根据主表id
     * @param applyId
     * @return
     */
    List<CreatePaaDetailPO> findPaaDetailByPaaId(@Param("applyId") Long applyId);

    /**
     *
     * @param poKeyList
     * @return
     */
    List<PaymentAdvanceApplyDetailPO> createGetPoSituationByPoKey(@Param("poKeyList") List<String> poKeyList);

    /**
     *
     * @param poKeyList
     * @return
     */
    List<PaymentAdvanceApplyDetailPO> findCodApplyByPoKey(@Param("poKeyList") List<String> poKeyList);

    /**
     *
     * @param existedItemIdList
     * @param poKeyList
     * @return
     */
    List<PaymentAdvanceApplyDetailPO> editGetPoSituationByApplyId(@Param("existedItemIdList") List<Long> existedItemIdList, @Param("poKeyList") List<String> poKeyList);

    /**
     *
     * @param poCodeList
     * @return
     */
    List<CreatePaaDetailPO> findPaymentDetailByPoCodeList(@Param("poCodeList") List<String> poCodeList);

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

    /**
     * 根据预付款申请ID或预付款申请单号获取预付款申请明细
     * 参数可以二选一
     *
     * @param appId 预付款申请ID
     * @param appNo 预付款申请单号
     * @return 结果
     */
    List<PaymentAdvanceApplyDetail> findByAppIdOrAppNo(@Param("appId") Long appId, @Param("appNo") String appNo);
    /**
     * 根据预付款申请ID删除申请明细数据
     *
     * @param applyIdList 预付款申请ID集合
     */
    void delDetailByApplyId(@Param("applyIdList") List<Long> applyIdList);

    /**
     * 开票申请获取预付款信息
     *
     * @param query 查询条件
     * @return 结果
     */
    List<InvoicedApplyPaPO> provideCreateAdvanceApply(@Param("query") PaymentApplyItemQuery query);

    /**
     * 2025-07-30 新的开票申请安照对账订单匹配查询
     * @param query
     * @return
     */
    List<InvoicedApplyPaPO> provideCreateAdvanceApplyNew(@Param("query") PaymentApplyItemQuery query,@Param("poKeyList") List<String> poKeyList);
    List<InvoicedApplyPaPO> provideCreateAdvanceApplyNew1(@Param("query") PaymentApplyItemQuery query,@Param("poKeyList") List<String> poKeyList);

    void updateReversedAmount(@Param("paymentChangeNumber")String paymentChangeNumber,@Param("paymentChangeItemNo")String paymentChangeItemNo,@Param("strikePrice")BigDecimal strikePrice);
}
