package com.jwipc.finance.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jwipc.finance.entity.PaymentAdvanceApply;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jwipc.finance.entity.PaymentAdvanceApplyDetail;
import com.jwipc.finance.entity.PaymentCodApplyDetail;
import com.jwipc.finance.model.po.CreatePcaDetailPO;
import com.jwipc.finance.model.po.PaymentAdvanceApplyDetailPO;
import com.jwipc.finance.model.po.PaymentAdvanceApplyPO;
import com.jwipc.finance.model.po.PaymentAdvanceRefundTransferApplyPO;
import com.jwipc.finance.model.query.PaymentApplyHeadQuery;
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 PaymentAdvanceApplyMapper extends BaseMapper<PaymentAdvanceApply> {
    /**
     * 查询列表
     * @param query
     * @return
     */
    List<PaymentAdvanceApply> selectListByPage(@Param("query") PaymentApplyHeadQuery query);

    /**
     * 查询列表
     * @param dbPage
     * @param query
     * @return
     */
    List<PaymentAdvanceApply> selectListByPage(@Param("dbPage") Page<PaymentAdvanceApply> dbPage, @Param("query") PaymentApplyHeadQuery query);

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

    /**
     * 查询数据
     * @param id
     * @return
     */
    PaymentAdvanceApplyPO findById(Long id);

    List<PaymentAdvanceApply> findDataStatusByIdList(@Param("applyIdList") List<Long> applyIdList);

    List<CreatePcaDetailPO> findByQuery(@Param("query") PaymentApplyItemQuery query);

    List<PaymentAdvanceRefundTransferApplyPO> selectPaaOrderListByPage(@Param("query") PaymentApplyHeadQuery query);

    List<PaymentAdvanceRefundTransferApplyPO> selectPaaOrderListByPage(@Param("dbPage") Page<PaymentAdvanceRefundTransferApplyPO> dbPage, @Param("query") PaymentApplyHeadQuery query);

    List<PaymentAdvanceApplyDetail> findDataBySupplierAndPoCodeAndAmount(@Param("supplierCode") String supplierCode, @Param("poCode") String poCode, @Param("budOutMoney") BigDecimal budOutMoney,@Param("id") Long id);

    BigDecimal getUnCleared1(@Param("supplierCode") String supplierCode);

    BigDecimal getUnCleared2(@Param("supplierCode") String supplierCode);

    BigDecimal getUnCleared3(@Param("supplierCode") String supplierCode);

    BigDecimal getUnCleared4(@Param("supplierCode") String supplierCode);

    BigDecimal getInPaymentAmount(@Param("supplierCode") String supplierCode,@Param("companyCode") String companyCode);
}
