package com.jwipc.contract.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwipc.contract.entity.ContractPaymentApply;
import com.jwipc.contract.entity.ContractPaymentInvoicedReceipt;
import com.jwipc.contract.mapper.ContractPaymentInvoicedReceiptMapper;
import com.jwipc.contract.model.po.ContractPaymentInvoicedReceiptPO;
import com.jwipc.contract.model.query.ContractPaymentInvoicedDetailQuery;
import com.jwipc.contract.service.IContractPaymentInvoicedReceiptService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 对账模块-关联发票明细 服务实现类
 * </p>
 *
 * @author shenyang.ou
 * @since 2024-03-05
 */
@Service
public class ContractPaymentInvoicedReceiptServiceImpl extends ServiceImpl<ContractPaymentInvoicedReceiptMapper, ContractPaymentInvoicedReceipt> implements IContractPaymentInvoicedReceiptService {

    /**
     * 根据开票申请单ID获取关联发票数据
     *
     * @param iaId 开票申请单ID
     * @return 关联发票数据
     */
    @Override
    public List<ContractPaymentInvoicedReceiptPO> getInvoiceReceiptListByIaId(Long iaId) {
        return baseMapper.getInvoiceReceiptListByIaId(iaId);
    }

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

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

    @Override
    public List<ContractPaymentInvoicedReceiptPO> findPageByQuery(Page<ContractPaymentApply> dbPage, ContractPaymentInvoicedDetailQuery query) {
        if (dbPage==null){
            return baseMapper.findPageByQuery(query);
        }
        return baseMapper.findPageByQuery(dbPage,query);
    }
}
