package com.jwipc.finance.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jwipc.finance.entity.AccountStatement;
import com.jwipc.finance.entity.CostInvoicedPaymentCertificate;
import com.jwipc.finance.entity.CostInvoicedPaymentCertificate;
import com.jwipc.finance.mapper.CostInvoicedPaymentCertificateMapper;
import com.jwipc.finance.model.po.CostInvoicedPaymentCertificatePO;
import com.jwipc.finance.model.query.InvoicedDetailQuery;
import com.jwipc.finance.service.ICostInvoicedPaymentCertificateService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 对账模块-费用关联缴款书明细 服务实现类
 * </p>
 *
 * @author shenyang.ou
 * @since 2025-11-05
 */
@Service
public class CostInvoicedPaymentCertificateServiceImpl extends ServiceImpl<CostInvoicedPaymentCertificateMapper, CostInvoicedPaymentCertificate> implements ICostInvoicedPaymentCertificateService {
    /**
     * 根据开票申请单ID获取关联发票数据
     *
     * @param iaId 开票申请单ID
     * @return 关联发票数据
     */
    @Override
    public List<CostInvoicedPaymentCertificatePO> getInvoiceReceiptListByIaId(Long iaId) {
        return baseMapper.getInvoiceReceiptListByIaId(iaId);
    }

    /**
     * 根据开票申请id和发票号码判断系统中是否已经存在
     *
     * @param iaId          开票申请id
     * @param invoiceNumber 发票号码
     * @return 结果
     */
    @Override
    public CostInvoicedPaymentCertificate getExitDataByIaIdAndInvoiceNumber(Long iaId, String invoiceNumber) {
        return baseMapper.getExitDataByIaIdAndInvoiceNumber(iaId, invoiceNumber);
    }

    /**
     * 根据开票申请id和数电发票号码判断系统中是否已经存在
     *
     * @param iaId                  开票申请id
     * @param electronInvoiceNumber 数电发票号码
     * @return 结果
     */
    @Override
    public CostInvoicedPaymentCertificate getExitDataByIaIdAndElectronInvoiceNumber(Long iaId, String electronInvoiceNumber) {
        return baseMapper.getExitDataByIaIdAndElectronInvoiceNumber(iaId, electronInvoiceNumber);
    }

    @Override
    public List<CostInvoicedPaymentCertificatePO> findPageByQuery(Page<AccountStatement> dbPage, InvoicedDetailQuery query) {
        if (dbPage==null){
            return baseMapper.findPageByQuery(query);
        }
        return baseMapper.findPageByQuery(dbPage,query);
    }
}
